> For the complete documentation index, see [llms.txt](https://developers.docstudio.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.docstudio.com/api-documentation/template-api/template-dynamic-fields-api/autonumber-field-api.md).

# Autonumber Field API

Use this page to add an autonumber field to template XML. An autonumber field is read-only and generates an incremental value for each new envelope draft created from the current template version.

### Autonumber field example

```xml
<field
    type="autonumber"
    name="invoice_number"
    roleId="fd8cb669-db1d-41e1-8f6c-2ad3f8fa981a"
    prefix="INV-"
    search="true"
/>
```

### Required attributes

* `type` — field type. Use `autonumber`.
* `name` — field name. Use 1 to 128 characters. Do not use `&`, `"`, `<`, or `>`. Keep the value unique within one document.
* `roleId` — role identifier for the field context.

### Optional attributes

* `prefix` — static prefix added before the generated number. Use 0 to 15 characters.
* `search` — set to `true` if the field value should be available in envelope search. If you omit it, the default value is `false`.

### Related topics

* [Template Dynamic Fields API](/api-documentation/template-api/template-dynamic-fields-api.md)
* [Template Structure API](/api-documentation/template-api/template-structure-api.md)
* [Send Envelope](/api-documentation/envelope/send-envelope.md)
* [Fill Envelope](/api-documentation/envelope/fill-envelope.md)
