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

# Read the card details

> Returns the PAN, the CVV and the expiration date encrypted to the key of
the application, after the account owner signed a
`cards.read_details.v1` challenge. The application calls this route
directly; your backend never sees the request or the reply. The route
takes no access token and allows any CORS origin.

Returns 401 with reason `INVALID_CHALLENGE` when any check of the
answer, the challenge or the signature fails, or when the challenge was
already used or expired. The reply does not say which check failed.
Returns 422 with reason `CARD_STATE_NOT_ALLOWED` when the card no longer
allows the action, 502 when the card processor failed after the challenge
was used (ask for a new challenge), and 503 when the request can be
retried with the same challenge.



## OpenAPI

````yaml https://core.sandbox.gnosispay.in/partner-api/openapi.json post /v1/cards/details
openapi: 3.2.0
info:
  title: Gnosis Pay Partner API
  version: 1.0.0
  description: >-
    Server-to-server API for onboarding users, creating accounts and cards,
    moving

    funds, and managing the card lifecycle. Call this API only from a trusted

    backend. Every request requires a partner access token, and every resource
    is

    scoped to the authenticated partner. The exceptions are the routes that the

    cardholder's application calls directly to read and change card data

    (`GET /v1/challenge/keys` and the card routes of the encrypted data

    protocol): they take no token and allow any CORS origin.
servers:
  - url: https://core.prod.gnosispay.com/partner-api
    description: Production
    variables: {}
  - url: https://core.sandbox.gnosispay.in/core
    description: Sandbox
    variables: {}
security:
  - BearerAuth: []
tags:
  - name: KYC
  - name: Accounts
  - name: Cards
  - name: Encrypted data
    description: >-
      Lets the cardholder's application read the card data (PAN, CVV, expiration

      date and PIN) and set a new PIN. The card data is encrypted between the

      application and GP. Your backend and your network never see it, even when

      a request passes through them.


      ## Goals


      - Only the application and GP can read the card data or the new PIN.

      - The account owner approves each action: the cardholder's wallet signs an
        EIP-712 message for it.
      - Your access token alone cannot read or change card data.

      - The application can verify that each challenge and each reply came from
        GP.

      ## Algorithms


      | Use | Algorithm |

      |---|---|

      | Keys | `EC` on the `P-256` curve |

      | Signature (JWS) | `ES256` |

      | Key agreement (JWE) | `ECDH-ES` |

      | Content encryption (JWE) | `A256GCM` |

      | Key thumbprint | RFC 7638 with SHA-256, base64url without padding |

      | Wallet signature | EIP-712 (`eth_signTypedData_v4`), checked with
      ERC-1271 for a smart account |


      Every token is a JWT. A standard JOSE library can create and verify all of

      them.


      ## Flow


      ```mermaid

      sequenceDiagram
          autonumber
          participant APP as Application
          participant WALLET as Wallet
          participant BACKEND as Your backend
          participant GP

          APP->>APP: create a signature key pair and an encryption key pair
          APP->>BACKEND: thumbprint of the signature public key
          BACKEND->>GP: POST /v1/challenge
          GP-->>BACKEND: challenge (JWS)
          BACKEND-->>APP: challenge
          APP->>GP: GET /v1/challenge/keys
          GP-->>APP: GP public keys (JWKS)
          APP->>APP: verify the challenge
          APP->>WALLET: sign the EIP-712 message of the challenge
          WALLET-->>APP: signature
          APP->>GP: POST /v1/cards/... with the signed and encrypted answer (JWE)
          alt read the card details or the PIN
              GP-->>APP: data (JWE that holds a JWS)
          else change the PIN
              GP-->>APP: proof (JWS)
          end
          APP->>APP: verify the reply and delete both key pairs
      ```
  - name: PCI
  - name: 3DS
  - name: Card transactions
  - name: Deposits
  - name: Withdrawals
  - name: Webhooks
paths:
  /v1/cards/details:
    post:
      tags:
        - Encrypted data
      summary: Read the card details
      description: >-
        Returns the PAN, the CVV and the expiration date encrypted to the key of

        the application, after the account owner signed a

        `cards.read_details.v1` challenge. The application calls this route

        directly; your backend never sees the request or the reply. The route

        takes no access token and allows any CORS origin.


        Returns 401 with reason `INVALID_CHALLENGE` when any check of the

        answer, the challenge or the signature fails, or when the challenge was

        already used or expired. The reply does not say which check failed.

        Returns 422 with reason `CARD_STATE_NOT_ALLOWED` when the card no longer

        allows the action, 502 when the card processor failed after the
        challenge

        was used (ask for a new challenge), and 503 when the request can be

        retried with the same challenge.
      operationId: cards.read_details.v1
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChallengeAnswerRequest'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CardDetailsReply'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - {}
components:
  schemas:
    ChallengeAnswerRequest:
      type: object
      required:
        - answer
      properties:
        answer:
          $ref: '#/components/schemas/ClientAnswerJwe'
          description: The answer of the application to the challenge.
      description: The body of every card route.
    CardDetailsReply:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/CardDetailsJwe'
          description: The PAN, the CVV and the expiration date.
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
          description: HTTP status code.
        message:
          type: string
          description: Generic human-readable text for the status code. Do not parse it.
        reason:
          type: string
          description: >-
            Stable machine-readable code identifying the specific cause, present
            only

            for errors that expose one (e.g. `CREATE_CARD_LIMIT_EXCEEDED`).
            Branch on

            this rather than on `message`.
    ClientAnswerJwe:
      type: string
      maxLength: 16384
      format: jwt
      description: >-
        A compact JWE (`ClientAnswerJweHeader`) to the GP encryption key that
        the

        `gp_enc_kid` claim of the challenge names. Its plaintext is a compact
        JWS

        (`ClientAnswerJwsHeader`) that the application signed with the private
        key

        of `client_sig_jwk`, with the claims `ClientAnswerClaims`.
      x-jwt-claims-schema: '#/components/schemas/ClientAnswerClaims'
      x-jws-header-schema: '#/components/schemas/ClientAnswerJwsHeader'
      x-jose-header-schema: '#/components/schemas/ClientAnswerJweHeader'
    CardDetailsJwe:
      type: string
      format: jwt
      description: |-
        A compact JWE (`ReplyJweHeader`) to `client_enc_jwk`. Its plaintext is a
        compact JWS (`ReplyJwsHeader`) that GP signed, with the claims
        `CardDetailsClaims`.

        The application decrypts it with the private key of `client_enc_jwk`,
        verifies the JWS with the key of `GET /v1/challenge/keys` whose `use` is
        `sig` and whose `kid` is the `kid` header, and checks that `jti` and
        `action` equal the ones of the challenge.
      x-jwt-claims-schema: '#/components/schemas/CardDetailsClaims'
      x-jws-header-schema: '#/components/schemas/ReplyJwsHeader'
      x-jose-header-schema: '#/components/schemas/ReplyJweHeader'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: Bearer

````

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