Fields
List All Fields
Returns a list of the fields available in the project.
Query Parameters
A limit on the number of objects that are returned.
How to sort the returned items. sort
is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-
) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ?
to sort randomly.
Responses
Unique name of the collection this field is in.
Unique name of the field. Field name is unique within the collection.
Any special transform flags that apply to this field.
The interface used for this field.
The interface options configured for this field. The structure is based on the interface used.
The display used for this field.
The configured options for the used display.
If the field is considered readonly in the Data Studio.
If the field is hidden from the edit page in the Data Studio.
Where this field is shown on the edit page in the Data Studio.
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
.
How this field's name is displayed in the different languages in the Data Studio.
Short description displayed in the Data Studio.
GET /fields
import { createDirectus, rest, readFields } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readFields());
POST /graphql/system
type Query {
fields: [directus_fields]
}
{
"data": [
{
"collection": "about_us",
"field": "id",
"special": [],
"options": {},
"translations": []
}
]
}
List Fields in Collection
Returns a list of the fields available in the given collection.
Query Parameters
Unique identifier of the collection the item resides in.
How to sort the returned items. sort
is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-
) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ?
to sort randomly.
Responses
Unique name of the collection this field is in.
Unique name of the field. Field name is unique within the collection.
Any special transform flags that apply to this field.
The interface used for this field.
The interface options configured for this field. The structure is based on the interface used.
The display used for this field.
The configured options for the used display.
If the field is considered readonly in the Data Studio.
If the field is hidden from the edit page in the Data Studio.
Where this field is shown on the edit page in the Data Studio.
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
.
How this field's name is displayed in the different languages in the Data Studio.
Short description displayed in the Data Studio.
GET /fields/{collection}
import { createDirectus, rest, readFieldsByCollection } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readFieldsByCollection(collection_name));
POST /graphql/system
type Query {
fields_in_collection(collection: String!): directus_fields
}
{
"data": [
{
"collection": "about_us",
"field": "id",
"special": [],
"options": {},
"translations": []
}
]
}
Create Field in Collection
Create a new field in a given collection.
Query Parameters
Unique identifier of the collection the item resides in.
Request Body
Directus specific data type. Used to cast values in the API.
Unique name of the field. Field name is unique within the collection.
The schema info.
The type of the field.
The name of the field.
The collection of the field.
The default value of the field.
The max length of the field.
If the field is nullable.
If the field is primary key.
If the field has auto increment.
Related column from the foreign key constraint.
Related table from the foreign key constraint.
Comment as saved in the database.
Database schema (pg only).
Related schema from the foreign key constraint (pg only).
The meta info.
Unique identifier for the field in the directus_fields
collection.
Unique name of the collection this field is in.
Unique name of the field. Field name is unique within the collection.
Transformation flag for field
What interface is used in the admin app to edit the value for this field.
What display is used in the admin app to display the value for this field.
If the field can be altered by the end user. Directus system fields have this value set to true
.
Prevents the user from editing the value in the field.
If this field should be required.
If this field should be hidden.
Sort order of this field on the edit page of the admin app.
Width of the field on the edit form.
What field group this field is part of.
A user provided note for the field. Will be rendered alongside the interface on the edit page.
Responses
Unique name of the collection this field is in.
Unique name of the field. Field name is unique within the collection.
Any special transform flags that apply to this field.
The interface used for this field.
The display used for this field.
The configured options for the used display.
If the field is considered readonly in the Data Studio.
If the field is hidden from the edit page in the Data Studio.
Where this field is shown on the edit page in the Data Studio.
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
.
How this field's name is displayed in the different languages in the Data Studio.
Short description displayed in the Data Studio.
POST /fields/{collection}
import { createDirectus, rest, createField } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(
createField(collection_name, {
field: field_name,
type: field_type,
field_field: value,
})
);
POST /graphql/system
type Mutation {
create_fields_item(collection: String!, data: create_directus_fields_input!): directus_fields
}
{
"data": {
"collection": "about_us",
"field": "id",
"special": [],
"options": {},
"translations": []
}
}
Retrieve a Field
Retrieves the details of a single field in a given collection.
Query Parameters
Unique identifier of the collection the item resides in.
Unique identifier of the field.
Responses
Unique name of the collection this field is in.
Unique name of the field. Field name is unique within the collection.
Any special transform flags that apply to this field.
The interface used for this field.
The display used for this field.
The configured options for the used display.
If the field is considered readonly in the Data Studio.
If the field is hidden from the edit page in the Data Studio.
Where this field is shown on the edit page in the Data Studio.
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
.
How this field's name is displayed in the different languages in the Data Studio.
Short description displayed in the Data Studio.
GET /fields/{collection}/{id}
import { createDirectus, rest, readField } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(readField(collection_name, field_name));
POST /graphql/system
type Query {
fields_by_name(collection: String!, field: String!): directus_fields
}
{
"data": {
"collection": "about_us",
"field": "id",
"special": [],
"options": {},
"translations": []
}
}
Delete a Field
Delete an existing field. This action can't be undone.
Query Parameters
Unique identifier of the collection the item resides in.
Unique identifier of the field.
Responses
DELETE /fields/{collection}/{id}
import { createDirectus, rest, deleteField } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(deleteField(collection_name, field_name));
POST /graphql/system
type Mutation {
delete_fields_item(collection: String!, field: String!): delete_field
}
Update a Field
Updates the given field in the given collection.
Query Parameters
Unique identifier of the collection the item resides in.
Unique identifier of the field.
Request Body
Directus specific data type. Used to cast values in the API.
Unique name of the field. Field name is unique within the collection.
The schema info.
The type of the field.
The name of the field.
The collection of the field.
The default value of the field.
The max length of the field.
If the field is nullable.
If the field is primary key.
If the field has auto increment.
Related column from the foreign key constraint.
Related table from the foreign key constraint.
Comment as saved in the database.
Database schema (pg only).
Related schema from the foreign key constraint (pg only).
The meta info.
Unique identifier for the field in the directus_fields
collection.
Unique name of the collection this field is in.
Unique name of the field. Field name is unique within the collection.
Transformation flag for field
What interface is used in the admin app to edit the value for this field.
What display is used in the admin app to display the value for this field.
If the field can be altered by the end user. Directus system fields have this value set to true
.
Prevents the user from editing the value in the field.
If this field should be required.
If this field should be hidden.
Sort order of this field on the edit page of the admin app.
Width of the field on the edit form.
What field group this field is part of.
A user provided note for the field. Will be rendered alongside the interface on the edit page.
Responses
Unique name of the collection this field is in.
Unique name of the field. Field name is unique within the collection.
Any special transform flags that apply to this field.
The interface used for this field.
The display used for this field.
The configured options for the used display.
If the field is considered readonly in the Data Studio.
If the field is hidden from the edit page in the Data Studio.
Where this field is shown on the edit page in the Data Studio.
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
.
How this field's name is displayed in the different languages in the Data Studio.
Short description displayed in the Data Studio.
PATCH /fields/{collection}/{id}
import { createDirectus, rest, updateField } from '@directus/sdk';
const client = createDirectus('directus_project_url').with(rest());
const result = await client.request(updateField(collection_name, field_name, partial_field_object));
type Mutation {
update_fields_item(collection: String!, field: String!, data: update_directus_fields_input!): directus_fields
}
{
"data": {
"collection": "about_us",
"field": "id",
"special": [],
"options": {},
"translations": []
}
}