-
First clone the repo if you have not done so already
-
cd my-project && cp .env.example .envto copy the example environment variables. You'll need to add theDATABASE_URIfrom your Cloud project to your.envif you want to use S3 storage and the PostgreSQL database that was created for you. -
pnpm install && pnpm devto install dependencies and start the dev server -
open
http://localhost:3000to open the app in your browser
That's it! Changes made in ./src will be reflected in your app. Follow the on-screen instructions to login and create your first admin user. Then check out Production once you're ready to build and serve your app, and Deployment when you're ready to go live.
If you prefer to use Docker for local development instead of a local PostgreSQL instance, the provided docker-compose.yml file can be used.
To do so, follow these steps:
- Modify the
DATABASE_URIin your.envfile to URI of your selected DB - Modify the
docker-compose.ymlfile'sDATABASE_URIto match the above<dbname> - Run
docker-compose upto start the database, optionally pass-dto run in the background.
Collections are the defined entities of your CMS. See the Collections docs for details on how to extend this functionality.
-
Users are auth-enabled collections that have access to the admin panel.
For additional help, see the official Auth Example or the Authentication docs.
-
This is the uploads enabled collection. It features pre-configured sizes, focal point and manual resizing to help you manage your pictures.
Payload automatically configures REST endpoints for the defined collections
For example the User Collection will have the
/api/users for the GET request of all users
and /api/users/[id] will query specific users based on the id.
Payload CMS automatically generates RESTful API endpoints for each collection you define. These endpoints allow you to interact with your data using standard HTTP methods such as GET, POST, PUT, and DELETE.
How it works:
- Each collection (e.g., Users, Media, Posts) gets its own set of endpoints under
/api/<collection-slug>. - You can perform CRUD operations (Create, Read, Update, Delete) on your collections via these endpoints.
- Authentication and access control are handled automatically for protected collections.
Examples:
GET /api/usersβ Retrieve a list of all usersGET /api/users/[id]β Retrieve a specific user by their unique IDPOST /api/usersβ Create a new user (requires appropriate permissions)PUT /api/users/[id]β Update an existing userDELETE /api/users/[id]β Delete a user
You can use similar endpoints for other collections, such as Media or Posts:
GET /api/mediaβ List all media filesGET /api/postsβ List all posts
For more details, see the Payload REST API documentation.
Payload CMS supports powerful query parameters that allow you to add filtering, sorting, pagination, and other logic to your REST API requests. These parameters transform simple GET requests into sophisticated database queries.
Filtering with where
Use the where parameter to filter results based on field values:
GET /api/users?where[status][equals]=active
GET /api/posts?where[title][contains]=payload
GET /api/media?where[mimeType][like]=image%
Common operators:
equals- Exact matchnot_equals- Not equal tocontains- Text contains substringlike- SQL LIKE pattern matchingin- Value is in arraynot_in- Value is not in arraygreater_than- Numeric/date comparisonless_than- Numeric/date comparisonexists- Field exists (true/false)
Sorting with sort
Sort results by one or more fields:
GET /api/posts?sort=createdAt # Ascending
GET /api/posts?sort=-createdAt # Descending (prefix with -)
GET /api/users?sort=lastName,firstName # Multiple fields
Pagination with limit and page
Control the number of results and pagination:
GET /api/posts?limit=10 # Limit to 10 results
GET /api/posts?limit=10&page=2 # Second page of 10 results
Population with depth
Control how deeply related documents are populated:
GET /api/posts?depth=1 # Populate one level deep
GET /api/posts?depth=0 # No population (IDs only)
Field Selection
Select specific fields to return:
GET /api/users?select=name,email # Only return name and email fields
Complex Query Example
Combine multiple parameters for sophisticated queries:
GET /api/posts?where[status][equals]=published&where[author][in]=123,456&sort=-createdAt&limit=5&depth=1
This query finds:
- Posts with status "published"
- By authors with IDs 123 or 456
- Sorted by creation date (newest first)
- Limited to 5 results
- With author details populated
For complete query syntax and advanced operators, see the Payload Queries documentation.
Custom Endpoints
API Endpoints with custom business logic needs to be implemented manually. Contact the development team for your request to be accomodated.