Skip to content

Commit 224a08c

Browse files
committed
docs: add CMS write endpoints to REST API reference
Document POST, PUT, PATCH, and DELETE endpoints for collection items that were missing from the API reference. Also expand GET list items query parameters (sort_by, order_by, limit, filter) and fix the response format example to match the actual API shape. Update API key permissions to reflect full CRUD access. Made-with: Cursor
1 parent e8dc05f commit 224a08c

File tree

2 files changed

+121
-8
lines changed

2 files changed

+121
-8
lines changed

content/api-reference/index.mdx

Lines changed: 119 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ Successful responses return JSON. List endpoints include pagination metadata:
3535

3636
```json
3737
{
38-
"data": [...],
39-
"meta": {
38+
"items": [...],
39+
"pagination": {
4040
"total": 42,
4141
"page": 1,
42-
"per_page": 20
42+
"per_page": 100
4343
}
4444
}
4545
```
4646

47-
Single-resource endpoints return the resource directly or wrapped in a `data` key depending on the endpoint.
47+
Single-resource endpoints return the resource directly as a JSON object.
4848

4949
## Error Handling
5050

@@ -74,8 +74,12 @@ Errors return appropriate HTTP status codes with a JSON body:
7474
|--------|----------|-------------|
7575
| GET | `/collections` | List all collections |
7676
| GET | `/collections/:id` | Get a single collection |
77-
| GET | `/collections/:id/items` | List items in a collection (supports pagination and filtering) |
77+
| GET | `/collections/:id/items` | List items in a collection |
7878
| GET | `/collections/:id/items/:itemId` | Get a single item |
79+
| POST | `/collections/:id/items` | Create a new item |
80+
| PUT | `/collections/:id/items/:itemId` | Full update of an item |
81+
| PATCH | `/collections/:id/items/:itemId` | Partial update of an item |
82+
| DELETE | `/collections/:id/items/:itemId` | Delete an item |
7983

8084
### List Collections
8185

@@ -104,8 +108,33 @@ Query parameters:
104108
| Parameter | Type | Description |
105109
|-----------|------|-------------|
106110
| page | number | Page number (default: 1) |
107-
| per_page | number | Items per page |
108-
| filter | object | Field filters (format depends on implementation) |
111+
| per_page | number | Items per page (default: 100, max: 1000) |
112+
| limit | number | Limit total records returned (max: 1000). Alternative to page-based pagination |
113+
| sort_by | string | Field slug to sort results by |
114+
| order_by | string | Sort direction: `asc` (default) or `desc`. Used with `sort_by` |
115+
| filter[field_slug] | string | Filter by exact field value. Replace `field_slug` with the slug of the field to filter on |
116+
117+
Example request with filtering and sorting:
118+
119+
```bash
120+
curl -H "Authorization: Bearer YOUR_API_KEY" \
121+
"https://your-project.ycode.dev/ycode/api/v1/collections/:id/items?sort_by=name&order_by=desc&filter[status]=active&per_page=50"
122+
```
123+
124+
Response:
125+
126+
```json
127+
{
128+
"items": [
129+
{ "id": "...", "name": "...", "slug": "...", ... }
130+
],
131+
"pagination": {
132+
"page": 1,
133+
"per_page": 50,
134+
"total": 12
135+
}
136+
}
137+
```
109138

110139
### Get Item
111140

@@ -115,6 +144,89 @@ GET /ycode/api/v1/collections/:id/items/:itemId
115144

116145
Returns a single collection item by ID.
117146

147+
### Create Item
148+
149+
```
150+
POST /ycode/api/v1/collections/:id/items
151+
```
152+
153+
Creates a new item in the collection. The item is created as published immediately.
154+
155+
Send a JSON body with field slugs as keys and their values:
156+
157+
```bash
158+
curl -X POST \
159+
-H "Authorization: Bearer YOUR_API_KEY" \
160+
-H "Content-Type: application/json" \
161+
-d '{"name": "New Blog Post", "slug": "new-blog-post", "content": "Hello world"}' \
162+
"https://your-project.ycode.dev/ycode/api/v1/collections/:id/items"
163+
```
164+
165+
The `id`, `created_at`, and `updated_at` fields are generated automatically and cannot be set manually.
166+
167+
Returns the created item with status `201`.
168+
169+
### Update Item (Full)
170+
171+
```
172+
PUT /ycode/api/v1/collections/:id/items/:itemId
173+
```
174+
175+
Replaces all field values on an item. Fields not included in the request body are cleared to `null`. Use this when you want to overwrite the entire item.
176+
177+
```bash
178+
curl -X PUT \
179+
-H "Authorization: Bearer YOUR_API_KEY" \
180+
-H "Content-Type: application/json" \
181+
-d '{"name": "Updated Title", "slug": "updated-title", "content": "New content"}' \
182+
"https://your-project.ycode.dev/ycode/api/v1/collections/:id/items/:itemId"
183+
```
184+
185+
The `id`, `created_at`, and `updated_at` fields are protected and cannot be overwritten. The `updated_at` timestamp is set automatically.
186+
187+
Returns the updated item.
188+
189+
### Update Item (Partial)
190+
191+
```
192+
PATCH /ycode/api/v1/collections/:id/items/:itemId
193+
```
194+
195+
Updates only the fields included in the request body. All other fields remain unchanged. Use this when you want to modify specific fields without affecting the rest.
196+
197+
```bash
198+
curl -X PATCH \
199+
-H "Authorization: Bearer YOUR_API_KEY" \
200+
-H "Content-Type: application/json" \
201+
-d '{"name": "Updated Title"}' \
202+
"https://your-project.ycode.dev/ycode/api/v1/collections/:id/items/:itemId"
203+
```
204+
205+
Returns the updated item.
206+
207+
### Delete Item
208+
209+
```
210+
DELETE /ycode/api/v1/collections/:id/items/:itemId
211+
```
212+
213+
Permanently deletes an item and its associated data.
214+
215+
```bash
216+
curl -X DELETE \
217+
-H "Authorization: Bearer YOUR_API_KEY" \
218+
"https://your-project.ycode.dev/ycode/api/v1/collections/:id/items/:itemId"
219+
```
220+
221+
Returns a confirmation:
222+
223+
```json
224+
{
225+
"deleted": true,
226+
"_id": "item-uuid"
227+
}
228+
```
229+
118230
## Forms Endpoints
119231

120232
| Method | Endpoint | Description |

content/integrations/api.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ All v1 API endpoints require this header. Requests without a valid key return 40
3737
API keys grant access to the public v1 API:
3838

3939
- List and read collections and items
40+
- Create, update, and delete collection items
4041
- List and read forms and submissions
41-
- Create form submissions (POST)
42+
- Create form submissions
4243

4344
Access is scoped to the project. Keys do not grant access to the Ycode dashboard or admin functions.
4445

0 commit comments

Comments
 (0)