Errors
A request can fail outright, or a search can be accepted and fail later. Handle both.
Error responses
Errors use the Error shape.
| Field | What it holds |
|---|---|
code | Required. A string that identifies the error. |
message | Required. A description to read. |
request_id | Optional. Log it and quote it when you ask for help. |
{
"code": "example_code",
"message": "A description of what went wrong.",
"request_id": "req_example_01"
}
Not specified yet
The values of code and which HTTP status goes with each failure. example_code above is a placeholder. Check the HTTP status first, log the whole error, and give unknown codes a safe default. Do not match on the wording of message.
Failed searches
A search can have status failed. The reason is in error, which is optional in the contract. Check status even when the HTTP request succeeded.
{
"id": "srch_example_04",
"status": "failed",
"created_at": "2026-12-03T12:00:00Z",
"error": {
"code": "example_code",
"message": "A description of what went wrong."
}
}
A completed search can also carry warnings. They are free-text strings. Log them and show them to whoever reviews the results.
Read errors safely
A network or gateway failure may not return the Error shape, so parse defensively.
async function humos(path: string, init: RequestInit = {}) {
const res = await fetch(process.env.HUMOS_API_URL + path, {
...init,
headers: {
Authorization: `Bearer ${process.env.HUMOS_API_KEY}`,
"Content-Type": "application/json",
},
signal: AbortSignal.timeout(75_000), // longer than the largest wait_seconds
});
const text = await res.text();
let body: any;
try {
body = text ? JSON.parse(text) : undefined;
} catch {
body = undefined;
}
if (!res.ok) {
throw new Error(
`Humos ${res.status} ${body?.code ?? "unknown"}: ` +
`${body?.message ?? text} (request ${body?.request_id ?? "n/a"})`,
);
}
return body; // undefined when the response has no body
}
Retrying
| Call | Advice |
|---|---|
Reads (GET) | Retry network and server failures with growing delays, a few times. |
| Search and unlock | Do not retry blindly. A repeat may run and charge again. |
| Other writes | Check whether the first call worked before you repeat it, where you can. |
| Rejected requests | Fix the request or key. Repeating it unchanged is unlikely to help. |
If a search call times out on your side, you may not have its id, and the contract has no operation that lists searches. Check usage before you send it again.
Idempotency and rate limits
Not specified yet
The contract defines no idempotency mechanism and no rate limits. Do not assume a repeated request is deduplicated. Limit your own concurrency, back off when requests fail, and cap the number of attempts.