Configuration
Set up the client with your API key, retries and timeouts.
The client reads its settings once, when you make it. Make one and share it across your app.
Options
import { Goomzo } from '@goomzo/sdk'
const goomzo = new Goomzo({
apiKey: process.env.GOOMZO_API_KEY,
maxRetries: 2,
timeout: 60_000,
})| Option | Description | Default |
|---|---|---|
apiKey | String. Your API key's secret. | GOOMZO_API_KEY |
maxRetries | Number. How many times a failed request is tried again. | 2 |
timeout | Number. Milliseconds to wait for each try. | 60000 |
baseUrl | String. Where the API is. | https://api.goomzo.africa |
fetch | Function. A fetch to use instead of the global one, such as for tests or a proxy. | The global fetch |
Important: Keep the API key on your server. Never put it in code that runs in a browser or an app.
Request options
Every method takes the options for one request as its last argument:
const controller = new AbortController()
await goomzo.messages.send(
{ messages: [{ to: '+255712345678', channel: 'sms', content: { text: 'Your order is ready.' } }] },
{ idempotencyKey: 'order-1042-ready', signal: controller.signal },
)| Option | Description |
|---|---|
idempotencyKey | String. Your own key, so a retry from your side isn't done twice. One is made otherwise. |
signal | AbortSignal. Cancels the request. |
API version
The SDK sends the Goomzo-Version it was written for, as API_VERSION:
import { API_VERSION } from '@goomzo/sdk'Next steps
Last updated