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

# Sync Cart

> Add one or more products to a user's merchant cart.



## OpenAPI

````yaml POST /cart
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:
    post:
      description: Add one or more products to a user's merchant cart.
      operationId: cart_sync
      requestBody:
        description: >-
          The input parameters required for adding products to a user's merchant
          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: 44
                products:
                  type: array
                  description: List of products to add to the cart.
                  items:
                    type: object
                    properties:
                      external_id:
                        type: string
                        description: >-
                          Merchant's identifier for the product. Format varies
                          by merchant.
                        example: '3324893784'
                      fulfillment:
                        type: object
                        description: ''
                        properties:
                          id:
                            type: string
                            description: >-
                              Unique identifier for the fulfillment option sent
                              in
                              [`SYNC_CART_SUCCEEDED`](https://docs.knotapi.com/shopping/webhook-events#sync-cart-succeeded).
                            example: >-
                              5cfbe095d0cb9e597e316170d6ee9a6c667bddcde4a999222d2cc2b5bbfef7cf
                        required:
                          - id
                    required:
                      - external_id
                delivery_location:
                  type: object
                  description: ''
                  properties:
                    address:
                      type: object
                      description: ''
                      properties:
                        line1:
                          type: string
                          description: First line of the delivery address.
                          example: 123 Main St
                          maxLength: 46
                        line2:
                          type: string
                          description: Second line of the delivery address.
                          example: Floor 4
                          maxLength: 46
                        city:
                          type: string
                          description: City portion of the delivery address.
                          example: Los Angeles
                        region:
                          type: string
                          description: >-
                            Region portion of the delivery address, usually a
                            state abbreviation. Must be an ISO 3166-2
                            sub-division code.
                          example: CA
                        postal_code:
                          type: string
                          description: Postal code of the delivery address.
                          example: '94105'
                          minLength: 5
                          maxLength: 10
                        country:
                          type: string
                          description: >-
                            Country portion of the delivery address. Must be an
                            ISO 3166-1 alpha-2 code.
                          example: US
                      required:
                        - line1
                        - city
                        - region
                        - postal_code
                        - country
                    first_name:
                      type: string
                      maxLength: 255
                      description: First name for the delivery address.
                      example: Ada
                    last_name:
                      type: string
                      maxLength: 255
                      description: Last name for the delivery address.
                      example: Lovelace
                    phone_number:
                      type: string
                      description: Phone number for the delivery address in E.164 format.
                      example: '+11234567890'
                    set_as_default:
                      type: boolean
                      description: >-
                        Whether the delivery address should be saved as the
                        user's default in the merchant account.
                      example: true
                      default: false
                  required:
                    - address
                    - first_name
                    - last_name
                    - phone_number
                    - set_as_default
                simulate:
                  description: Simulate a failure in the development environment.
                  oneOf:
                    - type: string
                      enum:
                        - failed
                      description: The sync cart attempt fails.
                      example: failed
              required:
                - external_user_id
                - merchant_id
                - products
            examples:
              Success:
                summary: Success
                value:
                  external_user_id: abc123
                  merchant_id: 44
                  products:
                    - external_id: '3324893784'
              Failure:
                summary: Failure
                value:
                  external_user_id: abc123
                  merchant_id: 44
                  products:
                    - external_id: '3324893784'
                  simulate: failed
      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.
                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.
                MerchantNotFound:
                  summary: Merchant was not found
                  value:
                    error_type: MERCHANT_ERROR
                    error_code: MERCHANT_NOT_FOUND
                    error_message: >-
                      The merchant was not found. 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.
                FulfillmentNotFound:
                  summary: Fulfillment was not found
                  value:
                    error_type: CART_ERROR
                    error_code: FULFILLMENT_NOT_FOUND
                    error_message: >-
                      The fulfillment option was not found. Please check the
                      fulfillment.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.
                ProductExternalIdRequired:
                  summary: product.external_id is required
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_FIELD
                    error_message: The product.external_id field is required.
                DeliveryLocationFieldRequired:
                  summary: Delivery location field required
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_FIELD
                    error_message: The delivery_location.phone_number field is required.
                InvalidDeliveryLocationField:
                  summary: Invalid delivery_location field
                  value:
                    error_type: INVALID_REQUEST
                    error_code: INVALID_FIELD
                    error_message: >-
                      The delivery_location.first_name must not be greater than
                      255 characters.
                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.

````