API Security (& IP Whitelisting)
Authenticate requests with your public key and an HMAC signature.
Centiiv uses asymmetric-style API key pairs (pk_ / sk_), HMAC-SHA256 request signing, replay protection, and IP allowlisting to secure requests to the Payment API and Protocol API.
Important Notice — Mandatory HMAC Signing Starting December 30, 2026
From December 30, 2026, all requests to both the Payment API and the Protocol API (including
GETrequests and non-transactional endpoints) must be authenticated with a V2 key pair and a valid HMAC-SHA256 signature.Legacy API keys (
cnt-) and unsigned requests will no longer be accepted after this date. If you are currently using legacy keys or unsignedGETrequests, please migrate to V2 request signing before December 30, 2026.
1. API Credentials
You can generate and manage your API key pairs directly from your Centiiv Dashboard:
- Payment API key pair: Available in your Centiiv Dashboard under your Payment API settings.
- Protocol API key pair: Available in your Centiiv Dashboard under your Protocol API settings.
Each API environment (Test and Live) has its own key pair consisting of a Public Key and a Secret Key:
| Credential | Format | Purpose | Status |
|---|---|---|---|
| V2 Public Key | pk_live_<32 hex> / pk_test_<32 hex> | Identifies your integration in request headers | Current |
| V2 Secret Key | sk_live_<64 hex> / sk_test_<64 hex> | Signs requests locally via HMAC-SHA256 | Current |
| Legacy API Key | cnt-live_<32 hex> / cnt-test_<32 hex> | Authenticates on its own | Deprecated (retiring Dec 30, 2026) |
Handling Your Keys Safely
- Store your secret key securely: Your secret key is shown only once when the key pair is generated and cannot be retrieved again. Store it in a secure secrets manager or server-side environment variable.
- Never expose your secret key: Never send your secret key in request headers, URLs, or payloads, and never embed it in frontend, browser, or mobile application code. It should only ever be used on your backend server to compute HMAC signatures.
- Rotate if lost or exposed: If you lose your secret key or suspect it has been compromised, generate a new key pair in the Centiiv Dashboard immediately. Generating a new pair invalidates the previous one right away.
Sending Your Public Key
Include your V2 public key in every request using either header:
X-Api-Public-Key: pk_live_...(recommended)Authorization: Bearer pk_live_...
2. Request Signing (HMAC-SHA256)
Every signed request must prove that the caller possesses the secret key, prevent payload tampering, and block replay attacks.
Required Headers
| Header | Description |
|---|---|
X-Api-Public-Key | Your V2 public key (pk_live_... or pk_test_...). |
X-Api-Timestamp | Current Unix timestamp in milliseconds. Must be within ±30 seconds of server time. |
X-Api-Nonce | A unique, single-use string of 16–128 URL-safe characters ([A-Za-z0-9_-]). Never reuse a nonce. |
X-Api-Signature | Lowercase hex-encoded HMAC-SHA256 signature of the canonical request string. |
Building the Canonical String
Construct the canonical string by joining the following six values with newline characters (\n) in this exact order:
v2
<METHOD>
<PATH>
<TIMESTAMP>
<NONCE>
<SHA256_HEX(raw body)>METHOD: Uppercase HTTP method (GET,POST,PUT,DELETE, etc.).PATH: The endpoint path as documented, without the host and without the/api/v1prefix (for example,/wallet/transfer/singleor/wallet/balance/NGN). Do not include query parameters in<PATH>.TIMESTAMP: The exact Unix millisecond value sent inX-Api-Timestamp.NONCE: The exact nonce string sent inX-Api-Nonce.SHA256_HEX(raw body): Lowercase hex SHA-256 digest of the exact raw request body bytes.-
For requests with no body (such as
GETrequests), use the SHA-256 hash of an empty string:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
-
Compute the signature using HMAC-SHA256 with your V2 secret key (sk_live_... or sk_test_...), encoded as lowercase hexadecimal.
Important: Hash the Exact Bytes You Send
Differences in whitespace, JSON key ordering, or number formatting between what you hash and what you transmit over HTTP will cause signature verification to fail. Always serialize your payload once, hash that exact string/buffer, and send those exact bytes as the request body.
Worked Example
Suppose you are making the following request:
- Method:
POST - Path:
/wallet/transfer/single - Timestamp:
1735689600000 - Nonce:
9f2c4e7a1b8d3c6f0a5e2d9b4c7f1a3e - Raw Body:
{"amount":100,"description":"payout"}
The canonical string is:
v2
POST
/wallet/transfer/single
1735689600000
9f2c4e7a1b8d3c6f0a5e2d9b4c7f1a3e
<lowercase sha256 hex of {"amount":100,"description":"payout"}>Sign the canonical string with your secret key and send the resulting headers:
X-Api-Public-Key: pk_live_...
X-Api-Timestamp: 1735689600000
X-Api-Nonce: 9f2c4e7a1b8d3c6f0a5e2d9b4c7f1a3e
X-Api-Signature: <hex-encoded HMAC-SHA256 signature>Node.js Example
import crypto from "node:crypto";
function buildSignedHeaders({ method, path, body = null, publicKey, secretKey }) {
const timestamp = Date.now().toString();
const nonce = crypto.randomBytes(16).toString("hex"); // 32 URL-safe characters
const rawBody = body ? JSON.stringify(body) : "";
const bodyHash = crypto
.createHash("sha256")
.update(rawBody, "utf8")
.digest("hex");
const canonical = [
"v2",
method.toUpperCase(),
path, // e.g., "/wallet/transfer/single" (no host or /api/v1 prefix)
timestamp,
nonce,
bodyHash,
].join("\n");
const signature = crypto
.createHmac("sha256", secretKey)
.update(canonical, "utf8")
.digest("hex");
return {
rawBody,
headers: {
"Content-Type": "application/json",
"X-Api-Public-Key": publicKey,
"X-Api-Timestamp": timestamp,
"X-Api-Nonce": nonce,
"X-Api-Signature": signature,
},
};
}Replay Protection
- Timestamp Window: Requests with a timestamp outside ±30 seconds of Centiiv's server time are rejected. Make sure your servers synchronize their clocks using NTP.
- Single-Use Nonces: Each
X-Api-Noncecan only be used once. Replaying a captured request—even within the 30-second window—is rejected with401 NONCE_REPLAYED.
3. IP Allowlisting
For an additional layer of protection, you can restrict your API credentials so they only accept traffic from your known server IP addresses.
How to Request IP Whitelisting
IP allowlisting is managed by our technical support team rather than self-served in the dashboard. To enable or update your allowlist, email [email protected] with:
- Your business name
- The environment (
TestorLive) and API (Payment APIorProtocol API) - The IP addresses or CIDR ranges you want allowlisted
Supported Formats
You may submit individual IPv4/IPv6 addresses or CIDR blocks:
203.0.113.7
203.0.113.0/24
2001:db8::/32Automatic Compromised-Key Protection
To protect your account if a secret key is ever leaked, Centiiv monitors valid, properly signed requests coming from unlisted IP addresses:
- A validly signed request from an unlisted IP is rejected with
403 IP_NOT_ALLOWED, along with a count of remaining attempts. - After 5 validly signed attempts from unlisted IPs within 15 minutes, your API credentials for that environment are automatically revoked. You will need to generate a new key pair in the Centiiv Dashboard.
(Unsigned or invalidly signed requests do not count toward this limit, ensuring no third party can lock out your integration using only your public key.)
Tip: Always email [email protected] to whitelist new server or NAT gateway IP addresses before routing live API traffic through them.
4. Error Reference
| Error Code | HTTP Status | Description |
|---|---|---|
SIGNATURE_REQUIRED | 401 | A public key was provided without a required HMAC signature. |
API_KEY_DEPRECATED | 401 | A legacy cnt- key was used after legacy authentication was disabled. |
INVALID_API_KEY | 400 | The API key is unknown or the HMAC signature did not match. |
NONCE_REPLAYED | 401 | The X-Api-Nonce value has already been used. |
API_KEY_REVOKED | 401 | The credential has been revoked and can no longer be used. |
IP_NOT_ALLOWED | 403 | The request originated from an IP address not on your allowlist. |
UNAUTHORIZED_OPERATION | 401 | Required authentication headers are missing or the timestamp is outside the ±30s window. |
5. Migrating Before December 30, 2026
To ensure uninterrupted access across both the Payment API and Protocol API before December 30, 2026:
- Generate V2 Key Pairs: Retrieve your V2 Payment API and Protocol API key pairs from your Centiiv Dashboard.
- Implement V2 Signing Everywhere: Update your integration to send
X-Api-Public-Key,X-Api-Timestamp,X-Api-Nonce, andX-Api-Signatureon all API requests, includingGETrequests. - Verify in Test Mode: Test your canonical string generation and empty-body
GETsignatures using yourpk_test_/sk_test_keys. - Configure IP Allowlists: Email [email protected] with your production server IP addresses or CIDR blocks if you want to restrict API access to trusted servers.
- Retire Legacy Keys: Remove all
cnt-keys from your codebase and environment configurations.
Updated 16 days ago