Skip to main content

User preferences

Preferences are a per-reader key/value store. Use it for things like a reader's favourite teams or display choices. A value can be any JSON. A key can also hold an ordered list of items, which you change with push, pop and the item routes.

Authentication​

Send X-API-Key plus the reader's identity, either an HMAC assertion or an OIDC ID token. Only end-user callers can use these routes. Other callers get 403.

A key is 1-255 characters. Write bodies take only { "value": … }.

Endpoints​

Method and pathStatusReturns
GET /api/v1/preferences200[{ key, value }], cursor paging, limit 1-100 (default 20)
GET /api/v1/preferences/{key}200{ key, value }, or 404 if missing
PUT /api/v1/preferences/{key}200{ key, value }
DELETE /api/v1/preferences/{key}200{ key, deleted: true }, or 404 if missing
GET /api/v1/preferences/{key}/items200{ items: [{ id, value }] }, or 404 if empty
POST /api/v1/preferences/{key}/push202{ id }
POST /api/v1/preferences/{key}/pop202{}, or 404 if missing
PUT /api/v1/preferences/{key}/items/{itemId}202{ id }, or 404 if the item is missing
DELETE /api/v1/preferences/{key}/items/{itemId}202{ id }, or 404 if the item is missing
GET /api/v1/preferences/{key}/length200{ length }, 0 if the key is missing
GET /api/v1/preferences/{key}/search?value=<json>200[{ id, value }]

Things to know​

  • Some writes are queued. A 202 means the change was accepted, not applied yet. A read right after it may not show the change.
  • PUT replaces. It sets the value and clears any list items under that key.
  • push is not safe to retry. Each call creates a new item with a new id, so a retry adds a duplicate. There is no Idempotency-Key support on these routes.
  • search filters by JSON. Pass the value query parameter as URL-encoded JSON. It returns items whose value contains that JSON. Each search counts double against the rate limit.
  • Size. Requests are limited to 1 MiB.
  • No events. Preference changes do not send webhooks or SSE events.
  • Data export. Preferences are part of the user data export.