Skip to main content

Error format

All errors return a JSON body with an error code and a message:
{
  "error": "invalid_body",
  "message": "Field 'level' is required"
}

Status codes

StatusCodeWhen
400invalid_bodyMissing required field or malformed JSON
401unauthorizedAuthorization header missing, key malformed, or revoked
403forbiddenKey does not have access to the requested resource
404not_foundResource does not exist
422invalid_levellevel is not one of DEBUG, INFO, WARN, ERROR
429rate_limitedRate limit exceeded
500server_errorUnexpected server error — contact support if this persists

Handling errors

const res = await fetch("https://api.streamlogia.com/v1/ingest", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify(entry),
});

if (!res.ok) {
  const error = await res.json();
  if (res.status === 429) {
    const wait = parseInt(res.headers.get("Retry-After") ?? "5", 10);
    await new Promise((r) => setTimeout(r, wait * 1000));
    // retry...
    return;
  }
  throw new Error(`[${error.error}] ${error.message}`);
}