Skip to content

The HTTP Responses

The HTTP response status line contains a status code. This code tells you whether the request succeeded or an error occurred, and when something went wrong, it indicates the type of error.

The following status codes are defined in the RE-ZIP API:

HTTP Status Description
200 OK Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action.
201 Created A new resource was created and a response body containing a representation of the new resource is being returned.
202 Accepted Request was accepted but not yet processed. A Location header containing the canonical URI for the newly created resource should also be returned.
204 No Content The server successfully processed the request, and is not returning any content.
400 Bad Request The request could not be processed because it contains missing or invalid information (such as validation error on an input field, a missing required value, and so on).
401 Unauthorized Similar to 403 Forbidden, but specifically for use when authentication is possible but has failed or not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource.
402 Payment required You need to create or upgrade your payment plan.
403 Forbidden The server recognized your credentials, but you do not possess authorization to perform this request.
404 Not Found The requested resource could not be found.
429 Too Many 4XX Requests You have sent too many requests in a short period that resulted in 4XX responses. A Retry-After header indicates how long to wait before trying again.
500 Internal Server Error The server encountered an unexpected condition which prevented it from fulfilling the request.
Header Description
Content-Type The media type of the response body
Content-Length Length (in bytes) of the response message body
Location Canonical URI of a newly created resource - if applicable
X-Request-UUID Optional Request UUID (v4) to identify request/response flows

The response body for any non-static resource requests will contain a JSON document. The JSON-encoded data will either be a hash or a list of hashes. Here are some examples:

Response for a successful request for a single resource:

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: n
{
"key1": "value1",
"key2": "value2"
}

Response for a successful request for a list of resources:

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: n
[
{
"key1": "value1",
"key2": "value2"
}
]

If processing of a request fails the response may look like this:

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=UTF-8
Content-Length: n
{
"message": "Validation error",
"errors": {
"key1": ["must be at least 8 chars"]
}
}

All error responses have message and errors keys, but errors may be null when, for example, the error is not related to any input data.

If the resource is a static resource, the Content-Type header reflects the media type in question, e.g. image/png or text/css. The response body contains the raw resource data, or is empty on errors.