legacy-knowledge-base
公開されました Sep. 10, 2025

How to retrieve Collection elements by the Collection's name using headless APIs

written-by

David Simon

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

Issue

  • Using Liferay's headless-delivery API, is it possible retrieve the elements of a Collection (called a ContentSet in APIs) based on the Collection's name?

Environment

  • Liferay DXP 2026.Q1+

Resolution

  • Headless Delivery APIs at 2026.q1.0+ can retrieve a collection's elements by its key instead of its ID:
    • GET /o/headless-delivery/v1.0/sites/{siteId}/content-sets/by-key/{key}/content-set-elements. 
  • Liferay creates the key from the collection's title by making it lowercase and replacing spaces with dashes (for example, "My Collection" becomes my-collection). If another collection in the site already has that key, Liferay adds a numeric suffix. 

Additional Information

  • Because the key comes from the name, it is the same in every environment where you create the collection with the same title (assuming no duplicate titles), so you can store it in an environment variable. Renaming the collection generates a new key.
  • You can also use External Reference Codes (ERCs) as stable identifiers across multiple environments.
did-this-article-resolve-your-issue

legacy-knowledge-base