Razorpay uses HTTP Basic Authentication for all API requests. Your Key ID acts as the username and your Key Secret acts as the password. Every request to the API must include these credentials.
Generating API keys
Generate your keys from the Razorpay Dashboard:
Dashboard → Account & Settings → API Keys
Razorpay provides two types of keys:
Never commit your API keys to source control. Store them as environment variables and load them at runtime.
Authenticating requests
Pass your Key ID and Key Secret using the -u flag in cURL, or as a Basic Auth header. Most SDKs handle this automatically.
Security best practices
- Never expose your Key Secret in client-side code (browser JavaScript, mobile apps).
- Use Test Mode keys during development so no real transactions occur.
- Rotate your keys immediately if you suspect they have been compromised — do this from Dashboard → Account & Settings → API Keys.