The pre-tree rules machinery is deleted: no row ever carried a rules array or a non-default match mode (verified in the dev DB), the web never read the envelope keys, and the Android app consumes none of it. Dead code gets no documentation. Removed: - PUT /api/collections/:id/match-mode — endpoint, route, and the UpdateCollectionMatchMode query. The tree's root mode owns any|all. - auto_assign_rules / rule_match_mode from every envelope (create/list/detail/update), from the create/update request shapes, and from the schema: both columns DROPPED (schema.sql carries idempotent DROP COLUMN IF EXISTS heals for existing DBs; sqlc regenerated). - The rules CRUD service layer (AddRule/SetRuleEnabled/RemoveRule + validateRule + UpdateCollectionRulesJSON), ParseRules / EnabledRules / IsSmartCollection, RulesToFilterTree (+ the SSR preload branch), the legacy branch of EvaluateSmartMembership, and SmartEvalOptions.MatchMode. IsCollectionSmart = tree presence; create-path isSmart = collection_type=smart OR a filter_tree. Kept (live consumers): POST /api/collections/preview still evaluates rules payloads in memory (the custom-section builder's preview), and include_auto stays on the list (the Android app sends it). The custom-section builder's SAVE was already broken — its stringified auto_assign_rules payload failed request binding (probed live: 400 invalid request). Create now rejects that payload loudly with a 400 naming the retirement, instead of silently creating a hollow static section; custom-section-builder.md carries the flag. The builder's tree migration remains the flagged follow-up. Test-side (asymmetry rule — deleted behavior, deleted tests): TestPodcastSmartCollections rewritten onto trees (mode lives in the tree root), match-mode subtests and tree_wins_over_legacy_rules deleted, TestRulesToFilterTree deleted, contract-pin envelope keys retracted per the contract_pins 2026-10-31 retirement entry. Mirrors hand-synced: openapi.yaml, bruno create/update, docs/api/*.md, docs/schema.go, api.d.ts. Full container suite green (155s).
2.0 KiB
2.0 KiB
method, path, auth, area
| method | path | auth | area |
|---|---|---|---|
| POST | /api/collections | jwt | collections |
Create Collection
Creates a new collection for the signed-in user. If any rules are present (or
collection_type is "smart"), the collection is a smart collection whose
membership is evaluated live; otherwise it is static.
Creating a collection whose name already exists for the user returns 409.
Example request
{
"name": "To Read",
"description": "Books I want to read soon",
"color": "#00FF00",
"icon": "📖",
"collection_type": "static",
"view_settings": { "kobo": { "view_mode": "grid" } }
}
Example response
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"user_id": "8f14e45f-ceea-467f-a429-0b21bfc0b1a2",
"name": "To Read",
"description": "Books I want to read soon",
"color": "#00FF00",
"icon": "📖",
"collection_type": "static",
"view_settings": { "kobo": { "view_mode": "grid" } },
"book_count": 0,
"created_at": "2026-10-24 13:57:01.81234 +0000 UTC"
}
Note: created_at is serialized with Go's time.String() format, not
RFC3339. Treat it as display text; do not parse it as an ISO timestamp.
Request fields
| Field | Type | Required | Notes |
|---|---|---|---|
| name | string | yes | unique per user |
| description | string | no | |
| color | string | no | hex color, e.g. "#FF5733" |
| icon | string | no | emoji |
| collection_type | string | no | "static" (default) or "smart"; also implied by a filter_tree |
| view_settings | object | no | per-device display preferences |
| filter_tree | object | no | the unified filter tree (qf DSL); presence makes the collection smart |
Errors
| Status | Body | When |
|---|---|---|
| 400 | {"error": "..."} |
invalid JSON or validation failure |
| 409 | {"error": "a collection with this name already exists"} |
name taken |
| 500 | {"error": "..."} |
unexpected server error |