API Authentication
FossaPay uses API keys to authenticate requests. You can view and manage your API keys in the FossaPay Dashboard.API Key Types
FossaPay provides two types of API keys:Test Keys
Use test keys in sandbox mode to test your integration without affecting real data or transactions.
Live Keys
Use live keys in production to process real transactions and manage actual customer data.
Getting Your API Keys
- Sign up or log in to your FossaPay Dashboard
- Navigate to Settings → API Keys
- Copy your Test Key or Live Key
- Use the test keys for development and live keys for production
Making Authenticated Requests
Include your secret key in thex-api-key header of your API requests:
Authentication Header Format
API Key Format
FossaPay API keys follow this format:- Test Key:
fp_test_sk_xxxxxxxxxxxxxxxx - Live Key:
fp_live_sk_xxxxxxxxxxxxxxxx
Request Headers
Every API request should include these headers:| Header | Value | Required |
|---|---|---|
x-api-key | YOUR_SECRET_KEY | Yes |
Content-Type | application/json | Yes |
X-Idempotency-Key | Unique request identifier | Recommended |
Example Request
Idempotency
To prevent duplicate requests, use theX-Idempotency-Key header. If you make the same request twice with the same idempotency key, FossaPay will return the same response without processing the request again.
Error Handling
Authentication Errors
If authentication fails, you’ll receive a401 Unauthorized response:
| Error Code | Description |
|---|---|
INVALID_API_KEY | The API key provided is invalid |
EXPIRED_API_KEY | The API key has expired |
MISSING_API_KEY | No API key was provided |
TEST_KEY_IN_PRODUCTION | Attempted to use test key in live mode |
LIVE_KEY_IN_TEST | Attempted to use live key in test mode |
Security Best Practices
Store Keys Securely
Store Keys Securely
- Never hardcode API keys in your application
- Use environment variables or secure key management systems
- Rotate keys regularly
Use HTTPS Only
Use HTTPS Only
- All API requests must use HTTPS
- HTTP requests will be rejected
Restrict API Key Access
Restrict API Key Access
- Limit API key permissions to only what’s needed
- Use different keys for different environments
- Monitor API key usage in your dashboard
Implement Rate Limiting
Implement Rate Limiting
- FossaPay implements rate limiting to protect against abuse
- Current limit: 100 requests per minute
- Contact support for higher limits
Testing Authentication
Test your authentication setup with this simple request:Next Steps
Create a Customer
Make your first API call