# Error responses and troubleshooting

> Every LocalPipe API status code and error string, which ones to retry, and a checklist for when submissions suddenly stop.
>
> Part of the LocalPipe API reference: https://www.localpipe.io/docs/errors (full reference in one file: https://www.localpipe.io/localpipe-api-docs.md, categories CSV: https://www.localpipe.io/localpipe-business-categories.csv)

# Error Responses

Every response returns a JSON body — **read it regardless of the status code**. Errors contain a machine-readable `error` string plus a human-readable `message`.

| Status | `error` | Description | Retryable? |
|--------|-------|-------------|---|
| 202 | — | **Accepted.** Job queued; returns `job_id` / `task_id`. Not an error. | n/a |
| 400 | Missing required fields | Required fields not provided | ❌ Fix the payload |
| 400 | Too many keywords | More than 1,000 keywords in maps-search | ❌ Fix the payload |
| 400 | Too many locations | More than 100 locations in maps-search | ❌ Fix the payload |
| 400 | No valid locations found | Could not resolve any provided locations | ❌ Fix the payload |
| 401 | Missing API key | No `x-api-key` header provided | ❌ Add the header |
| 401 | Invalid API key | The key is unknown or **deactivated**. Nothing is queued and nothing is billed. | ❌ See Troubleshooting below |
| 402 | `api_key_spend_cap_reached` | This key hit its monthly spend cap. Response includes `spent_cents` and `cap_cents`. | ❌ Raise/disable the cap |
| 402 | `free_plan_not_allowed` | Enrichment is not available on the free plan | ❌ Upgrade |
| 402 | `owner_name_limit_reached` | Monthly owner-name allowance exhausted (credit plans only) | ❌ Upgrade or wait for reset |
| 202 | `usage_balance_depleted` | Balance is $0.00 — the record is **held in the queue, not rejected**. Nothing is lost. | ✅ Starts automatically after top-up |
| 202 | `subscription_past_due` | Subscription payment failed — records are **held, not dropped** | ✅ Resumes after payment |
| 429 | `rate_limit_minute` | Sustained throughput exceeded the per-minute limit. `Retry-After: 60`. | ✅ **Always retry** |
| 429 | `rate_limit_daily` | Daily request limit reached (resets midnight UTC) | ✅ Retry tomorrow |
| 429 | `rate_limit_monthly` | Monthly request limit reached (resets on the 1st) | ✅ Retry next cycle |
| 500 | Internal server error | Transient platform fault | ✅ Up to 3× with backoff |

> **A 429 or 500 means the record was never ingested.** It does not enter the queue, does not trigger a webhook, and does not appear in usage analytics. If you don't retry, that lead is silently lost.

## Troubleshooting: submissions suddenly stop

If your pipeline stops landing records while your own code reports no errors, work this list in order:

1. **Check for 401s first.** The most common cause of a partial or total outage is a worker still using a **rotated or deactivated key** — some processes succeed while others fail, or throughput drops to zero with no visible error. Rejected key attempts are logged in your usage analytics with the key prefix and a reason of `unknown_api_key` or `deactivated_api_key`. Redeploy every worker with the current key, and only deactivate an old key once all traffic has moved off it.
2. **Log the status code and body of every non-2xx response.** Don't swallow failures in a `try/catch` — without client-side logs, a 401 or a dropped connection is indistinguishable from "no traffic was sent".
3. **Check for a 402.** `api_key_spend_cap_reached` rejects the call; `usage_balance_depleted` only holds it.
4. **Verify your outbound network path.** Short HTTP timeouts, connection-pool exhaustion, or DNS failures mean the request never reaches us — and anything that reaches us always produces a log entry.
5. **Check `callback_url`.** If you omit it, you will never receive a webhook and must poll instead. If you rely on webhooks, always send an explicit, publicly reachable URL that returns a 2xx.
6. **Don't assume a job is stuck.** Jobs never expire server-side. Poll `GET /get-job-status` for the true state before resubmitting — duplicates are billed twice.
