# Unrouted paths and wrong methods now return the documented JSON error body (https://docs.predictorsdk.com/changelog/2026-08-25-router-error-bodies)

2026-08-25 · Fix

Every documented error on this API is a JSON `ErrorResponse` — `{"error": …,
"status_code": …}` with an optional `message`. Two were not: a path matching no
route, and a path called with a method it does not accept. Those two were
answered by the Go router's defaults, `text/plain` bodies reading `404 page not
found` and `Method Not Allowed`.

They are also the first two errors a new caller hits. A mistyped path or a `POST`
where a `GET` was meant produced a completely different response shape from
every other failure on the API, and a typed SDK client deserializing the body
got a string where it expected an error object — a parse problem stacked on top
of the original mistake.

Both now match everything else:

```json
// GET /v1/nosuchroute
{ "error": "not found", "status_code": 404, "message": "No route on this API matches this path." }

// POST /v1/markets
{ "error": "method not allowed", "status_code": 405, "message": "This path accepts GET, HEAD." }
```

The `Allow` header on a `405` is unchanged and still lists the methods that path
accepts; the `message` now repeats it, so a client reading only the body can
recover. Neither response requires a valid API key — the router answers before
the key is read — and neither status code changed. If you were matching on the
old plain-text body, match on the status code and the `error` field instead.

`405` was previously absent from the reference. It is now documented at the API
level rather than per endpoint, because a rejected method belongs to no endpoint:
declaring it on `GET /v1/markets` would claim a status that `GET /v1/markets`
never returns. Errors a handler produces are unchanged — a market that does not
exist still returns `404 {"error": "market not found"}`, distinguishable from the
routing `404` above by that field.