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 Code

Description

200 OK

The request has succeeded. You can read response and headers.

201 CREATED

The new resource is created successfully.

204 NO CONTENT

The request has succeeded but there is no content.

400 BAD REQUEST

The request could not be understood by the server due to malformed syntax.

401 UNAUTHORIZED

The request requires to authentication. If the request includes authorization information, authorization has been refused for those credentials.

402 PAYMENT REQUIRED

The requested resource has reached out limitation. You can try it later or removing existing resources. Also you can contact with the support.

403 FORBIDDEN

Authorization information is correct but resource but you do not have permission to access this resource.

404 NOT FOUND

The requested resource is not found.

408 REQUEST TIMEOUT

No response within the given time.

422 UNPROCESSABLE ENTITY

The request contains invalid parameter. The parameter contains validation error.

429 TOO MANY REQUEST

The rate limit is applied.

500 INTERNAL SERVER ERROR

There is a problem, please contact Picus support.

503 SERVICE UNAVAILABLE

The service is not giving a response, please contact Picus support.

504 GATEWAY TIMEOUT

The 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"
}