Skip to main content
Back to App

Error responses

#HTTP status codes

CodeMeaning
200Success
201Resource created
400Request body / query validation failed
404Resource does not exist
429Rate limit exceeded
500Server error

#Response envelope

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": [
    "outcomeId must be a string",
    "side must be one of: BUY, SELL"
  ]
}
FieldDescription
statusCodeThe same number as the HTTP status
errorA short human-readable label ("Bad Request", "Not Found")
messagestring or string[]. Validation failures are always an array.
message can be an array

Validation failures from the NestJS ValidationPipe always 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 missing400 + ["outcomeId should not be empty"]
Invalid enum400 + ["status must be one of: ACTIVE, ..."]
Market not found404 + "Market not found"
Rate limit429 + "ThrottlerException: Too Many Requests"

#Rate limit

Public endpoints are rate-limited per IP at the application level — 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?