younifyd
Menu

Create Field

Create Field in Collection

POST/fields/{collection}

Use it in a workflow

  1. Add a step and choose the Directus connector.
  2. Pick the Create Field action (under Fields).
  3. Fill in the fields below, then reference the result from later steps as {{createField.response.data}}.

Request

Path parameters

collectionstringrequired

Unique identifier of the collection the item resides in.

Query parameters

concurrentIndexCreationboolean

Attempts to concurrently create a field index if supported

Default false

Request body

Enter the body as JSON in the step's Body field.

typestringrequired

Directus specific data type. Used to cast values in the API.

fieldstringrequired

Unique name of the field. Field name is unique within the collection.

schemaobject

The schema info.

typestring

The type of the field.

namestring

The name of the field.

tablestring

The collection of the field.

default_valuestring

The default value of the field.

max_lengthinteger

The max length of the field.

is_nullableboolean

If the field is nullable.

is_primary_keyboolean

If the field is primary key.

has_auto_incrementboolean

If the field has auto increment.

foreign_key_columnstring

Related column from the foreign key constraint.

foreign_key_tablestring

Related table from the foreign key constraint.

commentstring

Comment as saved in the database.

schemastring

Database schema (pg only).

foreign_key_schemastring

Related schema from the foreign key constraint (pg only).

metaobject

The meta info.

idinteger

Unique identifier for the field in the `directus_fields` collection.

collectionstring

Unique name of the collection this field is in.

fieldstring

Unique name of the field. Field name is unique within the collection.

specialarray<string>

Transformation flag for field

system-interfacestring

What interface is used in the admin app to edit the value for this field.

optionsobject

Options for the interface that's used. This format is based on the individual interface.

displaystring

What display is used in the admin app to display the value for this field.

display_optionsobject

Options for the display that's used. This format is based on the individual display.

lockedboolean

If the field can be altered by the end user. Directus system fields have this value set to `true`.

readonlyboolean

Prevents the user from editing the value in the field.

requiredboolean

If this field should be required.

hiddenboolean

If this field should be hidden.

sortinteger

Sort order of this field on the edit page of the admin app.

widthstring

Width of the field on the edit form.

One ofhalfhalf-lefthalf-rightfullfillnull

groupinteger

What field group this field is part of.

translationobject

Key value pair of `<language>: <translation>` that allows the user to change the displayed name of the field in the admin app.

notestring

A user provided note for the field. Will be rendered alongside the interface on the edit page.

json
{
  "type": "integer",
  "field": "id",
  "schema": {
    "type": "string",
    "name": "title",
    "table": "posts",
    "default_value": null,
    "max_length": null,
    "is_nullable": false,
    "is_primary_key": false,
    "has_auto_increment": false,
    "foreign_key_column": null,
    "foreign_key_table": null,
    "comment": null,
    "schema": "public"
  },
  "meta": {
    "id": 3,
    "collection": "posts",
    "field": "title",
    "special": null,
    "system-interface": "primary-key",
    "options": null,
    "display": null,
    "display_options": null,
    "locked": true,
    "readonly": false,
    "required": false,
    "hidden": true
  }
}

Response

Returns 200 with an object. Read it in later steps with {{createField.response.data.<field>}}.

dataobject
idinteger
collectionstring

Unique name of the collection this field is in.

fieldstring

Unique name of the field. Field name is unique within the collection.

specialarray<string>

Any special transform flags that apply to this field.

interfacestring

The interface used for this field.

optionsobject

The interface options configured for this field. The structure is based on the interface used.

displaystring

The display used for this field.

display_optionsstring

The configured options for the used display.

readonlyboolean

If the field is considered readonly in the Data Studio.

hiddenboolean

If the field is hidden from the edit page in the Data Studio.

sortinteger

Where this field is shown on the edit page in the Data Studio.

widthstring

How wide the interface is rendered on the edit page in the Data Studio. One of `half`, `half-left`, `half-right`, `half-space`, `full`, `fill`.

translationsarray<any>

How this field's name is displayed in the different languages in the Data Studio.

notestring

Short description displayed in the Data Studio.

requiredboolean
groupinteger
validation_messagestring
json
{
  "data": {
    "id": 0,
    "collection": "about_us",
    "field": "id",
    "special": [
      "string"
    ],
    "interface": "string",
    "options": {},
    "display": "string",
    "display_options": "string",
    "readonly": false,
    "hidden": false,
    "sort": 0,
    "width": "string"
  }
}

Need more? See the Directus guide for connection setup and behaviour shared by every action.

Was this page helpful?