{"service":"adhivakta-core-api-worker","description":"Core CRUD: customers/contacts, matters (cases), customer_matter M2M, billing (read), comments; §17 landing list/search (FTS5); firm onboarding + R2 provisioning; G3 audit.","endpoints":{"GET /health":"liveness probe","POST /v1/firms":"onboard a firm (tenant) + provision its R2 bucket name","POST /v1/customers":"create customer/contact","GET /v1/customers":"list customers — q (FTS5), state, country, has_open_case, sort, order, limit, page","GET /v1/customers/:id":"customer drill-down: profile + their matters + comments + billing summary","PATCH /v1/customers/:id":"edit customer","DELETE /v1/customers/:id":"soft-delete customer","POST /v1/matters":"create matter (case)","GET /v1/matters":"list matters — q (FTS5), status, court, practice_area, customer_id, hearing_from/to, sort, order, limit, page","GET /v1/matters/:id":"matter drill-down: matter + linked customers + comments + document count","GET /v1/matters/:id/overview":"matter workspace overview: counts + recent drafts/deadlines/documents/certificates/conversations + links","PATCH /v1/matters/:id":"edit matter","DELETE /v1/matters/:id":"soft-delete matter","POST /v1/matters/:id/customers":"link a customer to a matter with a role (M2M)","DELETE /v1/matters/:id/customers/:customerId":"unlink a customer (optional ?role=)","POST /v1/matters/:id/links":"attach a resource reference to a matter (draft/document/…)","DELETE /v1/matters/:id/links/:resourceType/:resourceId":"detach a resource reference","POST /v1/conversations":"create a Research chat thread (optional matterId + seed messages)","GET /v1/conversations":"list conversations — ?matterId=, limit, page","GET /v1/conversations/:id":"conversation drill-down: thread + messages (with G1 metadata)","POST /v1/conversations/:id/messages":"append message(s) to a conversation","PATCH /v1/conversations/:id":"rename a conversation","DELETE /v1/conversations/:id":"soft-delete a conversation","POST /v1/comments":"add comment (entity_type: customer|matter|document)","GET /v1/comments":"list comments for ?entity_type=&entity_id=","PATCH /v1/comments/:id":"edit comment body","DELETE /v1/comments/:id":"soft-delete comment","GET /v1/invoices":"list invoices — ?customer_id=&matter_id=&status= (+ paid roll-up)","POST /v1/invoices":"create a client invoice (line items + GST/discount; auto invoice number)","GET /v1/invoices/:id":"invoice detail: line items + payments + balance","PATCH /v1/invoices/:id":"edit invoice (metadata, draft-only line items, manual status transition)","DELETE /v1/invoices/:id":"soft-delete a payment-free invoice (void instead if it has payments)","POST /v1/invoices/:id/payments":"record a client receipt; recomputes paid/partial/paid status","DELETE /v1/invoices/:id/payments/:paymentId":"remove a recorded payment; recomputes status","GET /v1/invoices/:id/export":"download the invoice — ?format=html|csv|json (html mirrored to R2)","GET /v1/customers/:id/billing":"per-customer billing view: invoices + Billed/Paid/Outstanding","GET /v1/settings":"current user's profile + UI/model preferences (defaults when unset)","PUT /v1/settings":"persist a partial settings patch (theme/tz/locale/language/models + display_name)","GET /v1/entitlements":"resolved plan entitlements (limits + capabilities) + current-period usage snapshot"}}