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

# Request an access token

> Obtain an access token using the password grant type for authentication with the authentication service. This endpoint allows users to log in using their username and password credentials. The grant_type and format are pre-set; only the username and password need to be provided.

**Sample Request:**
```
POST /api/oauth/token/
Content-Type: application/x-www-form-urlencoded
grant_type=password
format=json
username=<your_username>
password=<your_password>
```



## OpenAPI

````yaml /openapi/peerlogic-api.json post /api/oauth/token/
openapi: 3.1.0
info:
  title: Peerlogic API
  version: 1.0.0
  description: >-
    Customer-facing API reference for accessing Peerlogic calls, insights,
    conversations, tasks, opportunities, subscriptions, and events.
servers:
  - url: https://api.prod.peerlogic.com
    description: Production
security: []
tags:
  - name: Authentication
    description: Obtain an access token for authenticated API requests.
  - name: Call insights
    description: Call records and aggregate performance insights.
  - name: Transcripts
    description: Transcripts, summaries, sentiment, pauses, and call-purpose details.
  - name: Aimee
    description: Aimee activity, configuration, and performance insights.
  - name: Conversations
    description: Conversation records, messages, and conversation actions.
  - name: Tasks
    description: Customer tasks and task workflow actions.
  - name: Opportunities
    description: Opportunities and follow-up reporting.
  - name: Subscriptions and events
    description: >-
      Create and manage event subscriptions, then inspect event records and
      analytics. For the complete webhook delivery flow, see the Webhooks and
      subscriptions guide.
  - name: Organizations and practices
    description: >-
      Discover the organizations and practices available to the authenticated
      account.
  - name: Contacts and patients
    description: Find contacts and patients for caller recognition and related workflows.
  - name: Appointments
    description: Retrieve appointment history and upcoming appointments for a patient.
  - name: Messaging
    description: Send practice messages, including missed-call recovery outreach.
  - name: Call recordings
    description: Retrieve recording metadata and secure audio URLs for calls.
paths:
  /api/oauth/token/:
    parameters: []
    post:
      tags:
        - Authentication
      summary: Request an access token
      description: >-
        Obtain an access token using the password grant type for authentication
        with the authentication service. This endpoint allows users to log in
        using their username and password credentials. The grant_type and format
        are pre-set; only the username and password need to be provided.


        **Sample Request:**

        ```

        POST /api/oauth/token/

        Content-Type: application/x-www-form-urlencoded

        grant_type=password

        format=json

        username=<your_username>

        password=<your_password>

        ```
      operationId: oauth_token_create
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                username:
                  description: Username (usually your email address) to authenticate.
                  type: string
                password:
                  description: Password associated with the username for authentication.
                  type: string
                grant_type:
                  description: >-
                    Grant type for the authentication flow. This value is
                    hardcoded as 'password'.
                  type: string
                  enum:
                    - password
                  default: password
                format:
                  description: Response format. This value is hardcoded as 'json'.
                  type: string
                  enum:
                    - json
                  default: json
              required:
                - username
                - password
        required: true
      responses:
        '200':
          description: Successful authentication returns an access token and refresh token.
          content:
            application/json:
              schema:
                type: object
                properties:
                  access_token:
                    description: Access token for the authenticated session.
                    type: string
                  refresh_token:
                    description: Refresh token for renewing the session.
                    type: string
                  expires_in:
                    description: Time in seconds until the access token expires.
                    type: integer
                  token_type:
                    description: Type of token issued. Usually 'Bearer'.
                    type: string
                  scope:
                    description: >-
                      Granted scopes for the access token, e.g.,
                      'offline_access'.
                    type: string
                    example: offline_access
              examples:
                response:
                  value:
                    access_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
                    refresh_token: def5020087681b9a...
                    expires_in: 86400
                    token_type: Bearer
                    scope: offline_access
        '400':
          description: Bad Request - Missing or invalid fields in the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthenticationError'
              example:
                detail: Malformed request.
        '403':
          description: >-
            The credentials are invalid, the account is disabled, or the user
            does not have permission to authenticate.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthenticationError'
              example:
                detail: You do not have permission to perform this action.
        '500':
          description: Internal Server Error - An unexpected error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
              example:
                detail: Server Error
        '503':
          description: The authentication service is unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
              example:
                detail: >-
                  Authentication service unavailable for Peerlogic API. Please
                  contact support.
      security: []
components:
  schemas:
    AuthenticationError:
      title: Authentication error
      type: object
      additionalProperties: true
      required:
        - detail
      properties:
        detail:
          type: string
          description: Why authentication failed.
    ServerError:
      title: Server error
      type: object
      additionalProperties: false
      required:
        - detail
      properties:
        detail:
          type: string
          description: Why the server could not complete the request.

````

## Related topics

- [Make your first API request](/quickstart.md)
- [Authentication](/authentication.md)
- [Peerlogic API](/developer-guides.md)
- [Organization, practice, and resource IDs](/concepts/organizations-and-practices.md)
- [Errors and rate limits](/concepts/errors-and-rate-limits.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.