Skip to content

HTTP status codes explained

What 200/201/204/400/401/403/404/422/429/500 mean, with the bodies the API returns for each.

A REST API is mostly a set of agreed rules on top of HTTP. Status codes are the most important part of those rules because they tell your code what happened, before it even looks at the body. This page goes through the codes the GoRest API actually returns, what each one means, and how a sensible client handles them.

Success codes

200 OK

The default success response. Returned by every read endpoint and by partial updates (PATCH). The body is the resource you asked for, or a list in the form { "data": [...], "meta": {...} }, as JSON. There is nothing to do beyond reading the body.

HTTP/1.1 200 OK
Content-Type: application/json
RateLimit-Policy: "token";q=300;w=60
RateLimit: "token";r=299;t=1

{
  "data": [
    { "id": "0190a8e4-0000-7000-8000-000000000001", "name": "Avani Iyer",
      "email": "avani@example.com", "status": "active", "read_only": false,
      "created_at": "2026-10-30T09:15:00Z", "updated_at": "2026-10-30T09:15:00Z" }
  ],
  "meta": { "has_more": false, "next_cursor": null, "total": null }
}

201 Created

A successful POST to a collection. The body is the newly created resource, with the server-assigned id filled in. The Location header points at the new row. Treat 201 the same way you treat 200 (read the body), but the id is the part you usually want to keep.

204 No Content

A successful DELETE. There is no response body to parse; that is what the 204 means. Do not call .json() on a 204; you will get a parse error.

Client errors (4xx)

400 Bad Request

The request was malformed. Common causes: invalid JSON in the body, a bad query parameter (such as page[size]=0 or an id that is not a UUID), or a header that the server cannot interpret. The code is invalid_parameter. Fix the syntax of your request and try again. Retrying the same request never fixes a 400.

401 Unauthorized

The Authorization header was missing, malformed, or the token did not match an active access token. Reads need no token, but a write does. Every 4xx and 5xx body is Problem Details (application/problem+json), and the code field is the part to switch on. The response also has a WWW-Authenticate: Bearer header:

HTTP/1.1 401 Unauthorized
Content-Type: application/problem+json
WWW-Authenticate: Bearer

{
  "type": "https://www.gorest.co.in/docs/api/errors#unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "This needs a token: Authorization: Bearer <token>.",
  "instance": "/public/v3/users",
  "request_id": "01a1933c-bbd6-781e-ab40-56f3d45de921"
}

If your token used to work and stopped, check whether you regenerated it; regenerating in /my/tokens invalidates the previous value. If you copy a token from a different environment, check that you also copied it correctly: the most common cause of a 401 is a stray newline.

403 Forbidden

You authenticated successfully, but this token cannot perform this operation. On GoRest that means one of two things. The token lacks the scope the operation needs, such as users:write (the response then has WWW-Authenticate: Bearer error="insufficient_scope"). Or the row is read-only sample data ("read_only": true), which nobody can change. The code is forbidden.

404 Not Found

The URL itself, or the id in the URL, does not point at a real resource. The API treats "you cannot see this" and "this never existed" the same way: 404 hides whether the row ever existed at all. Handle both cases in your code: a list filter that returns an empty data array is success (an empty page); a fetch by id that returns 404 means "no such row, full stop."

405 Method Not Allowed

The path is real but does not accept this verb. Easy to hit with a PUT, since v3 has only PATCH for updates. The Allow header lists which methods are allowed:

HTTP/1.1 405 Method Not Allowed
Content-Type: application/problem+json
Allow: GET, HEAD, POST, PATCH, DELETE

{ "type": "https://www.gorest.co.in/docs/api/errors#method_not_allowed",
  "title": "Method Not Allowed", "status": 405, "code": "method_not_allowed" }

415 Unsupported Media Type

Your Content-Type was not application/json. GoRest does not parse form-encoded bodies. Set the header explicitly when you send a body.

422 Unprocessable Entity

The body parsed fine, but failed validation. The errors array has one entry per wrong field, with a JSON Pointer to the field, a short code and a detail you can put straight into a form-error UI:

HTTP/1.1 422 Unprocessable Entity
Content-Type: application/problem+json

{
  "type": "https://www.gorest.co.in/docs/api/errors#validation_failed",
  "title": "Unprocessable Entity",
  "status": 422,
  "code": "validation_failed",
  "instance": "/public/v3/users",
  "errors": [
    { "pointer": "/email", "code": "taken", "detail": "has already been taken" }
  ]
}

Treat 422 as a user error, not a server error. Do not retry, and do not page anyone. Show the messages next to the wrong fields.

429 Too Many Requests

You used up your rate-limit budget. The Retry-After header tells you, in seconds, how long to wait. Sleep that long and try again; there is a separate guide on this in Rate limiting and retries.

Server errors (5xx)

500 Internal Server Error

Something broke on the server. Quote the X-Request-Id header (also request_id in the body) in any bug report so we can find the trace. Retrying once after a short delay is reasonable; retrying in a tight loop is not. 500s usually come together, and you will only make the underlying issue worse.

503 Service Unavailable

Down for maintenance, or briefly overloaded. The Retry-After header tells you when to come back. 503 is the only 5xx where retrying is clearly the correct response.

How to handle them in code

A pattern that works in any language: branch on three buckets, namely success (2xx), client error (4xx, where 401/403/404 are usually separate user-facing cases), and server/transport (5xx and network errors). The middle bucket gets shown in the UI; the third gets retried with back-off.

const res = await fetch(url, opts);
if (res.status >= 200 && res.status < 300) return res.json();
if (res.status === 401) return signIn();
if (res.status === 404) return null;
if (res.status === 422) throw new ValidationError(await res.json());
if (res.status === 429 || res.status >= 500) return retryWithBackoff();
throw new Error(`Unexpected ${res.status}`);

Test your error paths

The API has a test endpoint, /public/v3/http/status/N, that answers with the status code you name. Use it to check your error handling without waiting for a real failure: call /public/v3/http/status/429 and watch your 429 path, call /public/v3/http/status/500 and watch your retry path. A 4xx or 5xx answer is Problem Details with the code requested_status. A 429 or 503 comes with Retry-After, as real ones do. The full list of error codes is at /docs/api/errors.

Related guides

Keep going