Overview
Custom objects are new record types your app adds to a workspace — Post Card, Invoice, Subscription, anything specific to your domain. Each object declares its schema (fields, relations, default values) and a stable universal identifier that survives across syncs and deploys.src/objects/post-card.object.ts
Key points
- The
universalIdentifiermust be unique and stable across deployments. - Each field requires a
name,type,label, and its own stableuniversalIdentifier. - The
fieldsarray is required, but it can be empty — you can define objects without custom fields. openRecordInsets where records of this object open when clicked:ObjectOpenRecordIn.USER_CHOICE(the default, following each workspace member’s own preference from Settings → Experience),ObjectOpenRecordIn.SIDE_PANEL,ObjectOpenRecordIn.RECORD_PAGE, orObjectOpenRecordIn.SPLIT_VIEW. Pin it toRECORD_PAGEfor records that need a full page to be usable, the way workflows and dashboards do, or toSIDE_PANELfor records that only make sense as a quick panel, the way calendar events do.SPLIT_VIEWis meant to keep the list beside the open record; that layout is not available yet, so records pinned to it open on their full page for now.disabledObjectPermissionActionslists object permissions that cannot be granted on the object: any of'canReadObjectRecords','canCreateObjectRecords','canUpdateObjectRecords','canSoftDeleteObjectRecords'and'canDestroyObjectRecords', the same flags a role sets per object. Creating records still follows the update permission for now: disabling'canUpdateObjectRecords'also disables'canCreateObjectRecords', and disabling'canCreateObjectRecords'alone has no effect yet. Users, API keys and agents never get these actions on the object, whatever their role grants, and saving an object permission that grants one of them fails. Your app’s own logic functions keep them. For example,['canUpdateObjectRecords', 'canSoftDeleteObjectRecords', 'canDestroyObjectRecords']makes an object only your app can write, for configuration-like records that grant behavior.colorsets the accent color of the object in the UI. Omit it and Twenty picks one for the object.imageIdentifierFieldMetadataUniversalIdentifiernames the field whose value is shown as the record avatar. Omit it to let Twenty pick the default.isLabelSyncedWithName, on an object or on a field, keeps the API name in sync with the label when the label is edited in Settings. It defaults tofalse, so a renamed label leaves the name untouched.isSearchable: true, on a field, includes its values in the object’s full-text search (global search and the command menu). It requires the object itself to be searchable and a text-compatible field type. An omitted value means not searchable, except for the object’s label identifier field, which is always searchable and cannot be opted out. Each sync enforces the declared state, so a field toggled searchable from Settings reverts on your app’s next sync unless the manifest declares it.isAuditLogged: false, on a field, keeps its changes out of the record timeline. It defaults totrue, except on aPOSITIONfield, whose changes render blank in the timeline and are never logged. Set it on fields your app rewrites on a schedule, such as a last-contact timestamp or a rollup relation, so each sync does not add an activity row to every record it touches. An update whose whole diff is made of non audit logged fields produces no timeline activity at all. LikeisSearchable, each sync enforces the declared state.disabledFieldPermissionActions, on a field, lists field permissions that cannot be granted on it:'canReadFieldValue','canUpdateFieldValue'or both, the same flags a role sets per field. Users, API keys, agents and other apps never get these actions on the field, whatever their role grants, and saving a field permission that grants one of them fails. Your app’s own logic functions keep them. For example,['canUpdateFieldValue']keeps a value your app computes or syncs, such as a status or a score, read-only for everyone else. It also works on fields you add to objects you don’t own withdefineField().- A select or multi-select option can carry its own
id. When set, it must be a lowercase UUID (version 4 or later) and belong to one option only: a sync fails if two fields share an optionid. - Inline fields defined here do not need an
objectUniversalIdentifier— it’s inherited from the parent object. UsedefineField()to add fields to objects you don’t own. - You can scaffold new objects with
twenty app add object, which prompts for its names and can also create a view, a navigation menu item and a record page layout. See Scaffolding.
Base fields are added automatically. When you define a custom object,
Twenty creates standard fields like
id, name, createdAt, updatedAt,
createdBy, updatedBy, and deletedAt for you. You don’t need to declare
them in your fields array — only your custom fields. You can override a
default field by declaring one with the same name, but this is rarely a good
idea.Field types
The full set ofFieldType values, exported from twenty-sdk/define:
Composite types store multiple sub-fields (e.g.
FULL_NAME = first + last name; CURRENCY = amountMicros + currencyCode). SELECT and MULTI_SELECT require an options array as in the example above.
Select options
ForSELECT and MULTI_SELECT, provide a non-empty options array of objects. Each option has a value, label, and position. Its color is optional and defaults to gray when omitted or null. Its description is optional too: up to 255 characters, shown as a tooltip when people pick the option.
When provided, color must be one of: red, ruby, crimson, tomato, orange, amber, yellow, lime, grass, green, jade, mint, turquoise, cyan, sky, blue, iris, violet, purple, plum, pink, bronze, gold, brown, gray.
Both defineObject() and defineField() return validation errors for unsupported colors or option entries that are null, primitives, or arrays.
Workspace changes to your options
A workspace can relabel, recolor, describe, reorder and deactivate the options your app ships, and add options of its own. It cannot remove your options or change theirvalue.
These changes are kept when your app is synced again. Changing an option’s label, color, description or position in your app changes the default, not what a workspace already overrode. Options the workspace added and options it deactivated stay as they are.
When you read a field’s options from the metadata API, two properties describe that workspace state. Twenty sets them; your app does not declare them:
isActive: falsemarks an option the workspace deactivated. Records keep the value, but it is no longer offered when picking a value.applicationIdis present on an option that another application than the field’s owns, such as an option the workspace added to your field. It is read-only and ignored when you write options.
Default values
Literal string defaults must be wrapped in single quotes inside the string —defaultValue: "'Draft'", not defaultValue: "Draft". That’s why the status field above uses `'${PostCardStatus.DRAFT}'`.
Unquoted strings are reserved for computed defaults, evaluated when a record is created:
'uuid'— generates a UUID (forUUIDfields)'now'— the current timestamp (forDATE_TIMEfields)
{ source: "'MANUAL'" } on an ACTOR field) and to SELECT/MULTI_SELECT values. A literal string default left unquoted raises a warning when your app is built.
Nullability
isNullable controls whether a field accepts NULL. It defaults to true — omit it for optional fields. Set isNullable: false to make a field required at the database level.
Changes to isNullable are applied on every sync, including syncs that update an existing field — so you can flip a field’s nullability by editing the manifest and re-syncing.
Making an existing field non-nullable requires a default value. When you
change a field to
isNullable: false, you must also provide a non-null
defaultValue. The default backfills any existing NULL rows before the NOT NULL constraint is applied; without it the sync fails with Default value cannot be null for non-nullable fields. Relation fields and TS_VECTOR
fields are always nullable, so isNullable has no effect on them.Formula fields
Aformula makes a field computed: its value comes from an expression over other fields, and records cannot write it. It is a property of the field, next to universalSettings, not inside it, and it applies to TEXT, NUMBER, BOOLEAN, DATE, DATE_TIME, SELECT, RATING and CURRENCY fields.
formula.expressionreads fields of the record by name (price * quantity), composite parts with a dot (amount.amountMicros), fields of a many-to-one related record (company.name), and aggregates over a one-to-many relation (count(tasks),sum(deals.amount.amountMicros, deals.stage == 'WON')).- A
CURRENCYformula computes the amount in micros, and also needsformula.currencyCodeExpression, such as"USD"oramount.currencyCode. formula.evaluationsays when the value is computed:QUERY_TIME: on every read. It is never written, so events, webhooks and workflow triggers do not carry it, and other formulas cannot read it.WRITE_TIME: by the write of its record. The saved record, its event and its triggers carry the value at once. It reads fields of its own record and otherWRITE_TIMEformulas: no relation, noSTOREDformula.STORED: in the background, a moment after a write of the record or of a related record it reads. A formula with an aggregate must beSTORED(otherwise it fails withAGGREGATE_IN_LIVE_FORMULA); a many-to-one lookup can also beQUERY_TIME.WRITE_TIMEandSTOREDare written to the column: they readnullon existing records until their backfill reaches them, and cannot readnoworupdatedAt. A formula that others read cannot be switched toQUERY_TIME, and one thatWRITE_TIMEformulas read must stayWRITE_TIME.- Left out, the formula is
QUERY_TIMEon every sync, so a formula with an aggregate must sayevaluation: 'STORED'.
- A formula field cannot be unique, searchable or the object’s label identifier.
Formula fields are behind the
IS_FORMULA_FIELD_ENABLED feature flag. Syncing
a formula to a workspace without the flag fails with Formula fields are not enabled for this workspace.What’s next
- Connect this object to others — see Relations for the bidirectional relation pattern.
- Add fields to objects from other apps — see Extending Objects for
defineField(). - Display this object in the UI — see Navigation Menu Items to add a sidebar entry; see Views to add custom list configurations.