Skip to content

API key authentication (X-API-KEY)

Every call to the Senfenico API authenticates with a secret key sent in the X-API-KEY header.

X-API-KEY: sk_test_...

The header is named X-API-KEY, not Authorization. An Authorization: Bearer … header is ignored, and a request that sends only that header is refused.

Prefix Mode Real money IP restriction
sk_test_ Test No, everything is simulated Never
sk_live_ Live Yes If you set up an IP allowlist

There is no mode parameter: the key prefix selects the mode. Every object returned carries a live_mode field (false in test, true in live).

A payment created with the test key doesn’t exist for the live key, and vice versa. Fetching a test reference with the live key returns 404. If you get an unexpected 404, first check that you are using the right key.

Your keys are in the dashboard, under Developer › API keys (/user_dashboard/api_keys/).

  • Senfenico only stores a fingerprint of your keys, so a key is shown only once, when you generate it. Copy it straight into your secrets manager.
  • Generating a new key immediately invalidates the old one. Plan to update your servers right after.
  • The live key button only produces a key once your account is verified (see going live). Until then, it shows nothing.

If a key has leaked, regenerate it right away. For the live key, also add an IP allowlist. A stolen key then becomes useless anywhere but on your servers.

Reading the balance is a good first call, because it creates nothing.

Fenêtre de terminal
curl https://api.senfenico.com/v1/payment/balances/ \
-H "X-API-KEY: $SENFENICO_KEY"

Response (shortened):

{
"status": true,
"message": "Balance retrieved",
"data": {
"deposit_balances": { "bf": { "available": "…", "currency": "XOF" } },
"transfer_balances": { "orange_money_bf": { "available": "…" } }
}
}

Every response is JSON, with the same envelope. On success, it contains these fields:

Field Type Description
status boolean true
message string Human-readable message, in English
data object or list The result
pagination object Lists only (10 items per page, 50 for refunds, ?page=)

On error, it contains these fields:

Field Type Description
status boolean false
message string Human-readable explanation, for your logs
error_code string Stable code to branch on in your code, for example INVALID_DATA. Missing on some errors
errors object Per-field details, on validation errors
{
"status": false,
"message": "Invalid data provided. Please check the input and try again.",
"error_code": "INVALID_DATA",
"errors": { "amount": ["Ensure this value is greater than or equal to 100."] }
}

The full list of codes is in the error reference.

Code Meaning
200 Request processed. Read status: some operations (charge initialization, OTP submission) return 200 with status: false
201 Object created, for example a charge or a transfer
202 Transfer batch accepted for processing
400 Invalid data (INVALID_DATA, see errors)
403 Missing or invalid key, IP not allowed or insufficient balance. Read message and error_code
404 Object not found, or created in the other mode
429 Too many requests. Try again later
500 Internal error. Before retrying, check that the operation was not created (see Reconciliation)

Always check the HTTP code and the status field, in that order.

Without an X-API-KEY header, or with an unknown key (revoked, mistyped), the API returns 403:

{ "status": "False", "message": "Invalid API Key." }

Without the header, the message is No API key provided.

Fenêtre de terminal
# -w prints the HTTP code after the body
curl -s -w "\nHTTP %{http_code}\n" \
https://api.senfenico.com/v1/payment/balances/ \
-H "X-API-KEY: $SENFENICO_KEY"