Skip to main content

Authentication

Payscribe API requests authenticate with an API key in the Authorization Bearer header. Keep that key on infrastructure you control; your browser and mobile client should call your server, not Payscribe with an API key.

Never expose an API key

Do not put pk_... keys in frontend code, mobile apps, Git repositories, browser storage, screenshots, URLs, or support tickets. Rotate a key immediately if it is exposed.

Keys and environments

Create and manage API keys in Settings → API Keys in the Payscribe dashboard.

CredentialTypical prefixEnvironmentWhere to use it
Sandbox API keyps_pk_test_...https://sandbox.payscribe.ng/api/v1Your server during development and test
Production API keyps_pk_live_...https://api.payscribe.ng/api/v1Your production server only
Webhook secretps_test_... / ps_live_...Matches the webhook environmentVerifies the HMAC signature; it never goes in an API Authorization header

The dashboard may label pk_... credentials as public keys, but the current direct API authenticates business operations with them. Keep all direct API calls on your backend and protect the key accordingly. Production requests also require a configured server IP allowlist.

Make an authenticated request

Set PAYSCRIBE_API_KEY in your server environment, then send it as a Bearer token. Do not hardcode the key in these examples.

curl https://sandbox.payscribe.ng/api/v1/my-account/balances \
-H "Authorization: Bearer $PAYSCRIBE_API_KEY"

Handle authentication failures safely

Authentication errors must be useful to your engineering team without leaking credentials to users or logs.

Example authentication error
{
"status": false,
"description": "Invalid API key",
"status_code": 401
}
StatusMeaningSafe response
401The key is missing, invalid, expired, or paired with the wrong environment.Stop and check your server configuration. Do not retry automatically.
403The key is authenticated but does not have permission for the operation.Check dashboard access and contact support if the product should be enabled.

Log the HTTP status, endpoint, and a safe request reference where one exists. Never log the Authorization header or the raw API key.

Rotate keys without downtime

Plan key rotation as an operational change, not a last-minute emergency:

  1. Create a replacement key in the dashboard.
  2. Update the API key in your deployment environment.
  3. Deploy and confirm sandbox or production health checks with the new key.
  4. Revoke the old key once traffic is confirmed on the replacement.

If a key may have been exposed, rotate it immediately and review application logs and deployment history.

Continue building

Next taskUse this guide
Verify a sandbox requestQuickstart
Test a full workflow safelySandbox testing
Secure event deliveryWebhooks
Understand every endpointAPI authentication reference

Was this page helpful?

Report a docs issue →