Delivery API

This page describes the delivery endpoint version 2 for obtaining JCR data as JSON. Version 2 was introduced with Magnolia REST 2.1 and provides more flexibility. You can use it to define multiple endpoint configurations, deliver localized content and resolve references to nodes of other workspaces including assets and asset renditions.

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

This section contains the following 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

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

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).

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.

Until version 2.2.14 of the REST module (released with Magnolia 6.2.20), the request URL had to be formed with preview in the path.

This is now deprecated.

You can use the delivery endpoint path instead, though the preview path will work too, until module version 3.0.0, where the preview endpoint will be removed completely.

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.

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.

Retrieving all references for a specific item

To retrieve all references for a specific content item, you must use the item’s UUID in the filter request.

  • With full UUID and = (or LIKE).

    {
      books(filter: "@authors = '33fd679b-048d-4732-b8c5-6ce432bfc630'") {
        title
        publish_date
      }
    }
  • With a truncated UUID and LIKE. Using the truncated form may lead to ambiguities.

    {
      books(filter: "@authors LIKE '%33fd679b%'") {
        title
        publish_date
      }
    }
    Response
    {
      "data": {
        "books": [
          {
            "title": "A Brief History of Time: From the Big Bang to Black Holes",
            "publish_date": "1988-01-01"
          },
          {
            "title": "God Created the Integers: The Mathematical Breakthroughs That Changed History",
            "publish_date": "2005-10-04"
          }
        ]
      }
    }

Filter types

Property Description

Property filter

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

author=Magnolia%20Travels

@name filter

Filter by a node name.

@name=travel
Only the eq and ne filter operators are supported for use with this property filter.

@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/marketing-associate

Usage notes on Filtering

  • 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:

JCR workspace

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 higher).

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

You can define multiple endpoints in this version of the delivery endpoint. The endpointPath property is used to access the different configured endpoints.

Example

restEndpoints/delivery/my-endpoint.yaml
$type: jcrDeliveryEndpoint_v2
workspace: website
limit: 25
depth: 2
includeSystemProperties: true
nodeTypes:
  - mgnl:page
childNodeTypes:
  - mgnl:area
  - mgnl:component
#references

Properties

Property Description

$type or class

required (only one of these properties can be set)

Specifies the endpoint.

Possible values:

  • $type: jcrDeliveryEndpoint_v2 or
    class: info.magnolia.rest.delivery.jcr.v2.ConfiguredJcrDeliveryEndpointDefinition

    Creates JSON v2 responses.

  • $type: jcrPagesDeliveryEndpoint_v2 or
    class: info.magnolia.rendering.spa.rest.v2.JcrPagesDeliveryEndpointDefinition

    Pre-configured endpoint for pages to create JSON v2 responses and support component autogeneration and inheritance.
    A subclass of info.magnolia.rest.delivery.jcr.v2.ConfiguredJcrDeliveryEndpointDefinition.

    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
jcrPagesDeliveryEndpoint_v2 must be set if you want to use inheritance and/or autogeneration of components.

As of the Magnolia 6.2.16 release, the class property is set to info.magnolia.rest.delivery.jcr.v2.ConfiguredJcrDeliveryEndpointDefinition by default.

Therefore, technically, there is no need to specify the class property, or even the $type property, introduced with Magnolia 6.2.35.

However, we mark the class and $type as required to avoid potentially breaking changes in new versions of the Delivery endpoint.

For easier readability of endpoint definitions, we recommend using $type instead of class.

endpointPath

optional

If the property is not set, the endpointPath is evaluated automatically.

If you set the property manually, it should not contain special characters to fit into a proper URL.

workspace

required

The name of the JCR workspace to deliver content from.

rootPath

optional, default is /

The root path of this endpoint.

The path information when requesting the endpoint is added to this path.

nodeTypes

optional, default is mgnl:content

A list of allowed node types for depth-0 nodes.

childNodeTypes

optional, default is mgnl:contentNode

A list of allowed node types for child 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 childNodeTypes.

depth

optional, default is 0

Specifies how deep the node tree will be traversed.

The default value (0) means that child nodes are excluded.

includeSystemProperties

optional, default is false

Specifies whether the result should show system properties.

systemProperties

optional

List of system properties that should be returned in the response.

You can specify the properties using a full property name, as seen on line 4 below, or using a wildcard character (line 5, to request for example mgnl:lastActivatedBy, mgnl:createdBy and so on):

<light-module>/restEndpoints/<myEndpoint>.yaml
$type: jcrDeliveryEndpoint_v2
workspace: tours
bypassWorkspaceAcls: true
systemProperties:
 - mgnl:tags
 - "*By"

The systemProperties property overrides the setting of the includeSystemProperties property. In the above example, the two system properties will be fetched even if the includeSystemProperties is left in the default false state.

limit

optional, default is 10

The number of nodes (of level 0) in the result. Used only in the queryNodes method.

The property can be overridden when calling queryNodes with a request parameter.

bypassWorkspaceAcls

optional, default is false

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

references

optional

This property allows you to resolve referenced nodes.

For image variations to be resolved correctly, make sure that the fallback site has theme variations configured or extends a site definition with desired variations.

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 into fully expanded nodes and thus creating reference cycles.

If a self-reference is found and the property is set to false, only the value of the @id property of the self-referencing node is returned instead. If set to true, the self-reference will be fully resolved.

personalized

optional, default is false

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

For more details, see the Requesting personalized content with the delivery endpoint page.
This is a DX Core feature provided by the magnolia-personalization-rest submodule.

The endpointPath property

The endpointPath is used to access a configured delivery endpoint.

<magnolia-base-path>/.rest/<endpointPath>/{path}
<magnolia-base-path>/.rest/<endpointPath>?query-parameters

The value of the endpointPath can be set as a property in the configuration. If you do not set the property manually, the system evaluates it automatically.

If you do not set the property in the configuration:

  • The value set by the system is the path of the configuration relative to the restEndpoints folder.

  • You can add _v$number to the YAML file name or JCR node name that defines the endpoint in order to add a version to the endpointPath evaluated by the system .

    Examples

YAML file location

endpointPath

my-module/restEndpoints/my-endpoint.yaml

my-endpoint

my-module/restEndpoints/delivery/another-endpoint.yaml

delivery/another-endpoint

my-module/restEndpoints/delivery/another-endpoint_v3.yaml

delivery/another-endpoint/v3

JCR node path in the configuration workspace endpointPath

/modules/my-custom-module/restEndpoints/super-endpoint

super-endpoint

/modules/my-custom-module/restEndpoints/delivery/mega-endpoint

delivery/mega-endpoint

/modules/my-custom-module/restEndpoints/delivery/mega-endpoint_v2

delivery/mega-endpoint/v2

Location of the endpoint definitions

Magnolia REST endpoint definitions are true Magnolia Resources. You can create them in a light module, in a Magnolia Maven module or in the JCR configuration workspace.

Best practice

Put the delivery endpoint configurations under the delivery subfolder.

This makes the endpoints easier to use because the default role rest-anonymous is already configured to allow web access to the .rest/delivery/* path.

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

In the JCR configuration workspace

Add configurations to the folder /modules/my-custom-module/restEndpoints or to subfolders.

RESTendpoints JCR configuration

Feedback

DX Core

×

Location

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

You are currently perusing through the DX Core docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules