# Fill a document's fields with values

> POST /api/v1/documents/{id}/fill: Fill a document's fields with values.

`POST https://appliflo.com/api/v1/documents/{id}/fill`

Send your API key in the `Authorization: Bearer` header. Every response is JSON: `{ success, data, error }`.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `id` | path | yes | Document id |
| `Idempotency-Key` | header | no | A client-generated key scoping this request as a retry of a prior identical request. A replay within 24h returns the first response instead of repeating the side effect (e.g. a second send). The key is bound to the request it was first used with: the same key with a different body or target is refused (422, code idempotency_key_reused) |

## Request body (application/json)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `values` | map of string \| number \| boolean \| string[] | yes | Keyed by field id (the field's value) or by choice-group id (groups[].id: one option for a single question, a list for multi, each named by the option's value or label) |
| `deterministic` | boolean | no |  |

## Responses

| Status | Description |
| --- | --- |
| 200 | Per-field fill results, and one result per choice group. An answer a group refuses is a 422 and nothing is stamped. |
| 401 | Missing or invalid API key, or `api_key_expired` for a key past its expiry. |
| 403 | The API key's workspace does not have access to this resource, or `insufficient_scope` (with `required_scope`) for a key without the scope this route needs. |
| 404 | Resource not found in this workspace. |
| 422 | Request failed validation. |
| 500 | Internal error. |

## 200 response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `success` | true | yes |  |
| `data` | object | yes |  |
| `data.results` | object[] | yes |  |
| `data.results[].field_id` | string | yes |  |
| `data.results[].status` | string | yes | One of: filled, formatted, overflowed, skipped |
| `data.results[].rendered_text` | string | no |  |
| `data.results[].font_size` | number | no |  |
| `data.results[].lines` | integer | no |  |
| `data.results[].reason` | string | no |  |
| `data.groups` | object[] | yes |  |
| `data.groups[].group_id` | string | yes |  |
| `data.groups[].status` | string | yes | One of: filled, skipped |
| `data.groups[].chosen` | string[] | yes | The chosen options' values |
| `data.groups[].field_ids` | string[] | yes | The option boxes that were stamped |
| `data.download` | object | no |  |
| `data.download.artifact` | string | no | One of: filled |

See also: [Errors](https://dev.appliflo.com/guides/errors), [Rate limits](https://dev.appliflo.com/guides/rate-limits), [Idempotency](https://dev.appliflo.com/guides/idempotency).
