Docs Home

Actions

Some changes to a cluster take longer than a request should wait. In the Bonsai API v1, these run as Actions: the request starts the work and answers 202 Accepted at once, and you poll the Action to follow it.

ToCallStarts
Create a clusterPOST /v1/clusterscluster.provision
Delete a clusterDELETE /v1/clusters/{cluster_id}?name=cluster.deprovision
Change a cluster's planPOST /v1/clusters/{cluster_id}/plan_changescluster.change_plan

Renaming a cluster, and creating or revoking a credential, are quick, so they answer right away and start no Action.

Following an Action

The 202 response is the Action, and its Location header is the Action's URL. Poll that URL until the Action's state is success or error:

curl -s https://api.bonsai.io/v1/actions/act_3k9x0q2m7v1c8b4n \
  -H "Authorization: Bearer $BONSAI_TOKEN"

While the Action is unfinished, the response has a Retry-After header with the seconds to wait before the next poll. Polling more often doesn't make the Action go faster, and it uses up your rate limit.

An Action's state is one of:

StateMeaning
newStarted, and waiting to run.
runningRunning.
successFinished.
errorFailed. error says why.

An Action also has a subject, the cluster it acts on, and a list of steps, each with its own state, a message and a time.

Results

When an Action that creates something succeeds, its result names what it made. For cluster.provision, that's the new cluster and its first credential:

{
  "id": "act_3k9x0q2m7v1c8b4n",
  "type": "cluster.provision",
  "state": "success",
  "subject": { "type": "cluster", "id": "my-search-4823919" },
  "created_at": "2026-10-26T14:03:00Z",
  "finished_at": "2026-10-26T14:03:06Z",
  "error": null,
  "result": { "cluster": "my-search-4823919", "credential": "scc-a8Kd" },
  "steps": []
}

Get the credential, with its password and URL, from GET /v1/clusters/{cluster_id}/credentials/{credential_id}. That needs the credentials:read scope.

Failures

A failed Action has state error, and an error with a code and a message. Branch on code. The message is for people, and can change.

CodeMeaning
timed_outThe Action stopped making progress.
action_failedAnything else. Bonsai support can see what went wrong.
payment_failedBonsai couldn't charge the account, so billing for the cluster couldn't start. error.action_url is where a card can be added. Only Actions started through the legacy API fail this way. A v1 create charges before it builds, and answers a refused charge at once with 422 payment_failed.

More codes may be added, so treat a code you don't know like action_failed.

If a cluster fails to build, Bonsai stops billing for it.

One change at a time

A cluster runs one Action of a kind at a time. Starting another while one is running gets a 409 action_in_progress. Wait for the running one to finish, then try again.

Actions Bonsai starts

Bonsai starts some Actions on its own: cluster.read_only, cluster.disable and cluster.enable. They show up in a cluster's Action list alongside yours, so a client that lists Actions sees them too. More types may be added, so handle a type you don't know.

To list a cluster's Actions, newest first:

curl -s https://api.bonsai.io/v1/clusters/my-search-4823919/actions \
  -H "Authorization: Bearer $BONSAI_TOKEN"

The Action object lists every field. A cluster's latest_action also shows its most recent Action's ID, type and state.

Retrying safely

Creating a cluster, deleting one and changing its plan all take an Idempotency-Key, so a retry gets the same Action back instead of starting a second one. See Retrying safely.

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