HTTP API reference
Authenticate with session cookies and automate inventory, scanning, label printing, and settings over JSON HTTP endpoints.
Itemized exposes a JSON HTTP API under /api/* using either browser session cookies (itemized_session) or Personal API Tokens via Authorization: Bearer itm_... headers (created in Settings → API Tokens). All request and response bodies use application/json.
Error responses
Every error response returns a JSON object {"error": "<message>"} with one of the following HTTP status codes:
| Status | Canonical code | Meaning |
|---|---|---|
400 |
invalid json |
Malformed JSON body, invalid path ID, or invalid request parameters. |
401 |
unauthorized |
Missing, expired, or invalid session cookie or login credentials. |
403 |
forbidden |
Action requires administrator role, setup is already complete, or action is disabled in demo mode. |
404 |
not found |
Requested route or resource (product, item, category, location, user, printer) does not exist. |
409 |
conflict |
Uniqueness or referential integrity conflict (duplicate product name, email in use, or resource in use). |
413 |
request body too large |
JSON request body exceeded the 1 MiB limit. |
422 |
validation error |
Request JSON was valid but failed domain validation (missing required fields, invalid hierarchy, or invalid template). |
429 |
rate limited |
Too many login attempts or demo-mode UPC lookups in the rate-limit window. |
500 |
internal server error |
Unexpected server or database error. |
502 |
upstream unavailable |
External OIDC, OpenFoodFacts, LLM, or LAN printer endpoint failed or could not be reached. |
Verified API examples
The examples below are executed automatically against an in-process itemized server by go test ./internal/docsverify/....
Authentication (unauthenticated check)
GET /api/auth/me
# expect-status: 401
# expect-keys: error
Authentication (current user)
GET /api/auth/me
# expect-status: 200
# expect-keys: user
Invalid JSON input
POST /api/categories
Content-Type: application/json
{invalid-json
# expect-status: 400
# expect-keys: error
Categories
POST /api/categories
Content-Type: application/json
{"name": "API Snacks"}
# expect-status: 201
# expect-keys: category
# capture: category_id=category.id
Locations
POST /api/locations
Content-Type: application/json
{"name": "API Pantry", "is_freezer": false}
# expect-status: 201
# expect-keys: location
# capture: location_id=location.id
Products, variants, and barcodes
POST /api/products
Content-Type: application/json
{"name": "Crackers, Sea Salt", "category_id": {{category_id}}, "default_location_id": {{location_id}}, "default_due_days": 90, "use_average_for_due_date": false}
# expect-status: 201
# expect-keys: product
# capture: product_id=product.id
POST /api/products/{{product_id}}/variants
Content-Type: application/json
{"name": "Brand A 8 oz"}
# expect-status: 201
# expect-keys: variant
# capture: variant_id=variant.id
POST /api/variants/{{variant_id}}/barcodes
Content-Type: application/json
{"barcode": "012345678905"}
# expect-status: 201
# expect-keys: barcode
Items
POST /api/items
Content-Type: application/json
{"product_id": {{product_id}}, "variant_id": {{variant_id}}, "location_id": {{location_id}}, "quantity": 1}
# expect-status: 201
# expect-keys: items
POST /api/products/{{product_id}}/consume-next
# expect-status: 200
# expect-keys: item, previous
Scan and workflows
POST /api/scan/resolve
Content-Type: application/json
{"input": "012345678905"}
# expect-status: 200
# expect-keys: kind, product
Label printers and templates
GET /api/label-templates
# expect-status: 200
# expect-keys: templates
Settings
GET /api/settings
# expect-status: 200
# expect-keys: base_url, due_date_average_count
Onboarding
POST /api/onboarding/starter-taxonomy
Content-Type: application/json
{"categories": true, "locations": true}
# expect-status: 200
# expect-keys: categories_created, locations_created, categories, locations
Personal API tokens
POST /api/auth/tokens
Content-Type: application/json
{"name": "Home Assistant", "expires_in_days": 90}
# expect-status: 201
# expect-keys: token, metadata
# capture: api_token_id=metadata.id
GET /api/auth/tokens
# expect-status: 200
# expect-keys: tokens
DELETE /api/auth/tokens/{{api_token_id}}
# expect-status: 200
# expect-keys: deleted
Inventory summary
GET /api/summary
# expect-status: 200
# expect-keys: counts, due_soon_products, overdue_products, shopping_list_products
Store layouts and Shopping Mode
POST /api/store-layouts
Content-Type: application/json
{"name": "Neighborhood Market", "categories": []}
# expect-status: 201
# expect-keys: store_layout
# capture: store_layout_id=store_layout.id
GET /api/store-layouts
# expect-status: 200
# expect-keys: store_layouts
POST /api/shopping/sessions
Content-Type: application/json
{"store_layout_id": {{store_layout_id}}}
# expect-status: 201
# expect-keys: session, joined
# capture: shopping_session_id=session.id
GET /api/shopping/sessions/active
# expect-status: 200
# expect-keys: sessions
GET /api/shopping/sessions/{{shopping_session_id}}
# expect-status: 200
# expect-keys: session
POST /api/shopping/sessions/{{shopping_session_id}}/cancel
# expect-status: 200
# expect-keys: ok, phase
DELETE /api/store-layouts/{{store_layout_id}}
# expect-status: 200
# expect-keys: ok