ByteVerseDevelopers
Get API keys

Concepts

Errors

Errors use standard HTTP status codes and a consistent JSON body.

402 Payment Required
{
  "error": {
    "type": "insufficient_funds_error",
    "code": "insufficient_funds",
    "message": "Wallet balance (2000 NGN) is lower than the 5250 NGN required. Fund your wallet and retry.",
    "param": null,
    "request_id": "req_3c1f0b8e5a7d4c29b6e1a0f4"
  }
}
FieldMeaning
typeBroad category. Safe to switch on.
codeSpecific, stable machine-readable reason. Safe to switch on.
messageHuman-readable explanation. Do not parse it.
paramThe request field at fault, when there is one. Nested fields use dots, e.g. targeting.locations.
request_idQuote this to support.

Error catalog

HTTPtypecodeMeaning
400invalid_request_errorinvalid_parameter
invalid_budget
invalid_task_type
invalid_location
unknown_parameter
invalid_json
idempotency_key_required
The request is malformed or breaks a rule. param names the field.
400invalid_request_errorbudget_too_low
budget_too_high
Budget is outside the allowed range for the Growth Action type or your account limit.
401authentication_errorinvalid_api_keyMissing, malformed, revoked or expired API key.
402insufficient_funds_errorinsufficient_fundsWallet balance is lower than the total cost. Nothing was charged.
403permission_errorinsufficient_scope
account_suspended
test_mode_only
partner_inactive
The key cannot do this, or the account is suspended.
404not_found_errornot_found
route_not_found
No such resource (or it belongs to another partner or environment).
405invalid_request_errormethod_not_allowedWrong HTTP method for this path. The Allow header lists valid ones.
409conflict_errorduplicate_external_reference
invalid_state
request_in_progress
The request conflicts with current state, e.g. pausing a completed campaign.
413invalid_request_errorbody_too_largeBody is larger than 64 KB.
415invalid_request_errorunsupported_media_typeSend Content-Type: application/json.
422invalid_request_erroridempotency_key_reuseThe same Idempotency-Key was used with a different request.
429rate_limit_errorrate_limited
daily_limit_reached
Too many requests, or the daily campaign cap was reached. See Retry-After.
500api_errorinternal_errorSomething went wrong on our side. Safe to retry with the same Idempotency-Key; quote request_id if it persists.

Handling errors in code

const res = await fetch(url, options);
const body = await res.json();
if (!res.ok) {
  const { type, code, message, param, request_id } = body.error;
  if (res.status === 429) { await sleep(Number(res.headers.get("retry-after") ?? 5) * 1000); /* then retry */ }
  else if (code === "insufficient_funds") { /* ask your customer to top up */ }
  else { throw new Error(`${code} (${request_id}): ${message}`); }
}
res = requests.post(url, headers=headers, json=payload, timeout=30)
if not res.ok:
    err = res.json()["error"]
    if res.status_code == 429:
        time.sleep(int(res.headers.get("retry-after", 5)))  # then retry
    elif err["code"] == "insufficient_funds":
        ...  # ask your customer to top up
    else:
        raise RuntimeError(f'{err["code"]} ({err["request_id"]}): {err["message"]}')