> ## 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.

# Checkout

> Checkout a user's merchant cart.



## OpenAPI

````yaml POST /cart/checkout
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:
  /cart/checkout:
    post:
      description: Checkout a user's merchant cart.
      operationId: checkout
      requestBody:
        description: The input parameters required to checkout a cart.
        content:
          application/json:
            schema:
              type: object
              properties:
                external_user_id:
                  type: string
                  description: Your unique identifier for the user.
                  example: abc123
                merchant_id:
                  type: integer
                  description: Unique identifier for the merchant.
                  example: 456
                payment_method:
                  type: object
                  properties:
                    id:
                      type: string
                      description: Your unique identifier for the payment method.
                      example: 81n9al10a0ayn13
                    jwe:
                      type: string
                      description: >-
                        JWE value of the `user` and `card` objects. Created
                        using the public key retrieved from [Retrieve
                        JWK](https://docs.knotapi.com/api-reference/products/card-switcher/retrieve-jwk)
                      example: eyJhbGciOiJSU0EtT0FFUC0yNTYiLC...
                    is_single_use:
                      type: boolean
                      description: Whether the payment method is single-use only.
                      example: true
                      default: false
                  required:
                    - id
                    - jwe
                    - is_single_use
                simulate:
                  description: Simulate a failure in the development environment.
                  oneOf:
                    - type: string
                      enum:
                        - failed
                      description: The checkout attempt fails.
                      example: failed
              required:
                - external_user_id
                - merchant_id
      responses:
        '202':
          description: Successful request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Success message.
                    example: Success
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                UserNotFound:
                  summary: User was not found
                  value:
                    error_type: USER_ERROR
                    error_code: USER_NOT_FOUND
                    error_message: >-
                      The user was not found. Please check the external_user_id
                      provided.
                MerchantAccountNotFound:
                  summary: Merchant account was not found
                  value:
                    error_type: MERCHANT_ACCOUNT_ERROR
                    error_code: MERCHANT_ACCOUNT_NOT_FOUND
                    error_message: >-
                      The merchant account was not found. Please check the
                      merchant_id provided.
                CartNotFound:
                  summary: Cart was not found
                  value:
                    error_type: CART_ERROR
                    error_code: CART_NOT_FOUND
                    error_message: >-
                      The cart was not found. Please ensure you synced the cart
                      recently.
                MerchantAccountDisconnected:
                  summary: Merchant account is disconnected
                  value:
                    error_type: MERCHANT_ACCOUNT_ERROR
                    error_code: MERCHANT_ACCOUNT_DISCONNECTED
                    error_message: >-
                      The merchant account is disconnected. Please check the
                      merchant_id provided.
                MerchantUnavailable:
                  summary: Merchant is not available
                  value:
                    error_type: MERCHANT_ERROR
                    error_code: MERCHANT_UNAVAILABLE
                    error_message: >-
                      The merchant is unavailable. Please check the merchant_id
                      provided.
                MerchantIdRequired:
                  summary: merchant_id field is required
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_FIELD
                    error_message: The merchant_id field is required.
                ExternalUserIdRequired:
                  summary: external_user_id is required
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_FIELD
                    error_message: The external user id field is required.
                PaymentMethodFieldRequired:
                  summary: ID is missing in payment_method
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_FIELD
                    error_message: >-
                      The payment_method.id field is required when
                      payment_method is provided.
                UserFieldRequired:
                  summary: User object field required
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The user.phone number is required.
                CardNumberNotNumeric:
                  summary: Card number not numeric.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The card.number must be numeric.
                CardNumberTooLong:
                  summary: Card number too long.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The card.number is too long for card type.
                CardNumberTooShort:
                  summary: Card number too short.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The card.number is too short for card type.
                CardNumberInvalid:
                  summary: Card number invalid.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: >-
                      The card.number is invalid and does not pass the Luhn
                      check.
                CVVNotNumeric:
                  summary: CVV not numeric
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The card.cvv must be numeric.
                CVVTooLong:
                  summary: CVV to long.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The card.cvv is too long for card type.
                CVVTooShort:
                  summary: CVV to short.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The card.cvv is too short for card type.
                CVVRequired:
                  summary: CVV is required.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The card.cvv is required.
                CardExpirationInvalid:
                  summary: Card expiration invalid.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The card.expiration should be in MM/YYYY or MM/YY format.
                CardExpired:
                  summary: Card expired.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The card is expired.
                InvalidJWE:
                  summary: JWE invalid.
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_JWE
                    error_message: The jwe is invalid.
                OngoingOperation:
                  summary: There is an existing operation
                  value:
                    error_type: MERCHANT_ACCOUNT_ERROR
                    error_code: ONGOING_OPERATION
                    error_message: An existing operation is in progress.
        '401':
          description: Unauthorized request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                AuthFailed:
                  summary: Auth failed
                  value:
                    error_type: INVALID_INPUT
                    error_code: INVALID_API_KEYS
                    error_message: Invalid client_id or secret provided.
        '403':
          description: Forbidden request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                NoAccess:
                  summary: No access
                  value:
                    error_type: INVALID_REQUEST
                    error_code: NO_ACCESS
                    error_message: Please contact Knot for access to this endpoint.
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                InternalServerError:
                  summary: Unexpected server error
                  value:
                    message: Server Error
components:
  schemas:
    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
          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
            - ONGOING_OPERATION
            - CART_NOT_FOUND
            - FULFILLMENT_NOT_FOUND
          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.

````