Errors and HTTP status codes
HTTP status codes
HTTP status codes are used to indicate the status of an HTTP request made to a Mono API. There are several different types of status codes, each of which indicates a different outcome for the request. Here are some of the HTTP status codes Mono API uses:
Status | Notes | Methods |
---|---|---|
200 (OK) | Request completed successfully | GET |
201 (Created) | Indicates that a new resource was created as a result of the request | POST |
204 (NoContent) | Indicates that the request was successful, but there is no additional information to send back to the client. | DELETE |
400 (BadRequest) | Request has malformed, missing or non-compliant JSON body, URL parameters or header fields | ALL |
401 (Unauthorized) | Authorization header missing or invalid token | ALL |
403 (Forbidden) | Client doesn't have access to a resource or token is invalid | ALL |
404 (NotFound) | Client attempts to retrieve a resource that is not defined or not exist | ALL |
422 (UnprocessableEntity) | Request structure is valid, but the content coudn't be processed | ALL |
500 (InternalServerError) | Something went wrong on the Server | ALL |
Errors
Every request that returns an error, the API will return an standard error structure, it includes several attributes that provide information about the error:
-
code
: This attribute contains a string that represents the HTTP status code and phrase for the error. For example, "404 Not Found" or "500 Internal Server Error". -
errors
: This attribute is an array of objects that contain information about specific errors that occurred. Each object includes the following attributes:-
error_code
: This attribute contains a string that represents a unique code for the error. This code can be used to identify the specific type of error that occurred. -
message
: This attribute contains a string that provides a brief description of the error. -
path
: This attribute contains a string that represents the location of the error within the request payload. -
url
: This attribute contains a string that represents a URL to a documentation page that provides more information about the error.
-
-
id
: This attribute contains a string that represents a unique identifier for the error. This can be used to track the error for debugging or logging purposes. -
message
: This attribute contains a string that provides a brief description of the error. This message is intended for humans to read and understand, and may be displayed to the user if the error is encountered.
Here's an example that how it will be returned:
{
"code": "400 Bad Request",
"errors": [
{
"error_code": "item_not_found",
"message": "Item doesn't exist",
"path": "#/item/id",
"url": "https://{{api_domain}}/docs#errors"
}
],
"id": "log_7MkWaFqvfosB8fzHhb1Eql",
"message": "Malformed request"
}
Updated almost 2 years ago