Skip to main content
Most JSON errors use this shape:
{
  "error": "invalid api key"
}
Media downloads can return plain text errors because the success response is a binary stream.

Common statuses

StatusMeaning
400Invalid JSON or missing required fields.
401Missing, invalid, revoked, or incorrectly scoped API key.
402Active subscription required.
404Resource not found.
409State conflict, such as setup that must happen first.
502Upstream WhatsApp connection error.
503WhatsApp connection is not ready.

Pattern

Handle errors by status first, then display the error string when present.
if (!response.ok) {
  const text = await response.text();
  let message = text;
  try {
    message = JSON.parse(text).error ?? text;
  } catch {}
  throw new Error(message);
}