Creating new Content Types and Fetching Content

Agility CMS gives you the ability to create content using a variety of built-in fields (or custom fields), and create relationships between content. At the core of this, is Shared Content. 

Unlike Pages, Shared Content will make no assumptions over what or where content will be used. This means you can create a new content list or item in Shared Content, have it immediately available via the Content Fetch API and leave it up to the consuming application to determine how it wants to use the content.

The speed at which you can create content, and consume it in an application is why Headless CMSs have become so popular as of late.

In this tutorial, we'll walk you through how to create a new Content Definition, initialize a new List in Agility, and immediately start consuming it via the Content Fetch API.

The steps we'll cover are:

  1. Create a new Content Definition

  2. Initialize a new List in Shared Content

  3. Create Content Items in the List

  4. Accessing the Content using the Content Fetch API

We will be adding a list of Authors so that we can later associate this to content that we publish on the website such as Blog Post.

Create a new Content Definition

When creating a content list, you need to have a Content Definition that represents your content schema first. This allows you to create multiple lists from the same Content Definition. For example, you may have more than one list of Blog Posts or types of Authors.

  1. Login to Agility CMS.

  2. Go to Settings Customization/Development Content Definitions and select New (+).

  3. In the New Content List Definition flyout, under the Definition Details tab, enter a Title (the Reference Name field will auto-populate) and set a Description.

    Title = Author
    Reference Name = Author
    Description = Defines the schema for an Author.

  4. Next, click the Form Builder tab and click the (+) sign to create a new field.

  5. In the Field Properties flyout, enter the following information:

    Field Label = Name
    Field Name = Name
    Description = The name of the author.
    Field Type = Text
    Required = True (checked)
    [Leave all others as default values...]

  6. Click Save & New to apply the new field and create another field. This time we'll be adding an Image field for the Author's profile picture.

    Field Label = Image
    Field Name = Image
    Description = The image representing the profile photo for the author.
    Field Type = Image
    [Leave all others as default values...]

    Pro Tip
    When setting up Image field types, you can set size restrictions, valid types, and default values.

  7. Click Save & Close to apply the new field.

  8. Click Save & Close to finish creating the Author Content Definition. Your new definition should now be listed.


Initialize a new List in Shared Content

Now that you've created the definition, we can now create lists based on that definition (Author).

  1. Login to Agility CMS

  2. Navigate to Shared Content and click the (+) to open the New Content List flyout.


  3. Under Content List, set the following values:

    Content Definition = Author
    Display Name = Post Authors
    Reference Name = PostAuthors

    Note: A Content Definition should use a singular naming convention (i.e. Author), while instances of the list should be pluralized (i.e. Authors).

  4. Click Save to finish creating the list.

Create Content Items in the List

Now that you have created the list, you can start creating content items inside it. Let's create one or two authors so we can query the API later and fetch our content.

  1. Login to Agility CMS.

  2. Navigate to Shared Content and click the (+ New) button to open a stack panel to create a new content item.


  3. Enter some values for Name and click Upload to upload an image from your PC to the Image field.

  4. Click Publish to publish the content item and make it available to our live Content Fetch API. When publishing content in the CMS, you'll notice the status bar on the item turn from grey (Staging) to blue (Processing) to green (Published) when it is available to be consumed via the API.

  5. Optionally, repeat steps #2-4 to create additional authors.

Accessing the Content using the Content Fetch API

Now that we've created a new content definition, created a new list and populated it with some content, we are ready to request the content from the API.

When using the Content Fetch API, you can make a direct HTTP request to the REST service or use an SDK in your favorite programming language to simplify making requests. 

First time making an API request? Check out Making your First API Call with the Content Fetch API for details.

  1. You need to know what the Reference Name for your list is, that is the required parameter in order to retrieve all content items in a list. *** It's important to note that ALL reference names MUST be lowercased when using the REST API.

    If you don't know your Reference Name, you can retrieve this from Agility CMS by navigating to Shared Content > Select a List > Click the Settings tab > Note the Reference Name property.


    If the Reference Name in this case is PostAuthors, then we request that from the API using postauthors (lowercased).

  2. In this example, we'll use a simple curl command to illustrate how to access the content we just created.

  3. The response returned from the API is shown below.



0 out of 0 found this helpful



Please sign in to leave a comment.