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

# Validate Bank Account

> Checks an India bank account or UPI ID with the bank before you add it. Nothing is stored.

Validate Bank Account

Add the Zapyd "Validate Bank Account" call (`POST /cms/api/v1/bank/validate`) to my backend. Checks an India bank account or UPI ID with the bank before you add it. Nothing is stored.

* Sandbox: `POST https://api-sandbox.zapyd.com/cms/api/v1/bank/validate`
* Production: `POST https://api.zapyd.com/cms/api/v1/bank/validate`

JSON body:

* `country` (string, required): ISO 3166-1 alpha-3 country of the account. IND only.
* `bank_account_type` (string, optional): ACCOUNT\_DETAILS (account number and IFSC) or UPI. Defaults to ACCOUNT\_DETAILS.
* `identifiers` (object, required): The account to check: `{account_number, ifsc}` for ACCOUNT\_DETAILS, or `{vpa}` for UPI. account\_holder\_name is optional and isn't matched against the account.

Success: HTTP 200, `{status: true, message, data}`. `data`: `country`, `status` (VALID: the account exists and can receive money. INVALID: final for this account; don't retry it), `account_holder_name` (The name the bank holds for the account. null when INVALID or when the bank doesn't return one), `reason` (Why the account is INVALID. null when VALID), `country_details` (Facts only this country has. Fields: `is_non_resident_account`).
Errors (`{status: false, message, err_code, errors}`):

