Handles API

Errors

Failures are always JSON, always the same shape, and always carry a code you can branch on.

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:

404 Not Found
{
  "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

CodeStatusChargedRetryMeaning
unauthorized401NoNo, fix the requestNo API key was sent, or the key is unknown, revoked or expired.
not_found404YesNoThe account or resource does not exist. A lookup that finds nothing still did the work, so it is charged.
method_not_allowed405NoNo, fix the requestThe path exists but not for this HTTP method.
invalid_request422NoNo, fix the requestA parameter is malformed, out of range or mutually exclusive with another. error.details names the fields.
payload_too_large413NoNo, fix the requestThe request body is over the size limit. Split a bulk request into smaller ones.
rate_limited429NoYes, after Retry-AfterYou went over your plan's per-minute limit. Wait for Retry-After seconds.
live_limit_reached429NoYes, after Retry-AfterYou went over the live-call allowance for your plan. Live calls have their own limit on top of the per-minute limit.
quota_exceeded402NoNoYour plan's credits are used up and overage is off. Retrying does not help; upgrade, enable overage, or wait for the next period.
platform_unavailable503NoYes, with backoffThis platform cannot be read right now. Other platforms are unaffected.
upstream_timeout504NoYes, with backoffThe source was too slow. Retry with backoff; a narrower query or a smaller limit makes a timeout less likely.
upstream_error502NoYes, with backoffThe source was unreachable or returned something unusable. Back off further than for a timeout.
service_unavailable503NoYes, with backoffWe could not serve the request right now. Retry with backoff.
internal_error500NoYes, with backoffSomething 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

Node.js
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

A 502 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.

NextPlatforms and coverage