Authentication
Authenticate API requests with your business API key and identifiers, and understand the unified key and environment model.
ShadhinPay has two authentication schemes. Which one you use depends on the surface you're calling.
| Surface | Scheme | Used by |
|---|---|---|
| Integration API (payments, refunds, invoices) | API key | Your server-side code |
Dashboard API (/me/**, admin) | JWT bearer | The ShadhinPay dashboard itself |
If you're integrating ShadhinPay into your own product, you use API keys. The JWT scheme powers the dashboard UI and isn't part of the integration surface.
Unified API keys
Create API keys in the dashboard under your business (see Businesses & providers).
ShadhinPay uses unified API keys with the prefix SPay_:
- Unified format —
SPay_<32-character-base62>(e.g.SPay_9bgvOl24P2zfvj8Ai0Fa6XO8qyGSIavL). - A single API key authenticates both your testing and production transactions.
- Whether transactions run in Live or Sandbox (Test) mode is controlled directly in the dashboard on a per-vendor basis (under Businesses → Vendors). Toggle the Sandbox switch on for vendors you want to test without moving real money, and off when you're ready for live production payments.
A key's full value is shown only once at creation. ShadhinPay stores only a secure Argon2id hash plus the last four characters. If you lose it, generate a new one.
Keep keys server-side
API keys are secrets. Never embed them in a browser, mobile app, or any client-side code. Make ShadhinPay calls from your backend only.
Required headers
Every call to the integration API includes three headers that identify the business and authenticate the request:
Client-Id: SM_87ixWd_8
Business-Id: SB_01M6KF7RG99VW2CAXD7Y3PN5CW
X-Api-Key: SPay_9bgvOl24P2zfvj8Ai0Fa6XO8qyGSIavL| Header | What it is |
|---|---|
Client-Id | Your merchant (client) identifier (e.g. SM_87ixWd_8) |
Business-Id | The business the request applies to (e.g. SB_01M6KF7RG99VW2CAXD7Y3PN5CW) |
X-Api-Key | The secret API key for that business (SPay_...) |
A full request looks like:
curl -X POST https://request.shadhinpay.com/api/v1/payment/create \
-H "Client-Id: SM_87ixWd_8" \
-H "Business-Id: SB_01M6KF7RG99VW2CAXD7Y3PN5CW" \
-H "X-Api-Key: SPay_9bgvOl24P2zfvj8Ai0Fa6XO8qyGSIavL" \
-H "X-Idempotency-Key: order-7831-attempt-1" \
-H "Content-Type: application/json" \
-d '{ "amount": "500.00", "currency": "BDT", "merchantTxnId": "order-7831", "callbackUrl": "https://shop.example.com/return" }'Live vs sandbox environment
The integration environment is simple and flexible:
- Base URL: Always
https://request.shadhinpay.com/api/v1. - Per-vendor mode control: In your business dashboard under Businesses → Vendors, each configured provider (bKash, Nagad, Rocket, Upay, Stripe) has an independent Sandbox switch.
- When Sandbox is ON for a vendor, requests routed to that vendor run in the sandbox environment using test accounts (or ShadhinPay's central sandbox credentials) with zero risk of moving real money.
- When Sandbox is OFF, payments run in live mode using live credentials. See Testing.
Authentication errors
All authentication failures return 401 with a uniform errorType — the API
deliberately doesn't reveal which part was wrong, to avoid leaking information.
errorType | Meaning |
|---|---|
INVALID_API_KEY | The key is missing, wrong, revoked, or doesn't match the business |
AUTHENTICATION_ERROR | Credentials couldn't be verified |
SESSION_EXPIRED | (Dashboard/JWT) the session token is no longer valid |
See Errors for the complete catalogue.
Rotating and revoking keys
- Create new keys whenever you need to rotate or isolate integrations.
- Revoke a key to immediately terminate its access if compromised.
Both actions are done in the dashboard under Businesses → [Your Business] → Manage API Keys.