Every request to the UBN BaaS API requires authentication. Payment and KYC requests require an additional signature on top of your API key. Read this page fully before writing any integration code.
| Layer | Required for | What it protects against |
|---|---|---|
| API Key | All requests | Unauthenticated access |
| Request Signature (HMAC) | Payments and KYC | Tampering with request data in transit |
| mTLS Client Certificate | Production payments only | Man-in-the-middle attacks at the TLS layer |
API Key Authentication
Every request must include your API key in theAuthorization header using the ApiKey scheme.
Key prefixes and environments
Your API key prefix tells you which environment it belongs to. The platform enforces this — you cannot accidentally use a sandbox key against production or vice versa.| Prefix | Environment | Base URL |
|---|---|---|
ubn_sb_ | Sandbox | https://sandbox.api.unionbank.ng |
ubn_pk_ | Production | https://api.unionbank.ng |
403 ENVIRONMENT_MISMATCH error immediately. See Error Reference for details.
Code examples
Signing Requests
Payment and KYC endpoints require a request signature in addition to your API key. This signature proves that the request body has not been modified between your server and ours. Why we require signatures: If someone intercepts an outbound HTTP request from your server — a man-in-the-middle attack — they could change the destination account number or the transfer amount before it reaches us. Your API key alone cannot detect this. A signature, computed from the exact body you sent, makes tampering detectable: any change to the body invalidates the signature and we reject the request.How to compute the signature
Serialise the request body
Take your request body as a JSON string. The serialisation must be consistent — the same object must always produce the same string. Use compact serialisation (no extra spaces) and ensure key order is deterministic.
Compute an HMAC-SHA256 hash
Hash the JSON string using HMAC-SHA256 with your signing secret as the key. Your signing secret is separate from your API key — you receive it during onboarding and it is also available in the API Keys page of your dashboard.
Code examples
If you receive an
INVALID_SIGNATURE error, work through this checklist:- Confirm you are using the signing secret, not the API key.
- Confirm you are serialising with compact JSON (no extra whitespace).
- Confirm the body you sign is the exact bytes being sent in the HTTP request.
- Check that your signing secret has not been rotated since you last fetched it from the dashboard.
mTLS Client Certificates
Mutual TLS (mTLS) is required for all payment operations in the production environment. It is not required in sandbox. What mTLS means in plain English: Normally when you connect to an HTTPS server, only the server proves its identity to you (via its TLS certificate). With mTLS, you also prove your identity to the server — both sides show their “ID card” before the connection opens. This makes it impossible for an attacker to pose as you, even if they obtain your API key.How to get your client certificate
Your client certificate is issued during production onboarding. Contact your UBN relationship manager or email baas-support@unionbank.ng to start the process. You will receive:client.crt— your client certificate (public)client.key— your private key (keep this secret, never commit it)
Using mTLS with curl
Using mTLS in Node.js
mTLS is enforced at the network layer, before your request is processed. If the certificate is missing or invalid, the connection is terminated before the API key is checked and you will see a TLS handshake error, not an HTTP error response.
Idempotency Keys
What idempotency means
Networks fail. Connections drop. Load balancers time out. When you send a payment request and the response never arrives, you face a problem: did the payment go through, or not? If you retry the request and the original succeeded, you might send the same payment twice. Idempotency solves this. You generate a unique key (a UUID) and include it in theX-Idempotency-Key header. If you send the exact same key again — whether 5 milliseconds or 5 hours later — the API returns the original response without taking any new action. No duplicate payment. No duplicate account. No guessing.
Rules for idempotency keys
- Generate a new UUID for each distinct operation. Do not reuse keys across different requests.
- The replay window is 24 hours. After 24 hours, the same key is treated as a new request.
- If you send the same key with a different request body, the API returns a
409 CONFLICTerror — this prevents accidentally masking changes with an old key. - The
X-Idempotency-Replayed: trueresponse header tells you when a response is a replay. Log this — it means your retry worked and the original response is intact.