Skip to main content

Troubleshooting a failed request

Three reads settle most failures. Reach for them in this order.

  1. status names the failure class.
  2. type names the exact rule that fired (error catalog).
  3. request_id ties the call to a platform trace.

Fast lookups​

SymptomStatusUsual causeFix
Every secured route refuses the call401Header missing, or the token expiredMint a token and send Authorization: Bearer <token>, or send a key
One route refuses, others answer403The credential lacks that route's scopeRequest the scope named in the challenge
A key that worked on retail fails on animals403Keys carry a fixed scope setSend the ops key, or mint a token with write:animals
A key returns 401401The value is mistyped or retiredCopy the key from authentication
A record you know exists returns empty404Identifier typo, or a stale hold idRe-read the id from a fresh response
A second hold fails409Another applicant holds that animalRead expires_at and offer a waitlist
A hold fails with no live hold in sight422The animal sits in quarantine, or lacks clearanceCheck status and spay_neuter_certified
The console sends fine and the shell fails401The shell omits a header the console addedCopy the header from the console snippet
Requests fail in bursts429The credential passed its windowObey Retry-After (rate limits)

A secured call returns 401​

The WWW-Authenticate header names the scheme the route wants.

WWW-Authenticate: Bearer realm="bludhaven", error="invalid_token"

Five things produce that response.

  • The header is absent. A browser shell or a proxy can strip it.
  • The scheme word is wrong. Authorization: Basic fails against a bearer route.
  • The token is forged or edited. The gateway verifies an HMAC signature, so only a token it minted passes.
  • The token passed exp. Mint a new one (authentication).
  • The key is mistyped, retired, or sent to a route that takes only a token. The challenge reads ApiKey in that case, not Bearer.

A 401 on an open route never happens, because five routes carry no requirement. GET /animals, GET /animals/{animalId}, POST /applicants, POST /sessions, and POST /webhooks/test-dispatch answer without a credential.

A secured call returns 403​

The gateway identified the token and the route demands a scope the token lacks. The challenge names that scope:

WWW-Authenticate: Bearer realm="bludhaven", error="insufficient_scope", scope="write:animals"

The type reads https://api.bludhavenpets.com/errors/insufficient-scope, and detail names the missing scope in prose.

Two situations produce it:

  • A client credentials token asked for too narrow a set. Post the token request again with the scope the challenge names.
  • A consent screen approved a subset. Run Connect again and approve the scope the route needs.

The fix lives at authorization time. Retrying with the same token returns the same 403.

An animal returns 404​

GET /animals/{animalId} takes the intake identifier, which starts with pet_. A microchip number returns 404, so does a name, and so does an uppercase variant.

Send GET /animals?status=AVAILABLE first and copy an id from the page. That call confirms both the identifier shape and the branch that holds the animal.

A hold id that worked now returns 404​

Two targets lose holds by design.

TargetWhy the id dies
Browser demoA page reload clears the tab's hold table
Sandbox gatewayA recycled edge isolate drops the holds it kept in memory

Neither one released the animal through the API. Place a fresh hold and continue. Read the 404 as a missing record rather than a released animal.

A production hold survives both cases, because it lives in durable storage.

A hold fails with 422​

The platform refuses an ineligible animal even when no hold exists.

  • The animal stores a status other than AVAILABLE, such as MEDICAL_QUARANTINE.
  • spay_neuter_certified reads false, and municipal code blocks the release.
  • Rabies documentation expired before the hold window.

Read the animal record and surface status to the counselor. A waitlist entry beats a retry here, because nothing in the request changes the outcome.

The demo works and the sandbox refuses​

The sandbox gateway enforces the security requirements that the Browser demo skips, and that gap explains nearly every difference between the two targets.

Send a token the gateway minted on any route outside the five open ones. Build one with the client credentials grant, or press Connect in the reference. A made-up string returns 401, and a real token without the route's scope returns 403.

The gateway answers 404 for a documented operation​

A stale deployment explains it. Confirm the contract the gateway loaded.

curl https://sandbox.bludhaven-pets.workers.dev/health

A current deployment reports operations: 24 and secured: 19. Any lower count means the edge runs an older response table, and a redeploy fixes it (versioning).

Escalation​

Write to budbaker@bludhavenpets.com with four values.

  • The X-Request-Id from the failing response.
  • The operation and the target, production or sandbox.
  • The status and the type URI.
  • A timestamp with the time zone.

Support traces that identifier without asking you to reproduce the call. A report without it costs a round trip.