Skip to main content

Authentication

All API requests require authentication using API keys.

API Keys​

You need two keys for authentication:

HeaderDescription
X-API-KeyYour public API key - identifies your merchant account
X-API-SecretYour secret key - authenticates requests (keep this secure!)

Getting Your API Keys​

  1. Log in to Uplef Dashboard
  2. Navigate to Settings → API Keys
  3. Click Generate New API Key
  4. Select the permissions you need
  5. Copy both the API Key and API Secret
Important

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:

PermissionDescription
payment.createCreate orders and initiate payments
payment.readView orders and transactions
refund.createInitiate refunds
refund.readView refund history
settlement.createRequest settlements
settlement.readView settlement history
tip

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:

EnvironmentKey PrefixUse Case
Test/Sandboxpk_test_, sk_test_Development and testing
Live/Productionpk_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:

HeaderDescription
X-RateLimit-LimitMaximum requests per window
X-RateLimit-RemainingRemaining requests in current window
X-RateLimit-ResetUnix timestamp when the window resets

Next Steps​