error_code and, when there is a self-service fix, a resolve object that says who fixes it and where. Branch on error_code, not on the status alone: two 402s can mean “add a credential” and “stop, the plan needs attention”, and only one of them is worth retrying.
The envelope
GET /v1/entities?q=altman. detail names the endpoint to use and gives a worked example; a 422 from a bad parameter names the parameter in errors[]. Read it once, change the request, and send it once.
What to do by status
Two 402 codes deserve emphasis because they are the ones clients retry into the ground:
spend_limit_exceeded and credits_depleted do not clear on their own, and every retry is another rejected request. Surface resolve.message to the person who owns the account and stop.
A retry wrapper
Retry only where the table says to, and let the server pace you.Parameters that cause avoidable errors
- Omit optional parameters you do not need. A placeholder such as
x,-, or__omit__is a real filter value; it fails validation or matches nothing. - One name per concept.
qis the free-text query wherever one exists (/v1/podcasts/search,/v1/companies,/v1/entities/search);/v1/entitieslists and filters and takes noq. Sendingq,query, andsearchtogether does not hedge; it trips validation. - Slugs come from responses. A constructed slug returns 404; resolve the name and take the slug from the result. See From an empty page to the data.
Related
- Errors overview for the full code catalog and the
resolvecontract - Concepts for authentication and rate limits
- Pay per request with x402 for the keyless 402 flow