Skip to main content
ShadhinPay Docs

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.

SurfaceSchemeUsed by
Integration API (payments, refunds, invoices)API keyYour server-side code
Dashboard API (/me/**, admin)JWT bearerThe 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
HeaderWhat it is
Client-IdYour merchant (client) identifier (e.g. SM_87ixWd_8)
Business-IdThe business the request applies to (e.g. SB_01M6KF7RG99VW2CAXD7Y3PN5CW)
X-Api-KeyThe 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.

errorTypeMeaning
INVALID_API_KEYThe key is missing, wrong, revoked, or doesn't match the business
AUTHENTICATION_ERRORCredentials 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.

Next steps

On this page