* 400 `Bad Request`: `country` isn't `IND`, `bank_account_type` isn't `ACCOUNT_DETAILS` or `UPI`, or an identifier is missing
* 503 `Bank validation unavailable, retry`: The bank couldn't answer. Retry with backoff (`err_code: bank_validation_unavailable`)
* 500 `Internal Server Error`
  Every endpoint can also return 401 `AUTH_*` (signature, timestamp or key: fix, don't retry), and 429 or 5xx (retry with backoff).

Rules:

* Optional, India only: call it before `POST /bank/create` to check the account number and IFSC, or the UPI ID (`vpa`), while the user is on the form. No customer needed; nothing is stored.
* `VALID`: show `account_holder_name` for the user to confirm. `country_details.is_non_resident_account: true` means an NRE account, which can't receive payouts: ask for another. `INVALID` is final: show `reason`, don't retry. 503 `bank_validation_unavailable`: retry with backoff.
* Each call runs a penny drop, so call it once on submit, never per keystroke.

Signing (every request):

* Headers: `X-API-KEY`, `X-TIMESTAMP` (Unix seconds, within 300 s of server time; generate per request) and `X-SIGNATURE`.
* `X-SIGNATURE` = Base64(HMAC-SHA256(key = API secret, message = apiKey + "|" + timestamp + "|" + canonicalBody)). Base64 of the raw digest, not hex.
* canonicalBody: the JSON body with keys sorted at every nesting level, no whitespace (separators `,` and `:`), and every non-ASCII character escaped as lowercase `\uXXXX` (Python `json.dumps(body, sort_keys=True, separators=(",", ":"))`). Requests with no body (GET, DELETE) sign `{}`. Query parameters are not signed.
* Send the exact canonicalBody string you signed as the request body, with `Content-Type: application/json`.
* Test vector: key `3f1b2c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d`, secret `test-secret-do-not-use`, timestamp `1735689600`. Signing `{}` gives `6sCtVSRQjU9+2/af8gdwUAvY1l6Ii6ENcbRfanPkhY0=`. Body `{"customer_id":"78c99d71-f28f-47a9-8302-93b286efbe0e","amount":100.5,"currency":"INR","meta":{"note":"Café","b":2,"a":1}}` gives `l+DvQrzlKbsOSxSYOdWoWHEehcFRZfDJPKlLDkm2cSI=`.

Deliver:

1. A typed `validateBankAccount` function in this codebase's language and HTTP client. Reuse an existing Zapyd client and signer, or write one small shared client.
2. Config from `ZAPYD_API_KEY`, `ZAPYD_API_SECRET` and `ZAPYD_BASE_URL`. The secret stays on the server, never in a browser or app.
3. Return `data`. When `status` is false, throw an error with the HTTP status, `err_code`, `message` and `errors`. Don't show raw errors to end users.
4. Retry only 429 and 5xx: exponential backoff from 1 s, capped at 30 s, at most 5 attempts.
5. Amounts as strings. Types for every field above.
6. Tests: the signer against the test vector, and this call against sandbox.

Reference: `https://docs.zapyd.com/api-reference-exchange/endpoint/bank/validate.md`

## When to use it

Call it before [Add Bank Account](https://docs.zapyd.com/api-reference-exchange/endpoint/bank/create.md) to catch a wrong account number, IFSC or UPI ID while the user is still on the form. It needs no customer and stores nothing.

| `data.status` | What to do |
| - | - |
| `VALID` | Show `account_holder_name` so the user can confirm it's their account, then add it. If `country_details.is_non_resident_account` is `true`, ask for another account: NRE accounts can't receive payouts. |
| `INVALID` | Show the `reason` and ask for another account. Don't retry the same details. |

A 503 means the bank couldn't answer in time. Retry with backoff.

| `reason` | Meaning |
| - | - |
| `invalid_ifsc` | The IFSC doesn't exist |
| `invalid_account` | The account number and IFSC don't match an account |
| `account_not_found` | The account doesn't exist |
| `account_blocked` | The account is blocked |
| `account_closed` | The account is closed |
| `invalid_vpa` | The UPI ID can't receive money |
| `bank_validation_failed` | The bank rejected the account for another reason |

> [!NOTE]
>
> Each call runs a penny drop. Validate an account once, when the user submits it.

## Error Codes and Messages

| API Status Code | Response | Reason |
| - | - | - |
| 400 | Bad Request | `country` isn't `IND`, `bank_account_type` isn't `ACCOUNT_DETAILS` or `UPI`, or an identifier is missing |
| 503 | Bank validation unavailable, retry | The bank couldn't answer. Retry with backoff (`err_code: bank_validation_unavailable`) |
| 500 | Internal Server Error | Internal Server Error |


## OpenAPI

````yaml POST /bank/validate
openapi: 3.1.0
info:
  title: Zapyd API
  description: API for Zapyd - Customer, Payout, and Webhook services
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api-sandbox.zapyd.com/pos/api/v1
    description: Payout API Base URL
    variables:
      base_url:
        default: https://api-sandbox.zapyd.com
  - url: https://api-sandbox.zapyd.com/cms/api/v1
    description: Customer API Base URL
    variables:
      base_url:
        default: https://api-sandbox.zapyd.com
security:
  - ApiKeyAuth: []
    TimestampAuth: []
    SignatureAuth: []
tags:
  - name: Customer
    description: Customer related operations
    x-displayName: Customer
    x-traitTag: true
  - name: Payout
    description: Payout related operations
  - name: Webhooks
    description: Webhook related operations
  - name: Widget
    description: Hosted buy/sell widget session initialization
paths:
  /bank/validate:
    post:
      tags:
        - Bank
      description: >-
        Check a bank account or UPI ID with the bank before you add it. Nothing
        is stored and no customer is needed. Supported for India (IND). The
        response has the account holder's name as the bank holds it and whether
        the account is a non-resident (NRE) account. Each call runs a penny
        drop, so validate an account once, not on every keystroke.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - country
                - identifiers
              properties:
                country:
                  type: string
                  enum:
                    - IND
                  description: ISO 3166-1 alpha-3 country of the account. IND only.
                  example: IND
                bank_account_type:
                  type: string
                  enum:
                    - ACCOUNT_DETAILS
                    - UPI
                  description: >-
                    Optional. ACCOUNT_DETAILS (account number and IFSC) or UPI.
                    Defaults to ACCOUNT_DETAILS.
                  example: ACCOUNT_DETAILS
                identifiers:
                  type: object
                  description: >-
                    The account to check: {account_number, ifsc} for
                    ACCOUNT_DETAILS, or {vpa} for UPI. account_holder_name is
                    optional and isn't matched against the account.
                  example:
                    account_number: '7627389201'
                    ifsc: SBIN0001829
            examples:
              india_account:
                summary: India, account + IFSC
                value:
                  country: IND
                  bank_account_type: ACCOUNT_DETAILS
                  identifiers:
                    account_number: '7627389201'
                    ifsc: SBIN0001829
              india_upi:
                summary: India, UPI
                value:
                  country: IND
                  bank_account_type: UPI
                  identifiers:
                    vpa: priya@oksbi
      responses:
        '200':
          description: 'The bank answered. Read data.status: VALID or INVALID.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Success
                  data:
                    type: object
                    properties:
                      country:
                        type: string
                        example: IND
                      status:
                        type: string
                        enum:
                          - VALID
                          - INVALID
                        description: >-
                          VALID: the account exists and can receive money.
                          INVALID: final for this account; don't retry it.
                        example: VALID
                      account_holder_name:
                        type: string
                        nullable: true
                        description: >-
                          The name the bank holds for the account. null when
                          INVALID or when the bank doesn't return one.
                        example: PRIYA SHARMA
                      reason:
                        type: string
                        nullable: true
                        enum:
                          - invalid_ifsc
                          - invalid_account
                          - account_not_found
                          - account_blocked
                          - account_closed
                          - invalid_vpa
                          - bank_validation_failed
                        description: Why the account is INVALID. null when VALID.
                        example: null
                      country_details:
                        type: object
                        description: Facts only this country has.
                        properties:
                          is_non_resident_account:
                            type: boolean
                            nullable: true
                            description: >-
                              India: true for an NRE (non-resident) account,
                              which can't receive payouts. null when the bank
                              doesn't say.
                            example: false
        '400':
          description: >-
            Bad Request: an unsupported country or bank_account_type, or a
            missing identifier
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Bad Request
                  data:
                    type: 'null'
                  errors:
                    type: object
                    example:
                      identifiers:
                        ifsc:
                          - This field is required.
                  err_code:
                    type: string
                    example: REQ_FIELD_MISSING
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Internal Server Error
                  data:
                    type: 'null'
                  err_code:
                    type: string
                    example: SYS_INTERNAL_ERROR
                  errors:
                    type: string
                    example: Unexpected error occurred. Please try again later.
        '503':
          description: The bank couldn't answer. Retry with backoff.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    example: false
                  message:
                    type: string
                    example: Bank validation unavailable, retry
                  data:
                    type: 'null'
                  err_code:
                    type: string
                    example: bank_validation_unavailable
      servers:
        - url: https://api-sandbox.zapyd.com/cms/api/v1
          description: Bank API Base URL
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: API Key for authentication
    TimestampAuth:
      type: apiKey
      in: header
      name: X-TIMESTAMP
      description: Current timestamp in seconds since epoch
    SignatureAuth:
      type: apiKey
      in: header
      name: X-SIGNATURE
      description: HMAC SHA256 signature of the request encoded in Base64

````

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