Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.croma.run/llms.txt

Use this file to discover all available pages before exploring further.

Envelope

Successful responses return { "data": … }. Failures return an error object and a non-2xx HTTP status. Branch on the status code, not a body flag:
{
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_param",
    "message": "String must contain at least 3 character(s)",
    "param": "name",
    "details": { "issues": [{ "path": "name", "message": "String must contain at least 3 character(s)" }] }
  }
}
FieldNotes
typeBroad category (see below).
codeSpecific machine-readable code. Branch on this.
messageHuman-readable; safe to surface in UI.
paramOffending field. Present on validation errors.
detailsOptional structured detail (e.g. all validation issues).

Types and codes

StatustypecodeMeaning
400invalid_request_errorinvalid_paramBody failed validation; see param / details.
400invalid_request_errortoo_many_resultsQuery matched too many records to return. Narrow it.
401authentication_errorinvalid_api_keyMissing or invalid key.
401authentication_errorpersonal_api_key_not_allowedA personal key was used; org keys only.
404not_found_errorresource_not_foundNo record in the upstream source.
404not_found_errorendpoint_not_foundNo API endpoint at that path. See /catalog.
405invalid_request_errormethod_not_allowedWrong method. Data endpoints are POST.
429rate_limit_errorrate_limitedQuota exceeded; see Rate limits.
5xxupstream_error<source>_upstreamA government source failed or was unreachable.
500api_errorinternal_errorUnexpected internal error.
Not every endpoint emits every code. resource_not_found only applies to lookups that resolve a specific record (e.g. Registraduría, SUNAT, RREE). Endpoints that proxy a government source can return an upstream_error — for example Rama Judicial returns rama_judicial_upstream with the source’s own status code, falling back to 502. Each endpoint’s reference page lists its codes.

Handling errors

Branch on the HTTP status first, then error.code for programmatic handling and error.message for display:
const res = await fetch(url, options);
const body = await res.json();

if (!res.ok) {
  switch (body.error.code) {
    case "rate_limited":
      // back off using the Retry-After header, then retry
      break;
    case "resource_not_found":
      // treat as "no record", not a failure
      break;
    default:
      throw new Error(body.error.message);
  }
}

const { data } = body;
Include the X-Request-Id response header when reporting an issue. It lets us trace the exact request.