Error codes

Bodyguard uses HTTP response status codes to indicate the success or failure of your API requests.

There are three status code ranges you can expect:

  • 2xx success status codes confirm that your request worked as expected
  • 4xx error status codes indicate an error because of the information provided (e.g., a parameter is missing)
  • 5xx error status codes indicate an error with Bodyguard’s servers

Structure

Every error will have the following fields :

NameDescription
codeThe HTTP code.
statusThe HTTP status code.
messageA simple sentence to resume the error.
detailsAn object that will contain all information you need to fix the error.

Common error codes

CodeStatusDescriptionAction
400BAD_REQUESTOne or more of the request's parameters are missing or invalid.Check the error details field. It should give you more information about the wrong parameters.
401UNAUTHORIZEDThe provided API Key is invalid.Go in your dashboard and check that you have generated and provided the right API key.
403FORBIDDENYou do not have the right to access the resource.Check that you have set the right API key.
429TOO_MANY_REQUESTSYou have exceeded the rate limit.Wait until your quota is reset. You might need to implement a retry behavior.

Example

Let's try a wrong query using a REST call :

> curl -X POST "bamboo.bodyguard.ai/api/analyze" -H "X-Api-Key: YOUR_API_KEY" -H "Content-Type: application/json" -d '{"text":"Tu es un bouffon"}' | jq .
{
"error": {
"message": "Please check your parameters",
"status": "BAD_REQUEST",
"code": 400,
"details": [
"\"contents\" must be an array"
]
}
}