Errors
How the API signals failures and how to handle them.
Error response shape
All errors return JSON with a single error string. Check the HTTP status code for the category.
Example
{
"error": "Human-readable message"
}Handle errors in code
const res = await fetch("https://api.midasai.tech/v1/listings/invalid-id", {
headers: { Authorization: process.env.MIDASAI_API_KEY! },
})
if (!res.ok) {
const body = await res.json().catch(() => ({}))
throw new Error(`MidasAI ${res.status}: ${body.error ?? res.statusText}`)
}Status code reference
Common responses you will encounter in production.
400
Bad Request
{ "error": "Invalid input" }401
Unauthorized
{ "error": "Invalid API key" }403
Forbidden
{ "error": "API key missing 'write' permission" }404
Not Found
{ "error": "Listing not found" }429
Too Many Requests
{ "error": "Rate limit exceeded" }500
Server Error
{ "error": "Internal server error" }