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

# Login

> Autentica conta existente. **Três modos no mesmo endpoint:** (1) `email` + `password` → `sessionToken` ou, se 2FA ativo, `requiresSecondFactor` + `verificationToken`; (2) `verificationToken` + `totpCode` ou `backupCode` → completa 2FA (token vem do passo anterior, **não** do register); (3) `createApiKey: true` + opcional `workspaceId` → nova `apiKey` no workspace (OWNER/ADMIN). Sem `workspaceId`, usa o workspace OWNER mais recente.



## OpenAPI

````yaml /es/platform-api/api-reference/openapi-platform.json post /v1/platform/login
openapi: 3.0.3
info:
  title: Notifique API Platform
  description: >-
    Conta, billing, API keys, equipe e tudo que o painel faz — via API. Rotas
    públicas: `register`, `verify`, `login`. Autentique o restante com
    `Authorization: Bearer sk_live_...` ou `x-api-key`. Escopos: `api_keys:*`,
    `billing:*`, `workspace:members:*` conforme a rota.
  version: 1.0.0
servers:
  - url: https://api.notifique.dev
    description: Produção
security:
  - ntfPlatformBearerAuth: []
  - ntfPlatformApiKeyHeader: []
tags:
  - name: 'Platform: Conta'
    description: Registro, verificação de telefone e login.
  - name: 'Platform: Billing'
    description: >-
      Assinatura, saldo, recarga e histórico de uso de créditos (`billing:read`
      / `billing:manage`).
  - name: 'Platform: API Keys'
    description: Gestão de chaves do workspace (`api_keys:read` / `api_keys:manage`).
  - name: 'Platform: Workspace'
    description: Listagem de workspaces (sessão) e recursos por workspace.
  - name: 'Platform: Equipe'
    description: >-
      Membros e convites (`workspace:members:read` /
      `workspace:members:manage`).
  - name: Sandbox
    description: Mensajes de prueba interceptados en el entorno sandbox.
paths:
  /v1/platform/login:
    post:
      tags:
        - 'Platform: Conta'
      summary: Login
      description: >-
        Autentica conta existente. **Três modos no mesmo endpoint:** (1) `email`
        + `password` → `sessionToken` ou, se 2FA ativo, `requiresSecondFactor` +
        `verificationToken`; (2) `verificationToken` + `totpCode` ou
        `backupCode` → completa 2FA (token vem do passo anterior, **não** do
        register); (3) `createApiKey: true` + opcional `workspaceId` → nova
        `apiKey` no workspace (OWNER/ADMIN). Sem `workspaceId`, usa o workspace
        OWNER mais recente.
      operationId: ntfPlatform_postLogin
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NtfPlatform_LoginBody'
            examples:
              credentials:
                summary: 1. E-mail e senha
                value:
                  email: dev@empresa.com
                  password: SenhaSegura123!
              with_api_key:
                summary: Login + API key (workspace padrão)
                value:
                  email: dev@empresa.com
                  password: SenhaSegura123!
                  createApiKey: true
              with_workspace:
                summary: Login + API key em workspace específico
                value:
                  email: dev@empresa.com
                  password: SenhaSegura123!
                  createApiKey: true
                  workspaceId: clws_02HHomolog...
              second_factor:
                summary: 2. Completar 2FA (após requiresSecondFactor)
                value:
                  verificationToken: eyJhbGciOiJIUzI1NiIs...
                  totpCode: '482193'
                  createApiKey: true
                  workspaceId: clws_02HHomolog...
              session_only:
                summary: Só sessão (sem nova API key)
                value:
                  email: dev@empresa.com
                  password: SenhaSegura123!
                  createApiKey: false
      responses:
        '200':
          description: Login ou segundo fator requerido.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NtfPlatform_LoginResponse'
              examples:
                success:
                  value:
                    success: true
                    data:
                      requiresSecondFactor: false
                      sessionToken: sess_eyJhbGciOi...
                      apiKey: sk_live_abc123...
                      workspaceId: clws_02HHomolog...
                      user:
                        id: clus_01HABC...
                        email: dev@empresa.com
                        name: Maria Dev
                        phoneVerified: true
                        onboardingCompleted: true
                        workspaces:
                          - role: OWNER
                            id: clws_01HProducao...
                            name: Produção BR
                            slug: producao-br
                          - role: OWNER
                            id: clws_02HHomolog...
                            name: Homologação
                            slug: homologacao
                needs_2fa:
                  value:
                    success: true
                    data:
                      requiresSecondFactor: true
                      verificationToken: eyJhbGciOiJIUzI1NiIs...
        '401':
          $ref: '#/components/responses/NtfPlatform_Unauthorized'
      security: []
components:
  schemas:
    NtfPlatform_LoginBody:
      type: object
      properties:
        email:
          type: string
        password:
          type: string
        verificationToken:
          type: string
        totpCode:
          type: string
        backupCode:
          type: string
        createApiKey:
          type: boolean
        workspaceId:
          type: string
      example:
        email: string
        password: string
        verificationToken: string
        totpCode: string
        backupCode: string
        createApiKey: true
        workspaceId: clxx...
    NtfPlatform_LoginResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          type: object
          properties:
            requiresSecondFactor:
              type: boolean
            verificationToken:
              type: string
            sessionToken:
              type: string
            apiKey:
              type: string
            workspaceId:
              type: string
            user:
              $ref: '#/components/schemas/NtfPlatform_User'
      example:
        success: true
        data:
          requiresSecondFactor: true
          verificationToken: string
          sessionToken: string
          apiKey: string
          workspaceId: clxx...
          user:
            id: clxx...
            email: string
            name: Exemplo
            phone: string
            phoneVerified: true
            onboardingCompleted: true
    NtfPlatform_User:
      type: object
      properties:
        id:
          type: string
        email:
          type: string
        name:
          type: string
          nullable: true
        phone:
          type: string
          nullable: true
        phoneVerified:
          type: boolean
        onboardingCompleted:
          type: boolean
        workspaces:
          type: array
          items:
            type: string
          example:
            - role: OWNER
              id: clws_01HProducao...
              name: Produção BR
              slug: producao-br
            - role: OWNER
              id: clws_02HHomolog...
              name: Homologação
              slug: homologacao
      example:
        id: clxx...
        email: string
        name: Exemplo
        phone: string
        phoneVerified: true
        onboardingCompleted: true
    NtfPlatform_Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
        code:
          type: string
        message:
          type: string
          example: Campo inválido ou ausente.
        retryAfter:
          type: integer
          example: 60
      example:
        success: false
        error: string
        code: string
  responses:
    NtfPlatform_Unauthorized:
      description: Credenciais ou token inválidos.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfPlatform_Error'
          example:
            success: false
            code: VERIFICATION_TOKEN_INVALID
  securitySchemes:
    ntfPlatformBearerAuth:
      type: http
      scheme: bearer
      description: API key (`sk_live_...`) ou `sessionToken` de login.
    ntfPlatformApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: Alternativa ao Bearer.

````