Content API
This section covers all content-related API endpoints, including both Payload CMS and Builder.io integrations.
Payload CMS API
Base URL
Authentication
All Payload CMS endpoints require authentication. Include the access token in the Authorization header:
Collections
List Collections
Get a list of all available collections.
Response
Documents
List Documents
Get documents from a collection.
Query Parameters
Response
Get Document
Get a single document by ID.
Response
Create Document
Create a new document.
Request Body
Response
Update Document
Update an existing document.
Request Body
Delete Document
Delete a document.
Response
Builder.io API
Base URL
Authentication
Include your Builder.io API key in the headers:
Content
Get Page Content
Get content for a specific model.
Query Parameters
Response
Create Content
Create new content for a model.
Request Body
Update Content
Update existing content.
Request Body
Components
List Components
Get registered components.
Response
Preview URLs
Generate Preview URL
Generate a preview URL for content.
Request Body
Response
Error Handling
Both APIs use standard HTTP status codes:
200
: Success
400
: Bad Request
401
: Unauthorized
403
: Forbidden
404
: Not Found
500
: Internal Server Error
Error Response Format:
Examples
Fetching Content
Creating Content
Best Practices
-
Performance
- Use pagination for large collections
- Cache responses when possible
- Implement proper error handling
-
Security
- Validate input data
- Implement proper access control
- Use environment variables for API keys
-
Content Management
- Use proper content versioning
- Implement content previews
- Handle draft/published states
-
API Usage
- Follow rate limiting guidelines
- Implement proper error handling
- Use TypeScript for type safety
Related Resources