Troubleshooting a failed request
Three reads settle most failures. Reach for them in this order.
statusnames the failure class.typenames the exact rule that fired (error catalog).request_idties the call to a platform trace.
Fast lookups
| Symptom | Status | Usual cause | Fix |
|---|---|---|---|
| Every secured route refuses the call | 401 | Header missing, or the token expired | Mint a token and send Authorization: Bearer <token>, or send a key |
| One route refuses, others answer | 403 | The credential lacks that route's scope | Request the scope named in the challenge |
| A key that worked on retail fails on animals | 403 | Keys carry a fixed scope set | Send the ops key, or mint a token with write:animals |
| A key returns 401 | 401 | The value is mistyped or retired | Copy the key from authentication |
| A record you know exists returns empty | 404 | Identifier typo, or a stale hold id | Re-read the id from a fresh response |
| A second hold fails | 409 | Another applicant holds that animal | Read expires_at and offer a waitlist |
| A hold fails with no live hold in sight | 422 | The animal sits in quarantine, or lacks clearance | Check status and spay_neuter_certified |
| The console sends fine and the shell fails | 401 | The shell omits a header the console added | Copy the header from the console snippet |
| Requests fail in bursts | 429 | The credential passed its window | Obey 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: Basicfails 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
ApiKeyin that case, notBearer.
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.
| Target | Why the id dies |
|---|---|
| Browser demo | A page reload clears the tab's hold table |
| Sandbox gateway | A 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 asMEDICAL_QUARANTINE. spay_neuter_certifiedreadsfalse, 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-Idfrom the failing response. - The operation and the target, production or sandbox.
- The status and the
typeURI. - 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.
Related guides
- Errors and problem details - the nine error types and the retry each one deserves.
- Authentication and scopes - how to get a token that works.
- Holds and concurrency - the rules behind a 409 and a 422 on holds.
- Test requests - what each of the three targets enforces.