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

# Get an access token

> Exchanges a credential for an access token, using the OAuth 2.0 client credentials grant. Send a form-encoded or JSON body, with the credentials in the body or in HTTP Basic, where each is form-encoded first, as OAuth 2.0 says. The response and its errors follow OAuth 2.0, and there is no refresh token: when the token expires, exchange the credentials again.

Credentials: `partner`, `merchant`, as the API key's `client_id` and `client_secret` rather than a token



## OpenAPI

````yaml /api-reference/v1/payment-api.json post /oauth2/token
openapi: 3.1.0
info:
  title: Quidkey API
  version: 1.0.0
  description: >-
    The Quidkey public API.


    Within a version, a response can carry what this document doesn't list yet:
    a new field, a new value of an enum, a new error code. Handle a value you
    don't recognise rather than refusing the response. A client generated from
    this document turns an `enum` into a closed type unless told otherwise, so
    turn on its option for unknown values, such as openapi-generator's
    `enumUnknownDefaultCase`. A request is held to what's listed: a value it
    doesn't list is refused.
  contact:
    name: Quidkey
    url: https://docs.quidkey.com
servers:
  - url: https://api.quidkey.com/v1
security:
  - bearer: []
tags:
  - name: api_key
  - name: bank
  - name: bank_account
  - name: merchant
  - name: payment_link
  - name: payout
  - name: transaction
  - name: webhook_endpoint
paths:
  /oauth2/token:
    post:
      tags:
        - api_key
      summary: Get an access token
      description: >-
        Exchanges a credential for an access token, using the OAuth 2.0 client
        credentials grant. Send a form-encoded or JSON body, with the
        credentials in the body or in HTTP Basic, where each is form-encoded
        first, as OAuth 2.0 says. The response and its errors follow OAuth 2.0,
        and there is no refresh token: when the token expires, exchange the
        credentials again.


        Credentials: `partner`, `merchant`, as the API key's `client_id` and
        `client_secret` rather than a token
      operationId: api_key.getToken
      parameters: []
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/TokenRequest'
          application/json:
            schema:
              $ref: '#/components/schemas/TokenRequest'
      responses:
        '200':
          description: The response. It is not a resource document.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccessToken'
        '400':
          description: '`invalid_request`: The request can''t be processed as it was sent.'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthError'
          x-error-codes:
            - invalid_request
        '401':
          description: '`invalid_client`: Client authentication failed.'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthError'
          x-error-codes:
            - invalid_client
        '406':
          description: '`invalid_request`: The request can''t be processed as it was sent.'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthError'
          x-error-codes:
            - invalid_request
        '429':
          description: '`invalid_request`: The request can''t be processed as it was sent.'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
            Retry-After:
              $ref: '#/components/headers/RetryAfter'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthError'
          x-error-codes:
            - invalid_request
        '500':
          description: '`server_error`: Something went wrong on our side.'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthError'
          x-error-codes:
            - server_error
        '503':
          description: '`temporarily_unavailable`: The service is busy. Try again shortly.'
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
            Retry-After:
              $ref: '#/components/headers/RetryAfter'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthError'
          x-error-codes:
            - temporarily_unavailable
      security:
        - basic: []
        - {}
components:
  schemas:
    TokenRequest:
      additionalProperties: false
      type: object
      required:
        - grant_type
      properties:
        grant_type:
          const: client_credentials
          type: string
        client_id:
          type: string
          description: >-
            The `id` of the `api_key`. Leave it out when it's sent in HTTP
            Basic.
        client_secret:
          minLength: 1
          maxLength: 256
          description: The credential's secret. Leave it out when it's sent in HTTP Basic.
          type: string
    AccessToken:
      additionalProperties: false
      type: object
      required:
        - access_token
        - token_type
        - expires_in
      properties:
        access_token:
          description: 'Send this as `Authorization: Bearer <token>`.'
          type: string
        token_type:
          const: Bearer
          type: string
        expires_in:
          minimum: 1
          description: The number of seconds until the token expires.
          type: integer
    OAuthError:
      additionalProperties: false
      type: object
      required:
        - error
        - error_description
      properties:
        error:
          type: string
          enum:
            - invalid_request
            - invalid_client
            - server_error
            - temporarily_unavailable
        error_description:
          type: string
  headers:
    RequestId:
      description: Identifies this request. Quote it to support.
      schema:
        type: string
    RetryAfter:
      description: How many seconds to wait before retrying.
      schema:
        minimum: 0
        type: integer
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
    basic:
      type: http
      scheme: basic

````

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