# invalid_request

HTTP 422 · `code`: `invalid_request` · `title`: Invalid request

A parameter is missing, malformed, out of range or not allowed with another. The answer lists each wrong field in `errors`, with its messages.

When a value is not one the parameter accepts, the message lists the accepted ones, in order:

```json
{ "errors": { "scope": ["The scope must be one of: host, latest."] } }
```

A list filter names the position of the value it refuses (`status.0`). The same sentence is used by every field of the public API that takes one of a fixed set.

Also returned when a cursor does not match the call it is sent with (on the lists that page by time: log search, a custom metric’s samples, a service’s scans and runs; a page list ignores a `cursor`), a `page` or `per_page` is out of range, a window is longer than the operation allows, or a list filter value is unknown.

Also returned by a write that carries an `Idempotency-Key` the API cannot honour, with the problem on the `Idempotency-Key` header in `errors`:

| Message under `Idempotency-Key` | Meaning |
| --- | --- |
| This Idempotency-Key was used for a different request in the last 24 hours. | The same key was sent with another request (another incident, domain, scan type or body). Use a new key for a new request, and the same key only to retry the same one. |
| An Idempotency-Key is 1 to 255 visible ASCII characters. | The key is longer than 255 characters or holds a space or a character that is not visible ASCII. |

See [retrying a write safely](https://developer.watchtower15.com/api/acting-on-incidents-and-scans/#retrying-a-write-safely).

Also returned by a delete the console refuses because something still depends on the record. `errors` then holds `dependencies`, which is no field: a list of what blocks the delete, as `<what>: <how many>` (`servers: 3`, `default_profile: 1`, `system_group: 1`), and nothing is deleted. See [a refused delete](https://developer.watchtower15.com/api/changing-resources/#a-refused-delete).

## What the answer carries

Every [problem document](https://developer.watchtower15.com/api/errors/) carries `type`, `title`, `status`, `code`, `detail` and `request_id`. In addition: `errors`: an object of field names, each a list of messages, or `dependencies` for a refused delete, a list of what blocks it.

## What to do

Read `errors`, correct the named parameters and send the call again. Retrying the same call cannot succeed. For a refused delete, remove or move what `dependencies` names: the same delete then succeeds.

## This page's address

The API's answer names this page in `type` as `https://docs.watchtower15.com/api/errors/invalid_request/`, an identifier that never changes within `v1`. That address answers with a permanent redirect to this page, so a link in a log still opens it, and a client comparing `type` as a string never breaks.

**Response (422 Unprocessable Content)**

```http
HTTP/1.1 422 Unprocessable Content
Content-Type: application/problem+json
X-Request-Id: 4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d

{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

Source: https://developer.watchtower15.com/api/errors/invalid_request/
