Authentication
SwiftPay uses API keys to authenticate requests. You can view and manage your API keys in the Dashboard.API Keys
Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.Key Format
All API keys follow this format:mp_- Prefix identifying SwiftPay keyslive_- Environment indicator (all keys are live)xxxxxxxx...- Unique key identifier
Authentication Header
Authentication to the API is performed via theAuthorization header with the Bearer scheme:
Security Best Practices
Store keys securely
Store keys securely
Store your API keys in environment variables or a secure secrets manager.
Never hardcode them in your application.
bash # .env file SWIFTPAY_API_KEY=mp_live_your_api_key Use server-side only
Use server-side only
API keys should only be used in server-side code. Never expose them in
client-side JavaScript, mobile apps, or browser extensions.
Rotate keys regularly
Rotate keys regularly
Rotate your API keys periodically and immediately if you suspect they’ve been
compromised. You can create new keys in the dashboard.
Use separate keys per environment
Use separate keys per environment
If you have staging and production environments, use separate API keys for
each to isolate any issues.
Authentication Errors
| Error Code | Description |
|---|---|
401 | No API key provided or invalid key format |
403 | Valid key but insufficient permissions |
Session Authentication
In addition to API keys, SwiftPay also supports session-based authentication for dashboard access. This is used automatically when you’re logged into the dashboard.API keys are the recommended authentication method for programmatic access.
Session authentication is only used for the web dashboard.