Source: https://legiscore.in/docs/errors

# Errors

Every failure carries error.code and error.message. 422 and 429 also follow RFC 9457 problem details.

| HTTP | error.code | When |
| --- | --- | --- |
| 400 | invalid_body, too_many, invalid_idempotency_key, invalid_otp | Malformed request, more than 25 searches in a batch, or a bad idempotency key or OTP. |
| 401 | unauthorized | Missing, unknown or deactivated key. |
| 402 | insufficient_credits | Whole request refused, nothing charged. |
| 404 | not_found, unknown_dim, unsupported_state | No such search, lookup or state. |
| 409 | already_finished, not_waiting, not_finished, already_recovery, idempotency_key_reused | The search is not in a state that allows this call. |
| 410 | withheld | A document failed its integrity check. |
| 422 | invalid_params, search_unavailable | Parameters cannot be answered, or the search is held. Nothing charged. |
| 429 | rate_limited, too_many_open_searches, upstream_busy | Slow down. Honour Retry-After. |
| 502/503 | assist_failed, recovery_failed, recovery_unavailable, place_search_unavailable | Retry later. |
| 500 | internal | Unexpected. Safe to retry. |

## 422 invalid_params

Parameters are checked before anything is charged. Every problem is listed with field, value and reason; lookup names the lookup that resolves it.

```json
{
  "type": "https://legiscore.in/docs/errors#invalid-params",
  "title": "Unprocessable search parameters",
  "status": 422,
  "detail": "sro_code 9999 is not a registered office for telangana.",
  "invalid_params": [
    {
      "index": 0,
      "field": "sro",
      "value": "9999",
      "reason": "sro_code 9999 is not a registered office for telangana.",
      "lookup": "sro"
    }
  ],
  "error": {
    "code": "invalid_params",
    "message": "sro_code 9999 is not a registered office for telangana."
  }
}
```

422 search_unavailable: the search is HELD. Refused before any charge. Check the catalog.

## 429 too many requests

Three limits, one retry path. Response has Retry-After (seconds) and X-RateLimit-Limit / X-RateLimit-Remaining.

| Limit | Default | Applies to |
| --- | --- | --- |
| Submit | 120 searches per minute per key; a batch of 25 spends 25 | POST /api/v1/search |
| Reads | 10 times the submit budget per key | GET search and list |
| Open searches | 100 queued or running per workspace | POST /api/v1/search |
| Lookups | 120 calls per minute per key | GET lookups and places |

upstream_busy: the search service is at capacity. Nothing charged. Retry after the interval.
