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
})| Config | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | Required. Sent as X-API-Key and Authorization: Bearer. |
baseUrl | string | https://api.sendafrica.online/v1 | Override for sandbox or self-hosted APIs. |
timeoutMs | number | 15000 | Aborts requests after this many ms. |
maxRetries | number | 2 | Retries 429/5xx and network errors. |
fetch | function | globalThis.fetch | Injectable 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