Skip to content

Create a Field

Adds a new field to an existing collection.

POST /api/projects/{projectId}/collections/{slug}/fields

Request body

{
"name": "Published At",
"slug": "published_at",
"type": "datetime",
"isRequired": false,
"options": {}
}

Enumeration field

{
"name": "Status",
"slug": "status",
"type": "enumeration",
"isRequired": true,
"options": {
"values": ["draft", "published", "archived"]
}
}

Relation field

{
"name": "Author",
"slug": "author",
"type": "relation",
"isRequired": false,
"options": {
"targetCollection": "end_users"
}
}

Status codes

StatusDescription
201Created
409A field with this slug already exists
422Invalid field type or missing required options