How-to guides

How to handle API errors

Parse and act on RFC 7807 error responses from the UrbanFox API

Before you start

The UrbanFox API returns structured errors following the RFC 7807 standard. This guide shows you how to parse these responses and take the correct action for each error type.

  • An authenticated integration making requests to the UrbanFox API

Check the error shape

Every error response follows RFC 7807 Problem Details:

{
  "title": "Application Error",
  "status": 404,
  "type": "item-not-found",
  "detail": "Case not found",
  "errors": null
}

Parse the response

Use the same flow in any HTTP client:

  1. Check the HTTP status code.
  2. For 4xx or 5xx responses, parse the JSON response body.
  3. Use the type field for programmatic handling.
  4. Use the detail and errors fields for logs, support messages, or user-facing validation feedback.

Handle by status code

Use the status code and type field for the first routing decision:

StatusTypeAction
400bad-requestMalformed request; check the body and parameters
401unauthorizedToken is invalid or expired; re-authenticate
403access-deniedMissing permission or tenant mismatch; check credentials
404item-not-foundThe resource does not exist; verify the ID
409item-already-existsResource already exists; use a different ID or fetch the existing one
422validation-errorRequest body failed schema validation; see field errors
500internal-errorRetry with exponential backoff; report if persistent
502bad-gatewayUpstream dependency failed; retry after a short delay

Handle validation errors

For 422 responses, the errors array contains one entry per invalid field:

{
  "title": "Validation Error",
  "status": 422,
  "type": "validation-error",
  "detail": "Request validation failed",
  "errors": [{ "field": "email", "message": "Invalid email format" }]
}

Iterate over errors[] to surface field-specific messages to users or logs. For other error types, use detail as the operational message.

If it's not working

SymptomAction
Response body is not JSONCheck you are calling the correct base URL
errors array is null on a 400Not all 400 responses are validation errors; use type to distinguish

See also