Skip to content

Latest commit

 

History

History
73 lines (61 loc) · 4.93 KB

File metadata and controls

73 lines (61 loc) · 4.93 KB

Notes on RESTful API Design

This is a list of return codes in relation to a RESTful API design.

Some of the operations can have more than one outcome, so you need to decide on which one you find the most appropriate for your use case.

OperationHTTP MethodStatus Code On SuccessNotes
CreatePOST201 CreatedWhen the object is created immediately
202 AcceptedWhen the object is accepted but not created immediately
400 Bad RequestIf the submitted data are malformed
404 Not FoundIf referenced objects do not exist
409 ConflictIf you handle that the same object cannot be created more than once
422 Unprocessable ContentIf submitted data are validated and validation fails
ReadGET200 OKWhen the object requested in included in the response
404 Not FoundIf referenced object/objects do not exist
UpdatePUT200 OKWhen the updated object is returned as part of the response
204 No ContentWhen the updated object is not returned as part of the response
400 Bad requestIf the submitted data are malformed
404 Not FoundIf referenced object/objects do not exist
409 ConflictIf you handle that the object cannot be updated inconsistently
PATCH200 OKWhen the updated object is returned as part of the response
204 No ContentWhen the updated object is not returned as part of the response
400 Bad RequestIf the submitted data are malformed
404 Not FoundIf referenced object/objects do not exist
DeleteDELETE200 OKWhen an object changes status to deleted or similar (soft delete) and is returned as part of the response
202 AcceptedWhen an object changes status to deleted or similar and is deleted a part of a garbage collection process or similar
204 No ContentWhen an object is deleted immediately and the object is not returned
404 Not FoundIf referenced object do not exist
Status Code On ErrorNotes
401 UnauthorizedIf you receive a unauthenticated request, to a resource requiring authentication
403 ForbiddenIf you receive a authenticated but unauthorized request, to a resource requiring authorization
405 Method not allowedIf you receive a HTTP method not supported
429 Too Many RequestsIf you support rate limiting and set limit is reached
500 Internal Server ErrorFor you unhandled errors and errors server side
HTTP MethodIdempotentCan become Idempotent
POSTNoYes
PUTYes
PATCHNo
GETYes
HEADYes
DELETEYes
OPTIONSYes

Resources and References