Search

Errors and rate limits

Errors use standard HTTP status codes and a JSON body with a detail field. A refused search is never charged.

Error body

402 Payment Required
{
  "detail": "wallet balance (120 credits) is below the estimated cost of this search (~2400 credits, EUR 2.40) and no free queries remain"
}

A request that fails validation (422) has a list instead, one entry per problem:

422 Unprocessable Content
{
  "detail": [
    { "type": "less_than_equal", "loc": ["body", "top_k"],
      "msg": "Input should be less than or equal to 50", "input": 80 }
  ]
}

Match on the status code, not on the wording of detail: the text is for people and may change.

Status codes

StatusWhenWhat to do
400The Idempotency-Key is longer than 255 characters.Use a shorter key, such as a UUID.
401No bearer token, or the key or token is unknown, revoked or expired.Check the Authorization header; create a new key if it was revoked.
402No free searches left and the wallet holds less than the search's estimated cost.Top up, or lower top_k. Do not retry unchanged.
403The key's scopes do not cover this index or use case, the action is reserved for TRIVDA operators, or the organisation is suspended.Use a key with the right scopes. A suspension is lifted by TRIVDA.
404The resource does not exist or is not yours, for example another organisation's query_id or dataset.Check the id.
409A request with the same Idempotency-Key is still running, or a dataset id is already owned by another organisation.Retry the search after a moment; choose another dataset id.
422The body is invalid (for example a blank query or top_k above 50), or an Idempotency-Key was reused with a different body.Fix the request; use a new key for a new search.
429A rate limit or quota was exceeded.Wait the number of seconds in Retry-After, then retry.
500, 502, 503Something failed on TRIVDA's side.Retry with backoff and the same Idempotency-Key, so a search that did run is not charged twice.

Rate limits

Limits apply per organisation, across all its keys, to searches, re-fetches and uploads. They are counted in three windows, checked in this order:

WindowDefault limitResets
Per minute60 requestsAt the start of each minute
Per day10,000 requestsAt midnight UTC
Per month200,000 requestsOn the first of the month, UTC
GET /api/v1/search/quota
{
  "rpm_limit": 60, "rpm_remaining": 58,
  "daily_quota": 10000, "daily_remaining": 9811,
  "monthly_quota": 200000, "monthly_remaining": 196402,
  "free_queries_remaining": 0,
  "wallet_balance_tokens": 47790
}

wallet_balance_tokens is the wallet in credits; the name is historical.

Retrying safely

  1. Send an Idempotency-Key with every search, and reuse it on every retry of that search.
  2. Retry 429 after Retry-After, and 5xx or network errors with exponential backoff (for example 1, 2, 4, 8 seconds, then give up).
  3. Do not retry 400, 401, 402, 403, 404 or 422 unchanged: they will fail the same way.