Razorpay APIs

Number of APIs: 196

Razorpay is an India-based payment platform that lets businesses accept, manage, and distribute funds through its suite of products. The APIs follow REST conventions, and every response is sent in JSON.

API Authentication

Every Razorpay endpoint is secured with Basic Auth. To use Basic Auth you need:

  • [YOUR KEY ID]

  • [YOUR KEY SECRET]

For each call, set an Authorization header in the format Basic base64token, where base64token is the base-64 encoding of YOURKEYID:YOURKEYSECRET.

Watch Out!
The Authorization value must match the format shown above exactly. Anything else will fail. Some incorrect examples are:

  • BASIC base64token

  • basic base64token

  • Basic "base64token"

  • Basic $base64token

Generate API Key

Razorpay can be accessed in two environments—Test and Live—and each environment uses its own key.

To create your keys:

  1. Sign in to the Razorpay Dashboard.

  2. Choose the environment (Test or Live) for which the key is needed.

    • Test Mode: A sandbox to verify your integration; customers cannot pay here.
    • Live Mode: Once integration is done, switch to live, generate live keys, and replace the test keys so you can start taking real payments.
  3. Go to Settings → API Keys → Generate Key and generate a key for the selected environment.

Errors

Successful calls return HTTP 204. On failure, a JSON error object is returned describing what went wrong.

Understanding Error Response

The error payload contains the fields code, description, field, source, step, and reason to help diagnose the issue.

A common example is when a merchant tries to add new payer accounts after the overall limit has been reached:


Sample Error Response

{

  "error": {

    "code": "BAD_REQUEST_ERROR",

    "description": "Authentication failed due to incorrect otp",

    "field": null,

    "source": "customer",

    "step": "payment_authentication",

    "reason": "invalid_otp",

    "metadata": {

      "payment_id": "pay_EDNBKIP31Y4jl8",

      "order_id": "order_DBJKIP31Y4jl8"

    }

  }

}

Response Parameters

error
object — The containing error object.

code
string — The type of error.

description
string — A human-readable explanation of the error.

field
string — The request parameter that triggered the error.

source
string — The point of failure during the operation (for example, customer or business).

step
string — The stage at which the transaction failed, depending on the payment method.

reason
string — The precise reason, useful for programmatic handling.

metadata
object — Additional context about the request.


`payment_id`

  : `string` Unique ID of the payment.



`order_id`

  : `string` Unique ID of the order linked to the payment.

Learn more about Error Codes.

  1. Customers APIs - Create a Customer
    POST https://api.razorpay.com/v1/customers

  2. Customers APIs - Fetch all Customers
    GET https://api.razorpay.com/v1/customers

  3. Customers APIs - Fetch Customer by ID
    GET https://api.razorpay.com/v1/customers/{cust_id}

  4. Customers APIs - Edit a Customer
    PUT https://api.razorpay.com/v1/customers/{cust_id}

  5. Orders APIs - Create an Order
    POST https://api.razorpay.com/v1/orders

  6. Orders APIs - Fetch Orders (With Expanded Card Payments)
    GET https://api.razorpay.com/v1/orders?expand[]=payments.card

  7. Orders APIs - Fetch Orders by ID
    GET https://api.razorpay.com/v1/orders/{order_id}

  8. Orders APIs - Fetch Payments by Order
    GET https://api.razorpay.com/v1/orders/{order_id}/payments

  9. Orders APIs - Update Order
    PATCH https://api.razorpay.com/v1/orders/{order_id}

  10. Payments APIs-Payment Downtime API - Fetch Payment Downtime Details
    GET https://api.razorpay.com/v1/payments/downtimes