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

# Validate Recharge

> Use this API to check whether a recharge is likely to go through, before you take payment from the customer.

Send the same details as in the recharge request, without the `reference_id`. The API runs the same input checks as the recharge request, so a malformed request returns the same errors.

The API always returns HTTP 200. Read `data.status`:

- `VALID`: The recharge can be attempted. `data.validation_ref` holds the reference of the check. Keep it for your records and quote it if you contact support. The Recharge Request API does not need it.
- `INVALID`: The recharge cannot go through as sent. `data.reason_code` and `data.reason_message` tell you why. Do not take payment for it.
- `UNAVAILABLE`: The check could not be completed right now. You can still send the recharge request.

`reason_code` and `reason_message` are `null` when the status is `VALID`, and `validation_ref` is `null` for any other status.

## Validation checks

The API runs the following checks, depending on your account type and the fields that you send. For what prefunding and postfunding mean, see [Payment Scenarios](https://www.cashfree.com/docs/api-reference/other-apis/bbps-cou/payment-scenarios.md). The shortfall limit is the maximum amount by which your recharge wallet can go below zero. The last column lists the reason codes that the API returns when a check fails or cannot be completed:

| Check | Applies to | What the API checks | Reason codes |
| :- | :- | :- | :- |
| Recharge wallet | All accounts | A recharge wallet is set up for your account, and it is active. | `wallet_not_configured`, `wallet_inactive` |
| Wallet balance | Prefunding accounts | The wallet balance covers the full `amount`. | `insufficient_balance`, `wallet_unavailable` |
| Shortfall limit | Postfunding accounts | The amount that the wallet has to cover keeps the wallet within your shortfall limit. | `shortfall_limit_exceeded`, `shortfall_threshold_not_configured`, `shortfall_threshold_unavailable` |
| Payment | Requests where `payments` has a `pg_reference_id` | The Cashfree Payment Gateway payment is verified the same way as in the Recharge Request API. | `pg_payment_invalid`, `pg_payment_already_used`, `pg_unavailable` |
| Recharge details | All requests | The operator is supported for the service type, and the recharge number is valid for that operator. | - |
| Operator check | All requests | Cashfree validates the recharge with the operator. | - |

If `payments` has a `pg_amount` but no `pg_reference_id`, nothing is verified. The API uses `pg_amount` only to work out how much of the recharge the wallet has to cover.

> [!NOTE]
>
> A `VALID` result is advisory. The Recharge Request API checks everything again, so its result can differ if your wallet balance, your shortfall limit, or the payment changes between the two calls.

## Reason codes

When the status is `INVALID` or `UNAVAILABLE`, the API returns HTTP 200 with a `reason_code` and a `reason_message` that explain the result. Do not take payment for an `INVALID` recharge. For an `UNAVAILABLE` result, you can still send the recharge request. The following table lists the reason codes the API can return:

> [accordion] Reason codes
>
> | Reason code | Description | Status |
> | :- | :- | :- |
> | `wallet_not_configured` | No recharge wallet is set up for your account. | `INVALID` |
> | `wallet_inactive` | Your recharge wallet is not active. | `INVALID` |
> | `insufficient_balance` | Your wallet balance is lower than the amount. Prefunding accounts only. | `INVALID` |
> | `shortfall_limit_exceeded` | The recharge would take your wallet past your shortfall limit. Postfunding accounts only. | `INVALID` |
> | `shortfall_threshold_not_configured` | No shortfall limit is set for your account. Postfunding accounts only. | `INVALID` |
> | `pg_payment_invalid` | The payment cannot be used for this recharge. `reason_message` says why. | `INVALID` |
> | `pg_payment_already_used` | The payment is already linked to another recharge. | `INVALID` |
> | `wallet_unavailable` | The wallet balance could not be checked right now. | `UNAVAILABLE` |
> | `shortfall_threshold_unavailable` | The shortfall limit could not be checked right now. | `UNAVAILABLE` |
> | `pg_unavailable` | The payment could not be verified right now. | `UNAVAILABLE` |

Other reason codes can be returned. Handle them by `status`, and show `reason_message` where it helps.

## Error codes

The following table lists the error codes you may encounter when validating a recharge:

> [accordion] Error codes
>
> | Code | Description | Type | Status |
> | :- | :- | :- | :- |
> | `request_failed` | The `amount` is not a whole rupee amount greater than 0. Message: `amount must be a whole rupee amount greater than 0` | `invalid_request_error` | 400 |
> | `request_failed` | The `recharge_number` is not a valid Indian mobile number. Message: `recharge_number is not a valid indian mobile number` | `invalid_request_error` | 400 |
> | `request_failed` | The `pg_amount` in `payments` is more than the `amount`. Message: `payments[0].pg_amount must not be more than amount` | `invalid_request_error` | 400 |
> | `request_failed` | The `x-client-id` or `x-client-secret` is missing or incorrect. Message: `authentication Failed` | `authentication_error` | 401 |
> | `request_failed` | Your account is not set up for recharges, or its recharge access is switched off. Message: `Recharge is not enabled for this account` | `invalid_request_error` | 403 |
> | `request_failed` | You sent too many requests in a short time. Message: `Too many requests from IP. Check headers` | `rate_limit_error` | 429 |
> | `internal_error` | An unexpected error occurred at Cashfree. Message: `internal Server Error` | `api_error` | 500 |


## OpenAPI

````yaml openapi/bbps/recharge-cou.yaml post /bbps/cou/v1/recharge/validate
openapi: 3.0.3
info:
  title: Telecom Recharge for Customers (Customer Operating Unit)
  version: 1.0.0
  description: >
    APIs for Agent Institutions to offer mobile and direct-to-home (DTH)
    recharges to their customers as a Customer Operating Unit (COU). These APIs
    enable operator discovery, plan listing, recharge validation, recharge
    requests, and recharge status checks.
servers:
  - url: https://sandbox.cashfree.com
    description: Sandbox (Testing) environment.
  - url: https://api.cashfree.com
    description: Production environment.
security:
  - XClientID: []
    XClientSecret: []
paths:
  /bbps/cou/v1/recharge/validate:
    post:
      tags:
        - Recharge Validation
      summary: Validate Recharge
      description: >-
        Use this API to check whether a recharge is likely to go through, before
        you take payment from the customer.


        Send the same details as in the recharge request, without the
        `reference_id`. The API runs the same input checks as the recharge
        request, so a malformed request returns the same errors.


        The API always returns HTTP 200. Read `data.status`:


        - `VALID`: The recharge can be attempted. `data.validation_ref` holds
        the reference of the check. Keep it for your records and quote it if you
        contact support. The Recharge Request API does not need it.

        - `INVALID`: The recharge cannot go through as sent. `data.reason_code`
        and `data.reason_message` tell you why. Do not take payment for it.

        - `UNAVAILABLE`: The check could not be completed right now. You can
        still send the recharge request.


        `reason_code` and `reason_message` are `null` when the status is
        `VALID`, and `validation_ref` is `null` for any other status.
      operationId: validateRecharge
      parameters:
        - in: header
          name: x-api-version
          required: false
          description: >
            API version to be used. Format is YYYY-MM-DD. The only supported
            version for this API is `2025-01-01`. If not specified, `2025-01-01`
            is used.
          schema:
            type: string
            default: '2025-01-01'
            enum:
              - '2025-01-01'
          example: '2025-01-01'
      requestBody:
        description: >-
          The recharge to check. These are the fields of the recharge request,
          without `reference_id`.
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - recharge_number
                - operator
                - amount
                - service_type
              properties:
                recharge_number:
                  type: string
                  maxLength: 20
                  description: >-
                    The mobile number or direct-to-home (DTH) customer ID to
                    recharge. A mobile number must be a valid Indian mobile
                    number.
                  example: '9876543210'
                operator:
                  type: string
                  maxLength: 50
                  description: >-
                    The operator code, from the Fetch Operators or Fetch
                    Operator Details API.
                  example: JIO
                circle:
                  type: string
                  maxLength: 50
                  description: >-
                    The telecom circle of the number, as returned by the Fetch
                    Operator Details API, for example `Delhi`. It is optional
                    and is not case-sensitive.
                  example: Delhi
                amount:
                  type: number
                  description: >-
                    The recharge amount in rupees. It must be a whole rupee
                    amount greater than 0.
                  example: 299
                service_type:
                  type: string
                  description: The type of recharge.
                  enum:
                    - MOBILE
                    - DTH
                  example: MOBILE
                payments:
                  type: array
                  maxItems: 1
                  description: >-
                    How the customer paid, or will pay. Send it when the
                    customer pays through Cashfree Payment Gateway, so that the
                    check matches the recharge request. Leave it out when the
                    customer pays another way.
                  items:
                    type: object
                    required:
                      - source
                      - pg_amount
                    properties:
                      source:
                        type: string
                        description: The payment source.
                        enum:
                          - CASHFREE_PG
                        example: CASHFREE_PG
                      pg_reference_id:
                        type: string
                        maxLength: 64
                        description: >-
                          The Cashfree Payment Gateway transaction ID of the
                          payment. Send it when the customer has already paid,
                          and the payment is verified. Leave it out when the
                          customer has not paid yet.
                        example: '555001'
                      pg_amount:
                        type: number
                        description: >-
                          The amount that the customer paid, or will pay,
                          through Cashfree Payment Gateway. It must be greater
                          than 0, have at most 2 decimal places, and not be more
                          than `amount`.
                        example: 200
            examples:
              without_payment:
                summary: Customer pays another way
                value:
                  recharge_number: '9876543210'
                  operator: JIO
                  circle: Delhi
                  amount: 299
                  service_type: MOBILE
              with_payment:
                summary: Customer paid through Cashfree Payment Gateway
                value:
                  recharge_number: '9876543210'
                  operator: JIO
                  circle: Delhi
                  amount: 299
                  service_type: MOBILE
                  payments:
                    - source: CASHFREE_PG
                      pg_reference_id: '555001'
                      pg_amount: 200
      responses:
        '200':
          description: The check was completed. Read `data.status` for the result.
          headers:
            x-api-version:
              $ref: '#/components/headers/x-api-version'
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: >-
                      The status of the API call. Returns `OK` whenever the
                      request is processed, whatever the result.
                    example: OK
                  message:
                    type: string
                    description: A message describing the result.
                    example: Recharge validation processed
                  data:
                    type: object
                    description: The result of the check.
                    properties:
                      status:
                        type: string
                        description: The result of the check.
                        enum:
                          - VALID
                          - INVALID
                          - UNAVAILABLE
                        example: VALID
                      reason_code:
                        type: string
                        nullable: true
                        description: >-
                          Why the result is not `VALID`. `null` when the status
                          is `VALID`.
                        example: shortfall_limit_exceeded
                      reason_message:
                        type: string
                        nullable: true
                        description: >-
                          A readable explanation of the reason. `null` when the
                          status is `VALID`.
                        example: >-
                          The recharge would take the wallet past the shortfall
                          limit
                      validation_ref:
                        type: string
                        nullable: true
                        description: >-
                          The reference of the check. Returned only when the
                          status is `VALID`, and `null` otherwise.
                        example: VAL1732450001
              examples:
                valid:
                  summary: The recharge can be attempted
                  value:
                    status: OK
                    message: Recharge validation processed
                    data:
                      status: VALID
                      reason_code: null
                      reason_message: null
                      validation_ref: VAL1732450001
                invalid:
                  summary: The recharge cannot go through
                  value:
                    status: OK
                    message: Recharge validation processed
                    data:
                      status: INVALID
                      reason_code: insufficient_balance
                      reason_message: Recharge wallet balance is lower than the amount
                      validation_ref: null
                unavailable:
                  summary: >-
                    The check could not be completed, you can still send the
                    recharge
                  value:
                    status: OK
                    message: Recharge validation processed
                    data:
                      status: UNAVAILABLE
                      reason_code: pg_unavailable
                      reason_message: >-
                        The PG payment could not be verified right now, the
                        recharge can still be attempted
                      validation_ref: null
        '400':
          description: Bad request error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_amount:
                  summary: Amount is not a whole rupee amount
                  value:
                    message: amount must be a whole rupee amount greater than 0
                    code: request_failed
                    type: invalid_request_error
                invalid_mobile_number:
                  summary: Not a valid Indian mobile number
                  value:
                    message: recharge_number is not a valid indian mobile number
                    code: request_failed
                    type: invalid_request_error
                pg_amount_too_high:
                  summary: pg_amount is more than amount
                  value:
                    message: payments[0].pg_amount must not be more than amount
                    code: request_failed
                    type: invalid_request_error
        '401':
          description: Authentication Error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedResponse'
        '403':
          description: >-
            Your account is not set up for recharges, or its recharge access is
            switched off.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                institution_not_found:
                  summary: Recharge is not set up for your account
                  value:
                    message: Recharge is not enabled for this account
                    code: request_failed
                    type: invalid_request_error
        '429':
          description: Rate Limit Error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitResponse'
        '500':
          description: Internal Server Error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
      x-codeSamples:
        - lang: cURL
          label: Without payment
          source: |-
            curl --request POST \
              --url https://sandbox.cashfree.com/bbps/cou/v1/recharge/validate \
              --header 'Content-Type: application/json' \
              --header 'x-api-version: 2025-01-01' \
              --header 'x-client-id: <api-key>' \
              --header 'x-client-secret: <api-key>' \
              --data '{
                "recharge_number": "9876543210",
                "operator": "JIO",
                "circle": "Delhi",
                "amount": 299,
                "service_type": "MOBILE"
              }'
        - lang: cURL
          label: With a Cashfree Payment Gateway payment
          source: |-
            curl --request POST \
              --url https://sandbox.cashfree.com/bbps/cou/v1/recharge/validate \
              --header 'Content-Type: application/json' \
              --header 'x-api-version: 2025-01-01' \
              --header 'x-client-id: <api-key>' \
              --header 'x-client-secret: <api-key>' \
              --data '{
                "recharge_number": "9876543210",
                "operator": "JIO",
                "circle": "Delhi",
                "amount": 299,
                "service_type": "MOBILE",
                "payments": [
                  {
                    "source": "CASHFREE_PG",
                    "pg_reference_id": "555001",
                    "pg_amount": 200
                  }
                ]
              }'
