Content items

The content item contains the data, which aligns with the data model and is structured according to a content type. You can use query attributes to control the set of items returned. Before you start working with content items, you must authenticate.

Note

The base URL for creating and editing content items is https://content-api.sitecorecloud.io/. For guidance on API syntax, see Syntax.

Get a list of content items

Use this method to retrieve a list of content items. If you don't specify any filtering parameters, you will retrieve all available content items.

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location --request GET  '<BASE_URL>/api/content/v1/items' \
--header 'Accept: text/plain' \
--header 'Authorization: <BEARER_TOKEN>'

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 

{
    "totalCount": 27,
    "pageSize": 1,
    "pageNumber": 1,
    "data": [
        {
            "id": "eAIfbhsWK0aN2j6g3caMIA",
            "name": "Ireland",
            "fields": {
                "placeName": {
                    "value": "Kilkenny Castle",
                    "type": "ShortText"
                },
                "description": {
                    "value": {
                        "type": "doc",
                        "content": [
                            {
                                "type": "paragraph",
                                "content": [
                                    {
                                        "type": "text",
                                        "text": "Perched on the banks of the River Nore in Kilkenny, Kilkenny Castle is one of Ireland's most popular heritage sites. With a rich history dating back to the 12th century, this majestic fortress was once the stronghold of the influential Butler family. While its Victorian-inspired architecture dominates the present landscape, echoes of its medieval origins can still be felt."
                                    }
                                ]
                            }
                        ]
                    },
                    "type": "RichText"
                },
                "withtour": {
                    "value": true,
                    "type": "Boolean"
                },
                "destinationimage": {
                    "value": [],
                    "type": "Media"
                }
            },
            "system": {
                "contentType": {
                    "type": "Link",
                    "relatedType": "ContentType",
                    "id": "historicalDestinations",
                    "uri": "<BASE_URL>/api/content/v1/types/historicalDestinations"
                },
                "lastPublishProgress": null,
                "type": "Content",
                "version": "/AWzmJipFaHhR+JimowBQ+Z66aaWnvkc8gg0tJmMqHQ=",
                "status": "Draft",
                "createdBy": {
                    "type": "Link",
                    "relatedType": "User",
                    "id": "[email protected]",
                    "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
                },
                "createdAt": "2024-03-26T15:16:28.5731434Z",
                "updatedBy": {
                    "type": "Link",
                    "relatedType": "User",
                    "id": "[email protected]",
                    "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
                },
                "updatedAt": "2024-03-26T15:16:28.5731434Z",
                "publishedBy": null,
                "publishedAt": null
            }
        }
    ]
}

Get all references to a content item

Use this method to retrieve a list of all content items that reference a specific content item. This request uses the linkedTo query attribute and retrieves all the items that reference the content item with the ID 2PFAKkA-SEGNH74hfoKEcA.

RequestResponse
// [!code word:<BASE_URL>] 

curl --location '<BASE_URL>/api/content/v1/items?linkedTo=2PFAKkA-SEGNH74hfoKEcA' \
RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 

{
    "totalCount": 1,
    "pageSize": 20,
    "pageNumber": 1,
    "data": [
        {
            "id": "Lv3Vl590g0KA2M18QqmEBA",
            "name": "Ireland",
            "fields": {
                "relatedItems": {
                    "value": [
                        {
                            "type": "Link",
                            "relatedType": "Content",
                            "id": "2PFAKkA-SEGNH74hfoKEcA",
                            "uri": "<BASE_URL>/api/content/v1/items/2PFAKkA-SEGNH74hfoKEcA"
                        },
                        {
                            "type": "Link",
                            "relatedType": "Content",
                            "id": "swycL5rgh0uay0AXh3eKzw",
                            "uri": "<BASE_URL>/api/content/v1/items/swycL5rgh0uay0AXh3eKzw"
                        }
                    ],
                    "type": "Reference"
                },
                "heroImage": {
                    "value": [
                        {
                            "type": "Link",
                            "relatedType": "Media",
                            "id": "tilDmzS7zE2RukkDA14WLA",
                            "uri": "<BASE_URL>/api/content/v1/media/tilDmzS7zE2RukkDA14WLA"
                        }
                    ],
                    "type": "Media"
                }
            },
            "system": {
                "contentType": {
                    "type": "Link",
                    "relatedType": "ContentType",
                    "id": "destinations",
                    "uri": "<BASE_URL>/api/content/v1/types/destinations"
                },
                "lastPublishProgress": {
                    "type": "Publish",
                    "status": "Completed",
                    "triggeredBy": {
                        "type": "Link",
                        "relatedType": "User",
                        "id": "b.bijoux.com",
                        "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
                    },
                    "triggeredAt": "2023-10-03T14:26:08.948726Z"
                },
                "type": "Content",
                "version": "JG+Aoz3MKCPH48J7o3dlXq5rKWXK3jRonLLHxGWTcUg=",
                "status": "Published",
                "createdBy": {
                    "type": "Link",
                    "relatedType": "User",
                    "id": "[email protected]",
                    "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
                },
                "createdAt": "2023-10-03T14:05:27.579015Z",
                "updatedBy": {
                    "type": "Link",
                    "relatedType": "User",
                    "id": "[email protected]",
                    "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
                },
                "updatedAt": "2023-10-03T14:26:07.5013969Z",
                "publishedBy": {
                    "type": "Link",
                    "relatedType": "User",
                    "id": "[email protected]",
                    "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
                },
                "publishedAt": "2023-10-03T14:27:09.9357599Z"
            }
        }
    ]
}

