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

# Request Access Token

> Exchange a `device_code` for an access token once the user approves the request.



## OpenAPI

````yaml POST /oauth/token
openapi: 3.1.0
info:
  title: Knot API
  description: An API to interact with the Knot merchant connectivity platform.
  version: 1.0.0
servers:
  - url: https://development.knotapi.com
    description: Development server
security:
  - basicAuth: []
paths:
  /oauth/token:
    servers:
      - url: https://api.dashboard.knotapi.com
    post:
      summary: Request Access Token
      description: >-
        Exchange a `device_code` for an access token once the user approves the
        request.
      operationId: oauth_token_create
      requestBody:
        description: The input parameters required for requesting an access token.
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                grant_type:
                  type: string
                  description: >-
                    The grant type. Must be
                    `urn:ietf:params:oauth:grant-type:device_code`.
                  enum:
                    - urn:ietf:params:oauth:grant-type:device_code
                  example: urn:ietf:params:oauth:grant-type:device_code
                client_id:
                  type: string
                  description: >-
                    The same client ID you sent to [Request Device
                    Code](/api-reference/agent-authorization/request-device-code).
                  example: 9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c
                device_code:
                  type: string
                  description: >-
                    The `device_code` from [Request Device
                    Code](/api-reference/agent-authorization/request-device-code).
                  example: def50200a1b2c3d4e5f6
              required:
                - grant_type
                - client_id
                - device_code
            examples:
              DeviceCodeGrant:
                summary: Device code grant
                value:
                  grant_type: urn:ietf:params:oauth:grant-type:device_code
                  client_id: 9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c
                  device_code: def50200a1b2c3d4e5f6
      responses:
        '200':
          description: Successful request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  token_type:
                    type: string
                    description: Always `Bearer`.
                    example: Bearer
                  expires_in:
                    type: integer
                    description: Seconds until the access token expires.
                    example: 900
                  access_token:
                    type: string
                    description: Access token to send as a Bearer token.
                    example: >-
                      eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI5ZjNjMmExZSJ9.c2lnbmF0dXJl
              examples:
                AccessToken:
                  summary: Access token
                  value:
                    token_type: Bearer
                    expires_in: 900
                    access_token: >-
                      eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI5ZjNjMmExZSJ9.c2lnbmF0dXJl
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthError'
              examples:
                AuthorizationPending:
                  summary: Authorization pending
                  value:
                    error: authorization_pending
                    error_description: >-
                      The authorization request is still pending as the end user
                      hasn't yet completed the user interaction steps. The
                      client SHOULD repeat the Access Token Request to the token
                      endpoint
                    hint: ''
                SlowDown:
                  summary: Slow down
                  value:
                    error: slow_down
                    error_description: >-
                      The authorization request is still pending and polling
                      should continue, but the interval MUST be increased by 5
                      seconds for this and all subsequent requests.
                    hint: ''
                ExpiredToken:
                  summary: Expired device code
                  value:
                    error: expired_token
                    error_description: >-
                      The `device_code` has expired and the device authorization
                      session has concluded.
                    hint: device_code
                InvalidGrant:
                  summary: Device code already used or unknown
                  value:
                    error: invalid_grant
                    error_description: >-
                      The provided authorization grant (e.g., authorization
                      code, resource owner credentials) or refresh token is
                      invalid, expired, revoked, does not match the redirection
                      URI used in the authorization request, or was issued to
                      another client.
                SecretSent:
                  summary: Secret sent
                  value:
                    error: invalid_request
                    error_description: >-
                      Do not send your client secret. Agent authorization only
                      needs your client_id.
        '401':
          description: Unauthorized request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthError'
              examples:
                AccessDenied:
                  summary: Access denied
                  value:
                    error: access_denied
                    error_description: >-
                      The resource owner or authorization server denied the
                      request.
                InvalidClient:
                  summary: Invalid client
                  value:
                    error: invalid_client
                    error_description: Client authentication failed
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                InternalServerError:
                  summary: Unexpected server error
                  value:
                    message: Server Error
      security: []
components:
  schemas:
    OAuthError:
      type: object
      description: OAuth 2.0 error response, as defined in RFC 6749 and RFC 8628.
      properties:
        error:
          type: string
          description: OAuth error code.
          example: authorization_pending
        error_description:
          type: string
          description: Human-readable description of the error.
          example: The authorization request is still pending.
        hint:
          type: string
          description: Additional detail about the error, when available.
          example: Check the `device_code` parameter
    Error:
      type: object
      properties:
        error_type:
          type: string
          description: Type of error.
          enum:
            - INVALID_INPUT
            - INVALID_REQUEST
            - USER_ERROR
            - SESSION_ERROR
            - MERCHANT_ACCOUNT_ERROR
            - MERCHANT_ERROR
            - SUBSCRIPTION_ERROR
            - TRANSACTION_ERROR
            - CART_ERROR
            - WEBHOOK_ENDPOINT_ERROR
          example: INVALID_REQUEST
        error_code:
          type: string
          description: Error code.
          enum:
            - INVALID_API_KEYS
            - INVALID_FIELD
            - INVALID_JWE
            - INVALID_CURSOR_FORMAT
            - USER_NOT_FOUND
            - MERCHANT_ACCOUNT_NOT_FOUND
            - MERCHANT_ACCOUNT_DISCONNECTED
            - SESSION_NOT_FOUND
            - EXTEND_NOT_SUPPORTED
            - MERCHANT_UNAVAILABLE
            - NO_ACCESS
            - TRANSACTION_NOT_FOUND
            - NO_TRANSACTIONS
            - SUBSCRIPTION_NOT_FOUND
            - CANCELLABLE_SUBSCRIPTION_NOT_FOUND
            - MULTIPLE_CANCELLABLE_SUBSCRIPTIONS_FOUND
            - ONGOING_OPERATION
            - CART_NOT_FOUND
            - FULFILLMENT_NOT_FOUND
            - INVALID_ACCESS_TOKEN
            - INSUFFICIENT_SCOPE
            - INSUFFICIENT_ROLE
            - WEBHOOK_ENDPOINT_NOT_FOUND
            - WEBHOOK_ENDPOINT_LIMIT_REACHED
            - WEBHOOK_ENDPOINT_ALREADY_EXISTS
            - RATE_LIMIT_EXCEEDED
            - ENVIRONMENT_MISMATCH
          example: INVALID_FIELD
        error_message:
          type: string
          description: Detailed error message.
          example: The limit may not be greater than 10.
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >-
        Basic authentication header of the form `Basic <encoded-value>`, where
        `<encoded-value>` is the base64-encoded string `username:password`. Use
        your `client_id` as the `username` and your `secret` as the `password`
        value.

````

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