> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nohead.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Fields

> Manage a collection's fields.

Every command also takes the [global options](https://docs.nohead.io/cli/commands/global-options.md), such as `--json`.

## `nohead fields list`

List fields.

```bash theme={null}
nohead fields list [options] <collection>
```

| Argument | |
| - | - |
| `<collection>` | Collection slug or ID. |

| Option | |
| - | - |
| `--deleted` | List deleted fields instead. |
| `--limit <n>` | Page size (1-100, default 100) |
| `--cursor <cursor>` | Continue from a previous page's next\_cursor. |
| `--all` | Follow cursors and return every field. |

## `nohead fields add`

Add a field, e.g. nohead fields add posts title --type text --required.

```bash theme={null}
nohead fields add [options] <collection> <name>
```

| Argument | |
| - | - |
| `<collection>` | Collection slug or ID. |
| `<name>` | Field name; the key is derived from it unless --key is given. |

| Option | |
| - | - |
| `--type <type>` | One of: text, long\_text, rich\_text, integer, decimal, date, boolean, enum, asset, relation, json. |
| `--key <key>` | Field key (default: snake\_case of the name) |
| `--required` | Every record must have a value. |
| `--multiple` | Store a list of values. |
| `--options <list>` | Enum options, comma-separated. |
| `--target <collection>` | Relation target collection (slug or ID) |
| `--max-length <n>` | Maximum length for plain text fields. |
| `--min <n>` | Minimum for number fields. |
| `--max <n>` | Maximum for number fields. |
| `--description <text>` | Help text shown to editors. |
| `--include-time` | Date fields: a date and a time, not a day. |
| `--no-include-time` | Date fields: a day, with no time. |
| `--time-zone <zone>` | Date fields with a time: the IANA zone values are written in. |
| `--format <format>` | Text fields: slug, url or email. |
| `--no-format` | Text fields: plain text. |
| `--unique` | No two records share a value (text, integer) |
| `--no-unique` | Let records share a value. |
| `--searchable` | Match search words in this field. |
| `--no-searchable` | Leave this field out of search matching. |
| `--filterable` | Allow filter\[\<field>] in search. |
| `--no-filterable` | Disallow filtering in search. |
| `--sortable` | Allow sorting search results by this field. |
| `--no-sortable` | Disallow sorting search results. |

## `nohead fields update`

Update a field's settings (type, multiple and a date's time: nohead fields migrate)

```bash theme={null}
nohead fields update [options] <collection> <field>
```

| Argument | |
| - | - |
| `<collection>` | Collection slug or ID. |
| `<field>` | Field key or ID. |

| Option | |
| - | - |
| `--name <name>` | New display name. |
| `--key <key>` | New key (the old one keeps working as an alias for 6 months) |
| `--required` | Make the field required. |
| `--optional` | Make the field optional. |
| `--options <list>` | Enum options, comma-separated. |
| `--target <collection>` | Relation target collection (slug or ID) |
| `--max-length <n>` | Maximum length for plain text fields. |
| `--min <n>` | Minimum for number fields. |
| `--max <n>` | Maximum for number fields. |
| `--description <text>` | Help text shown to editors. |
| `--include-time` | Date fields: a date and a time, not a day. |
| `--no-include-time` | Date fields: a day, with no time. |
| `--time-zone <zone>` | Date fields with a time: the IANA zone values are written in. |
| `--format <format>` | Text fields: slug, url or email. |
| `--no-format` | Text fields: plain text. |
| `--unique` | No two records share a value (text, integer) |
| `--no-unique` | Let records share a value. |
| `--searchable` | Match search words in this field. |
| `--no-searchable` | Leave this field out of search matching. |
| `--filterable` | Allow filter\[\<field>] in search. |
| `--no-filterable` | Disallow filtering in search. |
| `--sortable` | Allow sorting search results by this field. |
| `--no-sortable` | Disallow sorting search results. |

## `nohead fields delete`

Delete a field (values are kept and come back on restore)

```bash theme={null}
nohead fields delete [options] <collection> <field>
```

| Argument | |
| - | - |
| `<collection>` | Collection slug or ID. |
| `<field>` | Field key or ID. |

## `nohead fields restore`

Restore a deleted field.

```bash theme={null}
nohead fields restore [options] <collection> <field>
```

| Argument | |
| - | - |
| `<collection>` | Collection slug or ID. |
| `<field>` | Deleted field key or ID. |

## `nohead fields migrate`

Change a field in a way that rewrites record values, e.g. nohead fields migrate products price --type decimal --dry-run.

```bash theme={null}
nohead fields migrate [options] <collection> <field>
```

| Argument | |
| - | - |
| `<collection>` | Collection slug or ID. |
| `<field>` | Field key or ID. |

| Option | |
| - | - |
| `--type <type>` | New field type. |
| `--multiple` | Store a list of values. |
| `--single` | Store a single value. |
| `--required` | Make the field required (see --backfill) |
| `--optional` | Make the field optional. |
| `--backfill <text>` | Value for records that have none. |
| `--backfill-json <json>` | Value for records that have none, as JSON. |
| `--clear-invalid` | Clear values that cannot be converted instead of refusing. |
| `--days-in <zone>` | Removing a date's time: the IANA zone whose day each moment falls on (default: the field's, else UTC) |
| `--dry-run` | Preview the outcome for every record. |
| `--no-wait` | Return once the migration is accepted. |
| `--options <list>` | Enum options, comma-separated. |
| `--target <collection>` | Relation target collection (slug or ID) |
| `--max-length <n>` | Maximum length for plain text fields. |
| `--min <n>` | Minimum for number fields. |
| `--max <n>` | Maximum for number fields. |
| `--description <text>` | Help text shown to editors. |
| `--include-time` | Date fields: a date and a time, not a day. |
| `--no-include-time` | Date fields: a day, with no time. |
| `--time-zone <zone>` | Date fields with a time: the IANA zone values are written in. |
| `--format <format>` | Text fields: slug, url or email. |
| `--no-format` | Text fields: plain text. |
| `--unique` | No two records share a value (text, integer) |
| `--no-unique` | Let records share a value. |
| `--searchable` | Match search words in this field. |
| `--no-searchable` | Leave this field out of search matching. |
| `--filterable` | Allow filter\[\<field>] in search. |
| `--no-filterable` | Disallow filtering in search. |
| `--sortable` | Allow sorting search results by this field. |
| `--no-sortable` | Disallow sorting search results. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.