Other request examples

You can include query parameters to control the set of items returned as shown in the following examples. You can also exclude all custom fields from the response by appending the query parameter view=excludeCustomFields. If you do this, the retrieved list only includes the NAME, CONTENT TYPE, UPDATED BY, UPDATED ON, and STATUS values for each item.

Example of an ID query for a single item

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location '<BASE_URL>/api/content/v1/items/QHuzN24s80i3DVDZXXQOiA' \
--header 'Authorization: <BEARER_TOKEN>'\
--data ''

Example of an ID query for multiple items

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location '<BASE_URL>/api/content/v1/items?QHuzN24s80i3DVDZXXQOiA%20%7C%20vqST-0YF10uA_3UiUV6owQ=null' \
--header 'Authorization: <BEARER_TOKEN>' \
--data '' 

Example of a search query

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location '<BASE_URL>/api/content/v1/items?search=hotel' \
--header 'Authorization: <BEARER_TOKEN>'
\--data '' 

Example of a sortBy query

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location '<BASE_URL>/api/content/v1/items?sortBy=system.updatedAt' \
--header 'Authorization: <BEARER_TOKEN>'
\--data '' 

Get a content item using the ID

Use this method to retrieve a content item with a specific ID. For a list of content item IDs, run the GET api/content/v1/types method or open the content item details page. This request returns a content item with the ID QHuzN24s80i3DVDZXXQOiA.

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location '<BASE_URL>/api/content/v1/items/QHuzN24s80i3DVDZXXQOiA' \
--header 'Authorization: <BEARER_TOKEN>' \
--data ''
RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 

{
  "id": "QHuzN24s80i3DVDZXXQOiA",
  "name": "Luxury-Inn",
  "fields": {
    "industry": {
      "value": "travel",
      "type": "ShortText"
    },
    "shortDescription": {
      "value": "The first choice for the rich and famous, the Luxury-Inn is renowned for its large and lavish breakfasts.",
      "type": "LongText"
    },
    "description": {
      "value": {
        "type": "doc",
        "content": [
          {
            "type": "paragraph",
            "content": [
              {
                "type": "text",
                "text": "As a strong contender for the grandest hotel, Luxury-Inn boasts a rich history and stunning décor combined with first rate amenities. This establishment originally opened its doors in 1913 and although the amenities have been modernised over the years, much of the imposing and regal style has been preserved. The spa is the perfect place to unwind in style as it comes complete with an infinity edged swimming pool, a steam room, and a sauna. There are 42 different suites to choose from, with the 320 square metre Royal Suite being the grandest of them all."
              }
            ]
          }
        ]
      },
      "type": "RichText"
    },
    "pricePerNight": {
      "value": 100,
      "type": "Integer"
    },
    "ratingstars": {
      "value": 4,
      "type": "Integer"
    },
    "amenities": {
      "value": [
        {
          "id": "airConditioning"
        },
        {
          "id": "restaurant"
        },
        {
          "id": "wifi"
        }
      ],
      "type": "Select"
    },
    "roomType": {
      "value": [],
      "type": "Select"
    },
    "relatedItems": {
      "value": [
        {
          "type": "Link",
          "relatedType": "Content",
          "id": "japan",
          "uri": "<BASE_URL>/api/content/v1/items/japan"
        }
      ],
      "type": "Reference"
    },
    "heroImage": {
      "value": [
        {
          "type": "Link",
          "relatedType": "Media",
          "id": "travelLuxuryInn",
          "uri": "<BASE_URL>/api/content/v1/media/travelLuxuryInn"
        }
      ],
      "type": "Media"
    }
  },
  "system": {
    "contentType": {
      "type": "Link",
      "relatedType": "ContentType",
      "id": "hotels",
      "uri": "<BASE_URL>/api/content/v1/types/hotels"
    },
    "lastPublishProgress": {
      "type": "Publish",
      "status": "Completed",
      "triggeredBy": {
        "type": "Link",
        "relatedType": "User",
        "id": "[email protected]",
        "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
      },
      "triggeredAt": "2023-06-11T11:30:19.665558Z"
    },
    "type": "Content",
    "version": "/uGX6R8wjjowSKD7RJJjpjgqJXnPdFc++ZVA8S42znw=",
    "status": "Published",
    "createdBy": {
      "type": "Link",
      "relatedType": "User",
      "id": "",
      "uri": "<BASE_URL>/api/content/v1/users/"
    },
    "createdAt": "2023-06-08T13:15:03.6540984Z",
    "updatedBy": {
      "type": "Link",
      "relatedType": "User",
      "id": "[email protected]",
      "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
    },
    "updatedAt": "2023-06-11T11:31:21.8717726Z",
    "publishedBy": {
      "type": "Link",
      "relatedType": "User",
      "id": "[email protected]",
      "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
    },
    "publishedAt": "2023-06-11T11:31:21.8704096Z"
  }
}

