Data Collections API: Sample Use Cases & Flows

This article presents possible use cases and corresponding sample flows that you can support. This can be a helpful starting point as you plan your implementation.

Set up a tutorials collection with references to collections for categories and authors

You can use the Data Collections API to set up a site's tutorials section by first creating collections for categories and authors to organize content, and then creating a tutorials collection that references those collections.

To set up the collections:

  1. Call Create Data Collection to create a categories collection. Include the following properties in your request:

    In the fields array, include fields with these recommended values for type:

    • title, slug, description, and videoUrl: TEXT
    • icon: IMAGE
    • sortOrder: NUMBER

  2. Call Create Data Collection to create an authors collection. Include the following properties in your request:

    In the fields array, include fields with these recommended values for type:

    • name, slug, bio, and email: TEXT
    • photo: IMAGE
    • socialLinks: OBJECT

  3. Call Create Data Collection to create a tutorials collection. Include the following properties in your request:

    In the fields array, include fields with these recommended values for type:

    • title, slug, and description: TEXT
    • content: RICH_TEXT
    • publishDate: DATETIME
    • featured: BOOLEAN
    • estimatedTime: NUMBER for the reading time in minutes.

    Also include the following fields to add cross references to your categories and authors collections created earlier.

    • category: with type set to MULTI_REFERENCE and typeMetadata.multireference.referencedCollectionId set to categories.
    • author: with type set to MULTI_REFERENCE and typeMetadata.reference.referencedCollectionId set to authors.

    Set permissions to control the collection's access as follows:

    • read: ANYONE so visitors can view tutorials
    • insert, update, and remove: ADMIN so only site owners can manage content.

  4. Call Get Data Collection with dataCollectionId set to tutorials to retrieve the full collection schema and confirm all fields are configured correctly.

Add draft/publish functionality to a collection

You can enable draft and publish functionality for a site's content by adding a publish plugin to a collection. This allows content creators to save work in progress without making it visible to site visitors.

To add publish functionality:

  1. Call Add Data Collection Plugin and set plugin.type to PUBLISH and plugin.publishOptions.defaultStatus to DRAFT so new content is created as a draft by default.
  2. The collection now supports draft and published states. Use the Data Items API to manage item publication status.
Did this help?