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

# Create a new access token

> Authenticates a user and issues a new access token



## OpenAPI

````yaml api-reference/openapi.json post /v1/auth/tokens
openapi: 3.1.0
info:
  title: Nextvisit API
  description: API for the Nextvisit Clinical Documentation platform for developers
  version: 1.0.0
  termsOfService: https://nextvisit.com/terms/
  contact:
    name: Nextvisit, Inc.
    email: support@nextvisit.com
  license:
    name: Proprietary
    url: https://nextvisit.app/terms-of-service
servers:
  - url: https://nextvisit.app/api
    description: Production API
  - url: http://localhost/api
    description: Developer Proxy
security: []
tags:
  - name: Tokens
    description: >-
      User token management endpoints for secure access to the Nextvisit
      platform. Includes login, logout, and token management operations.
  - name: Progress Notes
    description: >-
      Clinical progress note management including creating, updating,
      retrieving, and signing notes with associated transcriptions and analyses.
  - name: Users
    description: >-
      User account management including profile updates, permission settings,
      role assignments, and practice affiliations.
paths:
  /v1/auth/tokens:
    post:
      tags:
        - Tokens
      summary: Create a new access token
      description: Authenticates a user and issues a new access token
      operationId: apiCreateToken
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
            examples:
              default:
                $ref: '#/components/examples/LoginRequestExample'
      responses:
        '200':
          description: Token successfully created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
              examples:
                default:
                  $ref: '#/components/examples/TokenResponseExample'
        '422':
          $ref: '#/components/responses/Unprocessable'
components:
  schemas:
    LoginRequest:
      type: object
      properties:
        email:
          type: string
          format: email
          description: User's email address
          example: user@nextvisit.app
        password:
          type: string
          format: password
          description: User's password
          example: secureP@ssw0rd!
        device_name:
          type: string
          description: Name of the device requesting the token
          example: iPhone 14 Pro
      required:
        - email
        - password
        - device_name
    TokenResponse:
      type: object
      properties:
        status:
          type: string
          description: Status of the token request
          example: success
        token:
          type: string
          description: Authentication token value
          example: nv-sk-2|4qrD6iCn5FYhHyrdVX1IE4kk6RWg091WpboNklOC
        token_id:
          type: integer
          description: Unique identifier for the token
          example: 123
        user:
          type: object
          description: Basic information about the authenticated user
          properties:
            id:
              type: integer
              description: User's unique identifier
              example: 1
            name:
              type: string
              description: User's full name
              example: John Doe
            current_team_id:
              type: integer
              description: ID of the user's current team
              example: 5
            email:
              type: string
              format: email
              description: User's email address
              example: john.doe@example.com
        team:
          type: object
          description: Basic information about the user's current team
          properties:
            id:
              type: integer
              description: Team's unique identifier
              example: 5
            name:
              type: string
              description: Name of the team
              example: Medical Practice
      required:
        - status
        - token
        - token_id
        - user
        - team
    Error:
      type: object
      properties:
        message:
          type: string
          description: Error message
          example: Validation failed
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          description: Detailed validation errors by field
          example:
            email:
              - The email must be a valid email address
              - The email has already been taken
            password:
              - The password must be at least 8 characters
            template_name:
              - This field is required
      required:
        - message
  examples:
    LoginRequestExample:
      value:
        email: john.doe@example.com
        password: securepassword123
        device_name: iPhone 14 Pro
    TokenResponseExample:
      value:
        status: success
        token: nv-sk-2|4qrD6iCn5FYhHyrdVX1IE4kk6RWg091WpboNklOC
        token_id: 123
        user:
          id: 1
          name: John Doe
          current_team_id: 5
          email: john.doe@example.com
        team:
          id: 5
          name: Medical Practice
  responses:
    Unprocessable:
      description: Unprocessable entity
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            message: The provided credentials are incorrect.
            errors:
              email:
                - The provided credentials are incorrect.

````