REST API

One API key, clean endpoints and predictable responses. This page covers the essentials: where to send requests, how to authenticate, what comes back and how to handle errors and limits.

Overview

The AvenoLink API is a plain REST API. Requests and responses use JSON, authentication is a single header, and every channel follows the same style. You can call it from any language that can make an HTTP request, with no SDK required.

EnvironmentBase URLUse it for
Productionhttps://api.avenolink.comReal messages to real recipients. Uses SMS from your package.
Sandboxhttps://sandbox.avenolink.comBuilding and testing your integration safely.

Authentication

Send your API key in the x-api-key header on every request. That is all you need: there are no tokens to exchange or refresh. The examples in these docs use a separate key for each channel, such as YOUR_SMS_API_KEY, YOUR_WA_API_KEY and YOUR_EMAIL_API_KEY.

  • Keep keys on your server and load them from environment variables.
  • Never commit keys to source control or ship them in mobile or browser code.
  • Use sandbox keys while developing and production keys only when you go live.
  • If a key is exposed, replace it straight away and update your servers.

Quickstart

  1. 1

    Get your API key

    Contact our team or open your dashboard to receive a sandbox key for the channel you need.

  2. 2

    Send a test message

    Make the request below against the sandbox host and check you receive a queued response.

  3. 3

    Listen for delivery

    Add a webhook endpoint so your system learns when each message is delivered or fails.

  4. 4

    Go live

    Swap in your production key and host, then follow the go-live checklist in Resources.

POST /api/v1/send/sms
curl -X POST https://sandbox.avenolink.com/api/v1/send/sms \
  -H "x-api-key: YOUR_SMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "recipients": ["265XXXXXXXXX"],
    "sender_id": "AVENOLINK",
    "message": "Hello from AvenoLink"
  }'

Endpoints

All sending endpoints live under /api/v1/send. They accept the same style of request and return the same style of response.

MethodPathDescription
POST/api/v1/send/smsSend an SMS to one or more recipients.
POST/api/v1/send/whatsappSend a WhatsApp message to one or more recipients. Coming soon.
POST/api/v1/send/emailSend an email with HTML and plain-text bodies. Coming soon.

The SMS endpoint accepts these fields.

FieldRequiredDescription
recipientsYesA list of 1 to 100 Malawi phone numbers. Duplicates are sent once.
messageYesThe text to send, up to 480 characters. Longer messages use more than one SMS per recipient.
sender_idNoAn approved Sender ID of up to 11 characters. If you leave it out, your first approved Sender ID is used.
The complete list of endpoints, including account and reporting calls, is in the full API reference. Use the Read the docs button on this page to open it.

Responses

A successful send returns 200 OK with a summary of what was accepted. The message is queued at this point. Delivery results arrive later through webhooks.

200 OK
{
  "success": true,
  "batch_id": "bat_xk9m2p4q",
  "status": "queued",
  "recipients_count": 2,
  "credits_used": 2,
  "credits_remaining": 998,
  "package": "Starter"
}
FieldDescription
successtrue when the request was accepted.
batch_idIdentifier for this send. Store it to reconcile delivery events.
statusThe state of the batch. New sends start as queued.
recipients_countHow many recipients were in the request.
credits_usedSMS charged for this request: recipients multiplied by the SMS parts in your message.
credits_remainingSMS left on the package this send used.
packageThe name of the package this send used, such as Starter.

Errors

Errors use standard HTTP status codes and always return the same JSON shape. Check the status code first, then use the error code in your own logic and read message for the detail.

402 Payment Required
{
  "success": false,
  "error": "quota_exceeded",
  "message": "Your package limit has been reached, or this request is larger than what is left. Add a package or send fewer messages.",
  "sms_required": 3,
  "sms_remaining": 2
}
StatusError codeWhat it means and what to do
401missing_api_key, invalid_api_keyThe x-api-key header is missing, wrong or revoked. Check the header and the key.
402quota_exceededYour package limit is reached, or the request needs more SMS than are left. The response includes sms_required and sms_remaining. Add a package or send fewer messages.
403no_active_package, no_sender_id, sender_not_allowedYour account has no active package, no Sender ID, or the sender_id you sent is not yours. Fix the account or use an approved Sender ID.
422validation_failed, invalid_recipientsA field is missing or badly formatted, or a number is not a valid Malawi number. A validation_failed response also lists each problem under errors.
429rate_limitedToo many requests. Slow down and retry with a delay. See rate limits below.
502delivery_failedThe network refused the message. Nothing was deducted from your package, so it is safe to retry.
5xxserver_errorA temporary problem on our side. Retry with backoff and check API status if it continues.

Rate limits

Limits are generous and designed so normal traffic never notices them. When you do hit one, the response includes headers that describe the limit and tell you when to try again, so your code never has to guess.

Retry with exponential backoff (JavaScript)
async function sendWithRetry(url, options, attempts = 4) {
  for (let i = 0; i < attempts; i++) {
    const res = await fetch(url, options);
    if (res.status !== 429 && res.status < 500) return res;
    await new Promise((r) => setTimeout(r, 2 ** i * 500));
  }
  throw new Error("Request failed after retries");
}

Sending to many people? Put up to 100 recipients in one request as a recipients array instead of making a separate call for each. For longer lists, send several requests.

Versioning

The version is part of the path (/api/v1). We add new fields and endpoints without breaking existing integrations, so ignore response fields you do not recognise. Anything that would break your code is announced in the changelog before it changes.