+++
title = "API Error 400: Bad Request"
weight = 81
updated = 2026-10-13

[extra]
nav_title = "API Error 400: Bad Request"
weight = 5
+++

An HTTP 400: Bad Request error occurs when the API can't read a request: its body is not valid JSON, or it is missing something the call can't do without.

If you are receiving an HTTP 400: Bad Request error, there are a few possibilities for why it might be occurring:

- The request body is not valid JSON. This happens whatever the `Content-Type` header says.
- The request to [create](@/docs/api/endpoints/cluster-api/index.md#create-new-cluster) or [update](@/docs/api/endpoints/cluster-api/index.md#update-cluster) a cluster has no body at all. Those calls read their parameters from a JSON body, so an empty body gets the same error as one that isn't valid JSON.
- The request to [destroy a cluster](@/docs/api/endpoints/cluster-api/index.md#destroy-cluster) does not pass the cluster's `name`. A `name` in the body is only read when the request has a `Content-Type: application/json` header.

A request refused with a 400 changes nothing.

## Example

A request whose body is not valid JSON, or a create or update request with no body, gets this response:

```json
{
  "errors": [
    "The request body does not appear to be valid JSON."
  ],
  "status": 400
}
```

A request to destroy a cluster without its `name` gets this one:

```json
{
  "errors": [
    "Pass the name of the cluster as `name`."
  ],
  "status": 400
}
```

The `"status": 400` key indicates the HTTP 400: Bad Request error.

## Troubleshooting

Check the body your client actually sends, for example with curl's `-v` flag, and run it through a JSON validator. Common causes are a trailing comma, single quotes instead of double quotes, and a body built by string concatenation that isn't escaped.

Send a `Content-Type: application/json` header with every request that has a body. For a DELETE request, also check that your HTTP client sends the body at all: some drop the body of a DELETE. If yours does, pass `name` in the query string instead.

If all else fails, you can always [contact support](mailto:support@bonsai.io) and we will be glad to assist.
