Overview
Every API request must include three headers:x-api-key
Your API key ID only (format:
ak_live_xxx)x-timestamp
Current Unix timestamp in milliseconds
x-signature
HMAC-SHA256 signature of the request
Getting Your API Key
API Key Format:
ak_live_abc123.sk_live_xyz789- First part (
ak_live_abc123): Public key ID - sent inx-api-keyheader - Second part (
sk_live_xyz789): Secret key - used locally to derive signing key, NEVER transmitted
Signature Calculation
The signature is calculated using a derived signing key (hash of your secret):Why Use a Derived Key?
This design ensures your secret key is never transmitted over the network:- You send only the key ID in
x-api-key - The signature proves you possess the secret without revealing it
- Even if an attacker intercepts the request, they cannot forge new requests
Components:
- signingKey: SHA256 hash of your secret key (computed locally)
- timestamp: Unix timestamp in milliseconds (same value as
x-timestampheader) - method: HTTP method in UPPERCASE (
GET,POST,PATCH,DELETE) - path: Full request path including query parameters (e.g.,
/v1/payments?page=1) - body: Request body as JSON string (empty string for GET/DELETE requests)
Implementation Examples
Common Mistakes & Troubleshooting
1. Sending Full API Key in Header
❌ Wrong: Sending the full key including secret2. Using Raw Secret Instead of Derived Key
❌ Wrong: Signing with raw secret3. Incorrect Timestamp Format
❌ Wrong: Using seconds instead of milliseconds4. Incorrect Message Concatenation
❌ Wrong: Adding spaces or separators5. Query Parameters in Path
For GET requests with query parameters, include them in the path: ✅ Correct:6. JSON Body Formatting
Ensure the body is stringified exactly as sent in the request: ✅ Correct:7. Timestamp Expiration
Timestamps are valid for 5 minutes. If you get a timestamp error:- Ensure your server’s clock is synchronized (use NTP)
- Generate the timestamp immediately before making the request
- Don’t reuse old timestamps
Security Best Practices
-
Never expose your secret key
- Don’t commit it to version control
- Use environment variables
- Rotate keys if compromised
-
Use HTTPS only
- Never send API requests over HTTP
- Validate SSL certificates
-
Implement timestamp validation
- Reject requests with timestamps older than 5 minutes
- Prevents replay attacks
-
Log signature failures
- Monitor for unusual patterns
- Could indicate attempted attacks
-
Rotate API keys periodically
- Recommended: Every 90 days
- Immediately if compromised
-
Store the derived signing key securely
- Compute it once at application startup
- Keep it in memory, don’t log it
Testing Your Implementation
Use the webhook test endpoint to verify your signature calculation:x-api-keycontains ONLY the key ID (no.sk_live_...part)- Signing key is SHA256 hash of your secret
- Timestamp is current (within 5 minutes) and in milliseconds
- Signature calculation matches exactly
- HTTP method is uppercase
- Path includes query parameters if any
Error Responses
401 Unauthorized - Invalid x-api-key Format
x-api-key, not the full keyId.secret format.
401 Unauthorized - Invalid Signature
401 Unauthorized - Timestamp Outside Valid Window
401 Unauthorized - Invalid API Key
Rate Limits
API requests are rate-limited per endpoint. See rate-limits.md for details. Rate limit headers are included in every response:Need Help?
Quick Start Guide
Get started with your first payment in minutes
Error Codes
Understand and troubleshoot API errors
Contact Support
Reach out to our team for assistance