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 (Example: a parameter is missing).
5xx error status codes indicate an error with Bodyguard’s servers.
Structure
Every error will have the following fields :
Name | Description |
---|---|
code | The HTTP code. |
status | The HTTP status code. |
message | A simple sentence to resume the error. |
details | An object that will contain all information you need to fix the error. |
Common error codes
Code | Status | Description | Action |
---|---|---|---|
400 | BAD_REQUEST | One 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. |
401 | UNAUTHORIZED | The provided API Key is invalid. | Go in your dashboard and check that you have generated and provided the right API key. |
403 | FORBIDDEN | You do not have the right to access the resource. | Check that you have set the right API key. |
429 | TOO_MANY_REQUESTS | You 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 "https://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"
]
}
}