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

# Field types and formats

> The contact field types, the formats that validate and normalize values, and the related-record shapes those types accept.

Field `type` and `format` decide what a contact write accepts. Read both from [`GET /api/fields`](https://developers.conveyour.com/api-reference/fields/list-fields) for the organization you are calling. The workflow around that call is [Custom contact data](https://developers.conveyour.com/guides/custom-contact-data.md).

The type list is the field registry: `int`, `bool`, `string`, `date`, `email`, `list`, `textarea`, `time`, `related_contacts`, `image`, `relation`, `user_list`, `id_number`, `related_custom_object`, and `secret`. There is no `select` type. An allowed-option list is `values` on whatever type has `values_enabled`.

## Types

The vanity word is what a type error says (`The field {label} should be of type {vanity}`). An `int` that is not numeric says `The field {label} should be a non-negative number` instead. A numeric integer, including a negative one, is accepted and stored as an integer.

| `type` | Vanity in errors | What a write accepts |
| - | - | - |
| `string` | text | A trimmed string. |
| `textarea` | textarea | A trimmed string. |
| `int` | number | Blank becomes null. Any numeric value is cast to an integer. |
| `bool` | true or false | `true`, `false`, `True`, `False`, `1`, or `0`. Blank becomes false. |
| `date` | date | Blank becomes null. Otherwise PHP `date_create` in UTC. A 10-digit string is a Unix timestamp. Stored as a date. |
| `time` | time | The same parser as `date`, using the caller's timezone. |
| `email` | email | Blank is allowed. Otherwise the value must match the email pattern. This check does not lowercase the value. The built-in `email` key is lowercased on create. |
| `list` | list | A list of strings. See [Lists](#lists). |
| `relation` | Relation | The same splitting and lowercasing rules as `list`. |
| `user_list` | User List | An array. The type check does not lowercase it. |
| `image` | Image | Empty, or a URL that already starts with the file CDN used for stored files. |
| `id_number` | ID Number | Empty, or a JSON number. A numeric string is rejected. |
| `secret` | Secret | A trimmed string. It is stored encrypted. Reads return the ciphertext. Use [Reveal a secret field](https://developers.conveyour.com/api-reference/contacts/reveal-a-secret-field.md) for plaintext. |
| `related_contacts` | Related Contacts | Contact ids. See [Related contacts](#related-contacts). |
| `related_custom_object` | Related Custom Object | Custom-object record ids. See [Related custom objects](#related-custom-objects). |

On create, a value that fails its type fails the whole request inside `failed to create contact`. On update, the first failure stops the save with HTTP `400` and `The contact can not be edited`.

When `values_enabled` is true, the value must also be one of `values`. Matching is case-sensitive. Empty string and null skip the list.

## Formats

`format` validates and normalizes. It is not a display hint. These are the formats the API publishes, and the contact types each one allows:

| `format` | Contact types |
| - | - |
| `us_bank_routing_number` | `string`, `int`, `secret` |
| `us_bank_account_number` | `string`, `secret` |
| `us_state_abbreviation` | `string` |
| `us_ssn` | `string`, `secret` |
| `us_zip_code` | `string` |
| `email` | `string` |
| `us_date_mdy` | `date`, `time` |

`us_ssn` is marked sensitive. `GET /api/helpers/formats` returns this same catalog as `data`, with message `formats`, including each format's label and description. It has no reference page of its own. Call it when you need that text.

Formatters run on **update**. Create does not run them.

For `us_date_mdy` on update, a real `MM/DD/YYYY` value (one or two digits for the month and day) is stored as `Y-m-d`. A value that is already `Y-m-d`, or a 10-digit timestamp, is left as-is. The formatter's error messages are `US date is required`, `US date must be a complete MM/DD/YYYY date`, and `US date is not a valid calendar date`.

On read, `date` values are `Y-m-d` and `time` values are ISO 8601, except `created_at`, `last_seen`, `last_reply`, and any field whose suffix is `First` or `Last`: those are Unix timestamps.

## Lists

`list` and `relation` share these write rules:

* A string is split on characters other than letters, digits, underscore, and hyphen. Each piece is trimmed and lowercased. Duplicates and empty pieces are dropped.
* `add` and `remove` get that same treatment.
* On update, a JSON array is **merged** into the current values. It does not replace the list. Send `add` and `remove` when you need to name the change.

`user_list` must already be an array. On update, its `add` and `remove` values are lowercased. The type check itself does not lowercase a flat array.

`related_contacts` supports `add` and `remove` and does not lowercase ids.

## Related contacts

Send a list of contact ids, or a single id string (it is stored as a one-element list), under the field's machine name.

Ids that are not ObjectIds are dropped with no error. On update, an id equal to the contact you are editing fails with `{label} cannot be set to the contact itself.`

The read model adds `{name}_child_cnt` on both the flat list and the bucketed get. The count is an integer, and it is `0` when the field is empty. On get, that count is on the root of `data`, next to the bucket ids.

## Related custom objects

This is `related_custom_object`, not `relation`.

**One record.** Send the record id as `{name}` or `{name}_id`. It is stored as `{name}_id`. A blank value is allowed. Any other value must be an ObjectId for a custom-object record in this organization.

**Many records.** The field's machine name is treated as `{name}_ids`. Send either a full list of ids, or an object:

```json theme={null}
{
  "sites_ids": {
    "add": ["RECORD_ID"],
    "remove": ["OTHER_RECORD_ID"]
  }
}
```

> [!NOTE]
>
> `sites` is a sample field name. Use the `name` from `GET /api/fields`, then append `_ids` when the field holds many records.

You can put at most 50 linked records on the field. Over the cap, the message is `The field {label} cannot link more than 50 records`. A value that is neither a list of ids nor `{add, remove}` fails with `The field {label} must be a list of record ids or {add, remove}`.

An id that is not a record in this organization **fails the write**. It is not dropped. The message includes `Related custom object record id is invalid`. On an `{add, remove}` object, that check runs for `add`.

Update also requires permission to custom objects, as described in [Custom contact data](https://developers.conveyour.com/guides/custom-contact-data.md#check-the-field-then-write). Create does not apply that permission check.


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