Authentication
All API requests require authentication using API keys.
API Keys
You need two keys for authentication:
| Header | Description |
|---|---|
X-API-Key | Your public API key - identifies your merchant account |
X-API-Secret | Your secret key - authenticates requests (keep this secure!) |
Getting Your API Keys
- Log in to Uplef Dashboard
- Navigate to Settings → API Keys
- Click Generate New API Key
- Select the permissions you need
- Copy both the API Key and API Secret
Your API Secret is shown only once during creation. Store it securely in your environment variables or secrets manager. If you lose it, you'll need to generate a new key pair.
Using API Keys
Include both headers in every API request:
curl -X POST https://api.uplef.com/api/v1/orders \
-H "X-API-Key: pk_live_abc123..." \
-H "X-API-Secret: sk_live_xyz789..." \
-H "Content-Type: application/json" \
-d '{"amount": 1000}'
JavaScript Example
const response = await fetch('https://api.uplef.com/api/v1/orders', {
method: 'POST',
headers: {
'X-API-Key': process.env.UPLEF_API_KEY,
'X-API-Secret': process.env.UPLEF_API_SECRET,
'Content-Type': 'application/json',
},
body: JSON.stringify({ amount: 1000 }),
});
Python Example
import requests
import os
response = requests.post(
'https://api.uplef.com/api/v1/orders',
headers={
'X-API-Key': os.environ['UPLEF_API_KEY'],
'X-API-Secret': os.environ['UPLEF_API_SECRET'],
},
json={'amount': 1000},
)
API Key Permissions
When generating API keys, you can select which permissions to grant:
| Permission | Description |
|---|---|
payment.create | Create orders and initiate payments |
payment.read | View orders and transactions |
refund.create | Initiate refunds |
refund.read | View refund history |
settlement.create | Request settlements |
settlement.read | View settlement history |
Follow the principle of least privilege - only grant the permissions your integration actually needs.
Test vs Live Keys
Uplef provides separate API keys for testing and production:
| Environment | Key Prefix | Use Case |
|---|---|---|
| Test/Sandbox | pk_test_, sk_test_ | Development and testing |
| Live/Production | pk_live_, sk_live_ | Real transactions |
Test keys work with sandbox payment methods and won't process real payments.
Security Best Practices
Do's
- ✅ Store API secrets in environment variables
- ✅ Use a secrets manager in production (AWS Secrets Manager, HashiCorp Vault, etc.)
- ✅ Rotate keys periodically
- ✅ Use separate keys for different environments
- ✅ Grant minimum required permissions
Don'ts
- ❌ Never commit API secrets to version control
- ❌ Never expose secrets in client-side code
- ❌ Never share keys via email or chat
- ❌ Never log API secrets
Environment Variables Example
# .env file (never commit this!)
UPLEF_API_KEY=pk_live_abc123...
UPLEF_API_SECRET=sk_live_xyz789...
// Load from environment
const apiKey = process.env.UPLEF_API_KEY;
const apiSecret = process.env.UPLEF_API_SECRET;
Error Responses
Invalid API Key
{
"success": false,
"error": "UNAUTHORIZED",
"message": "Invalid API credentials"
}
HTTP Status: 401
Missing Permission
{
"success": false,
"error": "FORBIDDEN",
"message": "API key does not have permission for this action"
}
HTTP Status: 403
Rate Limiting
API requests are rate-limited per API key. When you exceed the limit, you'll receive:
{
"success": false,
"error": "RATE_LIMITED",
"message": "Too many requests. Please try again later."
}
HTTP Status: 429
Rate limit headers are included in all responses:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window |
X-RateLimit-Remaining | Remaining requests in current window |
X-RateLimit-Reset | Unix timestamp when the window resets |
Next Steps
- Quick Start - Create your first payment
- API Reference - Full API documentation