Razorpay API
Accept payments in India: orders, capture, refunds, customers, payment links, UPI QR codes, subscriptions and settlements.
PaymentsGuided#payments#upi#india#refunds#subscriptions#payment-links
Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.
Overview
Razorpay is an Indian payment gateway: cards, UPI, netbanking, wallets, EMI and, once enabled, international cards. Its REST API lets your server create orders for Checkout, look up and capture payments, issue refunds, store customers, send payment links, show UPI QR codes, run subscriptions and reconcile settlements. This collection covers those flows with requests you can send in Test mode straight away.
Get API keys
- Sign up at razorpay.com and open the Dashboard.
- Switch to Test mode (toggle in the Dashboard). Test mode simulates payments; no real money moves.
- Go to Account & Settings > API Keys (under Website and app settings) and choose Generate Key.
- Download or copy the Key ID and Key Secret. The secret is shown only once; if you lose it, regenerate the keys and update every integration.
- Paste them into keyId and keySecret (both secret variables). For live payments, finish account activation, switch to Live mode and generate separate live keys.
See API authentication and API keys.
Authentication and base URL
Every request uses HTTP Basic auth: the username is the key ID, the password is the key secret (Authorization: Basic base64(key_id:key_secret)). This collection sets it once. Base URL: https://api.razorpay.com/v1 for both modes; which keys you use decides test or live. Only the key ID may go to a browser (Checkout); the secret stays on your server.
Amounts are in paise
amount is always an integer in the currency's smallest unit. For INR that is paise: Rs 499.00 is 49900, Rs 1 is 100. Other currencies follow their own subunits (USD cents; zero-decimal currencies such as JPY use the whole amount). Sending 499.00 or 499 for Rs 499 is the most common mistake.
Verifying payments and webhooks
- Checkout: on success Checkout returns
razorpay_payment_id,razorpay_order_idandrazorpay_signature. On your server, compute HMAC-SHA256 overorder_id|razorpay_payment_id(your stored order ID, a pipe, the payment ID) with the key secret, hex-encoded, and compare it withrazorpay_signature. Do not fulfil without a match. See integration steps. - Webhooks: set a webhook secret in the Dashboard. Each delivery carries
X-Razorpay-Signature: HMAC-SHA256 of the raw request body with that secret. Verify before parsing the JSON, de-duplicate with thex-razorpay-event-idheader, and expect events out of order. See validate webhooks.
UPI and international notes
UPI works with Checkout, payment links (set upi_link: true for UPI-only links) and UPI QR codes; test with the UPI IDs success@razorpay and failure@razorpay. International cards must be activated under Account & Settings first; then pass the ISO currency and the amount in that currency's subunits. See international payments.
How to use this collection
Fill the two key variables, then run 1. Start here: orders. The other folders (payments, refunds, customers, payment links, QR codes, plans and subscriptions, settlements) can run in any order; each create request saves its ID for the fetch, cancel and refund requests that follow.
Common errors
| HTTP | error.code | What to do |
|---|---|---|
| 400 | BAD_REQUEST_ERROR | Read error.description and error.field: missing field, amount not an integer, wrong state (capturing a captured payment), or an ID from the other mode. |
| 401 | - | Wrong key ID or secret, or a test key used against live data. |
| 404 | - | Wrong path or ID. |
| 429 | - | Rate limited: retry with exponential backoff plus random jitter. |
| 5xx | - | Temporary: retry, then check the payment's status before charging again. |
Errors come as {"error": {"code", "description", "field", "source", "step", "reason", "metadata"}}. See errors.
Limits and pricing
Razorpay charges a fee per successful payment that depends on the method and your plan; see pricing. API calls are rate limited; handle 429 with backoff. Full reference: Razorpay API docs.
Endpoints 23
1. Start here: orders
- POSTCreate an order
/ordersCreates an order for the amount you want to collect. Do this on your server for every checkout attempt, then pass the returned id (order_...) to Checkout. The… - GETFetch an order
/orders/{{orderId}}Returns one order by its ID (orderId, saved by Create an order). Use it to check status (created, attempted, paid), amount_paid and amount_due before… - GETFetch payments for an order
/orders/{{orderId}}/paymentsLists every payment attempt made against the order: authorized, captured and failed ones. After Checkout, open the order in test mode, pay with test UPI ID…
2. Payments
- GETFetch all payments
/paymentsLists payments on your account, newest first. What comes back: a collection with count and items. Use it for reconciliation; for a single payment use Fetch a… - GETFetch a payment
/payments/{{paymentId}}Returns one payment (paymentId). Check status and captured before shipping goods, method (card, upi, netbanking, wallet, emi), fee and tax (Razorpay's charge,… - POSTCapture a payment
/payments/{{paymentId}}/captureMoves an authorized payment to captured. Only needed when automatic capture is off in your Dashboard. Body: amount must equal the authorized amount in paise,…
3. Refunds
- POSTCreate a refund
/payments/{{paymentId}}/refundRefunds a captured payment (paymentId). Leave out amount for a full refund, or pass a smaller amount in paise for a partial one; you can refund in several… - GETFetch a refund
/refunds/{{refundId}}Returns one refund by ID (refundId). Poll it, or better listen for the refund.processed and refund.failed webhooks, to tell the customer when money is on its… - GETFetch refunds for a payment
/payments/{{paymentId}}/refundsLists all refunds made against one payment (paymentId). Useful after several partial refunds to see what is left: compare the sum with the payment's…
4. Customers
- POSTCreate a customer
/customersCreates a customer record. name is 3-50 characters; contact is at most 15 characters with country code (digits and an optional leading +); email at most 64… - GETList customers
/customersLists customers, newest first. Page with count (default 10, maximum 100) and skip. Returns a collection of customer objects. - GETFetch a customer
/customers/{{customerId}}Returns one customer by ID (customerId, saved by Create a customer). To change the name, email or contact, send PUT /customers/{id} with the new values.
5. Payment Links
- POSTCreate a payment link
/payment_linksCreates a hosted payment page and returns its short_url to share. The id (plink_...) is saved into paymentLinkId. Set upi_link: true to create a UPI-only link… - GETFetch a payment link
/payment_links/{{paymentLinkId}}Returns one payment link (paymentLinkId) with its status, amount_paid and the payments made through it. Listen for the payment_link.paid webhook instead of… - POSTCancel a payment link
/payment_links/{{paymentLinkId}}/cancelCancels a link so it can no longer be paid. Only links in created status can be cancelled; paid, partially paid, expired or already cancelled links return…
6. UPI QR codes
- POSTCreate a UPI QR code
/payments/qr_codesCreates a UPI QR code and returns an image_url to display. The id (qr_...) is saved into qrCodeId. Status is active until paid (single use), closed by you or… - POSTClose a QR code
/payments/qr_codes/{{qrCodeId}}/closeCloses a QR code (qrCodeId) so it stops accepting payments, for example when the customer paid another way or the order was cancelled. Returns the QR code…
7. Plans and subscriptions
- POSTCreate a plan
/plansA plan is the price and billing frequency. period is daily, weekly, monthly, quarterly or yearly; interval multiplies it (2 + monthly = every two months;… - GETFetch a plan
/plans/{{planId}}Returns one plan (planId) with its period, interval and item (name, amount and currency). Use GET /plans to list all plans. - POSTCreate a subscription
/subscriptionsSubscribes a customer to a plan. You get a short_url where the customer makes the authorisation payment (or pass the subscription id to Checkout as… - GETFetch a subscription
/subscriptions/{{subscriptionId}}Returns one subscription (subscriptionId): status, paid_count, remaining_count, current_start / current_end of the billing cycle and charge_at (next charge).… - POSTCancel a subscription
/subscriptions/{{subscriptionId}}/cancelCancels a subscription. cancel_at_cycle_end: false (default) cancels now; true lets the customer keep the current paid cycle and cancels when it ends (status…
8. Settlements
- GETList settlements
/settlementsLists settlements (transfers to your bank account) with from / to (Unix seconds), count (default 10, maximum 100) and skip. Each settlement: id (setl_...),…
API details
- Base URL
https://api.razorpay.com/v1- Authentication
- HTTP Basic authentication (username and password)
- Operations
- 23 operations on 23 pathsGET 12POST 11
- Main resources
- 1. Start here: orders 32. Payments 33. Refunds 34. Customers 35. Payment Links 36. UPI QR codes 27. Plans and subscriptions 58. Settlements 1
- Description format
- Swastik Codes guided collection, API version
checked against the docs on 2026-11-17 - Links
- Documentation
How to test the Razorpay API in Swastik Codes
- Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
- Fork it into your workspaceChoose a workspace. You get your own copy of the Razorpay API collection, without the publisher's secrets.
- Add your credentialsThis API uses HTTP Basic authentication (username and password). Add yours in the collection's variables or an environment; the requests already reference it.
- Send a requestPick an endpoint, for example “Create an order” (POST /orders), and press Send. Check the response, add tests and run the whole collection with the runner.
Frequently asked questions
What is the Razorpay API?
Accept payments in India: orders, capture, refunds, customers, payment links, UPI QR codes, subscriptions and settlements. It is listed under Payments and has 23 endpoints.
Who publishes the Razorpay API?
It is listed from Razorpay's public API description (an OpenAPI document), not published by Razorpay on Swastik Codes. Anyone who controls razorpay.com can claim the profile by adding a DNS TXT record.
What is the base URL of the Razorpay API?
Requests go to https://api.razorpay.com/v1. Endpoint paths are added to this base URL.
How do I authenticate with the Razorpay API?
With HTTP Basic authentication (username and password).
How many endpoints does the Razorpay API have?
23 operations on 23 paths (12 GET, 11 POST). The largest groups are 1. Start here: orders, 2. Payments, 3. Refunds, 4. Customers.
Is forking the Razorpay API free?
Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.