Skip to Content
DocsAPI ReferenceREST API

REST API Reference

The Ycode public v1 API provides programmatic access to collections, items, forms, and submissions. Use it to build custom integrations, sync data, or power external applications.

Base URL

https://your-project.ycode.dev/ycode/api/v1

Replace your-project with your project subdomain or custom domain.

Authentication

All requests require a Bearer token (API key) in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Create API keys in project settings under Integrations > API Keys. Invalid or missing keys return 401 Unauthorized.

Request Format

  • Content-Type: application/json for request bodies
  • Accept: application/json for responses

Response Format

Successful responses return JSON. List endpoints include pagination metadata:

{ "items": [...], "pagination": { "total": 42, "page": 1, "per_page": 100 } }

Single-resource endpoints return the resource directly as a JSON object.

Error Handling

Errors return appropriate HTTP status codes with a JSON body:

{ "error": { "code": "NOT_FOUND", "message": "The requested resource was not found." } }
StatusMeaning
400Bad Request — Invalid parameters or body
401Unauthorized — Missing or invalid API key
403Forbidden — Valid key but insufficient permissions
404Not Found — Resource does not exist
422Unprocessable Entity — Validation failed
500Server Error — Internal error

Collections Endpoints

MethodEndpointDescription
GET/collectionsList all collections
GET/collections/:idGet a single collection
GET/collections/:id/itemsList items in a collection
GET/collections/:id/items/:itemIdGet a single item
POST/collections/:id/itemsCreate a new item
PUT/collections/:id/items/:itemIdFull update of an item
PATCH/collections/:id/items/:itemIdPartial update of an item
DELETE/collections/:id/items/:itemIdDelete an item

List Collections

GET /ycode/api/v1/collections

Returns all collections in the project.

Get Collection

GET /ycode/api/v1/collections/:id

Returns a single collection by ID, including field definitions.

List Items

GET /ycode/api/v1/collections/:id/items

Query parameters:

ParameterTypeDescription
pagenumberPage number (default: 1)
per_pagenumberItems per page (default: 100, max: 1000)
limitnumberLimit total records returned (max: 1000). Alternative to page-based pagination
sort_bystringField slug to sort results by
order_bystringSort direction: asc (default) or desc. Used with sort_by
filter[field_slug]stringFilter by exact field value. Replace field_slug with the slug of the field to filter on

Example request with filtering and sorting:

curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://your-project.ycode.dev/ycode/api/v1/collections/:id/items?sort_by=name&order_by=desc&filter[status]=active&per_page=50"

Response:

{ "items": [ { "id": "...", "name": "...", "slug": "...", ... } ], "pagination": { "page": 1, "per_page": 50, "total": 12 } }

Get Item

GET /ycode/api/v1/collections/:id/items/:itemId

Returns a single collection item by ID.

Create Item

POST /ycode/api/v1/collections/:id/items

Creates a new item in the collection. The item is created as published immediately.

Send a JSON body with field slugs as keys and their values:

curl -X POST \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name": "New Blog Post", "slug": "new-blog-post", "content": "Hello world"}' \ "https://your-project.ycode.dev/ycode/api/v1/collections/:id/items"

The id, created_at, and updated_at fields are generated automatically and cannot be set manually.

Returns the created item with status 201.

Update Item (Full)

PUT /ycode/api/v1/collections/:id/items/:itemId

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.

curl -X PUT \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name": "Updated Title", "slug": "updated-title", "content": "New content"}' \ "https://your-project.ycode.dev/ycode/api/v1/collections/:id/items/:itemId"

The id, created_at, and updated_at fields are protected and cannot be overwritten. The updated_at timestamp is set automatically.

Returns the updated item.

Update Item (Partial)

PATCH /ycode/api/v1/collections/:id/items/:itemId

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.

curl -X PATCH \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name": "Updated Title"}' \ "https://your-project.ycode.dev/ycode/api/v1/collections/:id/items/:itemId"

Returns the updated item.

Delete Item

DELETE /ycode/api/v1/collections/:id/items/:itemId

Permanently deletes an item and its associated data.

curl -X DELETE \ -H "Authorization: Bearer YOUR_API_KEY" \ "https://your-project.ycode.dev/ycode/api/v1/collections/:id/items/:itemId"

Returns a confirmation:

{ "deleted": true, "_id": "item-uuid" }

Forms Endpoints

MethodEndpointDescription
GET/formsList all forms
GET/forms/:idGet a single form
GET/forms/:id/submissionsList form submissions
POST/forms/:id/submissionsCreate a new submission
GET/forms/:id/submissions/:submissionIdGet a single submission

List Forms

GET /ycode/api/v1/forms

Returns all forms in the project.

Get Form

GET /ycode/api/v1/forms/:id

Returns a single form by ID, including field definitions.

List Submissions

GET /ycode/api/v1/forms/:id/submissions

Returns submissions for the form. Supports pagination.

Create Submission

POST /ycode/api/v1/forms/:id/submissions

Body: JSON object with form field names as keys and submitted values. Creates a new submission.

Get Submission

GET /ycode/api/v1/forms/:id/submissions/:submissionId

Returns a single submission by ID.

Tip

Use the POST submissions endpoint to submit forms from external applications or custom frontends. Ensure field names match the form configuration.

Last updated on