Collections (collections.ts)
Reference for managing content collections — CRUD operations, schema discovery, and entry revisions.
On this page
The Collections API provides standard CRUD (Create, Read, Update, Delete) operations for managing content entries. It handles schema discovery, data validation, and multi-tenant isolation through a database-agnostic interface.
⚡ Quick Reference
| Feature | HTTP Endpoint | Method | Permission Required |
|---|---|---|---|
| List Schemas | /api/collections |
GET |
collections:read |
| Find Entries | /api/collections/{id} |
GET |
collections:read |
| Get Entry | /api/collections/{colId}/{entId} |
GET |
collections:read |
| Create Entry | /api/collections/{id} |
POST |
collections:create |
| Update Entry | /api/collections/{colId}/{entId} |
PATCH |
collections:update |
| Delete Entry | /api/collections/{colId}/{entId} |
DELETE |
collections:delete |
1. Schema Discovery
Use the root collections endpoint to discover the structure and metadata of your content models.
Endpoint: GET /api/collections
Query Parameters:
includeFields: Iftrue, returns the full widget configuration for each collection.includeStats: Iftrue, returns count and health metrics for each collection.
2. Entry Management
Retrieval & Searching
To fetch entries from a specific collection, use the ID-based endpoint.
Endpoint: GET /api/collections/{collectionId}
Advanced Filtering: See the Content & Search Reference for deep query syntax.
Modifying Content
SveltyCMS enforces schema validation (via Valibot) on every write operation.
- Create:
POST /api/collections/{collectionId} - Update:
PATCH /api/collections/{collectionId}/{entryId}
Soft Deletion: By default, the DELETE method moves entries to the Trash. Permanent deletion requires the ?permanent=true query parameter.
3. The Mechanics
Architecture
The Collections handler acts as a thin dispatcher that invokes the LocalCMS SDK, which in turn coordinates between the Database Adapter and the Widget System.
Related Documents