Docs Home

Legacy API Authentication

The Bonsai API supports two methods of authenticating requests: Bearer authentication, and HTTP Basic Auth.

Every request to the API must carry an API token in its Authorization header, using one of two schemes:

  • Bearer authentication: Authorization: Bearer bonsai_<key>_<secret>. This is the simplest option for a new token.
  • HTTP Basic Auth: the token's key and secret as the username and password. Most HTTP clients support it out of the box.

Both schemes accept new bonsai_ tokens as well as the key and secret pairs of tokens created before that format. Send one credential per request: a request with more than one, such as both a Basic and a Bearer credential, is refused.

Both schemes send the token as it is, so only use them over https. Requests to https://api.bonsai.io are encrypted with TLS.

Failed Authentication

Requests that do not have the proper authentication will receive an HTTP 401: Unauthorized response. This can happen for a variety of reasons, including (but not limited to):

  1. The Authorization header is missing, or uses a scheme other than Basic or Bearer
  2. The token key can not be found (perhaps due to a typo)
  3. The token secret does not match the key
  4. The token has been revoked
  5. The token has expired

A token that authenticates but lacks the scope an API call needs gets an HTTP 403: Forbidden response instead. See scopes.

If you are having trouble authenticating your requests to the API, please reach out to support@bonsai.io.

Ready to power your search with AI?

Launch a fully managed Elasticsearch or OpenSearch cluster, with built-in vector search and AI capabilities.

Create an AI Ready Search Cluster
Calming Bonsai waves