Skip to Content
SDKsTypeScriptAuthentication

Authentication

The client authenticates with your developer API key. It is sent as both X-API-Key and Authorization: Bearer on every request.

import { SendAfricaClient } from 'sendafrica' const client = new SendAfricaClient({ apiKey: 'SA-...', // required baseUrl: 'https://api.sendafrica.online/v1', // optional override timeoutMs: 15_000, // optional, default 15000 maxRetries: 2, // optional, default 2 fetch: customFetch, // optional: supply your own fetch })
ConfigTypeDefaultDescription
apiKeystringRequired. Sent as X-API-Key and Authorization: Bearer.
baseUrlstringhttps://api.sendafrica.online/v1Override for sandbox or self-hosted APIs.
timeoutMsnumber15000Aborts requests after this many ms.
maxRetriesnumber2Retries 429/5xx and network errors.
fetchfunctionglobalThis.fetchInjectable fetch (needed on Node < 18).

Keep credentials server-side

Never instantiate SendAfricaClient in browser code — the apiKey would ship to every visitor. Create it in an API route, worker, or Next.js server action, and read the key from process.env.SENDAFRICA_API_KEY.

Last updated on