# Places and fields

A **place** is a spot on a document where something is drawn: a signature, a value a recipient
types or picks, a date, or fixed text. You define places in each document's `places` array and
then position them, either with placeholders written in the document or with fixed coordinates.

Markdown and HTML documents can also declare fields inline; see [Extensions](https://docs.signapi.dev/extensions).

## Define a place

Every place has a `key` (`^[a-z][a-z0-9_]*$`, up to 32 characters, unique in the document) and a
`type`. Most also name the `recipient_key` of the recipient who fills them in.

```json
{
  "key": "agreement",
  "url": "https://api.signapi.lumin.example/v1/v1/uploads/upl_…",
  "places": [
    { "key": "client_sig", "type": "signature", "recipient_key": "client" },
    { "key": "client_phone", "type": "text_input", "recipient_key": "client",
      "prompt": "Phone number", "requirement": "optional", "capture_as": "phone" },
    { "key": "signed_on", "type": "recipient_completed_date", "recipient_key": "client" }
  ]
}
```

## Place types

| Group | `type` | Notes |
|---|---|---|
| Signing | `signature` | `height` 20 to 60 points (default 60). |
| | `initials` | Same sizing as `signature`. |
| Input | `text_input` | One line. `width` 30 to 540 points, `font_size` 6 to 12. `format` checks the value: `email`, `zipcode-us`, or a `/regular expression/` with a `format_message` to show when it doesn't match. |
| | `boxed_text_input` | One character per box: `box_count` boxes across `width`. Characters past the last box are dropped; with `box_count: null` the text runs on. |
| | `multiline_text_input` | `line_count` lines across `width`. |
| | `dropdown` | `options` is a list of `{label, value}` or a predefined set (below). `behavior: auto` shows a searchable box when there are more than 10 options. |
| | `checkbox` | `symbol` is `check` (default) or `xmark`. Optional by default. |
| | `radio_group` | `options` lists `{value}` members. `symbol` `fill`, `check` or `xmark`; `shape` `circle` or `square`. |
| Informational | `text` | Fixed `value` (up to 1000 characters) in your `font_size` and `font_color`. No recipient. |
| | `recipient_name`, `recipient_email` | Filled from the recipient. |
| | `recipient_completed_date` | When that recipient finished, in `date_format` (default `D MMM YYYY`). |
| | `envelope_completed_date` | When the envelope completed. No recipient. |

Input places take `requirement` (`required` or `optional`; inputs default to required, checkboxes
to optional), a `prompt` shown as the field's label, and a `hint` shown inside an empty field.

Predefined dropdown sets: `world_countries_names`, `world_countries_2_letter_codes`,
`world_countries_3_letter_codes`, `world_countries_numeric_codes`, `us_states_names` and
`us_states_2_letter_codes`. Name sets store the name; code sets store the code and show
"Name (code)" to the signer.

### Who can own what

- Every `signer` needs at least one `signature` or `initials` place
  ([`signing_place_missing`](https://docs.signapi.dev/errors/signing_place_missing)).
- Approvers and preparers cannot own signing places
  ([`places_incompatible`](https://docs.signapi.dev/errors/places_incompatible)).
- A `recipient_key` that names no recipient, or one that can't use the place, is
  [`place_recipient_invalid`](https://docs.signapi.dev/errors/place_recipient_invalid).
- A document may define up to 100 places.

## Position with placeholders

Write `[[place_key]]` in the document where the place should go, for example in white text in a
Word template. Sign API finds each placeholder's text and puts the place's bottom-left corner at
the placeholder's bottom-left corner. A placeholder is found even when the PDF splits it across
fonts or text runs.

For a radio group, position each member separately with `[[group_key:value]]`.

Each placeholder may appear once ([`placeholder_duplicate`](https://docs.signapi.dev/errors/placeholder_duplicate)), and
every placeholder must name a place defined in `places`
([`placeholder_invalid`](https://docs.signapi.dev/errors/placeholder_invalid)). To
check a file before you send it, upload it and call
[Get upload structure](https://docs.signapi.dev/api/GetUploadStructure): it lists every placeholder with its page and
position, and any problem with it.

### Legacy signature placeholders

`[[recipient_key.signature]]` creates a 60-point `signature` place for that recipient without a
`places` entry. It is kept for older integrations: it can't be combined with `places`
([`placeholders_mixed`](https://docs.signapi.dev/errors/placeholders_mixed)) and only works when every recipient is a
signer.

## Position with coordinates

When you can't edit the document, list `fixed_positions` instead:

```json
"fixed_positions": [
  { "place_key": "client_sig", "page": 2, "top": 640, "left": 72 }
]
```

Positions are in points (1/72 inch). `left` is the distance from the page's left edge, and `top`
the distance from the page's top edge **to the place's bottom edge**, so together they name the
place's bottom-left corner, the same point a placeholder uses. A place must fit on its page
([`place_out_of_bounds`](https://docs.signapi.dev/errors/place_out_of_bounds)), and a place can't have both a placeholder
and a fixed position ([`placeholder_position_conflict`](https://docs.signapi.dev/errors/placeholder_position_conflict)).

## Read values back

When a place sets `capture_as`, its value appears in the envelope's `captures` under that name:
text as a string, a checkbox as `true` or `false`, and `null` while it is empty. Read
them with [Get an envelope](https://docs.signapi.dev/api/GetEnvelope) once you receive `envelope.completed`.

```json
"captures": { "phone": "+1 555 0100", "accepts_terms": true }
```

All places are checked while the envelope is created, so a problem comes back as an error on
[Create an envelope](https://docs.signapi.dev/api/CreateEnvelope) and nothing is stored.
