> ## 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 Device Code

> Request a device code to start the device authorization flow.



## OpenAPI

````yaml POST /oauth/device/code
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/device/code:
    servers:
      - url: https://api.dashboard.knotapi.com
    post:
      summary: Request Device Code
      description: Request a device code to start the device authorization flow.
      operationId: oauth_device_code_create
      requestBody:
        description: The input parameters required for requesting a device code.
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                client_id:
                  type: string
                  description: >-
                    Your client ID for the environment you want to manage, found
                    in the Knot Dashboard. Never send your secret.
                  example: 9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c
                scope:
                  type: string
                  description: >-
                    Space-delimited list of
                    [scopes](/api-reference/agent-authorization/overview#scopes)
                    to request. At least one is required.
                  example: webhooks:read webhooks:write
              required:
                - client_id
                - scope
            examples:
              ManageWebhookEndpoints:
                summary: Manage webhook endpoints
                value:
                  client_id: 9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c
                  scope: webhooks:read webhooks:write
      responses:
        '200':
          description: Successful request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  device_code:
                    type: string
                    description: >-
                      Code to exchange for an access token. Do not show it to
                      the user.
                    example: def50200a1b2c3d4e5f6
                  user_code:
                    type: string
                    description: >-
                      Code for the user to enter in the Knot Dashboard. Eight
                      letters; a hyphen is optional.
                    example: WDJBMJHT
                  verification_uri:
                    type: string
                    description: URL where the user approves the request.
                    example: https://api.dashboard.knotapi.com/oauth/device
                  verification_uri_complete:
                    type: string
                    description: >-
                      The `verification_uri` with the `user_code`. The approval
                      page still asks the user to enter the code.
                    example: >-
                      https://api.dashboard.knotapi.com/oauth/device?user_code=WDJBMJHT
                  expires_in:
                    type: integer
                    description: Seconds until the `device_code` and `user_code` expire.
                    example: 600
                  interval:
                    type: integer
                    description: Minimum seconds to wait between polling requests.
                    example: 5
              examples:
                DeviceCode:
                  summary: Device code
                  value:
                    device_code: def50200a1b2c3d4e5f6
                    user_code: WDJBMJHT
                    verification_uri: https://api.dashboard.knotapi.com/oauth/device
                    verification_uri_complete: >-
                      https://api.dashboard.knotapi.com/oauth/device?user_code=WDJBMJHT
                    expires_in: 600
                    interval: 5
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthError'
              examples:
                InvalidScope:
                  summary: Invalid scope
                  value:
                    error: invalid_scope
                    error_description: The requested scope is invalid, unknown, or malformed
                    hint: Check the `webhooks:admin` scope
                InvalidRequest:
                  summary: Missing parameter
                  value:
                    error: invalid_request
                    error_description: >-
                      The request is missing a required parameter, includes an
                      invalid parameter value, includes a parameter more than
                      once, or is otherwise malformed.
                    hint: Check the `client_id` parameter
                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:
                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.