> ## Documentation Index
> Fetch the complete documentation index at: https://docs.niadra.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Entrar

> Troca a credencial de uma pessoa pelo token que o Console e a API usam.



## OpenAPI

````yaml openapi/pt/control.json POST /v1/auth/login
openapi: 3.1.0
info:
  title: API de controle da Niadra
  version: '1'
  description: >-
    Tenants, projetos, fontes, chaves, pessoas, configuração e uso. Nunca recebe
    conteúdo de cliente.
servers:
  - url: https://control.api.niadra.com
security: []
paths:
  /v1/auth/login:
    post:
      summary: Entrar
      description: >-
        Autentica uma pessoa com e-mail, senha e o código TOTP e devolve o token
        que o Console e a API de controle usam. O token vale 15 minutos e abre
        um espaço; quem ainda não confirmou o autenticador recebe 401 "second
        factor enrollment required" e o configura com POST
        /v1/auth/second-factor. No Console, o acesso costuma vir por SAML 2.0 ou
        OIDC.


        **Autenticação.** Sem autenticação.
      operationId: login_v1_auth_login_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
            example:
              email: ana@acme.example
              password: correct horse battery staple
              totp: '492817'
              space_id: 0192f0a0-3d4e-7f50-8b61-7c8d9e0f1a23
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenOut'
              example:
                access_token: >-
                  eyJhbGciOiJFZERTQSIsImtpZCI6ImN0bC0yMDI2LTA5In0.eyJzdWIiOiIwMTkyZjBhMC00ZTVmIiwiZXhwIjoxNzU4NTYyMTIzfQ.Q2sX...
                token_type: Bearer
                expires_in: 900
                space_id: 0192f0a0-3d4e-7f50-8b61-7c8d9e0f1a23
          description: O token, o prazo dele em segundos e o espaço que ele abre.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: O pedido não bate com o contrato.
      security: []
components:
  schemas:
    LoginRequest:
      additionalProperties: false
      properties:
        email:
          maxLength: 320
          minLength: 3
          title: Email
          type: string
        password:
          maxLength: 1024
          minLength: 1
          title: Password
          type: string
        space_id:
          anyOf:
            - format: uuid
              type: string
            - type: 'null'
          title: Space Id
          description: >-
            O espaço que o token abre. Por padrão, o primeiro espaço a que a
            pessoa tem acesso.
        totp:
          anyOf:
            - pattern: ^\d{6}$
              type: string
            - type: 'null'
          title: Totp
          description: >-
            O código atual do aplicativo autenticador. Obrigatório quando a
            pessoa cadastrou o segundo fator.
      required:
        - email
        - password
      title: LoginRequest
      type: object
    TokenOut:
      additionalProperties: false
      properties:
        access_token:
          title: Access Token
          type: string
        expires_in:
          title: Expires In
          type: integer
          description: Segundos até o token vencer.
        space_id:
          format: uuid
          title: Space Id
          type: string
        token_type:
          default: Bearer
          title: Token Type
          type: string
      required:
        - access_token
        - expires_in
        - space_id
      title: TokenOut
      type: object
    Problem:
      additionalProperties: false
      description: >-
        Detalhes do problema no formato da RFC 9457; `code` vem do catálogo de
        erros versionado.
      properties:
        code:
          title: Code
          type: string
        detail:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Detail
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Request Id
        status:
          title: Status
          type: integer
        title:
          title: Title
          type: string
        type:
          default: about:blank
          title: Type
          type: string
      required:
        - title
        - status
        - code
      title: Problem
      type: object

````