---
title: "Create Entity Type Field"
method: POST
path: "/v2/entity-type-fields"
tags: ["Entity Type API"]
---

# Create Entity Type Field

`POST /v2/entity-type-fields`

Create a field on an entity type. Returns the schema_migration_id of the (already-completed) create migration; fetch it via Get Schema Migration to read the new field id from details.create_field.field_id.

## Request body

- SvstorePublicapiCreateEntityTypeFieldRequest
  - `entityTypeId` string — The entity type to create the field on (required).
  - `key` string, nullable — The unique key for the field. If omitted, derived from the name.
  - `name` string — The display name of the field (required).
  - `dataType` 'DATA_TYPE_UNSPECIFIED' | 'TEXT' | 'NUMBER' | 'BOOL' | 'TIMESTAMP' | 'ENUM' | 'ENTITY_REF' | 'USER_REF' | 'UNIQUE' | 'MULTI_SELECT' | 'FILE'
  - `enumOptions` SvstoreEnumOptionInput[] — Options for ENUM / MULTI_SELECT fields (required for those data types).
    - `value` string
    - `displayName` string
    - `displayOrder` integer
  - `isKeyField` boolean — Whether this field is the entity type's key (dedup identity) field.
  - `isNameField` boolean — Whether this field is the entity type's display-name field.
  - `refEntityTypeId` string, nullable — For ENTITY_REF fields: the entity type this field references.

## Response `200`

Success

- SvstorePublicapiCreateEntityTypeFieldResponse
  - `data` SvstorePublicapiSchemaMigrationRef — SchemaMigrationRef references the migration produced by a field mutation. Poll its state via GetSchemaMigration.
    - `schemaMigrationId` string — The ID of the schema migration. Empty when the request was a no-op (e.g. an Update that changed nothing).

## Other responses

- `default` — Error

---

[API](https://skmtc.net/serval/apis/serval-public-api.md) · [All operations](https://skmtc.net/serval/apis/serval-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/serval/serval-public-api/versions/0549515e9384/schema)
