Pottr/Docs
Topic:Working with Data (CRUD)
REST API
.md

Working with Data (CRUD)

Full reference for creating, reading, updating, partially patching, and soft-deleting entries.

1. List Entries

GET/collections/{slug}Public or Secret Key

Returns a paginated array of entries matching the collection schema. Entry IDs in lists are strings. See Querying Data for filters and sorting.

Response (200 OK)
{
  "data": [
    {
      "id": "1",
      "title": "First Task",
      "priority": "high",
      "completed": false,
      "created_at": "2026-05-01 12:00:00",
      "updated_at": "2026-05-01 12:00:00"
    }
  ],
  "meta": {
    "total": 1,
    "limit": 20,
    "offset": 0,
    "has_more": false
  }
}

2. Create Entry

POST/collections/{slug}Public or Secret Key

Creates a new entry. Validates submitted fields against schema rules. Returns 201 Created with the stored entry (id, collection, data, created_at, updated_at).

Request Body
{
  "title": "Deploy staging build",
  "priority": "urgent",
  "completed": false
}

3. Get Single Entry

GET/collections/{slug}/{id}Public or Secret Key

Retrieves a single entry by its ID. The response is the stored entry, the same shape as a create response.

4. Replace Entry (PUT)

PUT/collections/{slug}/{id}Public or Secret Key

Replaces the full entry record. All required schema fields must be present and will be re-validated. Omitted optional fields are reset to their default empty values.

Optimistic concurrency: include the updated_at_ts you received when you loaded the entry. If someone else saved a newer version since, Pottr returns 409 concurrency_conflict instead of overwriting their work. Send "force": true (or omit updated_at_ts) to overwrite anyway.

5. Partial Update (PATCH)

PATCH/collections/{slug}/{id}Public or Secret Key

Partially updates an entry. Only the submitted fields are validated and updated; omitted fields retain their existing values.

PATCH Request
// Mark a task as completed without sending other fields:
await fetch('https://example.com/wp-json/pottr/v1/collections/tasks/42', {
  method: 'PATCH',
  headers: {
    'Authorization': `Bearer ${API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ completed: true })
});

6. Delete Entry (Soft-Delete)

DELETE/collections/{slug}/{id}Public or Secret Key

Soft-deletes the entry. The entry immediately becomes invisible to all REST API queries. The row stays in the database, and removing it permanently is only possible from the WordPress admin.

Response (200 OK)
{
  "success": true,
  "id": 42
}

Standard Response Envelope

Add ?format=standard (or the header Accept: application/vnd.pottr.v1+json) to any collection endpoint to get the same shape for lists and single entries: data with string id, collection, attributes, created_at and updated_at, plus meta on lists. See API Overview.