> For the complete documentation index, see [llms.txt](https://docs.wproofreader.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wproofreader.com/v6.11.0/api-reference/style-guide-api/errors.md).

# Errors

### Error envelope

Errors use the standard HTTP API error format.

See [HTTP API Overview](/v6.11.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.`      |

### `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         |

### `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         |

### `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         |

### `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         |

### 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.11.0/deployment/configuration/application-server/access-key.md).
