Authentication
Every request to the Bencha API needs an API key. The key identifies your account, and requests without a valid one are rejected.
Create an API key
Sign in to the Bencha Console and create an API key there.
Send the key
Send the key as a bearer token in the Authorization header of every request:
Authorization: Bearer {api_key}curl --request POST \
--url https://api.bencha.io/v1/search/brands \
--header "Authorization: Bearer $BENCHA_API_KEY" \
--header "Content-Type: application/json" \
--data '{ "query": "Newbie" }'The Try in Playground button on each endpoint's page asks for your key too. The playground keeps it in your browser tab until you close it, and sends it only to api.bencha.io.
Errors
A request with a missing, malformed or unknown key gets a 403 Forbidden response:
{
"code": "unauthorized",
"status": 403,
"message": "provided token is missing or invalid",
"request_id": "request_01M9093P26RKCG4014R02280HF"
}Check that the header is spelled Authorization, that the value starts with Bearer followed by a space, and that the key is complete. If a request still fails, contact us with its request_id.
Keep your keys safe
Your API key gives access to your account, so treat it like a password.
- Call the API from your server. Don't put the key in code that runs in your users' browsers or apps, where anyone can read it.
- Keep keys out of your code. Read them from an environment variable or a secrets manager, and don't commit them to version control.