API Response

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 TypeCodeMessageDescription
Ok200SuccessThe request was successful.
Created201CreatedThe resource was created
Bad Request400Bad RequestA validation or client side error occurred and the request was not fulfilled.
Unauthorized401UnauthorizedAuthentication is required or failed.
Forbidden403ForbiddenThe request is understood, but access is not allowed.
Not Found404Not FoundThe requested resource could not be found.
Request Timeout408Request TimeoutThe server timed out waiting for the request.
Unprocessable Entity422Unprocessable EntityA validation or client side error occurred and the request was not fulfilled.
Internal Server Error500Internal Server ErrorThe server encountered an unexpected condition.
Bad Gateway502Bad GatewayThe server, while acting as a gateway or proxy, received an invalid response.
Service Unavailable503Service UnavailableThe 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.