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 Secret Key and Public Key
- Use the test keys for development and live keys for production
Making Authenticated Requests
Include your secret key in theAuthorization header of your API requests using the Bearer authentication scheme:
Authentication Header Format
API Key Format
Fossapay API keys follow this format:- Test Secret Key:
fp_test_sk_xxxxxxxxxxxxxxxx - Live Secret Key:
fp_live_sk_xxxxxxxxxxxxxxxx - Test Public Key:
fp_test_pk_xxxxxxxxxxxxxxxx - Live Public Key:
fp_live_pk_xxxxxxxxxxxxxxxx
Public keys are safe to use in client-side code, while secret keys must only be used server-side.
Request Headers
Every API request should include these headers:| Header | Value | Required |
|---|---|---|
Authorization | Bearer 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