Create a content item

Use this method to create a content item. This request creates a content item using the Historical Destinations content type.

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location '<BASE_URL>/api/content/v1/items' \
--header 'Content-Type: application/json' \
--header 'Authorization: <BEARER_TOKEN>' \
--data '{
    "id": "eAIfbhsWK0aN2j6g3caMIA",
    "name": "Ireland",
    "contentTypeId": "historicalDestinations",
    "fields": {
        "placeName": {
            "value": "Kilkenny Castle",
            "type": "ShortText"
        },
        "description": {
            "value": {
                "type": "doc",
                "content": [
                    {
                        "type": "paragraph",
                        "content": [
                            {
                                "type": "text",
                                "text": "Perched on the banks of the River Nore in Kilkenny, Kilkenny Castle is one of Ireland'\''s most popular heritage sites. With a rich history dating back to the 12th century, this majestic fortress was once the stronghold of the influential Butler family. While its Victorian-inspired architecture dominates the present landscape, echoes of its medieval origins can still be felt."
                            }
                        ]
                    }
                ]
            },
            "type": "RichText"
        },
        "withtour": {
            "value": true,
            "type": "Boolean"
        },
        "destinationimage": {
            "value": [],
            "type": "Media"
        }
    }}'
RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 

{
 "id": "6oOI7VsND0GAv1y8sHl2UQ",
 "name": "Episode #21",
 "fields": {
  "podcastName": {
   "value": "Wonderful wonderful",
   "type": "ShortText"
  },
  "episodeName": {
   "value": "It's a wonderful day.",
   "type": "LongText"
  },
  "description": {
   "value": "Join me for a whirlwind tour of all the wonderful East Coast music.",
   "type": "ShortText"
  },
  "presenter": {
   "value": [
    {
     "type": "Link",
     "relatedType": "Content",
     "id": "U1PvFl6Jgky2igTAPKS3LA",
     "uri": " <BASE_URL>/api/content/v1/items/U1PvFl6Jgky2igTAPKS3LA"
    }
   ],
   "type": "Reference"
  },
  "coverPhoto": {
   "value": [
    {
     "type": "Link",
     "relatedType": "Media",
     "id": "W1neLaYAxkiIu25rue8T7g",
     "uri": " <BASE_URL>/api/content/v1/media/W1neLaYAxkiIu25rue8T7g"
    }
   ],
   "type": "Media"
  }
 },
 "system": {
  "contentType": {
   "type": "Link",
   "relatedType": "ContentType",
   "id": "podcast",
   "uri": " <BASE_URL>/api/content/v1/types/podcast"
  },
  "lastPublishProgress": null,
  "type": "Content",
  "version": "qeQg1b83WcpK+nel+1dWFrvxGHB14kzDzWwBWaIwu0A=",
  "status": "Draft",
  "createdBy": {
   "type": "Link",
   "relatedType": "User",
   "id": "[email protected]",
   "uri": " <BASE_URL>/api/users/[email protected]"
  },
  "createdAt": "2022-12-08T14:28:56.8836651Z",
  "updatedBy": {
   "type": "Link",
   "relatedType": "User",
   "id": "[email protected]",
   "uri": " <BASE_URL>/api/users/[email protected]"
  },
  "updatedAt": "2022-12-08T14:28:56.8836651Z",
  "publishedBy": null,
  "publishedAt": null
 }
}

Update a content item

Use this method to update a content item. You can, for example, add or modify content, delete existing content, or change properties associated with the content (such as a taxonomy or its values).

This request updates the description of the content item with the ID eAIfbhsWK0aN2j6g3caMIA. It also changes the WithTour value to false.

Warning

