API Authentication & Sandbox Setup
Authentication process for Razorpay APIs and sandbox setup for testing the APIs.
Check how to authenticate the APIs.
All Razorpay APIs are authenticated using
Basic Auth. Basic auth requires the following:
Basic auth expects an
Authorization header for each request in the
Basic base64token format. Here,
base64token is a base64 encoded string of
Authorization header value should strictly adhere to the format mentioned above. Invalid formats will result in authentication failures. Few examples of invalid headers are:
Follow these steps to generate API keys:
- Log into your Dashboard with appropriate credentials.
- Select the mode (Test or Live) for which you want to generate the API key.
- Test Mode: The test mode is a simulation mode that you can use to test your integration flow. Your customers will not be able to make payments in this mode.
- Live Mode: When your integration is complete, switch to live mode and generate live mode API keys. Replace test mode keys with live mode keys in the integration to accept payments from customers.
- Navigate to Settings → API Keys → Generate Key to generate key for the selected mode.
Key Id and
Key Secret appear on a pop-up page.
Watch this video to see how to generate API keys in the test mode.
Watch this video to see how to generate API keys in the live mode.
- After generating the keys from the Dashboard, download and save them securely. If you do not remember your API Keys, you need to re-generate them from the Dashboard and replace it wherever required.
- Do not share your API Key secret with anyone or on any public platforms. This can pose security threats for your Razorpay account.
- Once you generate the API Keys, only the Key Id is visible on the Dashboard and not the Key secret as it can pose security threats for your Razorpay account.
You can roll the Live and Test mode API keys if you have lost them or exposed them. You can choose to regenerate the API keys by deactivating them immediately or after 24 hours.
Know how to regenerate API keys.
The test mode on the Razorpay Dashboard provides a sandbox environment for you to test Razorpay products during the integration process.
The test mode is a simulation mode. Your customers will not be able to make payments in this mode.
Dashboard: You can test the products on the Razorpay Dashboard by switching to the test mode.
API: You can generate the API keys in test mode on the Razorpay Dashboard and use these for authenticating the API requests.
After the integration or product testing is complete:
- Switch to the live mode of the Razorpay Dashboard and generate the live API keys.
- Switch the test API keys with the live ones to take the integration live.
The client SDK libraries are available on GitHub. You can use the API keys generated above to try out the API sample codes: