Content Delivery API
Get started with the Content Delivery API.
The Content Delivery API delivers headless capabilities built directly into Umbraco. It allows you to retrieve your content items in a JSON format and use your preferred technology to present them in different channels.
The feature preserves a friendly editing experience in Umbraco while ensuring a performant delivery of content in a headless fashion. With the different extension points, you can tailor the API to fit a broad range of requirements.
Getting Started
The Delivery API is an opt-in feature in Umbraco. It must be explicitly enabled through configuration before it can be utilized.
Enable the Content Delivery API
When creating your project, you can enable the Delivery API using the --use-delivery-api or -da flag. This will automatically add the necessary configuration to your project.
dotnet new umbraco -n MyProject -daYou can also enable the Delivery API at a later point by following these steps:
Open your project's
appsettings.json.Insert the
DeliveryApiconfiguration section underUmbraco:CMS.Add the
Enabledkey and set its value totrue.Open
Program.CsAdd
.AddDeliveryApi()tobuilder.CreateUmbracoBuilder()
{
"Umbraco": {
"CMS": {
"DeliveryApi": {
"Enabled": true
}
}
}
}builder.CreateUmbracoBuilder()
.AddBackOffice()
.AddWebsite()
.AddDeliveryApi()
.AddComposers()
.Build();
Once the Content Delivery API is enabled, the next step is to rebuild the Delivery API content index (DeliveryApiContentIndex). This can be done using the Examine Management dashboard in the Settings section of the Umbraco Backoffice.
Access the Umbraco Backoffice.
Navigate to the Settings section.
Open the Examine Management dashboard.
Click the DeliveryAPIContentIndex.

Scroll down and click the Rebuild index button.

