> 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.12.0/api-reference/spelling-autocorrect-api.md).

# Spelling autocorrect API

`autocorrect` takes a single word and returns one spelling suggestion.

It also returns a localized “revert” message for the UI.

**Command name:** `autocorrect`\
**Success status:** `200 OK`

### On this page

* [Common parameters](#common-parameters)
* [Parameters](#parameters)
* [Behavior notes](#behavior-notes)
* [Request examples](#request-examples)
* [Response schema](#response-schema)
* [Errors](#errors)

**Related**: [Overview](/v6.12.0/api-reference/overview.md), [Supported languages](/v6.12.0/features/supported-languages.md)

### Common parameters

`cmd` selects the command to run.

| Name  | Type   | Required | Description            |
| ----- | ------ | -------- | ---------------------- |
| `cmd` | string | Yes      | Must be `autocorrect`. |

These parameters work with any `cmd`.

| Name           | Type    | Required   | Description                                                                                                                                                                        |
| -------------- | ------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `serviceid`    | string  | Cloud only | Cloud API key. Required for Cloud requests. Not used on-premises.                                                                                                                  |
| `format`       | string  | No         | Response format. Values: `json` (default), `xml`.                                                                                                                                  |
| `callback`     | string  | No         | JSONP wrapper function name. Use only with `format=json`.                                                                                                                          |
| `short_answer` | boolean | No         | <p>JSON only. When <code>true</code>, shortens JSON keys to reduce payload size.<br>See <a href="/pages/VXTsQ0sY5BFRLUsqxnbL#boolean-parameter-values">boolean parameters</a>.</p> |

See [Overview](/v6.12.0/api-reference/overview.md#common-parameters) for details.

### Parameters

These are parameters specific to `cmd=autocorrect`.

| Name     | Type   | Required | Description                                                                                                                |
| -------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------- |
| `text`   | string | Yes      | Word to autocorrect. If it contains spaces, the command returns no suggestions.                                            |
| `lang`   | string | Yes      | Language code. Use a language that supports spelling. See [Supported languages](/v6.12.0/features/supported-languages.md). |
| `locale` | string | No       | Localization for the revert message shown to the user. Accepted formats: `es`, `es-ES`, `es_ES`.                           |

### Behavior notes

* The response contains **zero or one** suggestion.
* If `text` has more than one word, you get an empty result.
* An empty result is still a `200 OK`.

### Request examples

#### Example: suggestion found

Request:

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

```http
GET https://endpoint/api?cmd=autocorrect&lang=en_US&text=helo
```

{% endtab %}

{% tab title="POST" %}

```http
POST https://endpoint/api
Content-Type: application/json

{
  "cmd": "autocorrect",
  "lang": "en_US",
  "text": "helo"
}
```

{% endtab %}
{% endtabs %}

Response (`200 OK`):

{% tabs %}
{% tab title="JSON" %}
Use defaults: `format=json`, `short_answer=false`.

```json
{
  "result": {
    "message": "Revert to",
    "suggestions": [
      "hello"
    ]
  }
}
```

{% endtab %}

{% tab title="Short JSON" %}
Add `short_answer=true`.

```json
{
  "r": {
    "m": "Revert to",
    "s": [
      "hello"
    ]
  }
}
```

{% endtab %}

{% tab title="XML" %}
Set `format=xml`.

```xml
<result>
  <message>Revert to</message>
  <suggestions>
    <suggestions>hello</suggestions>
  </suggestions>
</result>
```

{% endtab %}
{% endtabs %}

#### Example: no suggestions

Request:

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

```http
GET https://endpoint/api?cmd=autocorrect&lang=en_US&text=hello
```

{% endtab %}

{% tab title="POST" %}

```http
POST https://endpoint/api
Content-Type: application/json

{
  "cmd": "autocorrect",
  "lang": "en_US",
  "text": "hello"
}
```

{% endtab %}
{% endtabs %}

Response (`200 OK`):

{% tabs %}
{% tab title="JSON" %}
Use defaults: `format=json`, `short_answer=false`.

```json
{
  "result": {}
}
```

{% endtab %}

{% tab title="Short JSON" %}
Add `short_answer=true`.

```json
{
  "r": {}
}
```

{% endtab %}

{% tab title="XML" %}
Set `format=xml`.

```xml
<result/>
```

{% endtab %}
{% endtabs %}

### Response schema

The response is always an object with a single `result`.

#### JSON (`short_answer=false`)

```json
{
  "result": {
    "message": "Revert to",
    "suggestions": [
      "hello"
    ]
  }
}
```

* `result` (object)\
  Always present. Empty object means “no suggestions”.
* `result.suggestions` (array of strings)\
  Zero or one element.
* `result.message` (string)\
  Localized label for the revert action. Present when a suggestion exists.

#### Short JSON (`short_answer=true`)

Key mapping:

* `result` → `r`
* `message` → `m`
* `suggestions` → `s`

### Errors

Errors use the shared error format from [Overview](/v6.12.0/api-reference/overview.md#errors).

#### Language code not found (`400 Bad Request`)

```json
{
  "error": true,
  "message": "Language code not found."
}
```

#### Language has no spelling support (`403 Forbidden`)

```json
{
  "error": true,
  "message": "Command 'autocorrect' for language 'ja_JP' is not enabled or unsupported."
}
```
