Request and Response
Both request body data and response data are formatted as JSON. Content type for responses will always be application/json
, except for the media service, where the content type for requests may be multipart/form-data
.
Response format
{
"success": boolean, // True if the details provided could be processed and no errors were encountered while processing
"message": string, // Explains why success is true or false, do not use for your checks
"data": object // contains actionable result of processing if present
}
For paginated response, there is response format is slightly different
{
"success": boolean, // True if the details provided could be processed and no errors were encountered while processing
"message": string, // Explains why success is true or false, do not use for your checks
"data": {
"items": array, // contains actionable result of processing if present
"meta": {
"total": number, // total number of items
"page": number, // number of items per page
"limit": number, // number of items per page
}
}
}
While we generally recommend that developers use HTTP status codes to determine the result of an API call, we have provided a handy success key to let you know upfront if the request was successful or not.
Response Codes
Below are the common HTTP response types returned by Primus API:
Response Type | Code | Message | Description |
---|---|---|---|
Ok | 200 | Success | The request was successful. |
Created | 201 | Created | The resource was created |
Bad Request | 400 | Bad Request | A validation or client side error occurred and the request was not fulfilled. |
Unauthorized | 401 | Unauthorized | Authentication is required or failed. |
Forbidden | 403 | Forbidden | The request is understood, but access is not allowed. |
Not Found | 404 | Not Found | The requested resource could not be found. |
Request Timeout | 408 | Request Timeout | The server timed out waiting for the request. |
Unprocessable Entity | 422 | Unprocessable Entity | A validation or client side error occurred and the request was not fulfilled. |
Internal Server Error | 500 | Internal Server Error | The server encountered an unexpected condition. |
Bad Gateway | 502 | Bad Gateway | The server, while acting as a gateway or proxy, received an invalid response. |
Service Unavailable | 503 | Service Unavailable | The server is not ready to handle the request. |
500, 502, 503 Request could not be fulfilled due to an error on Primus's end. This shouldn't happen so please report as soon as you encounter any instance of this.