Errors
The error envelope
A failed call returns { error: { code, message, request_id } } instead of { data, meta }. Invalid requests add error.details, with one entry per offending parameter. This is a real 404 from the API:
{
"error": {
"code": "not_found",
"message": "No company with slug 'microsoft' in the LinkedIn catalog.",
"request_id": "req_2a47ba4cc6a19856"
}
}Branch on error.code, which is stable. error.message is prose for humans and can change.
Error codes
| Code | Status | Charged | Retry | Meaning |
|---|---|---|---|---|
| unauthorized | 401 | No | No, fix the request | No API key was sent, or the key is unknown, revoked or expired. |
| not_found | 404 | Yes | No | The account or resource does not exist. A lookup that finds nothing still did the work, so it is charged. |
| method_not_allowed | 405 | No | No, fix the request | The path exists but not for this HTTP method. |
| invalid_request | 422 | No | No, fix the request | A parameter is malformed, out of range or mutually exclusive with another. error.details names the fields. |
| payload_too_large | 413 | No | No, fix the request | The request body is over the size limit. Split a bulk request into smaller ones. |
| rate_limited | 429 | No | Yes, after Retry-After | You went over your plan's per-minute limit. Wait for Retry-After seconds. |
| live_limit_reached | 429 | No | Yes, after Retry-After | You went over the live-call allowance for your plan. Live calls have their own limit on top of the per-minute limit. |
| quota_exceeded | 402 | No | No | Your plan's credits are used up and overage is off. Retrying does not help; upgrade, enable overage, or wait for the next period. |
| platform_unavailable | 503 | No | Yes, with backoff | This platform cannot be read right now. Other platforms are unaffected. |
| upstream_timeout | 504 | No | Yes, with backoff | The source was too slow. Retry with backoff; a narrower query or a smaller limit makes a timeout less likely. |
| upstream_error | 502 | No | Yes, with backoff | The source was unreachable or returned something unusable. Back off further than for a timeout. |
| service_unavailable | 503 | No | Yes, with backoff | We could not serve the request right now. Retry with backoff. |
| internal_error | 500 | No | Yes, with backoff | Something failed on our side. Internals are never leaked; quote the request_id to support. |
Only not_found is charged: a lookup that finds nothing still did the work. Every other error, whether you caused it or we did, costs no credits. A key without the scope an endpoint needs gets a 403 with the scope named in error.details.
Handling errors
const res = await fetch(url, { headers });
if (!res.ok) {
const { error } = await res.json();
switch (error.code) {
case "rate_limited":
case "live_limit_reached":
// wait Retry-After seconds, then retry
break;
case "upstream_timeout":
case "upstream_error":
case "platform_unavailable":
case "service_unavailable":
// retry with exponential backoff; do NOT record "not found" for these
break;
case "not_found":
// the account does not exist (or is not in the catalog)
break;
default:
throw new Error(`${error.code} (request ${error.request_id}): ${error.message}`);
}
}Never treat a 5xx as a missing account
A502 or 504 means the source failed, not that the account is gone. Retry those, and do not write a "not found" into your database on the strength of one.Keep request_id (also in the X-Request-Id header) in your logs. It is the one thing that lets us find your exact call; send it to [email protected] when you write in. For limits and budgets, see Credits and limits.