Skip to main content
Back to App

Error responses

#HTTP status codes

CodeMeaning
200Success
400Query validation failed, or the request is inconsistent
404Resource does not exist
429Rate limit exceeded
500Server error

#Response envelope

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": [
    "outcomeId must be a string",
    "outcomeId should not be empty"
  ]
}
FieldDescription
statusCodeThe same number as the HTTP status
errorA short human-readable label ("Bad Request", "Not Found"). Absent on 429 and 500.
messagestring or string[]. Query-validation failures are an array; errors raised by a handler (a missing outcomeId on the order book, a market that does not exist) are a single string.
message can be an array

Validation failures from the request validator come as message: string[]. Don't just show error.message as a single line — render each element of the array separately.

#A pattern for handling it on the client

type ApiError = {
  statusCode: number;
  error?: string;
  message: string | string[];
};
 
async function call() {
  const res = await fetch(url, init);
  if (!res.ok) {
    const err = (await res.json()) as ApiError;
    const messages = Array.isArray(err.message) ? err.message : [err.message];
    throw new Error(messages.join('\n'));
  }
  return res.json();
}

#Common scenarios

SituationResponse
outcomeId missing on the order book400 + "outcomeId is required"
outcomeId missing on price history400 + ["outcomeId must be a string", "outcomeId should not be empty"]
Invalid enum value400 + ["status must be one of the following values: ACTIVE, RESOLVED, CANCELLED"]
Unknown query parameter400 + ["property foo should not exist"]
Market not found404 + "Market not found: <id or slug>"
Outcome not found404 + "Outcome not found"
Outcome from another market400 + "Outcome does not belong to this market"
Rate limit429 + "ThrottlerException: Too Many Requests" (no error field)

#Rate limit

Public endpoints are rate-limited per IP — see Rate limits for the current numbers.

If you get a 429, retry after a short backoff (a few seconds). If you're persistently blocked, consult the Retry-After header.

#Next

Was this page helpful?