Create a collection
const url = 'https://api.example.com/cms/data';const options = { method: 'POST', headers: {'API-Key': '<API-Key>', 'Content-Type': 'application/json'}, body: '{"key":"matches","name":"Matches","description":"example","icon":"example","titleField":"example","fields":[{"key":"kickoff","name":"Kick-off","type":"text","description":"example","required":true,"multiple":true,"unique":true,"filterable":true,"maxLength":1,"min":1,"max":1,"integer":true,"values":["Grass","Hybrid"],"target":"record:teams","default":"example"}],"settings":{"cacheSeconds":1,"defaultStatus":"published"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.example.com/cms/data \ --header 'API-Key: <API-Key>' \ --header 'Content-Type: application/json' \ --data '{ "key": "matches", "name": "Matches", "description": "example", "icon": "example", "titleField": "example", "fields": [ { "key": "kickoff", "name": "Kick-off", "type": "text", "description": "example", "required": true, "multiple": true, "unique": true, "filterable": true, "maxLength": 1, "min": 1, "max": 1, "integer": true, "values": [ "Grass", "Hybrid" ], "target": "record:teams", "default": "example" } ], "settings": { "cacheSeconds": 1, "defaultStatus": "published" } }'Requires the “Structured data - Create collection” permission.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”A collection as POST /cms/data creates it and PUT /cms/data/{collection} changes it. On PUT, properties left out keep their value; fields replaces the whole list (a saved field left out is kept as deprecated: its data stays, the API stops using it).
object
POST only: the key (a lowercase letter, then lowercase letters, numbers and underscores, 64 at most)
Example
matchesName
Example
MatchesDescription
Bootstrap Icons class
The text field that names a record (the first text field when left out)
The fields, in order
A field of a structured data collection. Its key and type never change once saved.
object
The field’s name in a record’s data: a lowercase letter, then lowercase letters, numbers and underscores
Example
kickoffName shown in the CMS
Example
Kick-offField type
Example
datetimeHelp for connector developers
A value is required in every record
The value is a list of items of the type (text, number, date, datetime, enum, media, reference)
No two records of the collection can hold the same value
Can be used in filter[…] and sort when listing records. Lists, references and media always are.
Text: the maximum length
Number: the minimum
Number: the maximum
Number: whole numbers only
Enum: the allowed values
Example
[ "Grass", "Hybrid"]Reference: what it points to, “record:
Example
record:teamsThe value a record gets when none is sent
Settings
object
How long published records may be cached by frontends and the CDN (0–86400, default 60)
The status of a record written without one (default published)
Responses
Section titled “Responses”Created
object
A structured data collection: a user-defined shape whose records connectors write and frontends read.
object
Collection ID
The key used in the API path (/cms/data/{key}). Never changes.
Name
Description
Bootstrap Icons class
The text field whose value is a record’s title
The fields a record’s data can hold
A field of a structured data collection. Its key and type never change once saved.
object
The field’s name in a record’s data: a lowercase letter, then lowercase letters, numbers and underscores
Name shown in the CMS
Field type
Help for connector developers
A value is required in every record
The value is a list of items of the type (text, number, date, datetime, enum, media, reference)
No two records of the collection can hold the same value
Can be used in filter[…] and sort when listing records. Lists, references and media always are.
Text: the maximum length
Number: the minimum
Number: the maximum
Number: whole numbers only
Enum: the allowed values
Reference: what it points to, “record:
The value a record gets when none is sent
When the collection last changed
GET /cms/data/{collection} only: the JSON Schema of a record’s data, to validate what a connector sends
object
Example
{ "data": { "id": 3, "key": "matches", "name": "Matches", "icon": "bi-calendar-event", "titleField": "label", "fields": [ { "key": "kickoff", "name": "Kick-off", "type": "text", "values": [ "Grass", "Hybrid" ], "target": "record:teams" } ] }}Not valid (the message says why)
Needs an API key linked to a CMS user with the Structured data permission