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

# Get an access token

> Exchanges an API key for an access token (OAuth 2.0 client credentials). Send `grant_type=client_credentials`, `client_id` (the key id, `mk_…`) and `client_secret` (`ms_…`) as a form or JSON body, or the id and secret as HTTP Basic authentication. The token lasts 10 minutes; get a new one when it expires.



## OpenAPI

````yaml /api-reference/openapi.json post /oauth/token
openapi: 3.1.1
info:
  title: Mojo Payments API
  description: >-
    Invoices, deposits, payments and locations for merchants; the merchant
    portfolio for reseller partners. Authenticate with an API key: exchange it
    at `POST /oauth/token` for a 10-minute access token, and send that as
    `Authorization: Bearer <token>`. Guides:
    https://kb.paymentsmojo.com/developers/overview
  version: '1'
servers:
  - url: https://api.paymentsmojo.com
security:
  - Bearer: []
tags:
  - name: Reseller portfolio
  - name: Invoice payments
  - name: Authentication
  - name: Locations
  - name: Merchant accounts (MIDs)
  - name: Merchant applications
  - name: POS Gateway
  - name: Deposits
paths:
  /oauth/token:
    post:
      tags:
        - Authentication
      summary: Get an access token
      description: >-
        Exchanges an API key for an access token (OAuth 2.0 client credentials).
        Send `grant_type=client_credentials`, `client_id` (the key id, `mk_…`)
        and `client_secret` (`ms_…`) as a form or JSON body, or the id and
        secret as HTTP Basic authentication. The token lasts 10 minutes; get a
        new one when it expires.
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/TokenRequest'
          application/json:
            schema:
              $ref: '#/components/schemas/TokenRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthErrorResponse'
components:
  schemas:
    TokenRequest:
      required:
        - grant_type
        - client_id
        - client_secret
      type: object
      properties:
        grant_type:
          type:
            - 'null'
            - string
        client_id:
          type:
            - 'null'
            - string
        client_secret:
          type:
            - 'null'
            - string
    TokenResponse:
      required:
        - access_token
        - token_type
        - expires_in
        - scope
        - organization_id
      type: object
      properties:
        access_token:
          type: string
        token_type:
          type: string
        expires_in:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - integer
            - string
          format: int32
        scope:
          type: string
        organization_id:
          type: string
          format: uuid
    OAuthErrorResponse:
      required:
        - error
        - error_description
      type: object
      properties:
        error:
          type: string
        error_description:
          type: string
  securitySchemes:
    Bearer:
      type: http
      description: >-
        An access token from POST /oauth/token (your API key's id and secret).
        It lasts 10 minutes.
      scheme: bearer
      bearerFormat: JWT

````

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