Payload CMS icon

Payload CMS

Interact with Payload CMS collections and globals

Collection → Find

AI-generated

Summary

Fetch documents from a collection

Inputs

  • collection (required) — Choose the collection to operate on
  • depth — How deep to populate relationships
  • limit — Maximum number of documents to return
  • page — Page number for pagination
  • sort — Sort field (use - for descending, e.g., -createdAt)
  • where — Where clause for filtering (JSON format)
  • select — Fields to select (comma-separated)
  • locale — Locale for localized content
  • upload — Name of the binary property that contains the file to upload
  • query — Query parameters to add to the request url

Output shape

an array of document objects

Pagination via limit and page; optional fields may be omitted; errors are returned in an error envelope when continueOnFail is disabled

Examples

Example 1: Retrieve the first 10 documents from the "posts" collection, sorted by createdAt descending

collection: posts; limit: 10; sort: -createdAt

Example 2: Find all documents where "status" is "published" with a depth of 2

collection: articles; where: {"status":"published"}; depth: 2

Example 3: Fetch a single document by ID from the "pages" collection

collection: pages; documentId: 42

Links

Discussion