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

# Account fields

> Attach custom fields to an account, such as plan, MRR, or account owner.

Account fields are custom fields you can attach to an account. For example a plan name, MRR, account owner or any other attribute that is meaningful at the account level rather than per-customer.

<Snippet file="graphql/sdk-note.mdx" />

Working with account fields involves two layers:

1. **Account field schemas** define what fields exist (type, label, options). You create the schema once.
2. **Account field values** are the per-account values stored against a given schema.

This is the same model as thread fields: see [thread fields](https://www.plain.com/docs/graphql/threads/thread-fields.md) for the equivalent on threads.

Each operation needs its own permissions:

* `upsertAccountFieldSchema`: `tenantFieldSchema:create`, `tenantFieldSchema:update`, and `tenantFieldSchema:delete`
* `deleteAccountFieldSchema`: `tenantFieldSchema:delete`
* `upsertAccountField`: `tenantField:create`, `tenantField:update`, and `tenantFieldSchema:read`, plus `tenant:read` when you identify the account by `externalId`
* `deleteAccountField`: `tenant:edit`

## Create or update account field schemas

`upsertAccountFieldSchema` accepts an array of schemas to create or update in one call. Each schema is identified by the combination of `source` and `externalFieldId`.

Supported field types are `STRING_TYPE`, `NUMBER_TYPE`, `BOOLEAN_TYPE`, `STRING_ARRAY`, `DATETIME_TYPE`, `ENUM_TYPE`, `USER_REFERENCE_TYPE` and `ACCOUNT_REFERENCE_TYPE` (use `options` to define the allowed values).

<Snippet file="graphql/upsert-account-field-schema.mdx" />

## Delete an account field schema

Deleting a schema also removes any account field values stored against it.

<Snippet file="graphql/delete-account-field-schema.mdx" />

## Set an account field value

Once a schema exists, use `upsertAccountField` to set or update the value for a specific account. Pass exactly one of `stringValue`, `numberValue`, `booleanValue`, `arrayValue`, `dateValue`, `userReferenceValues` or `accountReferenceValues` matching the schema's `type`.

<Snippet file="graphql/upsert-account-field.mdx" />

## Delete an account field value

To clear an account's value for a specific field without removing the schema itself, call `deleteAccountField`.

<Snippet file="graphql/delete-account-field.mdx" />


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