0

We have an API and we want to reject requests beyond page 99.

EG:

GET example.com/users?page[number]=99 # Allowed, returns 200 OK
GET example.com/users?page[number]=100 # Disallowed, returns ???

What is the most appropriate status code to return?

We are considering:

  • 400: Too generic
  • 403: Most likely
  • 410: Gone. Maybe, but the old way was not temporary
  • 422: Close, but includes: "the server was unable to process the contained instructions", not quite accurate
  • 429: Doesn't honour Retry-After

1 Answer 1

1

400-Bad Request: Looks appropriate. You can include error details in the response body, like a message explaining why it is a bad request (page limit)

403-Forbidden: It does not look to fit well, it is not an access matter.

422-Unprocessable Content: Maybe this one works, once the request syntax is correct.

429-Too Many Requests: It is not the case.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.