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 StatusDescription
200 OKStandard 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 CreatedA new resource was created and a response body containing a representation of the new resource is being returned.
202 AcceptedRequest was accepted but not yet processed. A Location header containing the canonical URI for the newly created resource should also be returned.
204 No ContentThe server successfully processed the request, and is not returning any content.
400 Bad RequestThe 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 UnauthorizedSimilar 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 requiredYou need to create or upgrade your payment plan.
403 ForbiddenThe server recognized your credentials, but you do not possess authorization to perform this request.
404 Not FoundThe requested resource could not be found.
429 Too Many 4XX RequestsYou 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 ErrorThe server encountered an unexpected condition which prevented it from fulfilling the request.
HeaderDescription
Content-TypeThe media type of the response body
Content-LengthLength (in bytes) of the response message body
LocationCanonical URI of a newly created resource - if applicable
X-Request-UUIDOptional 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.