Delivery API

This page describes the Delivery endpoint for obtaining JCR data as JSON.

This REST resource is highly customizable. You can define multiple endpoint configurations to serve different needs. Each configured endpoint is accessed through a distinct endpointPath property and provides three methods. The methods, called with HTTP GET, allow you to read a node (and its subnodes) by a given path, get children of a node and query nodes.

To help you configure and try out the delivery scenarios mentioned on this page, we:

  • Use delivery as part of the endpoint path. Our webapps come with a pre-configured user role called rest-anonymous, which allows anonymous users to access the /.rest/delivery/* path.

  • Set the bypassWorkspaceAcls property to true in all endpoint configurations.

Otherwise, you would have to use the Security app and configure an access control list for the anonymous user to be able to access the nodes inside the various workspaces the delivery scenarios utilize.

Methods

Sending a request to a URI that ends with just the endpointPath invokes the Query nodes method. It is irrelevant if you add the trailing slash (/) or omit the slash to the endpointPath:

GET <magnolia-base-path>/.rest/endpointPath/

GET <magnolia-base-path>/.rest/endpointPath

Read node

Query parameters can only be used with the Query nodes method.

To further restrict content delivery with either the Read node or the Get children method, you must adjust the endpoint definition through the endpoint configuration properties in the Yaml configuration file.

Returns one node by a given path including its properties and child nodes down to a certain depth. Child nodes are returned in the natural order.

Request URL

GET <magnolia-base-path>/.rest/endpointPath/{path}

Parameters
Parameter Description Data type

path

required

The path relative to the rootPath defined in the configuration.

String

Example

Get all component nodes of the main area of the /travel/about page.

curl "http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/travel/about/main"

Response

{
    "@name": "main",
    "@path": "/travel/about/main",
    "@id": "f3b2681f-e747-4ff6-bcbb-2a9a9f01553e",
    "@nodeType": "mgnl:area",
    "00": {
        "@name": "00",
        "@path": "/travel/about/main/00",
        "@id": "01db6fc1-78af-4284-adf0-8c997309df6a",
        "@nodeType": "mgnl:component",
        "text": "<p>We are a full service, independent travel agency.</p>\n<p>We offer unique tours from every continent on the planet. Get inspired and book your tour with us for an experience you’ll always remember.</p> ",
        "imagePosition": "below",
        "headlineLevel": "small",
        "headline": "About Magnolia Travels",
        "@nodes": [
        ]
    },
    "04": {
        "@name": "04",
        "@path": "/travel/about/main/04",
        "@id": "834ef0b0-1519-4834-b1f5-4166ae004ac0",
        "@nodeType": "mgnl:component",
        "layout": "8x4",
        "@nodes": [
        ]
    },
    "@nodes": [
        "00",
        "04"
    ]
}

This result is returned for the following configuration:

$type: jcrDeliveryEndpoint_v2
workspace: website
bypassWorkspaceAcls: true
depth: 2
nodeTypes:
 - mgnl:area
childNodeTypes:
 - mgnl:component

Get children

Query parameters can only be used with the Query nodes method.

To further restrict content delivery with either the Read node or the Get children method, you must adjust the endpoint definition through the endpoint configuration properties in the Yaml configuration file.

This method is a special variant of the read node method. It uses the @nodes handle to retrieve child nodes of a path in a configured endpoint. To use the handle, append it to the path of a URI:

Request URL

GET <magnolia-base-path>/.rest/endpointPath/{path}@nodes

The items in the response are returned in their natural (unsorted) order. See also the orderBy parameter in the query nodes method.

Examples

Get child nodes in the root of the <myEndpoint> endpoint:
curl "http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/@nodes"

Response

[
    {
        "@name": "travel",
        "@path": "/travel",
        "@id": "b06b82a2-74b0-4994-8015-028c4fd60716",
        "@nodeType": "mgnl:page",
        "position": "bottom",
        "header": "Cookies are used on this website!",
        "layout": "block",
        "readMoreLinkexternal": "https://cookiesandyou.com/",
        "description": "Magnolia Travels is a demonstration project for Magnolia CMS. Browse the site to get an overview of Magnolia CMS features, and learn how to edit the content online. Or download the project and dig into the sources to learn the key templating features of Magnolia CMS.",
        "link": "Learn more ...",
        "title": "Travel Home",
        "dismiss": "Got it!",
        "bannerbackground": "#000",
        "deny": "Decline cookies",
        "message": "This website uses cookies to ensure you get the best experience on our website.",
        "readMoreLink": "external",
        "complianceType": "info",
        "buttontext": "#fff",
        "buttonbackground": "#ef6155",
        "hideInNav": "false",
        "searchResultPage": "6df1ebd8-fc9d-4db3-8539-02829c56b9f2",
        "allow": "Allow cookies",
        "keywords": "Magnolia CMS, Open Source CMS, Content management, Demonstration project, Demo project, Demo, Online demo, Website builder",
        "@nodes": [
        ]
    },
    {
        "@name": "sportstation",
        "@path": "/sportstation",
        "@id": "5f26a93e-9d21-4231-9e60-c8edbb0d339d",
        "@nodeType": "mgnl:page",
        "hideInNav": "false",
        "description": "Magnolia Travels is a demonstration project for Magnolia CMS. Browse the site to get an overview of Magnolia CMS features, and learn how to edit the content online. Or download the project and dig into the sources to learn the key templating features of Magnolia CMS.",
        "title": "Sportstation",
        "keywords": "Magnolia CMS, Open Source CMS, Content management, Demonstration project, Demo project, Demo, Online demo, Website builder",
        "@nodes": [
        ]
    }
]

This result is returned for the endpoint called <myEndpoint> with the following configuration:

$type: jcrDeliveryEndpoint_v2
workspace: website
bypassWorkspaceAcls: true
nodeTypes:
 - mgnl:page
Get child nodes in the root of the /travel page:
curl "http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/travel/@nodes"

Response

[
    {
        "@name": "tour-type",
        "@path": "/travel/tour-type",
        "@id": "05872876-073e-40a3-a3c5-0d0a18c1d43d",
        "@nodeType": "mgnl:page",
        "hideInNav": "false",
        "navigationTitle": "Tours",
        "title": "Tour Types",
        "@nodes": [
        ]
    },
    {
        "@name": "destination",
        "@path": "/travel/destination",
        "@id": "028a4a92-35df-45a3-b6ff-58381db74eb5",
        "@nodeType": "mgnl:page",
        "hideInNav": "false",
        "title": "Destinations",
        "@nodes": [
        ]
    },
    {
        "@name": "tour",
        "@path": "/travel/tour",
        "@id": "af4cd608-2dda-4535-a5e0-703ef92fd45a",
        "@nodeType": "mgnl:page",
        "hideInNav": "true",
        "title": "Tour detail",
        "@nodes": [
        ]
    },
    {
        "@name": "stories",
        "@path": "/travel/stories",
        "@id": "f8cbedd6-df91-4d7c-a952-2dc414d97704",
        "@nodeType": "mgnl:page",
        "title": "Stories",
        "@nodes": [
        ]
    },
    {
        "@name": "about",
        "@path": "/travel/about",
        "@id": "808ebe4c-72b2-49f1-b9f7-e7db22bce02f",
        "@nodeType": "mgnl:page",
        "hideInNav": "false",
        "title": "About",
        "@nodes": [
        ]
    },
    {
        "@name": "contact",
        "@path": "/travel/contact",
        "@id": "53b073cc-ea3a-4e44-bdea-8c8a790b55c5",
        "@nodeType": "mgnl:page",
        "hideInNav": "false",
        "title": "Contact",
        "@nodes": [
        ]
    },
    {
        "@name": "meta",
        "@path": "/travel/meta",
        "@id": "7ebd74f1-c6f7-4307-9953-afd549118a56",
        "@nodeType": "mgnl:page",
        "hideInNav": "true",
        "title": "Container for meta pages",
        "@nodes": [
        ]
    },
    {
        "@name": "book-tour",
        "@path": "/travel/book-tour",
        "@id": "60e1aa3e-23d6-4200-ad28-20c3b969ab89",
        "@nodeType": "mgnl:page",
        "hideInNav": "true",
        "title": "Book your tour",
        "@nodes": [
        ]
    },
    {
        "@name": "members",
        "@path": "/travel/members",
        "@id": "39257043-9524-49a8-bcf2-934ac797eddf",
        "@nodeType": "mgnl:page",
        "hideInNav": "false",
        "description": "Exclusive content, tips and special discounts for registered members.",
        "title": "Members",
        "@nodes": [
        ]
    },
    {
        "@name": "tour-finder",
        "@path": "/travel/tour-finder",
        "@id": "d25e69d9-27d0-4477-824c-7cc0714c97ce",
        "@nodeType": "mgnl:page",
        "hideInNav": "true",
        "title": "Tour Finder",
        "@nodes": [
        ]
    },
    {
        "@name": "tour-tag",
        "@path": "/travel/tour-tag",
        "@id": "a045a2d0-7b1c-466c-88bc-28352749959c",
        "@nodeType": "mgnl:page",
        "hideInNav": "true",
        "title": "Tagged tours",
        "@nodes": [
        ]
    }
]

This result is returned for the endpoint called <myEndpoint> with the following configuration:

$type: jcrDeliveryEndpoint_v2
workspace: website
bypassWorkspaceAcls: true
nodeTypes:
 - mgnl:page

Query nodes

Returns a list of nodes matching a query composed of the query parameters provided. You can also apply filters to the query.

Request URL

GET <magnolia-base-path>/.rest/endpointPath?param1=value1&param2=value2&…​

Use any of the optional query parameters or none.
Parameters

The parameters below are query parameters.

The <filter> option is not a parameter but acts as a filter for the response of the operation.
Parameter Description Data type

q

optional

A search phrase (full-text search).

The search ignores word fragments. For example, if the content contains better, but not bet, then requesting q=bet won’t return anything.

To include the content with better, use either the verbatim form (q=better) or a fragment with the asterisk wildcard character (q=bet*). The latter may, however, return not only the expected better, but also other content that matches the asterisked pattern, such as beta, betray, between, and so on.

The request returns a query exception if the search phrase only contains a wildcard character as in q=*, for example.

String

orderBy

optional

The properties by which to order the nodes. As of Magnolia 6.2.6, sorting is case-insensitive.

The result may be returned either in the ascending ( asc ) order or in the descending ( desc ) order. The ascending order is applied if the direction is not set.

Example

mgnl:lastModified desc,title asc

Special characters such as a space ( ) must be encoded when sent in an HTTP request. When using tools to generate a REST request, this may happen automatically. With simple cURL you must encode it manually or with an additional tool.
Example

orderBy=title%20desc

Up to Magnolia 5.6.5, the results provided by the endpoint were sorted alphabetically on node names (same as with the ORDER BY LOWER(NAME(t)) statement in the JCR-SQL2 query) even though no orderBy parameter was set in the request URL.

The results are returned unsorted if no orderBy parameter is set. This however does not mean "in natural order" since many other aspects may be involved, such as the setting of the respectDocumentOrder property or index consistency.

String

offset

optional

The start position in a result list (for pagination). Default is 0.

Integer

limit

optional

The number of nodes displayed in a page query. Use together with offset for pagination.

Integer

version

optional

Allows you to retrieve and view a specific version of a content item.

Example

Let there be a page /fldr/pg1 which can be accessed via the <myEndpoint> endpoint.

Provided two versions, 1.0 and 1.1, exist for the page, you can use the following URLs to request the versions 1.0 and 1.1, respectively:

  • https://<domain>>/<webapp>/.rest/delivery/<myEndpoint>/fldr/pg1?version=1.0

  • https://<domain>>/<webapp>/.rest/delivery/<myEndpoint>/fldr/pg1?version=1.1

String

<filter>

optional

There are multiple filter options to filter for a property of the node, for node names, for nodes which must be ancestors of a given path, and so on. You can combine filters with an AND operator.

Result count and pagination metadata

To make it easier to implement a comprehensive pagination behavior on the client, version 2.2.12 and higher of the REST module prefixes each REST response with three metadata properties informing about the total number of results (total) and the current pagination values (offset and limit).

Example response (truncated)

{
	"total": 36,
	"offset": 0,
	"limit": 50,
	"results": [{
		"@name": "Kyoto",
		"@path": "/magnolia-travels/Kyoto",
		"@id": "b475f27e-2929-427b-9517-815118a3b36e",
		"@nodeType": "mgnl:content",
		"name": "Kyoto",
		"description": "The natural side of Japan",
		"location": "Kyoto, Japan",
		...
	}]
}

Filters

queryNodes provides a filtering mechanism. Filters are added as request parameters. Filter values must be properly URL-encoded. You can use multiple filters within the same request.

Filter format

The filter parameter has the following format: property[operator]=value

Example filter used in a URL
http://localhost:8080/magnoliaAuthor/.rest/my-endpoint?description[like]=%25demonstration%25

In some REST clients, you may need to URL-encode also the key in the filter parameter. For example: http://localhost:8080/magnoliaAuthor/.rest/my-endpoint?description%5Blike%5D=%25demonstration%25

See also the RFC standard called Uniform Resource Identifier (URI): Generic Syntax (https://tools.ietf.org/html/rfc3986#section-2.2)

Filtering

Filter operators

Apart from ilike, all the other operators are case-sensitive.
Operator Meaning

eq

=

ne

<>

gt

>

lt

<

lte

gte

>=

in

IN

not-in

NOT IN

like

Can be used with:

% (percentage, URL encoded as %25)

_ (underscore)

LIKE

Can be used with:

Percentage - Wildcard character that can be used in the search pattern to mean zero or more additional characters.

Underscore - Wildcard character that can be used in the search pattern to stand for any single character.

To search for these wildcard characters literally, place the \ (URL-encoded as %5C) backslash escape character in front of them:

description[like]=\%
description%5Blike%5D=%5C%25
description[like]=\_
description%5Blike%5D=%5C_

ilike

Same as LIKE but case-insensitive.

null

NULL

The value can be either true or false.

For example, sending mgnl:created[null]=false is equivalent to issuing mgnl:created IS NOT NULL in JCR query.

The operator can be used with any property.

Filter types

Property Description

Property filter

Filter for a node property. The property value must be an exact match.

author=Magnolia%20Travels

@name property filter

Filter by a node name.

@name=travel

@path filter

Filter by a path.

@path=/travel/about/careers/

Only the eq (equal, default behavior) and ne (not equal, @path[ne]=/travel/about/careers/) operators can be used in the @path filter.

The like operator cannot be used since it is not supported by the underlying JCR implementation.

@jcr:uuid filter

Filter by the JCR node ID (uuid). The property value must be an exact match.

@jcr:uuid=<id>

@ancestor filter

Find nodes for which the path provided is the ancestor. The path must be absolute in the given workspace of the given workspace prefix.

@ancestor=/travel/about/careers

Usage notes

  • If no operator is provided, eq is used by default.

  • The value in the filter parameter is treated as String.

  • Use brackets to pass an operator, for example [eq], [ne], [lt], and so on.

  • For in and not-in, a range symbol ~ (the tilde) should be provided, for example:

    http://localhost:8080/magnoliaAuthor/.rest/<myEndpoint>?mgnl:created[in]=2015-12-01~2015-12-31
  • Ranges are inclusive: price[in]=100~200 is interpreted as price >= 100 AND price ⇐ 200.

  • For filtering by date and time, only two ISO 8601-based formats are accepted. The patterns shown are in JAVA notation (java.text.SimpleDateFormat):

    • Date: yyyy-MM-dd

      2018-01-01
    • Datetime: yyyy-MM-dd’T’HH:mm:ss.SSSXXX

      2018-01-11T10:26:47.438+07:00
  • If a filter can take multiple possible values which must match, use the | (OR) operator.

    @name=travel|about

    Make sure the operator is always properly URL-encoded for REST requests, either with the --data-urlencode flag when sent using the curl command or directly through the percent-encoding method:

    @name=travel%7Cabout


Filtering on specific languages

To get REST results for a specific language, specify a language suffix in the search query. See the below examples in the context of three apps in the Magnolia Demo bundle:

  • Tours app

  • Pages app

  • Stories app

Retrieving language variants (Tours app)

Content in the Tours app (stored in the tours workspace) is available both in English and in German, with English being the default language for the site.

Searching for Erleben in the content of the body properties of the workspace by sending a query such as:

http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/?body[like]=%Erleben%

yields no results since Erleben is present only in the German content variant:

image

In the search query you need specify the language by appending - in this case - the _de suffix to the body property and re-send

http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/?body_de[like]=%Erleben%

instead. Only this will return a result (click the link to expand to see the actual result):

Response

{
    "results": [
        {
            "@name": "Kyoto",
            "@path": "/magnolia-travels/Kyoto",
            "@id": "b475f27e-2929-427b-9517-815118a3b36e",
            "@nodeType": "mgnl:content",
            "name": "Kyoto",
            "description": "The natural side of Japan",
            "location": "Kyoto, Japan",
            "tourTypes": [
                "d2245867-ecaa-4b4e-8743-e0c939be68b7",
                "415025c6-e4b5-4506-9384-34f428a52104"
            ],
            "author": "Magnolia Travels",
            "body": "<p>Experience the still beauty that permeates and surrounds Kyoto. Kyoto is famous for many things, including countless <a href=\"http://www.japan-guide.com/e/e2058.html\" style=\"text-decoration:none;\" target=\"_blank\"><u>temples</u></a>, <a href=\"http://www.japan-guide.com/e/e2059.html\" style=\"text-decoration:none;\" target=\"_blank\"><u>shrines</u></a> and other fascinating historical buildings.</p>\n<p>Join us on a visit to the City of Ten Thousand Shrines. We'll visit Tō-ji, Ginkaku-ji, Kōzan-ji and their remarkable gardens before venturing into the mountains that surround the city. You’ll enjoy a day spent in green Miyama and a day hiking in Shizuhara. You’ll never think about Japan in the same way again.</p> ",
            "destination": [
                "7ec72c48-c33f-418e-b2ff-44cfb4bbb1f2"
            ],
            "duration": "7",
            "image": "jcr:44689d29-5966-4d41-8fd4-2dc7da783528",
            "@nodes": [
            ]
        }
    ]
}

This result is returned for the endpoint called <myEndpoint> with the following configuration:

$type: jcrDeliveryEndpoint_v2
workspace: tours
bypassWorkspaceAcls: true

Notice that in spite of searching within body_de the content in the output is in English. This is caused by sending the en value in the Content-Language header sent along with the query. To obtain a response with content in German, you would need to append &lang=de to the query.

If you try to find the English equivalent (Experience), you must not specify the _en suffix since English is the site’s default language. Using this suffix in the query returns an empty result set:

{"results":[]}
There’s no property body_en present in the tours workspace.
Alternatively, try searching with a more general search query such as ?q=Erleben which will also return a response where Erleben appears in the JCR (endpoint configuration is same as the one above):

Response

{
  "results": [{
    "@name": "North-Sea-Islands",
    "@path": "/magnolia-travels/North-Sea-Islands",
    "@id": "a2a00b27-7e39-4230-8c79-3ffc5a678a15",
    "@nodeType": "mgnl:content",
    "name": "North Sea Islands",
    "description": "At the mercy of the sea",
    "location": "Hamburg, Germany",
    "tourTypes": ["e007e401-1bf8-4658-8293-b9c743784264", "d2245867-ecaa-4b4e-8743-e0c939be68b7"],
    "author": "Magnolia Travels",
    "body": "<p>Off Germany’s coast in the North Sea lie the remote, romantic Halligen islands. Here, you’ll experience a unique environment and way of life shaped by the tides. Houses here are built on meter high man-made hills called Warften to keep them above the sea-floods - known here as Land Unter. The islands are traced with tiny canals to drain the water after storms. But the locals, some 400 people, have also installed dams to let the silt settle out of the water. They must rely on this to slowly build up the height of the islands. It’s like a slow-motion race against erosion and rising oceans. Speaking of slow - you’ll have plenty of opportunity to enjoy the island pastimes like the local card game (also called Land Unter), flying kites, or just wandering the wind-buffeted pastures, lightly populated with happy sheep and contented cows.</p>\n<p>Our trip will include walks on the extensive salt coated mudflats of this <a href=\"http://www.germany.travel/en/towns-cities-culture/unesco-world-heritage/the-wadden-sea.html\" style=\"text-decoration:none;\" target=\"_blank\"><u>World Heritage</u></a> nature reserve, where you’ll be able to observe some rare birdlife. We’ll discover many other fascinating critters, like ants that have adapted to build special nests that can withstand the periodic flooding. The broken remnants of houses and household goods to be found on the flats are a reminder of the elemental forces which shape the islands, and our tenuous relationship with them.</p> ",
    "destination": ["6cc50e28-fb0e-4e49-b3b6-728690a2e861"],
    "duration": "7",
    "image": "jcr:7f3cbb8f-a909-47da-b678-543ce6f244b9",
    "@nodes": []
  }, {
    "@name": "Lapland-for-Families",
    "@path": "/magnolia-travels/Lapland-for-Families",
    "@id": "705051cb-c0c3-43b2-b5fa-c571b5d5d2d4",
    "@nodeType": "mgnl:content",
    "isFeatured": "true",
    "name": "Lapland for Families",
    "description": "Your own Arctic Circle adventure",
    "location": "Kittilä, Finland",
    "tourTypes": ["415025c6-e4b5-4506-9384-34f428a52104", "17da160b-da66-4e09-9e31-5fd040880f4a"],
    "author": "Magnolia Travels",
    "body": "<p>Enjoy a family winter adventure in Lapland, Sweden where sledding, husky sledding and ice skating are all on the menu. We lend you toboggans for sledding, and there are gentle hills right outside your cabin. For something more adventurous, join our ‘crazy slope’ days out. Children will love the chance to drive their own sled, and snowballs and snowmen are possible any time of the day. You’ll also get the chance to experience the spectacular Northern Lights.</p>\n<p><br /> At Christmas time, children can also join visits to Santa and his famous grotto, going on a unique snowmobile journey to see where Santa manages all his toy operations.</p> ",
    "destination": ["ee483660-15cd-490d-b709-884b3f130286"],
    "duration": "7",
    "image": "jcr:71b9a58b-3c78-41bd-9fe4-17ce0f3b5dd4",
    "@nodes": []
  }, {
    "@name": "Kyoto",
    "@path": "/magnolia-travels/Kyoto",
    "@id": "b475f27e-2929-427b-9517-815118a3b36e",
    "@nodeType": "mgnl:content",
    "name": "Kyoto",
    "description": "The natural side of Japan",
    "location": "Kyoto, Japan",
    "tourTypes": ["d2245867-ecaa-4b4e-8743-e0c939be68b7", "415025c6-e4b5-4506-9384-34f428a52104"],
    "author": "Magnolia Travels",
    "body": "<p>Experience the still beauty that permeates and surrounds Kyoto. Kyoto is famous for many things, including countless <a href=\"http://www.japan-guide.com/e/e2058.html\" style=\"text-decoration:none;\" target=\"_blank\"><u>temples</u></a>, <a href=\"http://www.japan-guide.com/e/e2059.html\" style=\"text-decoration:none;\" target=\"_blank\"><u>shrines</u></a> and other fascinating historical buildings.</p>\n<p>Join us on a visit to the City of Ten Thousand Shrines. We'll visit Tō-ji, Ginkaku-ji, Kōzan-ji and their remarkable gardens before venturing into the mountains that surround the city. You’ll enjoy a day spent in green Miyama and a day hiking in Shizuhara. You’ll never think about Japan in the same way again.</p> ",
    "destination": ["7ec72c48-c33f-418e-b2ff-44cfb4bbb1f2"],
    "duration": "7",
    "image": "jcr:44689d29-5966-4d41-8fd4-2dc7da783528",
    "@nodes": []
  }, {
    "@name": "Jordan-s-Pearls",
    "@path": "/magnolia-travels/Jordan-s-Pearls",
    "@id": "3351f7b2-e67b-4dbd-a6c6-7394eaf86d36",
    "@nodeType": "mgnl:content",
    "isFeatured": "false",
    "name": "Jordan’s Pearls",
    "description": "Seeking the crossroads of civilizations ",
    "location": "Amman, Jordan",
    "tourTypes": ["e007e401-1bf8-4658-8293-b9c743784264"],
    "author": "Magnolia Travels",
    "body": "<p>This trip will give you a deep insight into the Middle East, allowing you to not only experience its rich and ancient heritage, but also to get a glimpse into daily life. The trip starts by flying into Amman, capital of Jordan. Shortly outside the city, we’ll take you to visit the breath-taking UNESCO world heritage site of Petra, an ancient city carved into the red rock by Nabateans. It is one of the world’s most important archaeological sites.</p>\n<p>From there, we’ll go by road to Jerash, often called the ‘Pompeii of the East’. The ancient Roman ruins at Jerash are famous for their remarkable state of preservation.</p> ",
    "destination": ["79da73f7-900b-4c91-b58b-3b1355485519"],
    "duration": "7",
    "image": "jcr:2b51aaf3-dc5a-4012-89e5-d3b3dd6c08cb",
    "@nodes": []
  }]
}
For i18n features to work correctly, check that the fallback site has locales configured or extends a site definition with desired locales.

Retrieving language variants (Pages app)

You can also use all as the value of the lang property to retrieve all language variants of content. Compare below the three requests and responses issued against the <myEndpoint> endpoint configured as follows:

$type: jcrDeliveryEndpoint_v2
workspace: website
bypassWorkspaceAcls: true
rootPath: /travel/book-tour/

nodeTypes:
 - mgnl:page

lang set to all

http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/?lang=all

Response

{
    "results": [
        {
            "@name": "meal",
            "@path": "/travel/book-tour/meal",
            "@id": "9b8ea1b2-a93f-4015-a822-84d730ca982a",
            "@nodeType": "mgnl:page",
            "hideInNav": "true",
            "title": "Meal",
            "title_de": "Menü",
            "@nodes": [
            ]
        },
        {
            "@name": "review",
            "@path": "/travel/book-tour/review",
            "@id": "17680c5a-82b2-49e8-b078-186b1ab9284d",
            "@nodeType": "mgnl:page",
            "hideInNav": "true",
            "title": "Review",
            "title_de": "Überprüfung",
            "@nodes": [
            ]
        },
        {
            "@name": "personal-details",
            "@path": "/travel/book-tour/personal-details",
            "@id": "829ee1ee-4a74-4fca-8dc1-87f473eedd32",
            "@nodeType": "mgnl:page",
            "hideInNav": "true",
            "title": "Personal details",
            "title_de": "Persönliche Angaben",
            "@nodes": [
            ]
        }
    ]
}

lang not set

http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/

Response

{
    "results": [
        {
            "@name": "meal",
            "@path": "/travel/book-tour/meal",
            "@id": "9b8ea1b2-a93f-4015-a822-84d730ca982a",
            "@nodeType": "mgnl:page",
            "hideInNav": "true",
            "title": "Meal",
            "@nodes": [
            ]
        },
        {
            "@name": "review",
            "@path": "/travel/book-tour/review",
            "@id": "17680c5a-82b2-49e8-b078-186b1ab9284d",
            "@nodeType": "mgnl:page",
            "hideInNav": "true",
            "title": "Review",
            "@nodes": [
            ]
        },
        {
            "@name": "personal-details",
            "@path": "/travel/book-tour/personal-details",
            "@id": "829ee1ee-4a74-4fca-8dc1-87f473eedd32",
            "@nodeType": "mgnl:page",
            "hideInNav": "true",
            "title": "Personal details",
            "@nodes": [
            ]
        }
    ]
}

lang set to de

http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/?lang=de

Response

{
    "results": [
        {
            "@name": "meal",
            "@path": "/travel/book-tour/meal",
            "@id": "9b8ea1b2-a93f-4015-a822-84d730ca982a",
            "@nodeType": "mgnl:page",
            "hideInNav": "true",
            "title": "Menü",
            "@nodes": [
            ]
        },
        {
            "@name": "review",
            "@path": "/travel/book-tour/review",
            "@id": "17680c5a-82b2-49e8-b078-186b1ab9284d",
            "@nodeType": "mgnl:page",
            "hideInNav": "true",
            "title": "Überprüfung",
            "@nodes": [
            ]
        },
        {
            "@name": "personal-details",
            "@path": "/travel/book-tour/personal-details",
            "@id": "829ee1ee-4a74-4fca-8dc1-87f473eedd32",
            "@nodeType": "mgnl:page",
            "hideInNav": "true",
            "title": "Persönliche Angaben",
            "@nodes": [
            ]
        }
    ]
}

Retrieving language variants (Stories app)

Internationalization of content is supported also in the Stories app and its parent — the Content Editor module (version 2.1 and later).

In the following example, sample English and German content is retrieved from an abbreviated story using the lang=all query parameter and the following endpoint configuration:

$type: jcrDeliveryEndpoint_v2
workspace: stories
depth: 2
bypassWorkspaceAcls: true

nodeTypes:
- mgnl:composition
childNodeTypes:
- mgnl:contentNode
- mgnl:block
http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/?lang=all

Response

{
    "results": [
        {
            "@name": "lost-and-found-in-swiss-alps",
            "@path": "/stories-demo/lost-and-found-in-swiss-alps",
            "@id": "07d3a126-2882-4329-802a-357ae2e1aeeb",
            "@nodeType": "mgnl:composition",
            "authorBio_de": "Der Engländer und begeisterte Bergsteiger Richard Douglas bloggt regelmäßig über seine Streifzüge durch die Natur. Sein jüngster Beitrag hat einen düsteren Unterton, denn er schreibt einige letzte Worte an seine Frau Margaret.",
            "stories": [
            ],
            "embedimage": "jcr:602d9a8a-4411-4239-a738-3cd98a483931",
            "location": "Birmingham, UK",
            "tours": [
            ],
            "title": "Losing and finding myself in the Swiss Alps",
            "authorBio": "Englishman and mountaineering enthusiast Richard Douglas blogs regularly about his forays into nature. His most recent post takes on darker overtones as he pens some last words to his wife Margaret.",
            "embedsource": "<iframe src=\"https://player.vimeo.com/video/228199156?background=1\" class=\"responsive-element\" width=\"640\" height=\"360\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> ",
            "location_de": "Birmingham, Großbritannien",
            "author": "Richard Douglas",
            "created": "2017-02-16T14:29:00.000Z",
            "author_de": "Richard Douglas",
            "lead_de": "Lieber M., hier ist ein Geständnis. Habe ich dir jemals erzählt, dass ich mein ganzes Leben lang Angst hatte? Angst vor den Herausforderungen, davor, den Anforderungen nicht gewachsen zu sein. Angst davor, zu versagen und zu scheitern. Mit Angst kommt man nicht sehr weit, also habe ich versucht, mich von dieser Angst zu befreien. Deshalb habe ich mich auf Aktivitäten eingelassen, die mich bis an meine Grenzen brachten. Erinnerst du dich an den November, als wir ein Wochenende in Zermatt verbrachten? Ich war einen Tag vor dir dort.",
            "visualType": "embed",
            "authorImage": "jcr:fba1c915-94d5-45b7-9e59-686fd0f3fad4",
            "lead": "Dear M, Here’s a confession. Did I ever tell you that I’ve been afraid all my life? Afraid of the challenges, of just not being up to it. Afraid of failing and falling down. Being afraid doesn’t get you very far, so I sought to rid myself of this fear. That’s why I took up those activities that pushed me to the edge of my limits. Remember that November when we spent a weekend in Zermatt? I was there a day before you joined me. ",
            "title_de": "Sich verlieren und wiederfinden in den Schweizer Alpen",
            "authorImage_de": "jcr:fba1c915-94d5-45b7-9e59-686fd0f3fad4",
            "blocks": {
                "@name": "blocks",
                "@path": "/stories-demo/lost-and-found-in-swiss-alps/blocks",
                "@id": "64716970-d237-4e46-b080-1fb8f93395c2",
                "@nodeType": "mgnl:contentNode",
                "1": {
                    "@name": "1",
                    "@path": "/stories-demo/lost-and-found-in-swiss-alps/blocks/1",
                    "@id": "7f3ea561-269a-4d3c-8906-8e596d5eeda0",
                    "@nodeType": "mgnl:block",
                    "text": "<p>I started off in the late morning with the train from Bern to Zermatt. I had a hangover from four beers the previous night - simply drank too much after those nights of abstinence while being on-call. All my gear was stashed in a large backpack, and a group of Swiss asked me if I was going to the Matterhorn.</p>",
                    "@nodes": [
                    ]
                },
                "2": {
                    "@name": "2",
                    "@path": "/stories-demo/lost-and-found-in-swiss-alps/blocks/2",
                    "@id": "f1412a64-00d6-48cf-b582-c5264ac100a1",
                    "@nodeType": "mgnl:block",
                    "text": "<p>My plan was to head for the Schönbielhütte (2694m) and spend the night there. The hut would not be manned in winter, but would be a resting place. The route takes about four hours and runs parallel to the north face of the Matterhorn along a lake and glacier towards the hut. It’s an easy trail in summer, but this was November. Still, the snow was not high as I started off in the mid-afternoon and made good progress.</p>",
                    "@nodes": [
                    ]
                },
                "@nodes": [
                    "1",
                    "2"
                ]
            },
            "blocks_de": {
                "@name": "blocks_de",
                "@path": "/stories-demo/lost-and-found-in-swiss-alps/blocks_de",
                "@id": "203f5169-b08e-42f4-83af-69ca54f30ac2",
                "@nodeType": "mgnl:contentNode",
                "0_de": {
                    "@name": "0_de",
                    "@path": "/stories-demo/lost-and-found-in-swiss-alps/blocks_de/0_de",
                    "@id": "b82beee3-3318-4fa4-81ed-22d3120152c9",
                    "@nodeType": "mgnl:block",
                    "text": "<p>Ich begann am späten Vormittag mit dem Zug von Bern nach Zermatt. Ich hatte einen Kater von vier Bieren in der Nacht zuvor - ich hatte einfach zu viel getrunken nach den Nächten der Abstinenz während des Bereitschaftsdienstes. Meine gesamte Ausrüstung war in einem großen Rucksack verstaut, und eine Gruppe von Schweizern fragte mich, ob ich auf das Matterhorn wolle.</p>",
                    "@nodes": [
                    ]
                },
                "1_de": {
                    "@name": "1_de",
                    "@path": "/stories-demo/lost-and-found-in-swiss-alps/blocks_de/1_de",
                    "@id": "ffdd5556-2f25-478e-a71f-cd0e8f5ad1e8",
                    "@nodeType": "mgnl:block",
                    "text": "<p>Mein Plan war, zur Schönbielhütte (2694m) zu gehen und dort zu übernachten. Die Hütte würde im Winter nicht besetzt sein, aber ein Rastplatz sein. Der Weg dauert etwa vier Stunden und führt parallel zur Nordwand des Matterhorns entlang eines Sees und Gletschers zur Hütte. Im Sommer ist es ein einfacher Weg, aber es war November. Trotzdem war der Schnee nicht hoch, als ich am späten Nachmittag aufbrach und gut vorankam.</p>",
                    "@nodes": [
                    ]
                },
                "@nodes": [
                    "0_de",
                    "1_de"
                ]
            },
            "@nodes": [
                "blocks",
                "blocks_de"
            ]
        }
    ]
}

Retrieving personalized content

For more details about this topic, see Requesting personalized content with the delivery endpoint.

Filtering examples

We assume you are familiar with cURL. Note that cURL requires URL encoding.

We go through a few examples below:

Example Description

Example A

Find webpages in the Travel Demo which were last modified before or on June 12, 2024.

Example B

Find webpages with the word Customer in the title.

Example C

Find all site nodes for which /travel/about/careers is the ancestor.

Example D

Find nodes in the tours workspace that contain the keyword beach.

Example E

Find a tour with the word Japan in its description.

Example F

Letter case: Using the like and ilike operators.

See tools to test REST requests for other possibilities.

Example A

Find webpages in the Travel Demo which were last modified before or on June 12, 2024:

curl 'http://localhost:8080/magnoliaAuthor/.rest/delivery//?mgnl:lastModified[lte]=2024-06-12' --globoff
By using the option --globoff you can specify URLs that contain the letters \{}[] without having them being interpreted by cURL itself.

Endpoint: <myEndpoint>

$type: jcrDeliveryEndpoint_v2
workspace: website
bypassWorkspaceAcls: true
rootPath: /
nodeTypes:
 - mgnl:page
includeSystemProperties: true

Response

{
    "results": [
        {
            "@name": "meta",
            "@path": "/travel/meta",
            "@id": "7ebd74f1-c6f7-4307-9953-afd549118a56",
            "@nodeType": "mgnl:page",
            "jcr:createdBy": "admin",
            "hideInNav": "true",
            "mgnl:template": "travel-demo:pages/standard",
            "mgnl:lastActivatedBy": "superuser",
            "jcr:created": "2019-09-25T08:49:30.320+02:00",
            "mgnl:lastActivated": "2019-09-25T08:49:35.482+02:00",
            "mgnl:created": "2015-02-02T20:58:23.939+01:00",
            "mgnl:createdBy": "superuser",
            "title": "Container for meta pages",
            "mgnl:lastModified": "2015-06-03T20:37:49.283+02:00",
            "mgnl:activationStatus": "true",
            "mgnl:lastModifiedBy": "superuser",
            "@nodes": [
            ]
        }
    ]
}

Example B

Find webpages with the word Customer in the title.

curl -g -G "http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>" --data-urlencode "title[like]=%Customer%"
Use --data-urlencode and -g -G to encode the request parameter values, if required.

Endpoint: <myEndpoint>

$type: jcrDeliveryEndpoint_v2
workspace: website
bypassWorkspaceAcls: true
rootPath: /
nodeTypes:
 - mgnl:page

Response

{
    "results": [
        {
            "@name": "customer-experience-agent",
            "@path": "/travel/about/careers/customer-experience-agent",
            "@id": "1f8af166-258f-4351-a543-3d0fc8bb00c0",
            "@nodeType": "mgnl:page",
            "hideInNav": "false",
            "title": "Customer Experience Agent",
            "@nodes": [
            ]
        },
        {
            "@name": "customer-experience-supervisor",
            "@path": "/travel/about/careers/customer-experience-supervisor",
            "@id": "c8e6902a-499a-44d7-9de9-45fd93d60a6b",
            "@nodeType": "mgnl:page",
            "hideInNav": "false",
            "title": "Customer Experience Supervisor",
            "@nodes": [
            ]
        }
    ]
}

Example C

Due to the use of a wildcard character in the URL with the [like] filter the number of results can potentially be higher. In the website workspace, find all nodes for which /travel/about/careers is the ancestor:

curl 'http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/?@ancestor=/travel/about/careers'

Endpoint: <myEndpoint>

$type: jcrDeliveryEndpoint_v2
workspace: website
bypassWorkspaceAcls: true
rootPath: /
nodeTypes:
 - mgnl:page

Response

{
    "results": [
        {
            "@name": "customer-experience-agent",
            "@path": "/travel/about/careers/customer-experience-agent",
            "@id": "1f8af166-258f-4351-a543-3d0fc8bb00c0",
            "@nodeType": "mgnl:page",
            "hideInNav": "false",
            "title": "Customer Experience Agent",
            "@nodes": [
            ]
        },
        {
            "@name": "marketing-associate",
            "@path": "/travel/about/careers/marketing-associate",
            "@id": "f19c60f2-3049-4883-a170-4bf65e3abb91",
            "@nodeType": "mgnl:page",
            "hideInNav": "false",
            "title": "Marketing Associate",
            "@nodes": [
            ]
        },
        {
            "@name": "customer-experience-supervisor",
            "@path": "/travel/about/careers/customer-experience-supervisor",
            "@id": "c8e6902a-499a-44d7-9de9-45fd93d60a6b",
            "@nodeType": "mgnl:page",
            "hideInNav": "false",
            "title": "Customer Experience Supervisor",
            "@nodes": [
            ]
        }
    ]
}

Example D

Find nodes in the tours workspace that contain the keyword beach. Return the results in descending order based on the location property and restrict the number of results to two:

curl 'http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>/?q=beach&orderBy=location%20desc&limit=2'

Endpoint: <myEndpoint>

$type: jcrDeliveryEndpoint_v2
workspace: tours
bypassWorkspaceAcls: true

Response

{
    "results": [
        {
            "@name": "Beach-Paradise-in-Brazil",
            "@path": "/magnolia-travels/Beach-Paradise-in-Brazil",
            "@id": "545d5815-a3dd-4b68-a539-c38eb1bba29b",
            "@nodeType": "mgnl:content",
            "isFeatured": "true",
            "name": "Beach Paradise in Brazil",
            "description": "An Amazonian beach holiday",
            "location": "São Luís, Brasil",
            "tourTypes": [
                "082c340c-b062-4b15-86b8-96dd9deff680"
            ],
            "author": "Magnolia Travels",
            "body": "<p>When you hear “Amazon”, you probably think of a deep jungle. Well, this remarkably well hidden beach paradise is right in the middle of it. Alter do Chão lies on Rio Tapajós, a tributary to the mighty Amazon, which is so wide here that you can’t even see across to the far shore. There’s plenty of nature to explore in the area on foot, but the inlet to the lake is also covered with cosy beach restaurants and bars, perfect for a post swim chill out. </p>\n<p>No fear of crocodiles here, but there are some sting rays to watch out for. You’ll start your adventure on the two-day boat ride from Manaus (capital of the Amazon) to Santarém, but be sure to bring your own hammock (and some rope) or just some extra coins for the bar!</p>\n<p>While you’re here, you’ll discover there’s much more to do than hanging out at the glorious beaches. The town lies at the entrance to the Lago Verde lagoon, home to many Amazon animals, and the perfect place to do a canoe trip. We also include tours to the beautiful Floresta Nacional do Tapajós and Rio Arapiuns.</p> ",
            "destination": [
                "bed2e297-199c-4dc8-90cd-54ad3cb4221b"
            ],
            "duration": "14",
            "image": "jcr:950cc73c-1b12-4f2a-bba7-97ad9d171f5d",
            "@nodes": [
            ]
        },
        {
            "@name": "West-Coast---Highway-101",
            "@path": "/magnolia-travels/West-Coast---Highway-101",
            "@id": "730c8850-d638-4e91-b3fb-4041a0c59ffe",
            "@nodeType": "mgnl:content",
            "name": "West Coast - Highway 101",
            "description": "Family travels in USA",
            "location": "Seattle, USA",
            "tourTypes": [
                "17da160b-da66-4e09-9e31-5fd040880f4a"
            ],
            "author": "Magnolia Travels",
            "body": "<p>Imagine walking in the footsteps of the explorers, missionaries, and soldiers who made America what it is today. Discover the famous El Camino Real (The Royal Road) based on the old trail which linked the Spanish Missions, Pueblos and Presidios.</p>\n<p>We'll kick off in Seattle and head south into Oregon and finally to California where we'll hit the beaches on California Highway 1. The trip will be infused with history and fabulous scenery, but there’ll be lots of time for fun, with some great beach activities at the end of the trip.</p> ",
            "destination": [
                "ed3dcd18-78af-46df-a9e1-bc732479f2e7"
            ],
            "duration": "7",
            "image": "jcr:d44f783c-91ca-4b48-9533-ea4e147e13e9",
            "@nodes": [
            ]
        }
    ]
}

Example E

Find a tour with the word Japan in its description. Return only the variant in the German language:

curl -g -G 'http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>?lang=de-DE' --data-urlencode "description[like]=%Japan%"
We use --data-urlencode to encode one of the request parameters, whereas the one that does not require encoding is added to the URL directly.

Endpoint: <myEndpoint>

$type: jcrDeliveryEndpoint_v2
workspace: tours
bypassWorkspaceAcls: true

Response

{
    "results": [
        {
            "@name": "Kyoto",
            "@path": "/magnolia-travels/Kyoto",
            "@id": "b475f27e-2929-427b-9517-815118a3b36e",
            "@nodeType": "mgnl:content",
            "name": "Kyoto",
            "description": "Die natürliche Seite Japans",
            "location": "Kyoto, Japan",
            "tourTypes": [
                "d2245867-ecaa-4b4e-8743-e0c939be68b7",
                "415025c6-e4b5-4506-9384-34f428a52104"
            ],
            "author": "Magnolia Travels",
            "body": "<p>Erleben Sie die Schönheit, die Kyoto durchdringt und umgibt. Kyoto ist berühmt für viele Dinge, darunter unzählige <a href=\"http://www.japan-guide.com/e/e2058.html\" target=\"_blank\">Tempel</a>, <a href=\"http://www.japan-guide.com/e/e2059.html\" target=\"_blank\">Schreine</a> und andere faszinierende historische Bauwerke.</p>\n<p>Kommen Sie mit uns auf einen Besuch der Stadt der zehntausend Schreine. Wir besuchen To-ji, Ginkaku-ji, Kōzan-ji und ihre bemerkenswerten Gärten, bevor wir einen Abstecher zu den Bergen in der Umgebung der Stadt machen. Sie werden es genießen, einen Tag im grünen Miyama und einen Tag mit Wandern in Shizuhara zu verbringen. Sie werden nie wieder wie bisher über Japan denken.</p> ",
            "destination": [
                "7ec72c48-c33f-418e-b2ff-44cfb4bbb1f2"
            ],
            "duration": "7",
            "image": "jcr:44689d29-5966-4d41-8fd4-2dc7da783528",
            "@nodes": [
            ]
        }
    ]
}

Example F

This example shows the difference between using the like and ilike operators.

Suppose you have the following three tours in your content app:

Three example Tours listed in the Tours app

The like and ilike operators will work as follows in example requests for tours with "families" in their names.

Endpoint: <myEndpoint>

$type: jcrDeliveryEndpoint_v2
workspace: tours
bypassWorkspaceAcls: true

The case-sensitive like does not return anything:

curl -g -G 'http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>' --data-urlencode "name[like]=%families%"

Response

{
  "total": 0,
  "offset": 0,
  "limit": 10,
  "results": []
}

The case-insensitive ilike does, however:

curl -g -G 'http://localhost:8080/magnoliaAuthor/.rest/delivery/<myEndpoint>' --data-urlencode "name[ilike]=%families%"

Response

{
  "total": 3,
  "offset": 0,
  "limit": 10,
  "results": [
    {
      "@name": "France-for-Families",
      "@path": "/tours/France-for-Families",
      "@id": "3f4e050b-17bc-4ae2-ae50-a114d536168f",
      "@nodeType": "mgnl:content",
      "name": "France for Families",
      "description": "Discover why its world’s most visited country",
      "location": "Paris, France",
      "tourTypes": [
        "17da160b-da66-4e09-9e31-5fd040880f4a"
      ],
      "author": "Magnolia Travels",
      "body": "<p>France is the most popular tourist destination in the world, and it&rsquo;s no surprise. Paris never fails to delight visitors with its magical atmosphere, romantic cruises and breathtaking architecture. Magnolia Travels brings you the magic of France, but takes you away from the usual touristic places to experience real French life too. You&rsquo;ll start your tour with a trip up the Eiffel Tower - you simply have to do it! But then we take you to stay in Provins, a beautiful medieval town only one hour from Paris. We&rsquo;ll take you to some authentic French caf&eacute;s and restaurants, away from the hustle and bustle. There&rsquo;s also an optional day trip to Disneyland Paris for little (and big) kids who can&rsquo;t resist.</p>\n<p>France for families offers many wonderful add on options, including: a week cruising on the Dordogne, horseriding in Normandy, castles and beaches of La Vend&eacute;e.</p> ",
      "destination": [
        "6cc50e28-fb0e-4e49-b3b6-728690a2e861"
      ],
      "duration": 14,
      "image": "jcr:090eb9c4-b35b-4869-a12f-6ea80292cba4",
      "@nodes": []
    },
    {
      "@name": "Lapland-for-Families",
      "@path": "/tours/Lapland-for-Families",
      "@id": "705051cb-c0c3-43b2-b5fa-c571b5d5d2d4",
      "@nodeType": "mgnl:content",
      "isFeatured": true,
      "name": "Lapland for Families",
      "description": "Your own Arctic Circle adventure",
      "location": "Kittilä, Finland",
      "tourTypes": [
        "415025c6-e4b5-4506-9384-34f428a52104",
        "17da160b-da66-4e09-9e31-5fd040880f4a"
      ],
      "author": "Magnolia Travels",
      "body": "<p>Enjoy a family winter adventure in Lapland, Sweden where sledding, husky sledding and ice skating are all on the menu. We lend you toboggans for sledding, and there are gentle hills right outside your cabin. For something more adventurous, join our &lsquo;crazy slope&rsquo; days out. Children will love the chance to drive their own sled, and snowballs and snowmen are possible any time of the day. You&rsquo;ll also get the chance to experience the spectacular Northern Lights.</p>\n<p><br /> At Christmas time, children can also join visits to Santa and his famous grotto, going on a unique snowmobile journey to see where Santa manages all his toy operations.</p> ",
      "destination": [
        "ee483660-15cd-490d-b709-884b3f130286"
      ],
      "duration": 7,
      "image": "jcr:71b9a58b-3c78-41bd-9fe4-17ce0f3b5dd4",
      "@nodes": []
    },
    {
      "@name": "Belize-for-Families",
      "@path": "/tours/Belize-for-Families",
      "@id": "3dc158ce-fa92-4eab-a060-3f65d467b9ab",
      "@nodeType": "mgnl:content",
      "isFeatured": true,
      "name": "Belize for Families",
      "description": "See Belize through the eyes of your children",
      "location": "Belize City, Belize",
      "tourTypes": [
        "17da160b-da66-4e09-9e31-5fd040880f4a"
      ],
      "author": "Magnolia Travels",
      "body": "<p>Located between Mexico and Guatemala in the heart of Central America, Belize&#39;s natural beauty will take your breath away. Our &lsquo;Belize for Families&rsquo; trip will set pulses racing for any active family. A week isn&rsquo;t really enough to discover the rainforest, reefs and ruins of Belize, but we&rsquo;ll certainly try. Your family will have the chance to try out scuba diving on Belize&rsquo;s barrier reef, as well as go caving in the limestone Cayo District.</p> ",
      "destination": [
        "bed2e297-199c-4dc8-90cd-54ad3cb4221b"
      ],
      "duration": 7,
      "image": "jcr:f90c8094-542d-4037-a4f5-dcd634fd0393",
      "@nodes": []
    }
  ]
}

Configuration

Endpoint path

You can define multiple endpoints. At runtime, the endpoint path for each endpoint is generated automatically from the path and name of the respective endpoint definition.

Examples
File path Endpoint path

/<module-name>/restEndpoint/stories.yaml

/.rest/stories

/<module-name>/restEndpoint/delivery/stories.yaml

/.rest/delivery/stories

/<module-name>/restEndpoint/stories/v3.yaml

/.rest/stories/v3

/<module-name>/restEndpoint/delivery/stories_v3.yaml

/.rest/delivery/stories/v3

Location of the endpoint definitions

Magnolia REST endpoint definitions are true Magnolia Resources. You can create them in:

  • a light module

  • a Magnolia Maven module

  • in the JCR configuration workspace, if you use the JCR v2 REST API (info.magnolia.rest.delivery.jcr.v2.JcrDeliveryEndpointDefinition).

In a light module

Add configurations to the folder restEndpoints or to subfolders.

my-light-module/
└── restEndpoints
    ├── delivery
    │ └── another-endpoint.yaml
    └── my-endpoint.yaml

In a Magnolia Maven module

Add configurations to the folder resources/my-maven-module/restEndpoints or to subfolders.

my-maven-module/
└── src
    └── main
        └── resources
            └── my-maven-module
                └── restEndpoints
                    ├── delivery
                    │ └── johns-endpoint.yaml
                    └── larrys-endpoint.yaml

Best practice

Put the delivery endpoint configurations under the delivery subfolder.

Properties

Property Description

$type

required (don’t set if class is set)

Specifies the endpoint type.

Possible values:

  • jcrDeliveryEndpoint_v2

    Pre-configured endpoint type to create JSON v2 responses.

  • jcrPagesDeliveryEndpoint_v2

    Pre-configured endpoint type for pages to create JSON v2 responses and support component autogeneration and inheritance.

    This endpoint type has pre-configured properties equal to the following definition:

    class: info.magnolia.rendering.spa.rest.v2.JcrPagesDeliveryEndpointDefinition
    workspace: website
    depth: 100
    personalized: true
    
    systemProperties:
      - mgnl:template
    
    nodeTypes:
      - mgnl:page
      - mgnl:component
      - mgnl:area
    
    childNodeTypes:
      - mgnl:area
      - mgnl:component
jcrDeliveryEndpoint_v2 must be set if you want to use inheritance and/or autogeneration of components.

class

required (don’t set if $type is set)

Specifies the endpoint type.

Possible values:

  • info.magnolia.rest.delivery.jcr.v2.JcrDeliveryEndpointDefinition

    Pre-configured endpoint type to create JSON v2 responses.

  • info.magnolia.rendering.spa.rest.v2.JcrPagesDeliveryEndpointDefinition

    Pre-configured endpoint type for pages to create JSON v2 responses and support component autogeneration and inheritance.

  • A subclass of info.magnolia.rest.delivery.jcr.v2.JcrDeliveryEndpointDefinition.

workspace

required

Name of the target workspace to serve content from.

rootPath

optional

Defines the root path used to resolve the given node path parameter and to execute queries.

properties

optional (By default, a response includes all properties, including metadata.)

List of properties to return.

Except for reference resolving, the list can be configured:

  • in the endpoint definition,

  • as querystring params,

  • in both ways.

In this case, the response includes the properties matching the intersection of the two lists.

For reference resolver configurations:

  • The list can’t be set as querystring params. It must be configured in the endpoint definition.

  • A property list defined at the top level of an endpoint configuration doesn’t apply to the reference resolver configuration (if present), where you need to specify a property list separately.

Querystring usage example
curl "http://localhost:8080/magnoliaAuthor/.rest/<myEndpoint>?q=about&properties=views,title"

See also below the excludeProperties property.

If both properties and excludeProperties are configured, the excludeProperties configuration is ignored.

Metadata (@-prefixed properties) can’t be specified.

excludeProperties

optional (By default, a response includes all properties, including metadata.)

List of properties to not return.

Except for reference resolving, the list can be configured:

  • in the endpoint definition,

  • as querystring params,

  • in both ways.

In this case, the response includes all properties not matching the concatenation of the two lists.

For reference resolver configurations:

  • The list can’t' be set as querystring params. It must be configured in the endpoint definition.

  • A property list defined at the top level of an endpoint configuration doesn’t apply to the reference resolver configuration (if present), where you need to specify a property list separately.

Querystring usage example
curl "http://localhost:8080/magnoliaAuthor/.rest/<myEndpoint>?q=about&excludeProperties=authors,contributors"

See also above the properties property.

If both properties and excludeProperties are configured, the excludeProperties configuration is ignored.

Metadata (@-prefixed properties) can’t be specified.

nodeTypes

optional

A list of allowed node types.

depth

optional

Defines the depth of child nodes to be included in the responses.

The depth is relative to result nodes.

strict

optional, default is false

Defines whether to include only the exact node type and ignore the sub types.

If true, then it is applied to both the nodeTypes and the childNodeTypes.

limit

optional, default is 10

Defines the number of results to be returned in a paginated result set.

maxLimit

optional, default is 100

The highest number of nodes a delivery endpoint may return when querying JCR with pagination.

references

optional

This property allows you to resolve referenced through a list of reference definitions.

The properties of a single reference are defined in info.magnolia.rest.reference.ReferenceDefinition.

For configuration of reference definitions, see the Properties for resolving references subsection below this table.

Example configuration

references:
  - name: tourTypeReference
    propertyName: tourTypes
    referenceResolver:
      $type: jcrReferenceResolver
      targetWorkspace: category

referenceDepth

optional, default is 1

Defines on how many levels the references should be considered and returned in a response if found.

referenceRepeat

optional, default is false

The default setting eliminates resolving self-references.

includeSystemProperties

optional, default is false

Defines whether jcr:- and mgnl:-prefixed properties will be included in responses.

systemProperties

optional

Defines which jcr:- and mgnl:-prefixed properties will be included in responses.

bypassWorkspaceAcls

optional, default is false

If set to true, JCR security is bypassed. Use this property with care and for development purposes only.

Defines whether workspace permissions (ACLs) should be evaluated.

This may be used to serve all content for the given workspace params to anonymous users until relevant JCR permissions are set up for the anonymous user.

The URI permissions are still evaluated. The rest-anonymous role has a GET permission set to /.rest/delivery/*.

personalized

optional, default is false

If set to true, the endpoint returns personalized content based on personalization traits and values defined in the request.

This is a DX Core feature provided by the magnolia-personalization-rest submodule.

timeToLive

optional

Defines the time-to-live (TTL) in seconds of the resources in the cache of the device that consumes it (a browser, for example).

It is used as the value of max-age of the cache-control response header.

Properties for resolving references

The references property node contains a list of reference definitions.

Property Description

name

optional

An arbitrary name. If you do not set the property, the first property must start with a - in order to have proper YAML list item.

Using the name property improves the readability of the YAML file.

nodeType

optional

The value must be a valid node type.

If set, references are resolved only on nodes of the given type.

propertyName

required

The value of this property contains the name of the JCR node property that stores one or multiple references to nodes of other workspaces.

referenceResolver

required

The reference resolver defines how references are resolved. The properties are defined in info.magnolia.rest.reference.ReferenceResolverDefinition.

Example configuration

...
    referenceResolver:
      $type: jcrReferenceResolver
      targetWorkspace: category
...

referenceResolver properties for resolving JCR node references

Property Description

$type

required

Must be jcrReferenceResolver.

targetWorkspace

required

The name of the workspace containing the nodes that are referenced.

expand

optional, default is true

If set to true, all properties of the referenced node are included in the JSON.

If false, the JSON contains only links to the referenced node. See generateLink below.

generateLink

optional, default is false

If true, the resolved node contains an additional link property. The value of the link property is a relative link to directly render the referenced node.

The format of the generated links depends on the configuration of the link generator (configured in config workspace at /server/rendering/linkManagement).

depthInReferencedNode

optional, default is 1

Sets the depth in the referenced nodes.

properties

optional

List of properties to return.

For configuration details, see Delivery API: Properties.

excludeProperties

optional

List of properties to not return.

For configuration details, see Delivery API: Properties.

referenceResolver properties for resolving asset references

Property Description

$type

required

Must be assetReferenceResolver.

expand

optional, default is true

If set to false, neither the list of defined renditions nor the meta data is shown.

If includeDownloadLink is set to true, a link is returned, otherwise the asset item key or original text is shown.

includeDownloadLink

optional, default is true

If set to false, the JSON file does not show the relative asset link.

includeAssetMetadata

optional, default is true

If set to false, metadata is not included.

assetRenditions

optional

A list of rendition names as defined in the theme linked to the current site.

     <rendition-name>

required

The rendition name.

To get the asset in its original (default) size, use original as the value.

If you add an undefined – and therefore non-existent rendition – the asset resolver creates a link to the default variation which is the same as the asset in its original size.

Example:

...
references:
  - name: referenceWithAsset
    propertyName: assetLink
    referenceResolver:
      $type: assetReferenceResolver
      assetRenditions:
        - 320x240
...
Property Description

$type

required

Must be richTextLinkReferenceResolver.

completeUrl

optional, default is true

The endpoint returns a full URL, using the value configured in server.defaultBaseUrl (see Configuration management).

If set to false, a relative link is returned instead, for example:

<p>Experience the still beauty that permeates and surrounds
 <a href=\"/magnoliaAuthor/dam/jcr:0a3bb34f-b49f-4e02-a9e9-e46cf860b612/kyoto.jpg\">Kyoto</a>.
 Kyoto is famous for many things,
Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the REST module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules