The Clusters API provides a means of managing clusters on your account.
The Clusters API provides a means of managing clusters on your account. This API supports the following actions:
- View all clusters in your account
- View a single cluster in your account
- Create a new cluster
- Update a cluster in your account
- Destroy a cluster in your account
All calls to the Clusters API must be authenticated with an active API token. Viewing clusters needs the clusters:read scope; creating, updating and destroying them needs clusters:write. A token without the scope a call needs gets an HTTP 403: Forbidden error.
The Bonsai Cluster Object
The Bonsai API provides a standard format for Cluster objects. A Cluster object includes:
| Attribute | Description |
|---|---|
| slug | A string representing a unique, machine-readable name for the cluster. The slug is made from the cluster's name at creation: up to its first three words, in lowercase letters only, joined with dashes and cut to 20 characters, then a dash and an 8-character random suffix. For example, a cluster named first_testing_cluster could get the slug first-testing-cluste-1rb4k7wm. Renaming the cluster does not change its slug. |
| name | A string representing the human-readable name of the cluster. |
| uri | A URI to get more information about this cluster. |
| plan | An Object with some information about the cluster's current subscription plan. This hash has two keys:
You can see more details about the plan by passing the slug to the Plans API. |
| release | An Object with some information about the cluster's current release. This hash has seven keys:
You can see more details about the release by passing the slug to the Releases API. |
| space | An Object with some information about where the cluster is running. This has three keys:
You can see more details about the space by passing the path to the Spaces API. |
| stats | An Object with a collection of statistics about the cluster. This hash has three keys:
This attribute should not be used for real-time monitoring! Stats are updated every 10-15 minutes. To monitor real-time metrics, monitor your cluster directly, via the Index Stats API. |
| access | An Object containing information about connecting to the cluster. This hash has three keys:
The cluster's credentials are not part of this object. See Create a new cluster for how to build the cluster's URL. |
| state | A String representing the current state of the cluster. This indicates what the cluster is doing at any given moment. There are 5 defined states:
A cluster's state is the first of |
| provision_state | A String with more detail about where the cluster is in its life. One of:
|
A cluster without a plan, release or space still gets the plan, release and space objects, with the same keys, all null. The exception is space.region: when a cluster has no space but has a region, region holds that region.
"plan": ,
"release": ,
"space":
View all clusters
The Bonsai API provides a method to get a list of all active clusters on your account. An HTTP GET call is made to the /clusters endpoint, and Bonsai will return a JSON list of Cluster objects. This API call will not return deprovisioned clusters. This call uses pagination, so you may need to make multiple requests to fetch all clusters.
Supported Parameters (Query String Parameters)
| Param | Description |
|---|---|
| q | Optional. A string for filtering clusters by name. A cluster matches when its name contains the string, ignoring case. |
| tenancy | Optional. child limits the results to clusters on multitenant (shared) hardware. Any other value is ignored. |
| location | Optional. A path limiting the results to the clusters in one place. It can be the path of a space, such as omc/bonsai/us-east-1/common, the first two parts of a space path, such as omc/bonsai, or the path of a server group (pod) in a space. You can get a list of available spaces with the [Spaces API](@/docs/api/legacy/endpoints/spaces-api/index.md). Any other path, such as a region path or a path that matches nothing, returns an empty list. |
| page | Optional. The page number, starting at 1. See [API Result Pagination](@/docs/api/legacy/reference/api-result-pagination/index.md). |
| size | Optional. The number of clusters on each page, from 1 to 1000. Defaults to 1000. |
HTTP Request
An HTTP GET call is made to /clusters.
HTTP Response
Upon success, Bonsai responds with an HTTP 200: OK code, along with a JSON list representing the clusters on your account, newest first:
View a single cluster
The Bonsai API provides a method to retrieve information about a single cluster on your account. Unlike the list, this also returns a destroyed cluster, in the DEPROVISIONED state.
Supported Parameters
No parameters are supported for this action.
HTTP Request
An HTTP GET call is made to /clusters/[:slug].
HTTP Response
Upon success, Bonsai will respond with an HTTP 200: OK code, along with a JSON body representing the Cluster object:
A slug that does not name a cluster on your account gets an HTTP 404: Not Found error, with the message Cluster not found.
Create a new cluster
The Bonsai API provides a method to create new clusters on your account. An HTTP POST call is made to the /clusters endpoint, and Bonsai will create the cluster.
Supported Parameters
| Param | Description |
|---|---|
| name | Required. A String representing the name for your new cluster. |
| plan | Required. A String representing the slug of the plan for your new cluster. You can get a list of available plans via the [Plans API](@/docs/api/legacy/endpoints/plans-api/index.md). |
| space | Required. A String representing the path of the Space where the new cluster will be created. You can get a list of available spaces with the [Spaces API](@/docs/api/legacy/endpoints/spaces-api/index.md). |
| release | Optional. A String representing the slug of the search service release to use. You can get a list of available releases with the [Releases API](@/docs/api/legacy/endpoints/releases-api/index.md). Without it, Bonsai picks the best release available for the plan. |
HTTP Request
An HTTP POST call is made to /clusters along with a JSON payload of the supported parameters:
HTTP Response
Bonsai will respond with an HTTP 202: Accepted code, along with a short message and details about the cluster that was created:
The user and pass are the cluster's credentials. Save them: no other API call returns them. You can also find them in the Access section of the cluster dashboard.
In this response, host is the cluster's slug rather than its host name, and url is only the credentials part of a URL. To build the cluster's URL:
- Poll the
monitorURL, which views the cluster, until itsaccess.hostis notnull. - Join the
schemeandaccess.hostfrom that response withuserandpassfrom this one:<scheme>://<user>:<pass>@<host>.
For the example above, that gives:
https://utji08pwu6:18v1fbey2y@test-x-1rb5c3hn.us-east-1.bonsaisearch.net
Polling every 3-5 seconds is enough, and keeps you within the rate limits. The cluster is ready when its state is PROVISIONED and its provision_state is provisioned.
Errors
A request with a missing or unknown name, plan, space or release gets an HTTP 422: Unprocessable Entity error naming the problem, and no cluster is created:
The API Error 422: Unprocessable Entity page lists every message. A body that is not valid JSON, or no body at all, gets an HTTP 400: Bad Request error.
Update a cluster
The Bonsai API provides a method to update the name or plan of your cluster. An HTTP PUT or PATCH call is made to the /clusters/[:slug] endpoint, and Bonsai will update the cluster.
Supported Parameters
| Param | Description |
|---|---|
| name | A String representing the new name for your cluster. Changing the cluster name will not change its slug or its URL. |
| plan | A String representing the slug of the new plan for your cluster. Updating the plan may trigger a data migration. You can get a list of available plans via the [Plans API](@/docs/api/legacy/endpoints/plans-api/index.md). |
HTTP Request
To make a change to an existing cluster, make an HTTP PUT or PATCH call to /clusters/[:slug] with a JSON body for one or more of the supported params.
HTTP Response
Bonsai will respond with an HTTP 202: Accepted code, along with short message:
Errors
If any part of the update is refused, the API responds with an error and applies nothing else in the request. For example, a name the cluster can't take gets an HTTP 422: Unprocessable Entity error with the validation message, and the plan in the same request is not changed:
A plan that is unknown, or that the cluster can't change to, also gets an HTTP 422: Unprocessable Entity error, and then the name is not changed either. See API Error 422: Unprocessable Entity for the other messages. A body that is not valid JSON, or no body at all, gets an HTTP 400: Bad Request error.
Destroy a cluster
The Bonsai API provides a method to delete a cluster from your account. To guard against deleting the wrong cluster, the request must include the cluster's name, like the confirmation in the dashboard.
Supported Parameters
| Param | Description |
|---|---|
| name | Required. A String with the name of the cluster you are deleting. It must match the cluster's name exactly, including case. This is the cluster's name, not its slug. |
HTTP Request
An HTTP DELETE call is made to the /clusters/[:slug] endpoint, with a JSON body and a Content-Type: application/json header:
The Content-Type: application/json header is required: without it, the API does not read the name in the body, and refuses the request as if there were no name. If your HTTP client can't send a body with a DELETE request, pass name in the query string instead, URL-encoded: /clusters/[:slug]?name=second_testing_cluster.
HTTP Response
Bonsai will respond with an HTTP 202: Accepted code, along with a short message:
Error
A request without a name parameter is refused with an HTTP 400: Bad Request error, and the cluster is not deleted:
A blank name gets the same error. A name that does not match the cluster's name exactly gets an HTTP 422: Unprocessable Entity error:
We are rolling out the checks on blank and mismatched names gradually, so for now such a request may still delete the cluster. Always send the cluster's exact name.
A cluster that has already been destroyed can't be destroyed or updated again: the request gets an HTTP 422: Unprocessable Entity error, Cluster [:slug] is terminated.
Ready to power your search with AI?
Launch a fully managed Elasticsearch or OpenSearch cluster, with built-in vector search and AI capabilities.