Docs Home

Using Basic Authentication

The Bonsai API supports HTTP Basic Authentication over TLS >= 1.2 as one means for authenticating requests.

The Bonsai API supports HTTP Basic Authentication over TLS >= 1.2 as one means for authenticating requests. The authentication protocol utilizes an Authorization header, with the contents: Basic <base64 of username:password>.

Many tools, such as curl, will construct this header automatically from credentials in a URL or the -u flag. For example, curl will translate https://user:pass@api.bonsai.io/ into a request to https://api.bonsai.io/ with the header Authorization: Basic dXNlcjpwYXNz.

Credentials

For Basic Auth, the token key corresponds to the "user" parameter and the token secret corresponds to the "password" parameter. This works for every token, whether it was created before or after the bonsai_ format:

curl -u "<key>:<secret>" https://api.bonsai.io/clusters

A token in the bonsai_<key>_<secret> format can also be sent whole as the password. The username is then ignored, so it can be anything:

curl -u "token:bonsai_<key>_<secret>" https://api.bonsai.io/clusters

See Creating an API Token for how a token splits into its key and secret. To send a token without encoding it, use Bearer authentication instead.

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