Reference
Errors & rate limits
Error shape
Every error returns the same JSON:
{
"code": "invalid_request",
"message": "toNumber must be in E.164 format",
"details": { "field": "toNumber" }
}| Field | What |
|---|---|
code |
A stable, lower_snake_case code you can switch on. |
message |
A human-readable description. Do not match on this — the wording can change. |
details |
Extra info for some errors (may be {}). |
Switch on code, never on message:
if (err.code === 'insufficient_balance') { /* top up */ }Status codes
| Status | Meaning |
|---|---|
200 |
OK. |
201 |
Created. |
202 |
Job queued. |
204 |
OK, no body (hangup, delete). |
400 |
Bad request body or fields. |
401 |
Missing or bad API key. |
403 |
Valid key, but missing scope or blocked IP. |
404 |
Not found, or another product's. |
409 |
Conflict — the request cannot be repeated as-is. |
429 |
Too many requests. |
500 |
Our fault. |
502 |
A service we depend on failed. |
503 |
No capacity right now — retry, see Retry-After. |
Error codes
| Code | HTTP | When | Retry? |
|---|---|---|---|
invalid_request |
400 | A field is missing or invalid. | No — fix the request. |
unauthorized |
401 | No valid key. | No. |
forbidden |
403 | Missing scope, or IP not allowed. | No. |
not_found |
404 | No such resource. | No. |
insufficient_balance |
409 | Wallet too low to start a call. | After topping up. |
idempotency_conflict |
409 | This client_request_id was already used. |
No — the call may already exist. |
conflict |
409 | The action is not valid in the current state. | No. |
capacity_unavailable |
503 | No dial capacity at this instant. Nothing is wrong. | Yes — wait Retry-After, then retry. |
upstream_error |
502 | A service we depend on failed. | Usually not — investigate. |
internal_error |
500 | Something broke on our side. | Safe to retry once. |
409 vs 503 — the one that matters
Both used to arrive as 409, and telling them apart required reading the
message. They are now distinct, because they need opposite handling:
if (res.status === 503) {
// capacity_unavailable — nothing is wrong, the line was momentarily full.
const wait = parseInt(res.headers.get('Retry-After') || '5', 10);
await sleep(wait * 1000);
return retry();
}
if (res.status === 409 && err.code === 'idempotency_conflict') {
// Permanent. The call may already have been placed — do NOT dial again.
return;
}Treating a capacity refusal as permanent silently drops calls that should have been retried.
Rate limits
Limits are per API key. When you go over, you get 429 with a Retry-After
header (seconds) — wait that long before retrying.
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1748255460
Retry-After: 12Exact limits depend on your plan. Always honour
Retry-After— hammering after a429extends your wait.
Retry safely
async function triggerCall(payload) {
const res = await fetch('https://platform.eurekatechlabs.com/v1/calls', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.EUREKA_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
// Both mean "wait, then try the same request again".
if (res.status === 429 || res.status === 503) {
const wait = parseInt(res.headers.get('Retry-After') || '5', 10);
await new Promise(r => setTimeout(r, wait * 1000));
return triggerCall(payload);
}
if (!res.ok) {
const err = await res.json();
throw new Error(`${err.code}: ${err.message}`);
}
return res.json();
}For calls, add an Idempotency-Key header so a retry never places a duplicate —
see Authentication.
