How-to

Manage documents

Create, read, update, and delete JSON documents in a collection.

Create a document

Post a JSON object to a collection to create a document. The request body is stored as-is as the document data.

curl
curl https://ineedadatabase.com/api/v1/projects/proj_123/collections/recipes/documents \
  -H "Authorization: Bearer inadb_..." \
  -H "Content-Type: application/json" \
  -d '{"title":"Pasta","servings":4,"published":true}'
response
{
  "id": "A1b2C3d4",
  "created_at": "2026-05-08T12:00:00Z",
  "updated_at": "2026-05-08T12:00:00Z",
  "revision": "rev_E5f6G7h8",
  "data": {
    "title": "Pasta",
    "servings": 4,
    "published": true
  }
}

List documents

List documents while building screens, admin views, or exports. List responses are objects with items and next_cursor, not bare arrays.

curl
curl https://ineedadatabase.com/api/v1/projects/proj_123/collections/recipes/documents \
  -H "Authorization: Bearer inadb_..."
response
{
  "items": [
    {
      "id": "A1b2C3d4",
      "created_at": "2026-05-08T12:00:00Z",
      "updated_at": "2026-05-08T12:00:00Z",
      "revision": "rev_E5f6G7h8",
      "data": {
        "title": "Pasta",
        "servings": 4,
        "published": true
      }
    }
  ],
  "next_cursor": null
}

Read a document

Read one document by id when editing a record or showing a detail view.

curl
curl https://ineedadatabase.com/api/v1/projects/proj_123/collections/recipes/documents/A1b2C3d4 \
  -H "Authorization: Bearer inadb_..."

Update a document

  1. Use PATCH to merge a partial JSON object.
  2. Use PUT to replace the whole document body.
  3. Send If-Match with the current revision to avoid overwriting newer edits.
patch
curl https://ineedadatabase.com/api/v1/projects/proj_123/collections/recipes/documents/A1b2C3d4 \
  -X PATCH \
  -H "Authorization: Bearer inadb_..." \
  -H "Content-Type: application/json" \
  -H "If-Match: rev_E5f6G7h8" \
  -d '{"servings":6}'
replace
curl https://ineedadatabase.com/api/v1/projects/proj_123/collections/recipes/documents/A1b2C3d4 \
  -X PUT \
  -H "Authorization: Bearer inadb_..." \
  -H "Content-Type: application/json" \
  -H "If-Match: rev_E5f6G7h8" \
  -d '{"title":"Pasta","servings":6,"published":true}'

Delete a document

Delete one document by id.

curl
curl https://ineedadatabase.com/api/v1/projects/proj_123/collections/recipes/documents/A1b2C3d4 \
  -X DELETE \
  -H "Authorization: Bearer inadb_..." \
  -H "If-Match: rev_E5f6G7h8"