# Correct fields and read each box

> What AppliFlo tells you about every box on a form, how to spot the unsure ones, correct a field and add help for the person filling it.

Detection finds each box on the form and says what it thinks the box is for. Most are right. This guide shows how to read what AppliFlo found and fix the rest before you fill or send. You need a key with the `read` and `draft` scopes, and a document you have [uploaded and detected](https://dev.appliflo.com/guides/upload-detect-fill).

## Read the fields

```bash
curl https://appliflo.com/api/v1/documents/$DOCUMENT_ID/fields \
  -H "Authorization: Bearer $APPLIFLO_API_KEY"
```

Each field in `data.fields` describes one box:

| Key | What it tells you |
| --- | --- |
| `label_text` | The label printed by the box. `label_source` says where it came from: the page text, the PDF's own field name or tooltip, AI, or a person. |
| `section` | The heading the box sits under, such as "Part 2. Information about you". |
| `semantic_type` | What it takes: `name`, `date`, `email`, `phone`, `address`, `currency`, `checkbox`, `signature`, `initials`, `comb` and others. |
| `format` | The format the form asks for, such as a date pattern. Values are changed to it when filled. |
| `comb` | For a row of single-letter boxes, `cells` is how many there are. |
| `multiline` | `true` when the box takes more than one line. |
| `role_hint` | `signer` for a signature box and its date, which a recipient fills. |
| `help` | A short line of help shown to the person filling the box, under its question. Absent when there is none. |
| `confidence` | How sure AppliFlo is, from 0 to 1. |
| `flagged` | `true` when AppliFlo is unsure. Check these first. |
| `source` | `acroform` for a fillable field built into the PDF, `vision` for a box AppliFlo found by reading the page. |

Choice questions are in `data.groups`: the question's `label`, whether one or several options can be picked (`kind`, `min`, `max`), the form's own `instruction` such as "Check only one", and its `options`, each with the `field_id` of its box.

## Correct a field

Send only what you want to change. Every key is optional:

| Key | What it changes |
| --- | --- |
| `label` | The box's label. |
| `semanticType` | What it takes, such as `date` or `email`. |
| `fieldType` | `text`, `checkbox` or `signature`. |
| `bbox` | The box's position, as four numbers. |
| `help` | Help for the person filling the box, up to 160 characters. `null` or an empty string removes it. |

**curl**

```bash
curl -X PATCH https://appliflo.com/api/v1/documents/$DOCUMENT_ID/fields/$FIELD_ID \
  -H "Authorization: Bearer $APPLIFLO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"label":"Date of birth","semanticType":"date","help":"As shown on your passport."}'
```

**Node**

```js
const res = await fetch(`https://appliflo.com/api/v1/documents/${documentId}/fields/${fieldId}`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.APPLIFLO_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ label: "Date of birth", semanticType: "date", help: "As shown on your passport." }),
});
const { data: field } = await res.json();
```

**Python**

```python
import os, requests

headers = {"Authorization": f"Bearer {os.environ['APPLIFLO_API_KEY']}"}
field = requests.patch(
    f"https://appliflo.com/api/v1/documents/{document_id}/fields/{field_id}",
    headers=headers,
    json={"label": "Date of birth", "semanticType": "date", "help": "As shown on your passport."},
).json()["data"]
```

The reply is the corrected field. Everything is checked before anything is saved, so a refused change leaves the field as it was. Corrections also help AppliFlo read the same form better next time.

The `correct_field` MCP tool takes the same keys in its `patch` input.

## A good order of work

1. Detect, then read `flagged_count`. If it is 0, fill straight away.
2. For each flagged field, check `label_text`, `semantic_type` and `section` against the form, and correct what is wrong.
3. For a value that came back `overflowed` after a fill, check `multiline` and `comb`. If the box is bigger than AppliFlo thought, correct its `bbox` and fill again.
4. Fill by field id, as in [Upload, detect and fill](https://dev.appliflo.com/guides/upload-detect-fill#fill-by-field-id).
