# Errors

### Error envelope

Errors use the standard HTTP API error format.

See [HTTP API Overview](/v6.12.0/api-reference/overview.md#errors).

Example:

```json
{
  "error": true,
  "is_critical": 0,
  "message": "Failed to add rule. ...",
  "command": "style_guide"
}
```

### Error Messages

Error responses include an **action-specific prefix** followed by the **specific error**.

### Prefixes

| Action                       | Prefix                         |
| ---------------------------- | ------------------------------ |
| `addrule`                    | `Failed to add rule.`          |
| `deleterule` / `deleterules` | `Failed to delete rule(s).`    |
| `editrule`                   | `Failed to edit rule.`         |
| `getrules`                   | `Failed to get rules.`         |
| `addcollection`              | `Failed to add collection.`    |
| `deletecollection`           | `Failed to delete collection.` |
| `editcollection`             | `Failed to edit collection.`   |
| `getcollections`             | `Failed to get collection(s).` |

### `addrule` errors

| Condition                                                 | Message                                                                                                                              | HTTP status |
| --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ----------- |
| Rule already exists (same `patterns` + `context_include`) | `Failed to add rule. Rule with pattern ["p1","p2"] and [no] include context already exists.`                                         | 400         |
| Missing required parameter                                | `Failed to add rule. Required parameter '{param}' missing.`                                                                          | 400         |
| Parameter is empty                                        | `Failed to add rule. Parameter '{param}' can't be empty.`                                                                            | 400         |
| Forbidden characters                                      | `Failed to add rule. Forbidden characters found in '{param}'.`                                                                       | 400         |
| Length exceeded                                           | `Failed to add rule. Parameter '{param}' exceeds maximum length of {N} characters. Make it shorter and retry.`                       | 400         |
| Too many rules (2000 limit)                               | `Failed to add rule. Maximum of 2000 rules reached. Delete unused rules and retry.`                                                  | 400         |
| Recursive suggestion                                      | `Failed to add rule. {Field} value can't be identical to or include the {other field} value.`                                        | 400         |
| Duplicate value within a parameter                        | `Failed to add rule. Value '{val}' is repeated in '{param}' parameter.`                                                              | 400         |
| Context value is substring of another                     | `Failed to add rule. Parameter '{param}' contains a value that fully includes another. Consider keeping only the more specific one.` | 400         |
| Collection name size exceeded limit                       | `Collection name exceeds the maximum length of 250 characters.`                                                                      | 400         |
| Collection not found                                      | `Collection '{collection}' for '{lang}' language(s) not found.`                                                                      | 404         |
| Collection name forbidden characters                      | `Collection name contains forbidden characters.`                                                                                     | 400         |

### `editrule` errors

| Condition                             | Message                                                                                                                               | HTTP status |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| Rule not found                        | `Failed to edit rule. Rule not found. Use 'getrules' to check available rules.`                                                       | 404         |
| Missing required parameter            | `Failed to edit rule. Required parameter '{param}' missing.`                                                                          | 400         |
| Parameter is empty                    | `Failed to edit rule. Parameter '{param}' can't be empty.`                                                                            | 400         |
| Forbidden characters                  | `Failed to edit rule. Forbidden characters found in '{param}'.`                                                                       | 400         |
| Length exceeded                       | `Failed to edit rule. Parameter '{param}' exceeds maximum length of {N} characters. Make it shorter and retry.`                       | 400         |
| Recursive suggestion                  | `Failed to edit rule. {Field} value can't be identical to or include the {other field} value.`                                        | 400         |
| Duplicate value within a parameter    | `Failed to edit rule. Value '{val}' is repeated in '{param}' parameter.`                                                              | 400         |
| No changes on edit                    | `Failed to edit rule. No changes detected.`                                                                                           | 400         |
| Context value is substring of another | `Failed to edit rule. Parameter '{param}' contains a value that fully includes another. Consider keeping only the more specific one.` | 400         |
| Collection name size exceeded limit   | `Collection name exceeds the maximum length of 250 characters.`                                                                       | 400         |
| Collection not found                  | `Collection '{collection}' for '{lang}' language(s) not found.`                                                                       | 404         |
| Collection name forbidden characters  | `Collection name contains forbidden characters.`                                                                                      | 400         |

### `deleterule` / `deleterules` errors

| Condition                            | Message                                                                                                              | HTTP status |
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------- | ----------- |
| Rule(s) not found                    | `Failed to delete rule(s). Rule(s) not found. Use 'getrules' to check available rules.`                              | 404         |
| Missing required parameter           | `Failed to delete rule(s). Required parameter '{param}' missing.`                                                    | 400         |
| Parameter is empty                   | `Failed to delete rule(s). Parameter '{param}' can't be empty.`                                                      | 400         |
| Forbidden characters                 | `Failed to delete rule(s). Forbidden characters found in '{param}'.`                                                 | 400         |
| Length exceeded                      | `Failed to delete rule(s). Parameter '{param}' exceeds maximum length of {N} characters. Make it shorter and retry.` | 400         |
| Collection name size exceeded limit  | `Collection name exceeds the maximum length of 250 characters.`                                                      | 400         |
| Collection not found                 | `Collection '{collection}' for '{lang}' language(s) not found.`                                                      | 404         |
| Collection name forbidden characters | `Collection name contains forbidden characters.`                                                                     | 400         |

### `getrules` errors

| Condition                            | Message                                                                                                         | HTTP status |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------- | ----------- |
| Rule not found                       | `Failed to get rules. Rule not found. Use 'getrules' to check available rules.`                                 | 404         |
| Missing required parameter           | `Failed to get rules. Required parameter '{param}' missing.`                                                    | 400         |
| Parameter is empty                   | `Failed to get rules. Parameter '{param}' can't be empty.`                                                      | 400         |
| Forbidden characters                 | `Failed to get rules. Forbidden characters found in '{param}'.`                                                 | 400         |
| Length exceeded                      | `Failed to get rules. Parameter '{param}' exceeds maximum length of {N} characters. Make it shorter and retry.` | 400         |
| Collection name size exceeded limit  | `Collection name exceeds the maximum length of 250 characters.`                                                 | 400         |
| Collection not found                 | `Collection '{collection}' for '{lang}' language(s) not found.`                                                 | 404         |
| Collection name forbidden characters | `Collection name contains forbidden characters.`                                                                | 400         |

### `addcollection` errors

| Condition                              | Message                                                                                      | HTTP status |
| -------------------------------------- | -------------------------------------------------------------------------------------------- | ----------- |
| Collection name size exceeded limit    | `Collection name exceeds the maximum length of 250 characters.`                              | 400         |
| Collection not found                   | `Collection '{collection}' for '{lang}' language(s) not found.`                              | 404         |
| Collection name forbidden characters   | `Collection name contains forbidden characters.`                                             | 400         |
| `collection` parameter is not provided | `Required parameter 'collection' missing.`                                                   | 400         |
| Collection already exists              | `Collection '{collection}' for '{lang}' language(s) already exists (case-insensitive match)` | 409         |

### `deletecollection` errors

| Condition                              | Message                                                         | HTTP status |
| -------------------------------------- | --------------------------------------------------------------- | ----------- |
| Collection name size exceeded limit    | `Collection name exceeds the maximum length of 250 characters.` | 400         |
| Collection not found                   | `Collection '{collection}' for '{lang}' language(s) not found.` | 404         |
| Collection name forbidden characters   | `Collection name contains forbidden characters.`                | 400         |
| `collection` parameter is not provided | `Required parameter 'collection' missing.`                      | 400         |

### `editcollection` errors

| Condition                                                             | Message                                                                                      | HTTP status |
| --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ----------- |
| Collection name size exceeded limit                                   | `Collection name exceeds the maximum length of 250 characters.`                              | 400         |
| Old ollection not found                                               | `Collection '{collection}' for '{lang}' language(s) not found.`                              | 404         |
| Collection name forbidden characters                                  | `Collection name contains forbidden characters.`                                             | 400         |
| `collection` parameter is not provided                                | `Required parameter 'collection' missing.`                                                   | 400         |
| `new_collection` parameter is not provided                            | `Required parameter 'new_collection' missing.`                                               | 400         |
| New collection already exists                                         | `Collection '{collection}' for '{lang}' language(s) already exists (case-insensitive match)` | 409         |
| Edit collection request contains the same old and new collection info | `No collection changes detected.`                                                            | 200         |

### `getcollections` errors

| Condition                            | Message                                                         | HTTP status |
| ------------------------------------ | --------------------------------------------------------------- | ----------- |
| Collection name size exceeded limit  | `Collection name exceeds the maximum length of 250 characters.` | 400         |
| Collection not found                 | `Collection '{collection}' for '{lang}' language(s) not found.` | 404         |
| Collection name forbidden characters | `Collection name contains forbidden characters.`                | 400         |

### Unknown action example

```json
{
  "error": true,
  "is_critical": 0,
  "message": "Action not found. Available actions: addrule, deleterules, editrule, getrules.",
  "command": "style_guide"
}
```

### Authorization error

An access key is required for this command. If it's not provided, you will see an error:

```json
{
    "error": true,
    "message": "Access key is required to use 'style_guide' command."
}
```

See [Access key](/v6.12.0/deployment/configuration/application-server/access-key.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wproofreader.com/v6.12.0/api-reference/style-guide-api/errors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
