Home
Content Management API⁡𝅶‍‍𝅺⁡‍𝅴⁡𝅴𝅹‍‍⁢𝅵‍‍⁣⁣‌⁡⁣𝅺⁣⁢⁣𝅸⁠⁢‍‍‍𝅷‍‍𝅳⁡‍⁠‍‍⁢𝅵‍‍𝅳⁡⁣⁡⁣⁡​⁡⁢⁢𝅵‍𝅺‍𝅺⁢𝅸⁡⁢‍𝅹⁣‌⁡⁣𝅺⁢𝅸⁡⁢‍𝅹⁢𝅺𝅸‍𝅺⁠⁣𝅴⁡⁣𝅺⁡‍‍𝅺𝅴⁡⁣⁠𝅸⁠𝅺⁡⁣⁡𝅴⁡​⁠⁡⁢‍𝅺⁢𝅳⁢‌⁢​⁢𝅴⁢‍⁢⁠‍𝅺𝅴⁡⁣⁠𝅸⁡⁢‍𝅺⁢⁢⁢𝅴⁢𝅳⁢⁢⁢‌⁢⁡⁢𝅳⁢‌‍‍⁡𝅸
Main resources
Upload-related
Site Search
Environments
UI
Workflows
Async jobs
Roles & permissions
Webhooks
Hosting & CI integrations
Subscription
Enterprise
    Show examples in:
    Field

    DatoCMS offers a number of different fields that you can combine together to create a Model. Using the database metaphore, fields are like table columns, and when creating them you need to specify their type (string, float, etc.) and any required validation.

    Different field types require different settings

    When looking at a field resource, you have to pay attention to two particular properties, validators and appearance.

    The validators property expresses the set of validations to be performed server-side on a specific field value for it to be considered valid, while the appearance property lets you specify how the field itself will be presented inside the form to the final editor.

    For both properties, the value to specify depends on the type of field itself. For example, you can add a "Limit character count" validation to a Single-line string field, or set its appearence to "Show it as heading", but they won't be accepted for a ie. Color field, as it supports different validations and appearance settings.

    Specifying validations

    The validators property requires an object whose keys are the validations that you want to be enforced, and the values are objects representing any settings that the validation itself requires. If the validation doesn't have additional settings, you just pass down an empty object.

    This is a valid example for a Single-line string field:

    {
    "validators": {
    // "required" validator has no settings
    "required": {},
    // "length" validator requires "min" and/or "max" properties
    "length": { "min": 80 }
    }
    }

    Below you'll find a summary of all the validators available for each field type with their settings.

    Some validators are required for a specific type of field. For example, the Slug field needs to have a slug_title_field validator to specify the ID of the Single-line string field that will be used to generate the slug itself.

    Specifying the appearance

    The appearance property requires an object with three specific properties: editor, parameters and addons.

    The editor represents the type of editor that the users will see inside the form to change the value of this specific field. Depending on the type of field, DatoCMS offers a number of different editors for you to choose from. The parameters property is an object representing any additional settings that the editor itself might require.

    This is a valid example for a Single-line string field:

    {
    "appearance": {
    // single_line is a DatoCMS built-in editor that you can use with single-line string fields
    "editor": "single_line",
    // each built-in editor has specific settings
    "parameters": { "heading": true },
    "addons": []
    },
    }

    Following you'll find a summary of all the editors available for each field type with their settings.

    Setting the appearance to a field editor provided by a plugin

    If the project contains a plugin that exposes manual field editors, you can also configure the field to be presented with it instead of using one of the build-in editors.

    In this case:

    • the editor property must be the ID of the plugin;
    • the field_extension property must be the ID of the specific manual field editor that the plugin exposes;
    • the parameters property must provide a configuration object compatible with the config screen of the manual field extension, or an empty object if it doesn't require any configuration.
    {
    "appearance": {
    // "2132" is a the ID of a plugin exposing a manual field editor
    "editor": "2134",
    // "starRating" is a manual field editor exposed by the plugin
    "field_extension": "starRating",
    // this is a valid configuration for the "starRating" field editor
    "parameters": { "maxRating": 5, "starsColor": "#ff0000" },
    "addons": []
    },
    }

    Configuring manual field addons

    If the project contains plugins that expose manual field addons, you can also add them to the field via the addons property.

    {
    "appearance": {
    "editor": "single_line",
    "parameters": { "heading": true },
    "addons": [
    {
    // "2138" is a the ID of a plugin exposing a manual addon editor
    "id": "2138",
    // "loremIpsumGenerator" is a manual field addon exposed by the plugin
    "field_extension": "loremIpsumGenerator",
    // this is a valid configuration for the "loremIpsumGenerator" field addon
    "parameters": { "sentences": 2 },
    }
    ]
    },
    }

    Available field types

    Single-line string (string)
    PropertyValue
    Codestring
    Built-in editors for the fieldsingle_line, string_radio_group, string_select
    Available validatorsrequired, unique, length, format, enum
    Multi-line text (text)
    PropertyValue
    Codetext
    Built-in editors for the fieldmarkdown, wysiwyg, textarea
    Available validatorsrequired, length, format
    Boolean (boolean)
    PropertyValue
    Codeboolean
    Built-in editors for the fieldboolean, boolean_radio_group
    Available validatorsno validators available
    Integer (integer)
    PropertyValue
    Codeinteger
    Built-in editors for the fieldinteger
    Available validatorsrequired, number_range
    Float (float)
    PropertyValue
    Codefloat
    Built-in editors for the fieldfloat
    Available validatorsrequired, number_range
    Date (date)
    PropertyValue
    Codedate
    Built-in editors for the fielddate_picker
    Available validatorsrequired, date_range
    Date time (date_time)
    PropertyValue
    Codedate_time
    Built-in editors for the fielddate_time_picker
    Available validatorsrequired, date_time_range
    Color (color)
    PropertyValue
    Codecolor
    Built-in editors for the fieldcolor_picker
    Available validatorsrequired
    JSON (json)
    PropertyValue
    Codejson
    Built-in editors for the fieldjson, string_multi_select, string_checkbox_group
    Available validatorsrequired
    Location (lat_lon)
    PropertyValue
    Codelat_lon
    Built-in editors for the fieldmap
    Available validatorsrequired
    SEO (seo)
    PropertyValue
    Codeseo
    Built-in editors for the fieldseo
    Available validatorsrequired_seo_fields, file_size, image_dimensions, title_length, description_length
    Slug (slug)
    PropertyValue
    Codeslug
    Built-in editors for the fieldslug
    Required validatorsslug_title_field
    Other validators availablerequired, length, slug_format
    External video (video)
    PropertyValue
    Codevideo
    Built-in editors for the fieldvideo
    Available validatorsrequired
    Single-asset (file)
    PropertyValue
    Codefile
    Built-in editors for the fieldfile
    Available validatorsrequired, file_size, image_dimensions, extension, required_alt_title
    Asset gallery (gallery)
    PropertyValue
    Codegallery
    Built-in editors for the fieldgallery
    Available validatorssize, file_size, image_dimensions, extension, required_alt_title
    Single link (link)
    PropertyValue
    Codelink
    Built-in editors for the fieldlink_select, link_embed
    Default editorlink_select
    Required validatorsitem_item_type
    Other validators availablerequired, unique
    Multiple links (links)
    PropertyValue
    Codelinks
    Built-in editors for the fieldlinks_select, links_embed
    Default editorlinks_select
    Required validatorsitems_item_type
    Other validators availablesize
    Modular content (rich_text)
    PropertyValue
    Coderich_text
    Built-in editors for the fieldrich_text
    Required validatorsrich_text_blocks
    Other validators availablesize
    Structured text (structured_text)
    PropertyValue
    Codestructured_text
    Built-in editors for the fieldstructured_text
    Required validatorsstructured_text_blocks, structured_text_links
    Other validators availablelength

    Validators

    date_range

    Accept dates only inside a specified date range.

    ParameterTypeRequiredDescription
    minISO 8601 dateMinimum date
    maxISO 8601 dateMaximum date

    At least one of the parameters must be specified.

    date_time_range

    Accept date times only inside a specified date range.

    ParameterTypeRequiredDescription
    minISO 8601 datetimeMinimum datetime
    maxISO 8601 datetimeMaximum datetime

    At least one of the parameters must be specified.

    enum

    Only accept a specific set of values

    ParameterTypeRequiredDescription
    valuesArray<String>Set of allowed values
    extension

    Only accept assets with specific file extensions.

    ParameterTypeRequiredDescription
    extensionsArray<String>Set of allowed file extensions
    predefined_listone of "image", "transformable_image", "video", "document"Allowed file type

    Only one of the parameters must be specified.

    file_size

    Accept assets only inside a specified date range.

    ParameterTypeRequiredDescription
    min_valueIntegerNumeric value for minimum filesize
    min_unitone of "B", "KB", "MB"Unit for minimum filesize
    max_valueIntegerNumeric value for maximum filesize
    max_unitone of "B", "KB", "MB"Unit for maximum filesize

    At least one couple of value/unit must be specified.

    format

    Only accept strings having a specific format.

    ParameterTypeRequiredDescription
    custom_patternRegexpRegular expression to be validated
    predefined_patternone of "email", "url"Allowed format

    Only one of the parameters must be specified.

    slug_format

    Only accept slugs having a specific format.

    ParameterTypeRequiredDescription
    custom_patternRegexpRegular expression to be validated
    predefined_pattern"webpage_slug"Allowed format

    Only one of the parameters must be specified.

    image_dimensions

    Accept assets only within a specified height/width range.

    ParameterTypeRequiredDescription
    width_min_valueIntegerNumeric value for minimum width
    width_max_valueIntegerNumeric value for maximum height
    height_min_valueIntegerNumeric value for minimum width
    height_max_valueIntegerNumeric value for maximum height

    At least one parameter must be specified.

    item_item_type

    Only accept references to records of the specified models.

    ParameterTypeRequiredDescription
    item_typesArray<Model ID>Set of allowed model IDs
    on_publish_with_unpublished_references_strategy"fail", "publish_references" (default value: "fail")Strategy to apply when a publishing is requested and this field references some unpublished records
    on_reference_unpublish_strategy"fail", "unpublish", "delete_references" (default value: "fail")Strategy to apply when unpublishing is requested for a record referenced by this field
    on_reference_delete_strategy"fail", "delete_references" (default value: "delete_references")Strategy to apply when deletion is requested for a record referenced by this field

    Possible values for on_publish_with_unpublished_references_strategy:

    • "fail": Fail the operation and notify the user
    • "publish_references": Publish also the referenced records

    Possible values for on_reference_unpublish_strategy:

    • "fail": Fail the operation and notify the user
    • "unpublish": Unpublish also this record
    • "delete_references": Try to remove the reference to the unpublished record (if the field has a required validation it will fail)

    Possible values for on_reference_delete_strategy:

    • "fail": Fail the operation and notify the user
    • "delete_references": Try to remove the reference to the deleted record (if the field has a required validation it will fail)
    items_item_type

    Only accept references to records of the specified models.

    ParameterTypeRequiredDescription
    item_typesArray<Model ID>Set of allowed model IDs
    on_publish_with_unpublished_references_strategy"fail", "publish_references" (default value: "fail")Strategy to apply when a publishing is requested and this field references some unpublished records
    on_reference_unpublish_strategy"fail", "unpublish", "delete_references" (default value: "fail")Strategy to apply when unpublishing is requested for a record referenced by this field
    on_reference_delete_strategy"fail", "delete_references" (default value: "delete_references")Strategy to apply when deletion is requested for a record referenced by this field

    Possible values for on_publish_with_unpublished_references_strategy:

    • "fail": Fail the operation and notify the user
    • "publish_references": Publish also the referenced records

    Possible values for on_reference_unpublish_strategy:

    • "fail": Fail the operation and notify the user
    • "unpublish": Unpublish also this record
    • "delete_references": Try to remove the reference to the unpublished record (if the field has a required validation it will fail)

    Possible values for on_reference_delete_strategy:

    • "fail": Fail the operation and notify the user
    • "delete_references": Try to remove the reference to the deleted record (if the field has a required validation it will fail)
    length

    Accept strings only with a specified number of characters.

    ParameterTypeRequiredDescription
    minIntegerMinimum length
    eqIntegerExpected length
    maxIntegerMaximum length

    At least one parameter must be specified.

    number_range

    Accept numbers only inside a specified range.

    ParameterTypeRequiredDescription
    minFloatMinimum value
    maxFloatMaximum value

    At least one of the parameters must be specified.

    required

    Value must be specified or it won't be valid.

    required_alt_title

    Assets contained in the field are required to specify custom title or alternate text, or they won't be valid.

    ParameterTypeRequiredDescription
    titleBooleanWhether the title for the asset must be specified
    altBooleanWhether the alternate text for the asset must be specified

    At least one of the parameters must be specified.

    required_seo_fields

    SEO field is to specify one or more properties, or it won't be valid.

    ParameterTypeRequiredDescription
    titleBooleanWhether the meta title must be specified
    descriptionBooleanWhether the meta description must be specified
    imageBooleanWhether the social sharing image must be specified
    twitter_cardBooleanWhether the type of Twitter card must be specified

    At least one of the parameters must be specified.

    title_length

    Limits the length of the title for a SEO field. Search engines usually truncate title tags to 60 character so it is a good practice to keep the title around this length.

    ParameterTypeRequiredDescription
    minIntegerMinimum value
    maxIntegerMaximum value

    At least one of the parameters must be specified.

    description_length

    Limits the length of the description for a SEO field. Search engines usually truncate description tags to 160 character so it is a good practice to keep the description around this length.

    ParameterTypeRequiredDescription
    minIntegerMinimum value
    maxIntegerMaximum value

    At least one of the parameters must be specified.

    rich_text_blocks

    Only accept references to block records of the specified block models.

    ParameterTypeRequiredDescription
    item_typesArray<Block Model ID>Set of allowed Block Model IDs
    sanitization

    Checks for the presence of malicious cose in HTML fields: content is valid if no dangerous code is present.

    ParameterTypeRequiredDescription
    sanitize_before_validationBooleanContent is actively sanitized before applying the validation
    structured_text_blocks

    Only accept references to block records of the specified block models.

    ParameterTypeRequiredDescription
    item_typesArray<Block Model ID>Set of allowed Block Model IDs
    structured_text_links

    Only accept itemLink to inlineItem nodes for records of the specified models.

    ParameterTypeRequiredDescription
    item_typesArray<Model ID>Set of allowed model IDs
    on_publish_with_unpublished_references_strategy"fail", "publish_references" (default value: "fail")Strategy to apply when a publishing is requested and this field references some unpublished records
    on_reference_unpublish_strategy"fail", "unpublish", "delete_references" (default value: "delete_references")Strategy to apply when unpublishing is requested for a record referenced by this field
    on_reference_delete_strategy"fail", "delete_references" (default value: "delete_references")Strategy to apply when deletion is requested for a record referenced by this field

    Possible values for on_publish_with_unpublished_references_strategy:

    • "fail": Fail the operation and notify the user
    • "publish_references": Publish also the referenced records

    Possible values for on_reference_unpublish_strategy:

    • "fail": Fail the operation and notify the user
    • "unpublish": Unpublish also this record
    • "delete_references": Try to remove the reference to the unpublished record (if the field has a required validation it will fail)

    Possible values for on_reference_delete_strategy:

    • "fail": Fail the operation and notify the user
    • "delete_references": Try to remove the reference to the deleted record (if the field has a required validation it will fail)
    size

    Only accept a number of items within the specified range.

    ParameterTypeRequiredDescription
    minIntegerMinimum length
    eqIntegerExpected length
    maxIntegerMaximum length
    multiple_ofIntegerThe number of items must be multiple of this value

    At least one parameter must be specified.

    slug_title_field

    Specifies the ID of the Single-line string field that will be used to generate the slug

    ParameterTypeRequiredDescription
    title_field_idField IDThe field that will be used to generate the slug
    unique

    The value must be unique across the whole collection of records.

    Configuration parameters for DatoCMS built-in field editors

    If a field editor is not specified in this table, just pass an empty object {} as its configuration parameters.

    boolean_radio_group

    Radio group input for boolean fields.

    ParameterTypeRequiredDescription
    positive_radio{ label: string, hint?: string }Radio input for positive choice (true)
    negative_radio{ label: string, hint?: string }Radio input for negative choice (false)
    string_radio_group

    Radio group input for string fields.

    ParameterTypeRequiredDescription
    radiosArray<{ label: string, value: string, hint?: string }>The different radio options
    string_select

    Select input for string fields.

    ParameterTypeRequiredDescription
    optionsArray<{ label: string, value: string, hint?: string }>The different select options
    string_multi_select

    Select input for JSON fields, to edit an array of strings.

    ParameterTypeRequiredDescription
    optionsArray<{ label: string, value: string, hint?: string }>The different select options
    string_checkbox_group

    Multiple chechboxes input for JSON fields, to edit an array of strings.

    ParameterTypeRequiredDescription
    optionsArray<{ label: string, value: string, hint?: string }>The different select options
    single_line

    Simple textual input for Single-line string fields.

    ParameterTypeRequiredDescription
    headingBooleanIndicates if the field should be shown bigger, as a field representing a heading
    markdown

    Markdown editor for Multiple-paragraph text fields.

    ParameterTypeRequiredDescription
    toolbarArray<String>Specify which buttons the toolbar should have. Valid values: "heading", "bold", "italic", "strikethrough", "code", "unordered_list", "ordered_list", "quote", "link", "image", "fullscreen"
    wysiwyg

    HTML editor for Multiple-paragraph text fields.

    ParameterTypeRequiredDescription
    toolbarArray<String>Specify which buttons the toolbar should have. Valid values: "format", "bold", "italic", "strikethrough", "code", "ordered_list", "unordered_list", "quote", "table", "link", "image", "show_source", "undo", "redo", "align_left", "align_center", "align_right", "align_justify", "outdent", "indent", "fullscreen"
    textarea

    Basic textarea editor for Multiple-paragraph text fields.

    color_picker

    Built-in editor for Color fields.

    ParameterTypeRequiredDescription
    enable_alphaBooleanShould the color picker allow to specify the alpha value?
    preset_colorsArray<Hex color string>List of preset colors to offer to the user
    slug

    Built-in editor for Slug fields.

    ParameterTypeRequiredDescription
    url_prefixStringA prefix that will be shown in the editor's form to give some context to your editors.
    rich_text

    Built-in editor for Modular content fields.

    ParameterTypeRequiredDescription
    start_collapsedBooleanWhether you want block records collapsed by default or not
    structured_text

    Built-in editor for Structured text fields.

    ParameterTypeRequiredDescription
    nodesArray<String>Specify which nodes the field should allow. Valid values: "blockquote", "code", "heading", "link", "list", "thematicBreak"
    marksArray<String>Specify which marks the field should allow. Valid values: "strong", "emphasis", "underline", "strikethrough", "code", "highlight"
    heading_levelsArray<Integer>If nodes includes "heading", specify which heading levels the field should allow. Valid values: numbers between 1 and 6
    blocks_start_collapsedBooleanWhether you want block nodes collapsed by default or not
    show_links_target_blankBooleanWhether you want to show the "Open this link in a new tab?" checkbox, that fills in the target: "_blank" meta attribute for links
    show_links_meta_editorBooleanWhether you want to show the complete meta editor for links
    link_select and links_select

    Use a select input with auto-completion to pick the records to reference inside the field.

    link_embed and links_embed

    Use an expanded view with records' image preview to pick the records to reference inside the field.

    Object payload

    id  string
    ID of field
    type  string
    Must be exactly "field"
    label  string

    The label of the field

    field_type  enum

    Type of input

    api_key  string

    Field API key

    localized  boolean

    Whether the field needs to be multilanguage or not

    validators  object

    Optional field validations

    position  integer

    Ordering index

    hint  string, null

    Field hint

    default_value  boolean, null, string, number, object

    Default value for Field. When field is localized accepts an object of default values with site locales as keys

    appearance  object

    Field appearance details, plugin configuration and field add-ons

    item_type  { type: "item_type", id: item_type.id }

    Field item type

    fieldset  null, { type: "fieldset", id: fieldset.id }

    Fieldset linkage

    Available endpoints