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

# Custom fields

> Store your own details on people and on your organization, and choose which of them reach sign-in tokens.

Custom fields let you keep your own details next to a person or your organization, such as a customer plan, an employee number or a region. Your apps can read them, and public fields can be added to sign-in tokens.

> [!NOTE]
>
> Custom fields, the token template and the sign-in check are available on the Pro plan and above.

## Three kinds of field

| Kind | Who can read it | Who can change it | In tokens |
| - | - | - | - |
| **public** | Your apps, admins, your server | Admins with **Manage sign-in security**, and your server | Yes, through the token template |
| **private** | Admins and your server only. Never the person. | Admins and your server | Never. Stored encrypted. |
| **person** | The person, admins, your server | The person themselves, admins, your server | Never |

> [!WARNING]
>
> The person can change their own **person** fields to anything. Never use them to decide access.

Organizations have **public** and **private** fields. People have all three kinds.

## Limits

* Each kind is a JSON object, like `{"plan": "gold"}`.
* Each kind holds at most 8 KB.
* A top-level name starts with a letter and has only letters, digits and `_`, up to 64 characters.
* Values nest at most 5 levels deep.
* A write replaces each kind it names. Send an empty object to clear one. Kinds you leave out stay as they are.

## In the console

* **A person's fields**: go to **People**, open the person, and find **Custom fields**. This needs **Manage people**, and you only see people whose role is within your own access. Changing **public** fields also needs **Manage sign-in security**, because they can reach tokens.
* **Your organization's fields**: go to **Developers** and find **Organization's custom fields**. This needs **Manage sign-in security**.

People change their own **person** fields from their own account.

## Through the admin API

Your server reads and writes fields with an [API key](https://docs.aiveth.com/account/api-keys.md).

| Method and path | Key power |
| - | - |
| `GET /v1/admin/people/{id}/fields` | `people:manage` |
| `PUT /v1/admin/people/{id}/fields` | `people:manage`. Changing `public` also needs `organization:fields`. |
| `GET /v1/admin/organization/fields` | `organization:fields` |
| `PUT /v1/admin/organization/fields` | `organization:fields` |

```bash cURL theme={null}
curl -X PUT https://accounts.aiveth.com/v1/admin/people/PERSON_ID/fields \
  -H "Authorization: Bearer aiveth_sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"public": {"plan": "gold"}, "private": {"crm_id": "C-1042"}}'
```

```ts Node theme={null}
await aiveth.people.setFields(personId, { public: { plan: 'gold' } });
const fields = await aiveth.people.fields(personId); // { public, private, person }

await aiveth.organization.setFields({ public: { tier: 'enterprise' } });
```

## Put fields in sign-in tokens

Under **Developers** → **What sign-in tokens include**, you can write one JSON template for your organization. It adds claims to the ID token and to `/oauth/userinfo` for every app, whatever scope the app asked for.

```json theme={null}
{
  "plan": "{{user.public.plan}}",
  "tier": "{{org.public.tier}}",
  "who": "{{user.email}}"
}
```

The placeholders you can use are:

* `user.id`, `user.email`, `user.first_name`, `user.last_name`, `user.public.*`
* `org.id`, `org.slug`, `org.name`, `org.public.*`

How values are filled in:

* A value that is a single placeholder keeps its type. A number stays a number.
* A placeholder inside other text becomes text.
* A placeholder that finds nothing drops its key.
* Private fields and person fields can never be used.
* Claims Aiveth sets itself, such as `sub`, `iss`, `aud`, `exp` and the role claims, can't be changed.
* The template, and what it renders to, is at most 3 KB. A result over that adds nothing.

Every change to the template emails your Owners. See [Tokens and claims](https://docs.aiveth.com/apps/tokens-and-claims.md) for the claims Aiveth sets.


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