Once the index is rebuilt, the API can serve the latest content from the multiple-items endpoint.
Additional configuration
When the Delivery API is enabled in your project, all your published content will be made available to the public by default.
A few additional configuration options will allow you to restrict access to the Delivery API endpoints and limit the content returned.
{
"Umbraco": {
"CMS": {
"DeliveryApi": {
"Enabled": true,
"PublicAccess": true,
"ApiKey": "my-api-key",
"DisallowedContentTypeAliases": ["alias1", "alias2", "alias3"],
"RichTextOutputAsJson": false
}
}
}
}Find a description of each of the configuration keys in the table below.
PublicAccess
Determines whether the enabled Delivery API should be publicly accessible or if access should require an API key.
ApiKey
Specifies the API key needed to authorize access to the API when public access is disabled. This setting is also used to access draft content for preview.
DisallowedContentTypeAliases
Contains the aliases of the content types that should never be exposed through the Delivery API, regardless of any other configurations.
RichTextOutputAsJson
Enable outputting rich text content as JSON rather than the default HTML output. JSON can be a preferred format in many scenarios, not least because it supports the routing of internal links better than HTML does.
Concepts
Before exploring the API endpoints detailed below, there are a few concepts to know.
Endpoints
The Delivery API output can represent a specific content item or a paged list of multiple items.
Gets a content item by id
GET /umbraco/delivery/api/v2/content/item/{id}
Returns a single item.
Path Parameters
id*
String
GUID of the content item.
Query Parameters
expand
String
Which properties to expand and therefore include in the output if they refer to another piece of content.
fields
String
Which properties to include in the response. All properties are included by default.
Headers
Accept-Language
String
Requested culture.
Api-Key
String
Access token.
Preview
Boolean
Whether draft content is requested.
Start-Item
String
URL segment or GUID of the root content item.
200: OK
Content item.
401: Unauthorized
Missing permissions after protection is set up.
404: Not Found
Content item not found.
Gets a content item by route
GET /umbraco/delivery/api/v2/content/item/{path}
Returns a single item.
Path Parameters
path*
String
Path of the content item.
Query Parameters
expand
String
Which properties to expand and therefore include in the output if they refer to another piece of content.
fields
String
Which properties to include in the response. All properties are included by default.
Headers
Accept-Language
String
Requested culture.
Api-Key
String
Access token.
Preview
Boolean
Whether draft content is requested.
Start-Item
String
URL segment or GUID of the root content item.
200: OK
Content item.
401: Unauthorized
Missing permissions after protection is set up.
404: Not Found
Content item not found.
Gets content item(s) by id
GET /umbraco/delivery/api/v2/content/items
Returns single or multiple items by id.
Query Parameters
id*
String Array
GUIDs of the content items.
expand
String
Which properties to expand in the response.
fields
String
Which properties to include in the response. All properties are included by default.
Headers
Accept-Language
String
Requested culture.
Api-Key
String
Access token.
Preview
Boolean
Whether draft content is requested.
Start-Item
String
URL segment or GUID of the root content item.
200: OK
Content item.
401: Unauthorized
Missing permissions after protection is set up.
Gets content item(s) from a query
GET /umbraco/delivery/api/v2/content
Returns single or multiple items.
Query Parameters
fetch
String
Structural query string option (e.g. ancestors, children, descendants).
filter
String Array
Filtering query string options (e.g. contentType, name, createDate, updateDate).
sort
String Array
Sorting query string options (e.g. createDate, level, name, sortOrder, updateDate).
skip
Integer
Amount of items to skip.
take
Integer
Amount of items to take.
expand
String
Which properties to expand and therefore include in the output if they refer to another piece of content.
fields
String
Which properties to include in the response. All properties are included by default.
Headers
Accept-Language
String
Requested culture.
Api-Key
String
Access token.
Preview
Boolean
Whether draft content is requested.
Start-Item
String
URL segment or GUID of the root content item.
200: OK
Content item.
401: Unauthorized
Missing permissions after protection is set up.
404: Not Found
Content item not found.
All endpoints are documented in a Swagger document at {yourdomain}/umbraco/swagger. This document is not available in production mode by default. For more information read the API versioning and OpenAPI article.
Query parameters
The Content Delivery API provides query parameters that allow you to customize the content returned by the API. The relevant query parameters for each endpoint are already specified in the corresponding documentation above.
In addition to standard parameters like skip and take, the API provides different possibilities for the value of the expand, fields, fetch, filter and sort parameters. Below are the options that are supported out of the box.
?expand=properties[$all]
All expandable properties on the retrieved content item will be expanded.
?expand=properties[alias1]
A specific expandable property with the property alias alias1 will be expanded.
?expand=properties[alias1,alias2,alias3]
Multiple expandable properties with the specified property aliases will be expanded.
?expand=properties[alias1[properties[nestedAlias1,nestedAlias2]]]
The property with the property alias alias1 will be expanded, and likewise the properties nestedAlias1 and nestedAlias2 of the expanded alias1 property.
?fields=properties[$all]
Includes all properties of the retrieved content item in the output.
?fields=properties[alias1]
Includes only the property with the property alias alias1 in the output.
?fields=properties[alias1,alias2,alias3]
Includes only the properties with the specified property aliases in the output.
?fields=properties[alias1[properties[nestedAlias1,nestedAlias2]]]
Includes only the property with the property alias alias1 in the output. If this property is expanded, only the properties nestedAlias1 and nestedAlias2 of the expanded alias1 property are included.
You can apply a selector option to the /umbraco/delivery/api/v2/content endpoint to query content items based on their structure. The selector allows you to fetch different subsets of items based on a GUID or path of a specific content item. The Delivery API will search all available content items if no fetch parameter is provided. The following built-in selectors can be used out of the box:
?fetch=ancestors:id/path
All ancestors of a content item specified by either its id or path will be retrieved.
?fetch=children:id/path
All immediate children of a content item specified by either its id or path will be retrieved.
?fetch=descendants:id/path
All descendants of a content item specified by either its id or path will be retrieved.
For example, the following API call will attempt to retrieve all the content items that are directly below an item with the id dc1f43da-49c6-4d87-b104-a5864eca8152:
Request
GET /umbraco/delivery/api/v2/content?fetch=children:dc1f43da-49c6-4d87-b104-a5864eca8152The filter query parameter allows you to specify one or more filters. These filters must match for a content item to be included in the response. The API provides a few built-in filters that you can use right away with the /umbraco/delivery/api/v2/content endpoint:
?filter=contentType:alias
This filter restricts the results to content items that belong to the specified content type. Replace alias with the alias of the content type you want to filter by.
?filter=name:nodeName
Only content items whose name matches the specified value will be returned when this filter is applied. Replace nodeName with the name of the item that you want to filter by.
?filter=createDate>date
Only content items created later than the specified value will be returned when this filter is applied. Replace date with the date that you want to filter by.
?filter=updateDate>date
Only content items updated later than the specified value will be returned when this filter is applied. Replace date with the date that you want to filter by.
Multiple filters can be applied to the same request in addition to other query parameters:
Request
GET /umbraco/delivery/api/v2/content?filter=contentType:article&filter=name:guide&skip=0&take=10This technique can also be used to perform range filtering. For example, fetch articles created in 2023:
Request
GET /umbraco/delivery/api/v2/content?filter=contentType:article&filter=createDate>:2023-01-01&filter=createDate<2024-01-01&skip=0&take=10Specifying how the results should be ordered, can be achieved using the sort query option. You can use this parameter to sort the content items by fields, including create date, level, name, sort order, and update date. For each field, you can specify whether the items should be sorted in ascending (asc) or descending (desc) order. Without a sort query parameter, the order of the results will be determined by the relevance score of the DeliveryApiContentIndex for the search term.
?sort=createDate:asc/desc
An option to sort the results based on the creation date of the content item in either asc or desc order.
?sort=level:asc/desc
An option to sort the results based on the level of the content item in the content tree in either asc or desc order.
?sort=name:asc/desc
An option to sort the results based on the name of the content item in either asc or desc order.
?sort=sortOrder:asc/desc
An option to sort the results based on the sort order of the content item in either asc or desc order.
?sort=updateDate:asc/desc
An option to sort the results based on the last update date of the content item in either asc or desc order.
Different sorting options can be combined for the /umbraco/delivery/api/v2/content endpoint, allowing for more advanced sorting functionality. Here is an example:
Request
GET /umbraco/delivery/api/v2/content?sort=name:asc&sort=createDate:ascExtension points
The Delivery API has been designed for extensibility, offering multiple extension points that provide greater flexibility and customization options. These extension points allow you to tailor the API's behavior and expand its capabilities to meet your specific requirements.
You can find detailed information about the specific areas of extension in the articles below:
Handling deeply nested JSON output
.NET imposes a limit on the depth of object nesting within rendered JSON. This is done to detect cyclic references. Learn more about it in the official .NET API docs.
If the limit is exceeded, .NET will throw a JsonException.
The content models might be so deeply nested that the Delivery API produces JSON that exceeds this limit. If this happens, the JsonException will be logged and shown in the Umbraco log viewer.
To handle this we have to change the limit. Since the Delivery API has its own JSON configuration, we can do so without affecting the rest of our site.
Add the following
usingstatements toProgram.cs:
using Umbraco.Cms.Api.Common.DependencyInjection;
using Umbraco.Cms.Core;Add the following code snippet to the
Program.csfile:
builder.Services.AddControllers().AddJsonOptions(
Constants.JsonOptionsNames.DeliveryApi,
options =>
{
// set the maximum allowed depth of
options.JsonSerializerOptions.MaxDepth = {desired max depth}
});Current Limitations
The Content Delivery API provides a powerful and flexible way to retrieve content from the Umbraco CMS. There are, however, certain limitations to be aware of.
In this section, we will discuss some of the known limitations of the API, and how to work around them if necessary.
Protected content
The Delivery API supports protected content and member authentication. This is an opt-in feature. You can read more about it in the Protected Content in the Delivery API article.
If member authentication is not explicitly enabled, protected content is ignored and never exposed by the Delivery API.
As a result, lifting protection from a content item requires an additional step to ensure it becomes accessible through the Delivery API. The recommended way is to publish the content item again. Alternatively, you can manually rebuild the DeliveryApiContentIndex to reflect the changes.
Property editors
Certain limitations are associated with some of the built-in property editors in Umbraco. These limitations are listed below.
Rich Text Editor
Internal links may be insufficient in a multi-site setup when outputting the Rich Text Editor content as HTML (the default format). There is a possibility that this limitation may be addressed in future updates. However, consider the alternative approach to rendering the Rich Text Editor content as JSON.
Member Picker
The Member Picker property editor is not supported in the Delivery API to avoid the risk of leaking member data.
Content Picker
The Content Picker property editor is not supported in the Delivery API when configured for Members. This is due to the concern of potentially leaking member data.
Making changes to DisallowedContentTypeAliases
DisallowedContentTypeAliasesWhen changing the content type aliases in the Umbraco:CMS:DeliveryApi:DisallowedContentTypeAliases configuration setting, DeliveryApiContentIndex should be rebuilt. This ensures that disallowed content types are not exposed through the Delivery API.
Alternatively, the relevant content items can be republished. This will ensure that changes are reflected, eliminating the need to rebuild the index.
Last updated
Was this helpful?