DatoCMS icon

DatoCMS

Interact with DatoCMS API

Overview

This node integrates with the DatoCMS API to manage content records of various item types. Specifically, the "Create or Update" (upsert) operation allows users to either create a new record or update an existing one based on matching field values. This is useful in scenarios where you want to ensure data synchronization without creating duplicates, such as syncing product information, user profiles, or blog posts from external sources.

Practical examples:

  • Automatically updating a product catalog by matching products via SKU or unique ID and creating new entries if they don't exist.
  • Managing user-generated content where updates are applied if the record exists, otherwise a new record is created.
  • Synchronizing CMS content from external databases or APIs while avoiding duplicate entries.

Properties

Name Meaning
Item Type The type of item (content model) to work with. You can select from a list of available item types or specify an ID directly.
Fields The fields to upsert in the record. This includes the data to set or update. You can define fields manually or auto-map input data. Matching fields are used to identify existing records for update.
Create If Not Found Boolean flag indicating whether to create a new record if no existing record matches the specified matching fields. Defaults to true.
Additional Fields Extra options for the operation. Currently supports:
• Auto Publish: Whether to automatically publish the record after creation or update.

Output

The output JSON contains the resulting record object returned by the DatoCMS API after the upsert operation. This includes all fields of the record, including system fields like IDs and timestamps.

If the "Auto Publish" option is enabled, the output reflects the published state of the record.

No binary data is output by this operation.

Dependencies

  • Requires an API key credential for authenticating with the DatoCMS API.
  • The node uses the official DatoCMS Node.js client library internally.
  • Proper permissions on the API key are necessary to perform create, update, and publish operations on records.
  • The environment (e.g., project environment) must be configured in the credentials.

Troubleshooting

  • Error: No matching fields configured
    Occurs if no fields are selected to match existing records during upsert. Solution: Select at least one unique or identifying field in the "Fields" property under matching fields.

  • Error: No value provided for matching field 'X'
    Happens when the matching field has no value in the input data. Ensure that the input data or manual field mapping provides a value for the matching field.

  • Error: Multiple records found with matching field
    Indicates that the matching field is not unique and multiple records were found. Use a unique field for matching to avoid ambiguity.

  • Permission errors (e.g., 401 Unauthorized)
    Check that the API key credential is valid and has sufficient permissions for the requested operation.

  • JSON parsing errors on fields
    Some fields require JSON strings or arrays. The node attempts to parse and format these automatically, but malformed input may cause errors. Verify the input format for complex fields like modular content or JSON fields.

Links and References

Discussion