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

# Field types

> How to write and read a value of each field type

Every field in [`GET /schema`](https://docs.vectorshift.ai/ontology/schema/get) has a `storage`, which decides how its value is written and read. Record values are plain JSON under `values`, keyed by field id, on [create](https://docs.vectorshift.ai/ontology/records/create.md) and [update](https://docs.vectorshift.ai/ontology/records/update.md), and records come back the same way.

```json theme={"languages":{}}
{
  "values": {
    "name": "Elm Court",
    "status": "under_contract",
    "amenities": ["pool", "gym"],
    "units": 24,
    "purchase_price": 3200000,
    "cap_rate": 0.0625,
    "acquired_on": "2024-03-01",
    "address": {"street_address": "12 Elm St", "city": "Austin", "state": "TX", "postal_code": "78701"},
    "owner_entity": "6650a1f4c2e9b81d3f0e7a12"
  }
}
```

## Types

| `storage` | Write | Reads back as | Filters as |
| - | - | - | - |
| `string`, `text` | A string. | A string. | text |
| `url` | An absolute `http` or `https` URL. | A string. | text |
| `phone` | A phone number, as a string. | A string. | text |
| `int` | A whole number. | A number. | number |
| `decimal`, `number` | A number. | A number. | number |
| A unit, such as `USD`, `EUR` or `1/year` | A number in that unit. See [Amounts and percents](#amounts-and-percents). | A number. | number |
| `bool` | `true` or `false`. | A boolean. | boolean |
| `timestamp` | An RFC 3339 time (`"2024-03-01T00:00:00Z"`), a date (`"2024-03-01"`, read as midnight UTC) or epoch seconds. | An RFC 3339 string. | date |
| `single_select` | One option value. See [Options](#options). | A string. | text |
| `multi_select` | An array of option values, each at most once. | An array. | list |
| `string_list` | An array of strings. When the field lists `allowed_values`, each must be one of them. | An array. | list |
| `personal_name` | An object with `first_name` and `last_name`. A middle name or initial goes in `first_name`. | An object with `first_name`, `last_name` and `full_name`. | text, compared by `full_name` |
| `location` | An object with any of `street_address`, `city`, `state`, `postal_code` and `country`. | The same object, plus `display`: the parts joined in one line. | text, compared by `display` |
| `ref(<type_id>)` | A record id of that type. | The record id. | text, compared by id |
| `ref_list(<type_id>)` | An array of record ids, at most 500, each at most once. | An array of record ids. | list |
| `ref(user)`, `ref_list(user)` | A person's user id, or an array of them. See [People](#people). | The user id, or ids. | text, or list |
| `image` | `{"id": "<file id>"}`, naming a file already in your organization. This API does not upload files. | An object describing the file. | cannot be filtered |

A field that names more than one type, such as `ref(company,person)`, takes a record id of any of them.

A name's `full_name` is always `first_name` and `last_name` joined by a space. You can leave it out; if you send it, it must match, or the value is refused. Write "Jane Q. Doe" as `{"first_name": "Jane Q.", "last_name": "Doe"}`.

Every value is checked against its field before anything is written. A value of the wrong shape is refused with `422` and the code `wrong_shape`, and `path` points at it, such as `/values/units`.

## Clearing a field

Send `null` in `values`, or name the field in `unset`. Both clear it:

```json theme={"languages":{}}
{"values": {"end_date": null}}
```

```json theme={"languages":{}}
{"unset": ["end_date"]}
```

A field that is `required` cannot be cleared. Clearing it is refused with `422 required`.

## Options

A `single_select`, a `multi_select`, and a `string_list` that lists `allowed_values` take only those values. Write and filter by the **value**, never by its label. `option_labels` maps each value to the label people see in the app:

```json theme={"languages":{}}
{
  "name": "status",
  "storage": "single_select",
  "allowed_values": ["active", "under_contract", "sold"],
  "option_labels": {"active": "Active", "under_contract": "Under contract", "sold": "Sold"}
}
```

Write `"under_contract"`, not `"Under contract"`. Any other value is refused with `422 not_an_option`, and the error lists every value with its label.

Some fields offer different options depending on a parent record. A field with `choice_overrides` takes the override's `allowed_values` on records whose `scope_attribute` holds the override's `scope_record_id`.

## Amounts and percents

A field's `unit` and `format` never change how a value is written. The value is always a plain number:

* **Amounts are in the field's unit.** A `USD` field holding \$3.2M takes `3200000`. Send dollars, not cents.
* **A percent is a fraction.** A field whose `format` is `percent` holds 6.25% as `0.0625`. Sending `6.25` stores 625%.
* **A multiple is the number itself.** A field whose `format` is `multiple` holds 2.5x as `2.5`.
* `decimals` and `separator` only change how the app shows a number.

The API cannot tell `0.0625` from `6.25`, or cents from dollars, so these mistakes are stored without a refusal. Check `unit` and `format` before writing a number.

## Lists

A list field (`multi_select`, `string_list`, `ref_list(...)`) written under `values` is replaced whole. To add or remove items without replacing the rest, use `list_add` and `list_remove` on an [update](https://docs.vectorshift.ai/ontology/records/update.md):

```json theme={"languages":{}}
{
  "list_add": {"flags": {"items": ["late_payer"]}},
  "list_remove": {"flags": {"items": ["pet"]}}
}
```

These apply to the list as it is when the update lands, not to a copy you read earlier. An item someone else added in the meantime stays, and an item already on the list is not added twice. An edit that changes nothing, such as removing an item the list doesn't hold, leaves the list as it was. One update can change a field through `values`, through `unset`, or through `list_add` and `list_remove`, but not through two of these.

## References and links

A `ref(...)` field holds a record id as its value. A [relation](https://docs.vectorshift.ai/ontology/working-with-your-schema.md#reference-fields-and-relations) is a link between records, written under `links` rather than `values`. They are separate: setting a reference field adds no link, and adding a link sets no field. See [Working with your schema](https://docs.vectorshift.ai/ontology/working-with-your-schema.md#reference-fields-and-relations).

## People

A `ref(user)` field holds a person's VectorShift user id, not an email or a name. People belong to the VectorShift platform, not to the ontology, so you look them up outside this API, with [`GET /v1/users`](https://docs.vectorshift.ai/api-reference/users/lookup):

```bash theme={"languages":{}}
curl "https://api.vectorshift.ai/v1/users?email=jane@example.com" \
  -H "Authorization: Bearer $VECTORSHIFT_API_KEY"
```

```json theme={"languages":{}}
{"users": [{"id": "6650e7a2c4b1f93d2a8e5c10", "email": "jane@example.com", "name": "Jane Doe", "invited": false}]}
```

Write the `id`. The lookup finds the organization's members and the people invited to it; anyone else is not found. A key with scopes needs `users:read` (**Look up people**) for it. A record's `created_by` and `updated_by` are user ids too.

## Refusals

A refused value comes back as `422`, with `path` pointing at the field:

| Code | Meaning |
| - | - |
| `unknown_field` | The type has no such field, or it is archived. |
| `not_an_option` | The value is not one of the field's options. |
| `wrong_shape` | The field cannot hold the value: text for a number, one value where a list belongs, a malformed date, URL, phone number or record id. |
| `required` | A required field is missing, empty or cleared. |
| `not_unique` | Another record of the type already holds the value in a `unique` field. |
| `fixed_after_create` | An update changes a field that is set only when a record is created. |
| `conflicting_changes` | One update both sets or clears a field and adds or removes its items. |

Fix the value and send the request again under a **new** `Idempotency-Key`. The old key keeps answering with the refusal. See [Idempotency](https://docs.vectorshift.ai/ontology/idempotency.md).


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