The Update method does not merge content; rather, it fully replaces the existing content using the body of the request. For this reason, your request must include the new version of all the content, including your updates and any data you want to retain. Anything not included in your request will be replaced.

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location --request PUT '<BASE_URL>/api/content/v1/items/eAIfbhsWK0aN2j6g3caMIA' \
--header 'Content-Type: application/json' \
--header 'Authorization: <BEARER_TOKEN> ' \
--data '{
    "id": "eAIfbhsWK0aN2j6g3caMIA",
    "name": "Ireland",
    "contentTypeId": "historicalDestinations",
    "fields": {
        "placeName": {
            "value": "Kilkenny Castle",
            "type": "ShortText"
        },
        "description": {
            "value": {
                "type": "doc",
                "content": [
                    {
                        "type": "paragraph",
                        "content": [
                            {
                                "type": "text",
                                "text": "Perched on the banks of the River Nore in Kilkenny, Kilkenny Castle is one of Ireland'\''s most popular heritage sites. With a rich history dating back to the 12th century, this majestic fortress was once the stronghold of the influential Butler family. While its Victorian-inspired architecture dominates the present landscape, echoes of its medieval origins can still be felt. Prepare to be captivated by the sheer grandeur of Kilkenny Castle, where history comes alive and dreams are woven into the very fabric of reality. Uncover the secrets that lie within its ancient walls, and let the enchantment of this extraordinary landmark transport you to a realm of pure wonder and awe."
                            }
                        ]
                    }
                ]
            },
            "type": "RichText"
        },
        "withtour": {
            "value": false,
            "type": "Boolean"
        },
        "destinationimage": {
            "value": [],
            "type": "Media"
        }
    }}'
RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BASE_URL>] 

{
    "id": "eAIfbhsWK0aN2j6g3caMIA",
    "name": "Ireland",
    "fields": {
        "placeName": {
            "value": "Kilkenny Castle",
            "type": "ShortText"
        },
        "description": {
            "value": {
                "type": "doc",
                "content": [
                    {
                        "type": "paragraph",
                        "content": [
                            {
                                "type": "text",
                                "text": "Perched on the banks of the River Nore in Kilkenny, Kilkenny Castle is one of Ireland's most popular heritage sites. With a rich history dating back to the 12th century, this majestic fortress was once the stronghold of the influential Butler family. While its Victorian-inspired architecture dominates the present landscape, echoes of its medieval origins can still be felt. Prepare to be captivated by the sheer grandeur of Kilkenny Castle, where history comes alive and dreams are woven into the very fabric of reality. Uncover the secrets that lie within its ancient walls, and let the enchantment of this extraordinary landmark transport you to a realm of pure wonder and awe."
                            }
                        ]
                    }
                ]
            },
            "type": "RichText"
        },
        "withtour": {
            "value": false,
            "type": "Boolean"
        },
        "destinationimage": {
            "value": [],
            "type": "Media"
        }
    },
    "system": {
        "contentType": {
            "type": "Link",
            "relatedType": "ContentType",
            "id": "historicalDestinations",
            "uri": "<BASE_URL>/api/content/v1/types/historicalDestinations"
        },
        "lastPublishProgress": null,
        "type": "Content",
        "version": "W2nq+SxNybXcp3ARdB2qQjBK2FHu1TFrAoQ0Uq5j+3I=",
        "status": "Draft",
        "createdBy": {
            "type": "Link",
            "relatedType": "User",
            "id": "[email protected]",
            "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
        },
        "createdAt": "2024-03-26T15:16:28.5731434Z",
        "updatedBy": {
            "type": "Link",
            "relatedType": "User",
            "id": "[email protected]",
            "uri": "<BASE_URL>/api/content/v1/users/[email protected]"
        },
        "updatedAt": "2024-03-26T21:07:11.4681771Z",
        "publishedBy": null,
        "publishedAt": null
    }
}

Delete a content item

Use this method to delete a content item with a specific ID. If the content item is published, you must unpublish it first. This request deletes a content item with the ID a16GWyfJiEO-pXkecaCFdQ.

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location --request DELETE '<BASE_URL>/api/content/v1/items/qwvfY-ilvkOez14S7Li-gQ' \
--header 'Authorization: <BEARER_TOKEN>'

Publish a content item

Use this method to publish a content item with a specific ID. This request publishes a content item with the ID -fAJSB0BwEW0OaOmxYS06w.

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location --request POST '<BASE_URL>/api/content/v1/items/-fAJSB0BwEW0OaOmxYS06w/publish' \
--header 'Accept: text/plain' \
--header 'Authorization: <BEARER_TOKEN>' 

Unpublish a content item

Use this method to unpublish a content item with a specific ID. This request publishes a content item with the ID -fAJSB0BwEW0OaOmxYS06w.

RequestResponse
// [!code word:<BASE_URL>] 
// [!code word:<BEARER_TOKEN>] 

curl --location --request DELETE '<BASE_URL>/api/content/v1/items/-fAJSB0BwEW0OaOmxYS06w/publish'
 \--header 'Accept: text/plain' \
--header 'Authorization: <BEARER_TOKEN>'

Do you have some feedback for us?

If you have suggestions for improving this article,