Create Collection Item
Create a new item in a collection.
Request
POST https://app.ycode.com/api/v1/collections/{collection_id}/itemsPath parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | Yes | Unique identifier for the collection |
Headers
| Header | Value |
|---|---|
| Authorization | Bearer YOUR_API_TOKEN |
| Content-Type | application/json |
Request body
Send a JSON object with the collection field names as keys. You can include any fields that exist in your collection.
| Field | Type | Description |
|---|---|---|
_draft | boolean | Optional. When true, only a draft item is created. If omitted and your project is published, both a published and draft item are created. |
All other keys correspond to field names in your collection.
Example request body
{
"Name": "Another blogpost title",
"Summary": "Lorem ipsum dolor sit amet...",
"Body": "<p>Full blog post content here...</p>",
"Main Image": "https://example.com/image.jpg",
"Featured": 0,
"Author": "16687859744696377a736727d8",
"Categories": [
"1669309639520637fa4c77eea7",
"1669309662211637fa4de338d6"
]
}Response
Returns the created item with all fields, including auto-generated system fields like _ycode_id, ID, Slug, Created date, and Updated date.
Example response
{
"_ycode_id": "16687868024636377aa7270ea9",
"ID": 2,
"Name": "Another blogpost title",
"Created date": "2022-11-18T15:53:22+00:00",
"Updated date": "2022-11-18T15:53:22+00:00",
"Created by": "1669309548521637fa46c7f477",
"Updated by": "1669309560083637fa478145c2",
"Summary": "Lorem ipsum dolor sit amet...",
"Body": "<p>Full blog post content here...</p>",
"Main Image": "https://example.com/image.jpg",
"Slug": "another-blogpost-title"
}Example request
curl -X POST https://app.ycode.com/api/v1/collections/637781341a6f7/items \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"Name": "Another blogpost title",
"Summary": "Lorem ipsum dolor sit amet...",
"Body": "<p>Full blog post content here...</p>"
}'To create a draft-only item:
curl -X POST https://app.ycode.com/api/v1/collections/637781341a6f7/items \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"_draft": true,
"Name": "Draft blogpost"
}'Last updated on