components:
  headers:
    x-api-version:
      schema:
        type: string
        format: YYYY-MM-DD
        enum:
          - '2025-01-01'
      description: >-
        The API version used to process this request, echoed back in the
        response.
  schemas:
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: A description of the error explaining what went wrong.
        code:
          type: string
          description: >-
            An error code for the failure. Use the HTTP status code and the
            `message` to decide how to handle an error.
        type:
          type: string
          description: The category of the error indicating the class of failure.
    UnauthorizedResponse:
      type: object
      properties:
        message:
          type: string
          description: A description of the error explaining what went wrong.
          example: authentication Failed
        code:
          type: string
          description: >-
            An error code identifying the specific failure. Use this to handle
            errors programmatically.
          example: request_failed
        type:
          type: string
          description: The category of the error indicating the class of failure.
          example: authentication_error
    RateLimitResponse:
      type: object
      properties:
        message:
          type: string
          description: A description of the error explaining what went wrong.
          example: Too many requests from IP. Check headers
        code:
          type: string
          description: >-
            An error code identifying the specific failure. Use this to handle
            errors programmatically.
          example: request_failed
        type:
          type: string
          description: The category of the error indicating the class of failure.
          example: rate_limit_error
    InternalServerErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: A description of the error explaining what went wrong.
          example: internal Server Error
        code:
          type: string
          description: >-
            An error code identifying the specific failure. Use this to handle
            errors programmatically.
          example: internal_error
        type:
          type: string
          description: The category of the error indicating the class of failure.
          example: api_error
  securitySchemes:
    XClientID:
      type: apiKey
      in: header
      name: x-client-id
      description: >-
        Your unique client identifier issued by Cashfree. You can find this in
        your [Merchant
        Dashboard](https://merchant.cashfree.com/verificationsuite/developers/api-keys).
    XClientSecret:
      type: apiKey
      in: header
      name: x-client-secret
      description: >-
        Your unique client secret issued by Cashfree. Keep this confidential and
        never expose it in client-side code. You can find this in your [Merchant
        Dashboard](https://merchant.cashfree.com/verificationsuite/developers/api-keys).

````

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