> 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.10.0.0/api-reference/style-guide-api/response-schema.md).

# Response schema

Success envelope and rule object schema for the Style guide API.

This API returns a consistent success envelope.

### Success

The success response always has two top-level fields:

| Field     | Type   | Notes                                                                    |
| --------- | ------ | ------------------------------------------------------------------------ |
| `message` | string | Human-readable result of the action.                                     |
| `result`  | array  | Always an array of rule objects. Can contain multiple items or be empty. |

{% tabs %}
{% tab title="JSON" %}

```json
{
  "message": "Rule added.",
  "result": [
    {
      "state": true,
      "language": "en_US",
      "id": {
        "category": "STYLE_GUIDE",
        "rule": "STYLE_5933619761905272220"
      },
      "patterns": ["webspellchecker"],
      "suggestions": ["WebSpellChecker"],
      "description": "The company name should be spelled in the mixed case.",
      "context_include": [],
      "context_exclude": []
    }
  ]
}
```

{% endtab %}

{% tab title="XML" %}

```xml
<message>Rule added.</message>

<result>
  <rule>
    <state>true</state>
    <language>en_US</language>
    <id>
      <category>STYLE_GUIDE</category>
      <rule>STYLE_5933619761905272220</rule>
    </id>
    <patterns>
      <patterns>webspellchecker</patterns>
    </patterns>
    <suggestions>
      <suggestions>WebSpellChecker</suggestions>
    </suggestions>
    <description>The company name should be spelled in the mixed case.</description>
    <context_include/>
    <context_exclude/>
  </rule>
</result>
```

{% endtab %}
{% endtabs %}

#### Notes

* `result` is always an array.
* The array can contain one or more rule objects.

### Success messages

The `message` value depends on `action`.

| Action                      | Message          |
| --------------------------- | ---------------- |
| `addrule`                   | Rule added.      |
| `editrule`                  | Rule updated.    |
| `deleterule`, `deleterules` | Rule(s) deleted. |
| `getrules`                  | Rules retrieved. |

### Rule object

`language` is the rule language scope.

It matches the request `lang` value (`common`, `en`, `en_US`, etc).

#### Fields

| Field             | Type (JSON)      | Notes                                                      |
| ----------------- | ---------------- | ---------------------------------------------------------- |
| `id`              | object           | Rule identifier.                                           |
| `id.category`     | string           | Category name / namespace.                                 |
| `id.rule`         | string           | Unique rule ID.                                            |
| `state`           | boolean          | `true` means enabled.                                      |
| `language`        | string           | Same scope as request `lang` (`common`, `en`, `en_US`, …). |
| `patterns`        | array of strings | Patterns to match.                                         |
| `suggestions`     | array of strings | Replacement suggestions. Can be empty.                     |
| `description`     | string           | Optional explanatory message.                              |
| `context_include` | array of strings | Additional context required for match. Can be empty.       |
| `context_exclude` | array of strings | Context that blocks a match. Can be empty.                 |

### Errors

Errors use the standard HTTP API error format.

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