Authentication
Authentication
All SagaPay API requests require authentication using your API credentials. This page explains how to obtain and use your credentials securely.
API Credentials
Each API request must include the following headers:
Example Request
Obtaining Credentials
1. Access the Key Management Portal
Visit the Key Management section in this documentation to create and manage your API keys.
2. Verify Your Identity
You’ll need to verify ownership of your merchant account:
- Enter your Merchant ID and Store ID
- We’ll send a one-time code to the email registered with that store
- Enter the code to access key management
3. Create an API Key
Once verified, you can:
- Create new API keys with custom names
- Set permissions for each key
- Optionally scope keys to specific stores
- Set expiration dates
Important: Your API Secret is only shown once when created. Save it immediately in a secure location. If you lose it, you’ll need to create a new key.
API Key Scoping
API keys can be scoped to limit their access:
Merchant-Level Keys
Access all stores under your merchant account:
Store-Level Keys
Access only a specific store:
Best Practice: Use store-scoped keys whenever possible. This limits the blast radius if a key is compromised.
Security Best Practices
Never expose your API Secret
- Don’t commit secrets to version control
- Don’t include secrets in client-side code
- Use environment variables or secret managers
Use store-scoped keys
- Create separate keys for each store
- Limit permissions to what’s needed
- Rotate keys periodically
Monitor API usage
- Check the Key Management portal for usage stats
- Set up alerts for unusual activity
- Revoke unused keys
Use HTTPS only
- All API requests must use HTTPS
- HTTP requests will be rejected
Rate Limits
To protect the API, we enforce rate limits:
Rate limit headers are included in all responses:
If you exceed the limit, you’ll receive a 429 Too Many Requests response:
Error Responses
401 Unauthorized
Missing or invalid credentials:
403 Forbidden
Key doesn’t have access to the requested resource:
Revoking Keys
If you believe a key has been compromised:
- Go to Key Management
- Verify your identity with OTP
- Find the compromised key
- Click “Revoke” to immediately disable it
Revoked keys cannot be reactivated. You’ll need to create a new key.