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

# Switch Card JWE

> Switch a card in a user's merchant account.

<Tip>See code samples [here](/card-switcher/sending-card-data#code-samples) for how to structure and encrypt the JWE in various programming languages.</Tip>

Receiving a successful response from this endpoint means your request has passed validations, including for the `jwe`.


## OpenAPI

````yaml /api-reference/openapi.json POST /card
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:
  /card:
    post:
      description: Switch a card in a user's merchant account.
      operationId: card_switch
      requestBody:
        description: The input parameters required for switching a card.
        content:
          application/json:
            schema:
              oneOf:
                - title: CardSwitcher
                  type: object
                  properties:
                    jwe:
                      type: string
                      description: JWE value.
                      example: eyJhbGciOiJSU0EtT0FFUC0yNTYiLC...
                    task_id:
                      type: string
                      description: >-
                        `task_id` value provided in the
                        [`AUTHENTICATED`](/link/webhook-events/authenticated)
                        webhook.
                      example: '123456'
                  required:
                    - jwe
                    - task_id
                - title: CardUpdater
                  type: object
                  properties:
                    jwe:
                      type: string
                      description: JWE value.
                      example: eyJhbGciOiJSU0EtT0FFUC0yNTYiLC...
                    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
                    card_name:
                      type: string
                      description: >-
                        Name of the card. Learn more
                        [here](/sdk/ios#customerconfiguration).
                      example: My Credit Card
                    customer_name:
                      type: string
                      description: >-
                        Name of the customer. Learn more
                        [here](/sdk/ios#customerconfiguration).
                      example: John Doe
                  required:
                    - jwe
                    - external_user_id
                    - merchant_id
      responses:
        '200':
          description: >-
            Successful request. Receiving this response means your request has
            passed validations, including the `jwe`.
          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:
                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.
                JWEInvalid:
                  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.
        '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.
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.

````