Payload CMS icon

Payload CMS

Consume the Payload CMS REST API

Actions5

Overview

This node integrates with the Payload CMS REST API to manage entries within collections. Specifically, for the "Collection" resource and the "Get Many" operation, it retrieves multiple entries from a specified collection. This is useful when you want to fetch a list of documents stored in a Payload CMS collection, such as retrieving all blog posts, products, or user profiles.

Practical examples include:

  • Fetching all articles from a "blogPosts" collection to display on a website.
  • Retrieving a limited number of product entries from an e-commerce catalog.
  • Getting user data entries for processing or reporting.

Properties

Name Meaning
Collection Slug The unique slug identifier of the collection in Payload CMS from which to retrieve data.
Return All Whether to return all entries in the collection or limit the number of results returned.
Limit Maximum number of entries to return if not returning all (only applicable if Return All is false).

Output

The output is an array of JSON objects, each representing a single entry/document retrieved from the specified collection. The structure of each JSON object corresponds directly to the fields defined in the Payload CMS collection schema.

If the collection contains multiple entries, the node outputs them as individual items in the main output array.

No binary data output is produced by this operation.

Dependencies

  • Requires an active connection to a Payload CMS instance via its REST API.
  • Needs an API authentication token or key configured in n8n credentials to authorize requests.
  • Uses a helper function to make HTTP requests to the Payload CMS API endpoints.

Troubleshooting

  • Common issues:

    • Incorrect or missing collection slug will result in failed API calls or empty results.
    • Insufficient permissions or invalid API credentials can cause authorization errors.
    • Setting "Return All" to true on very large collections may lead to long execution times or timeouts.
  • Error messages:

    • Unknown operation getAll: Indicates the operation parameter was not recognized; ensure "Get Many" is selected.
    • API request failures typically return HTTP error codes; check credentials and collection slug validity.
  • Resolutions:

    • Verify the collection slug matches exactly what is configured in Payload CMS.
    • Confirm API credentials are valid and have appropriate access rights.
    • Use the "Limit" property to restrict the number of entries fetched if performance issues occur.

Links and References

Discussion