Response Codes

Response Codes

The Picus Rest API uses the following response status codes, as defined in the RFC 7231, RFC 7235, RFC 4918 and RFC 6585:

Status CodeDescription
200 OKThe request has succeeded. You can read response and headers.
201 CREATEDThe new resource is created successfully.
204 NO CONTENTThe request has succeeded but there is no content.
400 BAD REQUESTThe request could not be understood by the server due to malformed syntax.
401 UNAUTHORIZEDThe request requires to authentication. If the request includes authorization information, authorization has been refused for those credentials.
402 PAYMENT REQUIREDThe requested resource has reached out limitation. You can try it later or removing existing resources. Also you can contact with the support.
403 FORBIDDENAuthorization information is correct but resource but you do not have permission to access this resource.
404 NOT FOUNDThe requested resource is not found.
408 REQUEST TIMEOUTNo response within the given time.
422 UNPROCESSABLE ENTITYThe request contains invalid parameter. The parameter contains validation error.
429 TOO MANY REQUESTThe rate limit is applied.
500 INTERNAL SERVER ERRORThere is a problem, please contact Picus support.
503 SERVICE UNAVAILABLEThe service is not giving a response, please contact Picus support.
504 GATEWAY TIMEOUTThe gateway did not get a response in time, please contact Picus support.

Error Response Schema

The error response has common format. The status code will give about error type. Also other detail information will be in response body.

{
  "message": "The error message",
  "error_code" : 1001, //Optional, If there is a specific error. You should check endpoint documentations
  "errors": //Optional, If there are multi error. You should check endpoint documentation 
  {
    "error1": "message",
    "error2": "message2"
  }

Validation Error Example

If parameter has validation error, a 422 status code error will be returned. "Errors" will contain validation error details. See the validation error example below.

//STATUS CODE: 422
{
    "message": "validation error",
    "errors": {
        "parsing error": "strconv.ParseUint: parsing \"abc\": invalid syntax"
    }
}

Authentication Error Example

If the request has no "Authentication": "Bearer access_token" header, response status code will be 401. See the authentication error example below.

//STATUS CODE: 401
{
    "message": "auth header is empty"
}

If the request has "Authentication": "Bearer access_token" header but access token is not valid, response status code will be 401.

{
    "message": "illegal base64 data at input byte 37"
}

Not Found Error Example

If the requested record is not found, an endpoint returns a '404 not found error'.

//STATUS CODE: 404
{
    "message": "not found error"
}