Error codes

Every error the API can return, what it means and how to fix it, plus what to do when a message is accepted but cannot be delivered.

How errors work

When a request fails, the API returns a standard HTTP status code and a JSON body that explains what went wrong. Check the status code first to decide what to do, then read the message for the detail.

  • 2xx means the request worked.
  • 4xx means something about the request needs fixing. Retrying the same request will fail again.
  • 5xx means a temporary problem on our side. Retrying after a short wait usually works.

Error format

Every failed request returns success: false with a short error code and a readable message. Some errors add extra fields that help you fix the problem.

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
}
FieldDescription
successAlways false for an error.
errorA short code for the problem. Use it in your code to decide what to do.
messageA readable explanation. Show it in logs, not to your customers.
errorsOnly on validation_failed. Lists each field and what is wrong with it.
sms_required, sms_remainingOnly on quota_exceeded. How many SMS the request needed and how many are left.

HTTP status codes

StatusMeaningWhat to do
200The request was accepted and the message is queued.Store the batch_id and wait for delivery events.
401The API key is missing, wrong or revoked.Check the x-api-key header and the key itself.
402Your package limit is reached.Add a package, or send fewer messages, then retry.
403Your account cannot send yet, or the Sender ID is not yours.Check that you have an active package and an approved Sender ID.
404The endpoint or resource does not exist.Check the path, for example /api/v1/send/sms.
422A field is missing or badly formatted, or a number is invalid.Check the body against the field table and fix it before retrying.
429You are sending too many requests.Slow down and retry with a delay. See Rate limits.
500Something went wrong on our side.Retry with backoff. Contact us if it continues.
502The network refused the message. Nothing was deducted.Retry with backoff.

Error codes

The error field gives a more specific reason than the status code alone.

ErrorStatusCause and fix
missing_api_key401No x-api-key header was sent. Add it to the request.
invalid_api_key401The key is wrong or has been revoked. Use a valid key.
unauthenticated401A dashboard login token is missing or expired. Log in again.
validation_failed422A required field such as recipients or message is missing or too long. Read errors for the exact field.
invalid_recipients422A number is not a valid Malawi number. Use the country code, for example 265, followed by the number.
quota_exceeded402The package limit is reached or too low for this send. Add a package or send fewer messages.
no_active_package403There is no active package on the account. Choose a package, or ask us to activate it.
no_sender_id403No Sender ID is assigned to the account yet. Contact us.
sender_not_allowed403The sender_id you sent is not available on your account. Use an approved Sender ID.
not_found404The path is wrong. Check the endpoint.
rate_limited429You exceeded the request limit. Wait, then retry with backoff.
delivery_failed502The network refused the message and nothing was deducted. Retry after a short wait.
server_error500A problem on our side. Retry after a short wait.

Delivery failures

A 200 response only means the message was queued. If it cannot be delivered later, you receive a message.failed webhook event with a reason.

ReasonMeaningWhat to do
invalid_numberThe number does not exist or is not valid.Check the number and remove it from your list.
unreachableThe phone was off or out of coverage for too long.Try again later or use another channel.
blockedThe recipient has blocked or opted out of messages.Do not retry. Respect the opt-out.
not_on_whatsappThe number is not registered on WhatsApp.Send the message by SMS instead.
mailbox_unavailableThe email address does not exist or the inbox is full.Check the address and remove it if it keeps failing.

Handling errors in code

Retry only the errors that can fix themselves, and fix the rest at the source.

  • Retry 429, 500 and 502 with exponential backoff.
  • Do not retry 401, 402, 403, 404 or 422. Fix the request, key or package first.
  • Log the error code, the message and the batch_id for every failure.
  • Never show raw API messages to your customers. Show your own friendly text.
JavaScript
const res = await fetch(url, options);
const data = await res.json();

if (!res.ok) {
  switch (data.error) {
    case "quota_exceeded":
      notifyAdmin("Add an AvenoLink package");
      break;
    case "invalid_recipients":
      reviewNumbers(data.message);
      break;
    case "rate_limited":
      await retryLater();
      break;
    default:
      console.error("AvenoLink error", res.status, data);
  }
}

Still stuck?

Contact support with the error code, the HTTP status, the time of the request and the batch_id if you have one. Remove your API key from anything you send us.