{"openapi":"3.1.0","info":{"title":"Chattels API","version":"0.4.0","description":"Household-inventory service for AI agents. Two doors, one domain: REST (this spec) and MCP Streamable HTTP at POST \/mcp (see docs\/mcp.md). Every tenant-scoped id that belongs to another tenant answers 404."},"servers":[{"url":"\/"}],"security":[{"bearerAuth":[]}],"paths":{"\/api\/health":{"get":{"summary":"Health check","x-required-scope":"none (public)","security":[],"responses":{"200":{"description":"OK","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Health"}}}}}}},"\/api\/auth\/login":{"post":{"summary":"Log in with email + password","x-required-scope":"none (public)","security":[],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email"},"password":{"type":"string"}}}}}},"responses":{"200":{"description":"Token pair","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/TokenPair"}}}},"401":{"$ref":"#\/components\/responses\/Unauthorized"},"429":{"$ref":"#\/components\/responses\/RateLimited"}}}},"\/api\/auth\/register":{"post":{"summary":"Open registration; creates a new tenant + owner user. An optional household invite_token joins the inviter\u0027s household instead.","x-required-scope":"none (public)","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["email","password"],"properties":{"email":{"type":"string","format":"email"},"password":{"type":"string","minLength":8},"invite_token":{"type":"string","description":"Optional: plaintext household invite token \u2014 redeemer joins the minter\u0027s household as a co-manager"},"referrer":{"type":"string","description":"Optional: the page the visitor arrived from (document.referrer); used only in the admin signup notification"}}},"example":{"email":"alex@example.com","password":"s3cret-password","invite_token":"9f2c\u202664-hex-chars"}}}},"responses":{"200":{"description":"Token pair (same shape as login)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/TokenPair"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"429":{"$ref":"#\/components\/responses\/RateLimited"}}}},"\/api\/auth\/refresh":{"post":{"summary":"Rotate a refresh token","x-required-scope":"none (public)","security":[],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["refresh_token"],"properties":{"refresh_token":{"type":"string"}}}}}},"responses":{"200":{"description":"Fresh token pair","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/TokenPair"}}}},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/auth\/logout":{"post":{"summary":"Revoke a refresh token (idempotent)","x-required-scope":"none (public)","security":[],"requestBody":{"content":{"application\/json":{"schema":{"type":"object","properties":{"refresh_token":{"type":"string"}}}}}},"responses":{"200":{"description":"Logged out","content":{"application\/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}}}}}}}}},"\/api\/auth\/password\/request":{"post":{"summary":"Request a password-reset email (always 200)","x-required-scope":"none (public)","security":[],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"}}}}}},"responses":{"200":{"description":"OK (never reveals whether the email exists)","content":{"application\/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}}}}}},"429":{"$ref":"#\/components\/responses\/RateLimited"}}}},"\/api\/auth\/password\/reset":{"post":{"summary":"Reset the password with a reset token","x-required-scope":"none (public)","security":[],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["token","new_password"],"properties":{"token":{"type":"string"},"new_password":{"type":"string","minLength":8}}}}}},"responses":{"200":{"description":"Password changed","content":{"application\/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}}}}}},"400":{"$ref":"#\/components\/responses\/BadRequest"}}}},"\/api\/me":{"get":{"summary":"Current user identity \u2014 email, tenant, and member-since","x-required-scope":"none (any authenticated caller; JWT or API key)","responses":{"200":{"description":"Identity of the authenticated user","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Me"}}}},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/invites":{"get":{"summary":"List my own invites (never includes token or hash)","x-required-scope":"sharing:manage","responses":{"200":{"description":"Invites minted by the authenticated user","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/Invite"}}}}},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Mint a multi-use household invite (plaintext token returned once)","x-required-scope":"sharing:manage","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","properties":{"email":{"type":["string","null"],"format":"email","description":"Optional binding: only this address may redeem"},"days":{"type":"integer","minimum":1,"maximum":90,"default":30,"description":"Days until expiry; clamped to 1-90"},"max_uses":{"type":"integer","minimum":1,"maximum":100,"default":10,"description":"How many times the invite may be redeemed"},"type":{"type":"string","enum":["household"],"default":"household","description":"household = redeemer joins YOUR household as a co-manager (only type; registration is open)"}}},"example":{"email":"friend@example.com","days":30,"type":"signup"}}}},"responses":{"201":{"description":"Invite + one-time plaintext token (never returned again)","content":{"application\/json":{"schema":{"type":"object","required":["token","expires_at","invite"],"properties":{"token":{"type":"string","description":"Plaintext token (64 hex chars), shown only here"},"expires_at":{"type":"string","format":"date-time"},"invite":{"type":"object","required":["id","type","email","created_at","expires_at"],"properties":{"id":{"type":"integer"},"type":{"type":"string","enum":["signup","household"]},"email":{"type":["string","null"],"format":"email"},"created_at":{"type":"string","format":"date-time"},"expires_at":{"type":"string","format":"date-time"},"max_uses":{"type":"integer","description":"Redemptions allowed"},"use_count":{"type":"integer","description":"Redemptions consumed so far"},"remaining_uses":{"type":"integer","description":"Redemptions left"}}}}},"example":{"token":"9f2c\u202664-hex-chars","expires_at":"2026-10-21T00:00:00+00:00","invite":{"id":7,"type":"signup","email":"friend@example.com","created_at":"2026-09-21T00:00:00+00:00","expires_at":"2026-10-21T00:00:00+00:00"}}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"429":{"$ref":"#\/components\/responses\/RateLimited"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/invites\/{id}\/revoke":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"post":{"summary":"Revoke one of my active invites (remaining uses, unexpired, unrevoked)","x-required-scope":"sharing:manage","responses":{"200":{"description":"Revoked invite record","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Invite"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/contact":{"post":{"summary":"Send a contact message (public, rate-limited)","description":"Public: anyone may send a message from the contact page. The message is forwarded as plain-text email to the support mailbox; nothing is persisted. Always the same generic 201 for valid submits, even when mail delivery fails. Rate-limited to 5\/hour per IP.","x-required-scope":"none (public)","security":[],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["name","email","message"],"properties":{"name":{"type":"string","minLength":1,"maxLength":120},"email":{"type":"string","format":"email"},"message":{"type":"string","minLength":1,"maxLength":5000}}},"example":{"name":"Ada Lovelace","email":"ada@example.com","message":"Love the API \u2014 will MCP tools cover loans too?"}}}},"responses":{"201":{"description":"Message received (same body even when mail delivery fails)","content":{"application\/json":{"schema":{"type":"object","required":["ok","message"],"properties":{"ok":{"type":"boolean"},"message":{"type":"string"}}}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"429":{"$ref":"#\/components\/responses\/RateLimited"}}}},"\/api\/household\/members":{"get":{"summary":"List the users of the authenticated user\u0027s household (tenant)","x-required-scope":"keys:manage","responses":{"200":{"description":"Household members, oldest first","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/HouseholdMember"}}}}},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/household\/members\/{id}\/remove":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"post":{"summary":"Remove a household member to a brand-new empty household (their library content stays)","x-required-scope":"keys:manage","responses":{"200":{"description":"Moved member","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/HouseholdMember"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/household\/leave":{"post":{"summary":"Leave my household to a brand-new empty household","x-required-scope":"keys:manage","responses":{"200":{"description":"Leaver with new tenant id","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/HouseholdMember"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/grants":{"get":{"summary":"Library grants I own (granted) and grants shared with me (received), incl. revoked","x-required-scope":"sharing:manage","responses":{"200":{"description":"Granted and received grant lists","content":{"application\/json":{"schema":{"type":"object","required":["granted","received"],"properties":{"granted":{"type":"array","items":{"$ref":"#\/components\/schemas\/LibraryGrant"}},"received":{"type":"array","items":{"$ref":"#\/components\/schemas\/LibraryGrant"}}}}}}},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Share library kinds with a user in another household (per-kind, no per-item exceptions)","x-required-scope":"sharing:manage","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["grantee_email","kinds"],"properties":{"grantee_email":{"type":"string","format":"email","description":"Must be a registered user outside your household"},"kinds":{"type":"array","items":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"]},"description":"Non-empty subset of work kinds to share (built-ins plus this tenant\u0027s custom kinds \u2014 see GET \/api\/custom-kinds)"}}},"example":{"grantee_email":"friend@example.com","kinds":["book","board_game"]}}}},"responses":{"201":{"description":"Created grant","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/LibraryGrant"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"409":{"$ref":"#\/components\/responses\/Conflict"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/grants\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"put":{"summary":"Update the shared kinds of one of my active grants","x-required-scope":"sharing:manage","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["kinds"],"properties":{"kinds":{"type":"array","items":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"]},"description":"Non-empty subset of work kinds to share (built-ins plus this tenant\u0027s custom kinds \u2014 see GET \/api\/custom-kinds)"}}},"example":{"kinds":["book"]}}}},"responses":{"200":{"description":"Updated grant","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/LibraryGrant"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/grants\/{id}\/revoke":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"post":{"summary":"Soft-revoke one of my grants (grantee loses browse + request access)","x-required-scope":"sharing:manage","responses":{"200":{"description":"Revoked grant","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/LibraryGrant"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/shared\/works":{"get":{"summary":"Browse a library shared with me (grantee view, kinds limited by the grant)","x-required-scope":"inventory:read","parameters":[{"name":"grant_id","in":"query","required":true,"schema":{"type":"integer"},"description":"Active grant where I am the grantee"},{"name":"kind","in":"query","schema":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"]},"description":"Narrow to one granted kind (built-ins plus this tenant\u0027s custom kinds \u2014 see GET \/api\/custom-kinds)"},{"name":"q","in":"query","schema":{"type":"string"},"description":"Full-text title search within the granted kinds"},{"name":"page","in":"query","schema":{"type":"integer","default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","default":20,"maximum":100}}],"responses":{"200":{"description":"Shared works with their copies (available copy ids are loan-requestable). Owner-private notes are never included in the grantee view.","content":{"application\/json":{"schema":{"type":"object","required":["grant_id","owner_tenant","kinds","data","total","page","per_page"],"properties":{"grant_id":{"type":"integer"},"owner_tenant":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer"},"name":{"type":"string"}}},"kinds":{"type":"array","items":{"type":"string"}},"data":{"type":"array","items":{"allOf":[{"$ref":"#\/components\/schemas\/SharedWork"},{"type":"object","properties":{"copies":{"type":"array","items":{"$ref":"#\/components\/schemas\/SharedCopy"}}}}]}},"total":{"type":"integer"},"page":{"type":"integer"},"per_page":{"type":"integer"}}}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/loan-requests":{"get":{"summary":"List loan requests \u2014 incoming (my household\u0027s, optional status filter) or outgoing (my own)","x-required-scope":"loans:write","parameters":[{"name":"direction","in":"query","schema":{"type":"string","enum":["incoming","outgoing"],"default":"incoming"}},{"name":"status","in":"query","schema":{"type":"string","enum":["pending","approved","declined","cancelled","all"],"default":"all"},"description":"Incoming only"}],"responses":{"200":{"description":"Loan requests, newest first","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/LoanRequest"}}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Request a loan of a shared copy (grantee)","x-required-scope":"loans:write","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["grant_id","copy_id"],"properties":{"grant_id":{"type":"integer","description":"Active grant where I am the grantee"},"copy_id":{"type":"integer","description":"Copy in the grant owner tenant, of a granted kind"},"due_at":{"type":"string","format":"date-time","description":"Requested return date"},"notes":{"type":"string","description":"Note to the library owner"}}},"example":{"grant_id":3,"copy_id":42,"notes":"For the camping trip, please!"}}}},"responses":{"201":{"description":"Pending loan request","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/LoanRequest"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"409":{"$ref":"#\/components\/responses\/Conflict"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/loan-requests\/{id}\/approve":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"post":{"summary":"Approve a loan request (owner) \u2014 creates the loan","x-required-scope":"loans:write","responses":{"200":{"description":"Created loan","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Loan"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"409":{"$ref":"#\/components\/responses\/Conflict"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/loan-requests\/{id}\/decline":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"post":{"summary":"Decline a loan request (owner)","x-required-scope":"loans:write","responses":{"200":{"description":"Declined request","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/LoanRequest"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/loan-requests\/{id}\/cancel":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"post":{"summary":"Cancel my own pending loan request (requester)","x-required-scope":"loans:write","responses":{"200":{"description":"Cancelled request","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/LoanRequest"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/locations":{"get":{"summary":"List locations","x-required-scope":"inventory:read","responses":{"200":{"description":"Locations","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/Location"}}}}},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Create a location","x-required-scope":"inventory:write","parameters":[{"$ref":"#\/components\/parameters\/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"parent_id":{"type":["integer","null"]}}}}}},"responses":{"201":{"description":"Created","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Location"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/locations\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"Get a location","x-required-scope":"inventory:read","responses":{"200":{"description":"Location","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Location"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"patch":{"summary":"Rename \/ reparent a location","x-required-scope":"inventory:write","requestBody":{"content":{"application\/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"parent_id":{"type":["integer","null"]}}}}}},"responses":{"200":{"description":"Location","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Location"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"delete":{"summary":"Delete a location","x-required-scope":"inventory:write","responses":{"204":{"description":"Deleted"},"404":{"$ref":"#\/components\/responses\/NotFound"},"409":{"$ref":"#\/components\/responses\/Conflict"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/people":{"get":{"summary":"List people (owners\/borrowers)","x-required-scope":"inventory:read","responses":{"200":{"description":"People","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/Person"}}}}},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Create a person","x-required-scope":"inventory:write","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"notes":{"type":["string","null"]}}}}}},"responses":{"201":{"description":"Created","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Person"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/people\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"Get a person","x-required-scope":"inventory:read","responses":{"200":{"description":"Person","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Person"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"patch":{"summary":"Update a person","x-required-scope":"inventory:write","requestBody":{"content":{"application\/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"notes":{"type":["string","null"]}}}}}},"responses":{"200":{"description":"Person","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Person"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"delete":{"summary":"Delete a person","x-required-scope":"inventory:write","responses":{"204":{"description":"Deleted"},"404":{"$ref":"#\/components\/responses\/NotFound"},"409":{"$ref":"#\/components\/responses\/Conflict"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/custom-kinds":{"get":{"summary":"List my tenant\u0027s custom work kinds","x-required-scope":"inventory:read","responses":{"200":{"description":"Custom kinds","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/CustomKind"}}}}},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Create a custom work kind (label; slug is auto-derived)","x-required-scope":"inventory:write","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["label"],"properties":{"label":{"type":"string","description":"Display label, e.g. Wine Cellar \u2014 the slug (wine-cellar) is derived by lowercasing, turning spaces\/underscores into dashes, and dropping other characters"}}},"example":{"label":"Wine Cellar"}}}},"responses":{"201":{"description":"Created","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/CustomKind"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/custom-kinds\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"delete":{"summary":"Delete a custom work kind (409 while works use it)","x-required-scope":"inventory:write","responses":{"204":{"description":"Deleted"},"404":{"$ref":"#\/components\/responses\/NotFound"},"409":{"$ref":"#\/components\/responses\/Conflict"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/works":{"get":{"summary":"List works (paginated, optional kind + platform filters)","x-required-scope":"inventory:read","parameters":[{"name":"kind","in":"query","description":"Work kind \u2014 the 8 built-ins, plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)","schema":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"]}},{"name":"platform","in":"query","description":"Game platform filter (e.g. PS5) \u2014 case-insensitive exact match, combinable with kind","schema":{"type":"string"}},{"name":"genre","in":"query","description":"Book genre filter (attributes.genre) \u2014 one of the curated book genres; \u0027Uncategorized\u0027 also matches books with no stored genre. Defaults kind to book when kind is omitted.","schema":{"type":"string"}},{"name":"page","in":"query","schema":{"type":"integer","default":1}},{"name":"per_page","in":"query","schema":{"type":"integer","default":20}}],"responses":{"200":{"description":"Page of works","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/WorkPage"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Create a work","x-required-scope":"inventory:write","parameters":[{"$ref":"#\/components\/parameters\/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/WorkInput"}}}},"responses":{"201":{"description":"Created","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Work"}}}},"409":{"description":"Exact identifier already owned (tenant-scoped)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/DuplicateConflict"},"example":{"error":"duplicate","duplicate_of":{"id":4,"title":"Dune"}}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/works\/genres":{"get":{"summary":"Genre facet \u2014 per-genre work counts for a kind (Library book breakdown)","x-required-scope":"inventory:read","parameters":[{"name":"kind","in":"query","description":"Work kind (defaults to book)","schema":{"type":"string","default":"book"}}],"responses":{"200":{"description":"Genre counts, ordered by count descending","content":{"application\/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","required":["genre","count"],"properties":{"genre":{"type":"string","description":"Curated genre; books with no stored genre report as \u0027Uncategorized\u0027"},"count":{"type":"integer"}}}}}}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/works\/search":{"get":{"summary":"FULLTEXT + identifier search over works (matches titles, creators\/artists, identifiers)","x-required-scope":"inventory:read","parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string"}},{"name":"kind","in":"query","description":"Work kind \u2014 the 8 built-ins, plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)","schema":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"]}},{"name":"platform","in":"query","description":"Game platform filter (e.g. PS5) \u2014 case-insensitive exact match","schema":{"type":"string"}}],"responses":{"200":{"description":"Matching works","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/Work"}}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/works\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"Get a work with its copies","x-required-scope":"inventory:read","responses":{"200":{"description":"Work + copies","content":{"application\/json":{"schema":{"allOf":[{"$ref":"#\/components\/schemas\/Work"},{"type":"object","properties":{"copies":{"type":"array","items":{"$ref":"#\/components\/schemas\/Copy"}}}}]}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"patch":{"summary":"Update a work","x-required-scope":"inventory:write","requestBody":{"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/WorkInput"}}}},"responses":{"200":{"description":"Work","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Work"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"delete":{"summary":"Delete a work (only when it has no copies)","x-required-scope":"inventory:write","responses":{"204":{"description":"Deleted"},"404":{"$ref":"#\/components\/responses\/NotFound"},"409":{"$ref":"#\/components\/responses\/Conflict"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/copies":{"get":{"summary":"List copies (optional work_id\/location_id\/status filters)","x-required-scope":"inventory:read","parameters":[{"name":"work_id","in":"query","schema":{"type":"integer"}},{"name":"location_id","in":"query","schema":{"type":"integer"}},{"name":"status","in":"query","schema":{"type":"string","enum":["available","loaned","lost","sold","broken","retired"]}}],"responses":{"200":{"description":"Copies","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/Copy"}}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Add a copy of a work","x-required-scope":"inventory:write","parameters":[{"$ref":"#\/components\/parameters\/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["work_id","owner_id","format"],"properties":{"work_id":{"type":"integer"},"owner_id":{"type":"integer"},"location_id":{"type":["integer","null"],"description":"Omit\/null for digital licenses"},"format":{"type":"string","description":"book: physical|kindle|audible|pdf|epub; board_game: physical|digital; cd: cd|vinyl|disc|digital_download; video_game: disc|cartridge|digital_download; tool, outdoor_recreation, spice, jewelry, and custom kinds: physical"},"status":{"type":"string"},"lending_model":{"type":"string","enum":["physical","account_bound","shareable_digital"]},"platform":{"type":["string","null"]},"components_missing":{"type":["string","null"]},"condition":{"type":["string","null"]},"acquired_at":{"type":["string","null"],"format":"date"},"notes":{"type":["string","null"]}}}}}},"responses":{"201":{"description":"Created","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Copy"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/copies\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"Get a copy","x-required-scope":"inventory:read","responses":{"200":{"description":"Copy","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Copy"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"patch":{"summary":"Update a copy (status loaned is owned by the loan endpoints)","x-required-scope":"inventory:write","requestBody":{"content":{"application\/json":{"schema":{"type":"object","properties":{"owner_id":{"type":"integer"},"location_id":{"type":["integer","null"]},"format":{"type":"string"},"status":{"type":"string"},"lending_model":{"type":"string"},"platform":{"type":["string","null"]},"components_missing":{"type":["string","null"]},"condition":{"type":["string","null"]},"acquired_at":{"type":["string","null"],"format":"date"},"notes":{"type":["string","null"]}}}}}},"responses":{"200":{"description":"Copy","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Copy"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"delete":{"summary":"Delete a copy","x-required-scope":"inventory:write","responses":{"204":{"description":"Deleted"},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/copies\/{id}\/qr":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"post":{"summary":"Mint (or rotate) the copy\u0027s QR label token","description":"Returns the unguessable token plus the absolute scan lookup URL (built from the request host). Stick the label on the item; later, GET \/api\/copies\/by-qr\/{token} answers \u0022where is it\u0022 in one call. Each mint rotates the token \u2014 the previous one stops resolving.","x-required-scope":"inventory:write","responses":{"200":{"description":"QR token + lookup URL","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/QrMint"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/copies\/by-qr\/{token}":{"parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string","description":"QR label token from POST \/api\/copies\/{id}\/qr or the label payload"}}],"get":{"summary":"Scan-to-item lookup \u2014 resolve a QR token to the copy","description":"Returns the copy with its work (title, kind, attributes), location path (root first), status, and active loan (if any). Unknown tokens \u2014 and other tenants\u0027 tokens \u2014 answer a uniform 404.","x-required-scope":"inventory:read","responses":{"200":{"description":"Copy with work, location path, and loan","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/ScanResult"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/copies\/{id}\/label":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"Printable QR label data for a copy","description":"Label-printer\/HTML-ready payload: qr_svg is a QR code SVG string encoding the token (pure-PHP SVG, no image pipeline needed). Mints a token first when the copy has none yet.","x-required-scope":"inventory:read","responses":{"200":{"description":"Label data","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/CopyLabel"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/copies\/{id}\/attachments":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"List a copy\u0027s attachments (photos, receipts, warranty), newest first","x-required-scope":"inventory:read","responses":{"200":{"description":"Attachment records (metadata only, no file bytes)","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/Attachment"}}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Attach a file to a copy","description":"multipart\/form-data with fields `file` and `kind` (photo|receipt|warranty|manual|other). Max 10 MB; JPEG, PNG, WebP, GIF, or PDF only \u2014 anything else is 422. Files are stored under a random server-side name (path-traversal safe); deleting the copy cascades to its attachments. Binary upload stays REST-only \u2014 it doesn\u0027t fit the MCP JSON tools.","x-required-scope":"inventory:write","requestBody":{"required":true,"content":{"multipart\/form-data":{"schema":{"type":"object","required":["file","kind"],"properties":{"file":{"type":"string","format":"binary"},"kind":{"type":"string","enum":["photo","receipt","warranty","manual","other"]}}}}}},"responses":{"201":{"description":"Attachment record","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Attachment"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/attachments\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"Download an attachment (inline, with its Content-Type)","x-required-scope":"inventory:read","responses":{"200":{"description":"File bytes","content":{"application\/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"delete":{"summary":"Delete an attachment (removes the DB row and the file)","x-required-scope":"inventory:write","responses":{"204":{"description":"Deleted"},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/copies\/{id}\/maintenance":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"List a copy\u0027s maintenance history, newest first","x-required-scope":"inventory:read","responses":{"200":{"description":"Maintenance records","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/MaintenanceRecord"}}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Log maintenance on a copy","x-required-scope":"inventory:write","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["kind"],"properties":{"kind":{"type":"string","enum":["cleaned","sharpened","oiled","calibrated","repaired","replaced_part","inspected","other"]},"performed_at":{"type":["string","null"],"format":"date","description":"YYYY-MM-DD, defaults to today"},"notes":{"type":["string","null"]},"cost_cents":{"type":["integer","null"],"minimum":0}}}}}},"responses":{"201":{"description":"Maintenance record","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/MaintenanceRecord"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/maintenance\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"delete":{"summary":"Delete a maintenance record","x-required-scope":"inventory:write","responses":{"204":{"description":"Deleted"},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/loans":{"get":{"summary":"List loans by status","x-required-scope":"inventory:read","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["open","overdue","all"],"default":"open"}}],"responses":{"200":{"description":"Loans","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/Loan"}}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/loans\/checkout":{"post":{"summary":"Check a copy out to a borrower","x-required-scope":"loans:write","parameters":[{"$ref":"#\/components\/parameters\/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["copy_id","borrower_id"],"properties":{"copy_id":{"type":"integer"},"borrower_id":{"type":"integer"},"due_at":{"type":["string","null"],"format":"date-time"},"notes":{"type":["string","null"]}}},"example":{"copy_id":7,"borrower_id":2,"due_at":"2026-10-17T00:00:00+00:00"}}}},"responses":{"201":{"description":"Open loan","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Loan"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"409":{"$ref":"#\/components\/responses\/Conflict"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/loans\/{id}\/checkin":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"post":{"summary":"Close an open loan; the copy becomes available","x-required-scope":"loans:write","responses":{"200":{"description":"Closed loan","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Loan"},"example":{"id":5,"copy_id":7,"borrower_id":2,"loaned_at":"2026-09-17T12:00:00+00:00","due_at":"2026-10-17T00:00:00+00:00","returned_at":"2026-09-18T12:00:00+00:00","open":false,"overdue":false,"notes":null}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"409":{"$ref":"#\/components\/responses\/Conflict"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/loans\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"Get a loan","x-required-scope":"inventory:read","responses":{"200":{"description":"Loan","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Loan"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/stats":{"get":{"summary":"Library dashboard stats","x-required-scope":"inventory:read","responses":{"200":{"description":"Stats payload","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Stats"}}}},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/admin\/stats":{"get":{"summary":"Site-wide user statistics (admin only)","description":"ROLE_ADMIN JWT sessions only (API-key callers are refused). Total accounts, new signups (today \/ 7d \/ 30d), and active users \u2014 DAU\/WAU\/MAU split into human_users (JWT) and agent_keys (API keys), counted across all tenants from the daily active-principal table.\n","x-required-scope":"ROLE_ADMIN","responses":{"200":{"description":"Site-wide totals and active-user windows","content":{"application\/json":{"schema":{"type":"object","properties":{"users":{"type":"object","properties":{"total":{"type":"integer"},"new_today":{"type":"integer"},"new_7d":{"type":"integer"},"new_30d":{"type":"integer"}}},"active":{"type":"object","properties":{"daily":{"type":"object","properties":{"date":{"type":"string","format":"date"},"human_users":{"type":"integer"},"agent_keys":{"type":"integer"}}},"weekly":{"type":"object","properties":{"human_users":{"type":"integer"},"agent_keys":{"type":"integer"}}},"monthly":{"type":"object","properties":{"human_users":{"type":"integer"},"agent_keys":{"type":"integer"}}}}}}}}}},"403":{"description":"Admin access required","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Error"}}}},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/analytics":{"get":{"summary":"Usage analytics \u2014 API calls per endpoint, MCP calls per tool, active keys\/users, totals, signups, kinds","x-required-scope":"inventory:read","parameters":[{"name":"from","in":"query","required":false,"description":"Range start YYYY-MM-DD (default trailing 30 days)","schema":{"type":"string","format":"date"}},{"name":"to","in":"query","required":false,"description":"Range end YYYY-MM-DD (default today)","schema":{"type":"string","format":"date"}},{"name":"dimension","in":"query","required":false,"description":"Filter call counts to one door (api|mcp); other sections still return","schema":{"type":"string","enum":["api","mcp"]}}],"responses":{"200":{"description":"Analytics payload","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Analytics"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/agent-keys":{"get":{"summary":"List agent API keys (no key material)","x-required-scope":"keys:manage","responses":{"200":{"description":"Keys","content":{"application\/json":{"schema":{"type":"array","items":{"$ref":"#\/components\/schemas\/ApiKey"}}}}},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"post":{"summary":"Mint an agent API key (plaintext returned once)","x-required-scope":"keys:manage","parameters":[{"$ref":"#\/components\/parameters\/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["name","scopes"],"properties":{"name":{"type":"string"},"scopes":{"type":"array","minItems":1,"items":{"type":"string","enum":["inventory:read","inventory:write","loans:write","keys:manage","sharing:manage"]}},"expires_at":{"type":["string","null"],"format":"date-time"}}},"example":{"name":"household-agent","scopes":["inventory:read","inventory:write","loans:write"]}}}},"responses":{"201":{"description":"Key record + one-time plaintext","content":{"application\/json":{"schema":{"allOf":[{"$ref":"#\/components\/schemas\/ApiKey"},{"type":"object","required":["key"],"properties":{"key":{"type":"string","description":"Full key (chattels_...), shown only here"}}}]},"example":{"id":3,"name":"household-agent","prefix":"chattels_X","scopes":["inventory:read","inventory:write","loans:write"],"request_count":0,"last_used_at":null,"expires_at":null,"revoked_at":null,"created_at":"2026-09-17T12:00:00+00:00","key":"chattels_\u202648-url-safe-chars\u2026"}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/agent-keys\/{id}":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"patch":{"summary":"Rename and\/or rescoping an agent API key in place (no rotation, no revocation)","x-required-scope":"keys:manage","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Trimmed, non-empty, max 255 chars"},"scopes":{"type":"array","minItems":1,"items":{"type":"string","enum":["inventory:read","inventory:write","loans:write","keys:manage","sharing:manage"]}}}},"example":{"name":"household-agent","scopes":["inventory:read","inventory:write"]}}}},"responses":{"200":{"description":"Updated key record (never includes key material)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/ApiKey"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/agent-keys\/{id}\/revoke":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"post":{"summary":"Revoke an agent API key","x-required-scope":"keys:manage","responses":{"200":{"description":"Revoked key record","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/ApiKey"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/agent-keys\/{id}\/usage":{"parameters":[{"$ref":"#\/components\/parameters\/IdParam"}],"get":{"summary":"Per-key usage \u2014 key summary plus per-day request counts for the last 30 days","x-required-scope":"keys:manage","responses":{"200":{"description":"Usage report","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/KeyUsage"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/metadata\/lookup":{"get":{"summary":"Look up filled-in metadata by ISBN (book), BGG id (board_game), barcode (cd), or game id (video_game). Kinds without metadata providers (tool, outdoor_recreation, spice, jewelry, plus this tenant\u0027s custom kinds) answer 422 \u0027No metadata providers for kind ...\u0027","x-required-scope":"inventory:read","parameters":[{"name":"kind","in":"query","required":true,"description":"Work kind \u2014 the 8 built-ins, plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)","schema":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"]}},{"name":"identifier","in":"query","required":true,"schema":{"type":"string","description":"ISBN-10\/13 (any hyphenation) for books, numeric BGG id for board games, 12-digit UPC-A \/ 13-digit EAN barcode for CDs, provider game id for video games"}}],"responses":{"200":{"description":"Metadata result (includes which provider answered as `source`)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/MetadataResult"}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/metadata\/check":{"get":{"summary":"Pre-check whether the tenant already owns this identifier","x-required-scope":"inventory:read","parameters":[{"name":"kind","in":"query","required":true,"description":"Work kind \u2014 the 8 built-ins, plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)","schema":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"]}},{"name":"identifier","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Already owned","content":{"application\/json":{"schema":{"type":"object","required":["duplicate_of"],"properties":{"duplicate_of":{"$ref":"#\/components\/schemas\/DuplicateOf"}}}}}},"404":{"$ref":"#\/components\/responses\/NotFound"},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/works\/fast-add":{"post":{"summary":"Create one work from an identifier (ISBN, BGG id, CD barcode, or game id), metadata-filled; or manual fast-add for tool, outdoor_recreation, spice, jewelry (pass title instead of an identifier \u2014 no metadata providers exist for these kinds). This tenant\u0027s custom kinds answer 422 \u2014 create those works directly via POST \/api\/works","x-required-scope":"inventory:write","parameters":[{"$ref":"#\/components\/parameters\/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/FastAddInput"},"example":{"kind":"book","identifier":9780441172719,"notes":"Living-room shelf"}}}},"responses":{"201":{"description":"Created (metadata-filled work)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Work"}}}},"404":{"description":"No metadata found for this identifier (fall back to POST \/api\/works)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Error"}}}},"409":{"description":"Exact identifier already owned (tenant-scoped)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/DuplicateConflict"},"example":{"error":"duplicate","duplicate_of":{"id":4,"title":"Dune"}}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/import\/csv":{"post":{"summary":"Bulk import works from CSV text (one request, per-row results)","x-required-scope":"inventory:write","parameters":[{"name":"dry_run","in":"query","schema":{"type":"string","enum":["1","true"],"description":"Validate every row and return the report without persisting"}},{"$ref":"#\/components\/parameters\/IdempotencyKey"}],"requestBody":{"required":true,"content":{"text\/csv":{"schema":{"type":"string","description":"Raw CSV text with a required header row: title,kind,isbn,bgg_id,upc,barcode,game_id,platform,authors,published_year,notes. Only title is required per row (kind defaults to book; title may be blank when an identifier resolves via metadata). Valid kinds: book, board_game, cd, video_game, tool, outdoor_recreation, spice, jewelry, plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds) \u2014 the last four built-ins and all custom kinds have no metadata providers, so their rows are always manual (title required, no enrichment). authors is semicolon-separated. barcode (else upc) carries the CD barcode for cd rows; game_id the provider game id and platform (e.g. PS5) the platform for video_game rows. Max 500 rows.","example":"title,kind,isbn,bgg_id,upc,barcode,game_id,platform,authors,published_year,notes\nDune,book,9780441172719,,,,,,Frank Herbert,1965,shelf 1\nCatan,board_game,,13,,,,,Klaus Teuber,1995,\nKind of Blue,cd,,,,074646589123,,,Miles Davis,1959,\nElden Ring,video_game,,,,,119171,PS5,FromSoftware,2022,"}}}},"responses":{"200":{"description":"Per-row report (one bad row never fails the import)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/ImportReport"},"example":{"summary":{"total":3,"created":1,"duplicates":1,"errors":1},"rows":[{"row":1,"status":"created","work_id":12},{"row":2,"status":"duplicate","duplicate_of":{"id":4,"title":"Dune"}},{"row":3,"status":"error","error":"Kind must be one of book, board_game, cd, video_game, tool, outdoor_recreation, spice, jewelry."}]}}}},"422":{"$ref":"#\/components\/responses\/ValidationError"},"403":{"$ref":"#\/components\/responses\/InsufficientScope"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}}},"\/api\/openapi.json":{"get":{"summary":"This spec as JSON (public, machine-readable)","x-required-scope":"none (public)","security":[],"responses":{"200":{"description":"OpenAPI document","content":{"application\/json":{"schema":{"type":"object"}}}}}}},"\/mcp":{"post":{"summary":"MCP Streamable HTTP endpoint \u2014 initialize, then tools\/list and tools\/call (19 tools)","x-required-scope":"inventory:read floor + per-tool scope","description":"JSON-RPC 2.0 over POST with the agent API key in Authorization. Flow: initialize (no session) \u2192 200 + Mcp-Session-Id header \u2192 notifications\/initialized (202) \u2192 tools\/list \u2192 tools\/call. Every call needs inventory:read plus the tool\u0027s own scope; a missing scope is JSON-RPC code -32003. Validation failures are -32602 with data.errors, unknown ids -32001, duplicates -32009 with data.duplicate_of (same shape as the REST 409). Single messages only \u2014 batches are rejected. 19 tools: the 18 library tools plus get_analytics (same payload as GET \/api\/analytics). See docs\/mcp.md.","requestBody":{"required":true,"content":{"application\/json":{"schema":{"type":"object","required":["jsonrpc","method"],"properties":{"jsonrpc":{"type":"string","enum":["2.0"]},"id":{"description":"Request id (absent for notifications)"},"method":{"type":"string","enum":["initialize","notifications\/initialized","ping","tools\/list","tools\/call"]},"params":{"type":"object","description":"initialize takes protocolVersion\/capabilities\/clientInfo; tools\/call takes name + arguments"}},"example":{"jsonrpc":"2.0","id":1,"method":"tools\/call","params":{"name":"search_works","arguments":{"q":"dune"}}}}}}},"parameters":[{"name":"Mcp-Session-Id","in":"header","required":false,"description":"Session id from initialize (required for everything past initialize)","schema":{"type":"string"}}],"responses":{"200":{"description":"JSON-RPC result or error object","content":{"application\/json":{"schema":{"type":"object","properties":{"jsonrpc":{"type":"string"},"id":{"description":"Echoed request id"},"result":{"type":"object","description":"tools\/list returns tools; tools\/call returns content with the payload as JSON text"},"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","description":"-32003 scope, -32602 validation, -32001 not found, -32009 duplicate, -32000 other"},"message":{"type":"string"},"data":{"type":"object","description":"data.errors (validation), data.duplicate_of {id, title} (duplicates)"}}}}}}}},"202":{"description":"Notification accepted (no body)"},"404":{"$ref":"#\/components\/responses\/NotFound"},"401":{"$ref":"#\/components\/responses\/Unauthorized"}}},"get":{"summary":"MCP SSE stream (not supported \u2014 use POST)","x-required-scope":"none (public)","responses":{"405":{"description":"Method not allowed","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Error"}}}}}},"delete":{"summary":"Terminate an MCP session","x-required-scope":"any authenticated credential","parameters":[{"name":"Mcp-Session-Id","in":"header","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Session terminated (empty body)"}}}},"\/":{"get":{"summary":"Minimal signup\/landing page (the only human-facing web surface in v1)","x-required-scope":"none (public)","security":[],"responses":{"200":{"description":"HTML signup page","content":{"text\/html":{"schema":{"type":"string"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"JWT access token (15 min) or agent API key (chattels_\u2026). JWT-authenticated callers hold every permission and bypass scope checks. API keys carry a subset of five scopes, checked literally (no hierarchy \u2014 holding one scope never implies another): inventory:read (read inventory), inventory:write (add\/edit inventory), loans:write (checkout\/checkin), keys:manage (mint, list, update, revoke, and usage of agent API keys), sharing:manage (mint\/list\/revoke invites at \/api\/invites and create\/list\/update\/ revoke library grants at \/api\/grants)."}},"parameters":{"IdParam":{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retry for this create request. The first request executes and stores its response; a repeat with the same key AND same body replays the stored response byte-for-byte with the original status plus an Idempotent-Replayed: true header (no new row). The same key with a different body is 422 {errors: {idempotency_key}}. Keys are tenant-scoped and expire after 24h.","schema":{"type":"string"}}},"responses":{"BadRequest":{"description":"Bad request","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Error"}}}},"Unauthorized":{"description":"Missing\/invalid credentials","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Error"}}}},"NotFound":{"description":"Not found (includes cross-tenant ids)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Error"}}}},"Conflict":{"description":"State conflict (loan exists, work has copies, \u2026)","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Error"}}}},"ValidationError":{"description":"Validation failure","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/FieldErrors"}}}},"IdempotencyMismatch":{"description":"Idempotency-Key already used with a different payload","content":{"application\/json":{"schema":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","required":["idempotency_key"],"properties":{"idempotency_key":{"type":"string"}}}}}}}},"InsufficientScope":{"description":"API key lacks the required scope","content":{"application\/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","enum":["insufficient_scope"]}}}}}},"RateLimited":{"description":"Too many requests","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/Error"}}}}},"schemas":{"Health":{"type":"object","properties":{"ok":{"type":"boolean"}}},"TokenPair":{"type":"object","required":["access_token","refresh_token"],"properties":{"access_token":{"type":"string","description":"JWT HS256, 15 min"},"refresh_token":{"type":"string","description":"Opaque token, 30 days, rotating"}}},"Me":{"type":"object","required":["email","tenant","created_at"],"properties":{"email":{"type":"string","format":"email"},"tenant":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer"},"name":{"type":"string"}}},"created_at":{"type":"string","format":"date-time"},"is_admin":{"type":"boolean","description":"True for admins (app:user:create --admin or app:user:promote --admin); gates the analytics dashboard (M9)"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"FieldErrors":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","additionalProperties":{"type":"string"}}}},"Location":{"type":"object","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"name":{"type":"string"},"parent_id":{"type":["integer","null"]},"created_at":{"type":"string","format":"date-time"}}},"Person":{"type":"object","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"name":{"type":"string"},"user_id":{"type":["integer","null"]},"notes":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}}},"CustomKind":{"type":"object","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"slug":{"type":"string","description":"URL-safe key derived from the label (lowercase, spaces\/underscores to dashes, other characters dropped); used as the work kind"},"label":{"type":"string"},"created_at":{"type":"string","format":"date-time"}}},"Work":{"type":"object","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"kind":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"],"description":"Built-in kinds plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)"},"title":{"type":"string"},"subtitle":{"type":["string","null"]},"creators":{"type":"array","items":{"type":"string"}},"identifiers":{"type":"object","additionalProperties":{"type":"string"}},"publisher":{"type":["string","null"]},"year":{"type":["integer","null"]},"platform":{"type":["string","null"],"description":"Game platform for video_game works (e.g. PS5, Switch, PC) \u2014 one title on one platform is one work"},"cover_url":{"type":["string","null"],"description":"Cover\/photo URL (http\/https). For jewelry insurance records this can carry a photo reference of the piece"},"parent_id":{"type":["integer","null"]},"attributes":{"type":"object","description":"Kind-specific extras. Conventions: book {genre (one of the curated book genres, see GET \/api\/works\/genres)}; jewelry {estimated_value (USD number), appraisal_date (YYYY-MM-DD), serial_number}; spice {expiry_date, opened_date (YYYY-MM-DD)}; tool {brand, model, power_source (manual|battery|corded|gas, validated), purchase_year (1000-2100, validated), serial_number (validated)}; outdoor_recreation {brand, size}; cd {track_count, ...}; video_game {genre, ...}"},"external_refs":{"type":"object"},"notes":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}}},"WorkInput":{"type":"object","required":["kind","title"],"properties":{"kind":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"],"description":"Built-in kinds plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)"},"title":{"type":"string"},"subtitle":{"type":["string","null"]},"creators":{"type":"array","items":{"type":"string"}},"identifiers":{"type":"object","additionalProperties":{"type":"string"}},"publisher":{"type":["string","null"]},"year":{"type":["integer","null"]},"platform":{"type":["string","null"],"description":"Game platform for video_game works (e.g. PS5)"},"cover_url":{"type":["string","null"],"description":"Cover\/photo URL (http\/https). For jewelry insurance records this can carry a photo reference of the piece"},"parent_id":{"type":["integer","null"]},"attributes":{"type":"object","description":"Kind-specific extras. Conventions: jewelry {estimated_value (USD number), appraisal_date (YYYY-MM-DD), serial_number}; spice {expiry_date, opened_date (YYYY-MM-DD)}; tool {brand, model, power_source (manual|battery|corded|gas, validated), purchase_year (1000-2100, validated), serial_number (validated)}; outdoor_recreation {brand, size}; cd {artist, label, release_year, track_count, barcode}; video_game {developer, publisher, release_year, genre, platform}"},"external_refs":{"type":"object"},"notes":{"type":["string","null"]}}},"WorkPage":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#\/components\/schemas\/Work"}},"total":{"type":"integer"},"page":{"type":"integer"},"per_page":{"type":"integer"}}},"DuplicateOf":{"type":"object","required":["id","title"],"properties":{"id":{"type":"integer"},"title":{"type":"string"}}},"DuplicateConflict":{"type":"object","required":["error","duplicate_of"],"properties":{"error":{"type":"string","enum":["duplicate"]},"duplicate_of":{"$ref":"#\/components\/schemas\/DuplicateOf"}}},"FastAddInput":{"type":"object","required":["kind"],"properties":{"kind":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"],"description":"Built-in kinds plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)"},"identifier":{"type":"string","description":"ISBN-10\/13 (any hyphenation) for books, numeric BGG id for board games, 12-digit UPC-A \/ 13-digit EAN barcode for CDs, provider game id for video games. Required for those kinds; ignored for tool\/outdoor_recreation\/spice\/jewelry (manual mode \u2014 attach serial numbers and other ids via \u0022identifiers\u0022 instead). This tenant\u0027s custom kinds answer 422 \u2014 create those works directly via POST \/api\/works"},"title":{"type":["string","null"],"description":"Required for tool\/outdoor_recreation\/spice\/jewelry (manual fast-add \u2014 no metadata lookup); overrides the metadata title when present and non-blank for the other kinds"},"subtitle":{"type":["string","null"]},"creators":{"type":"array","items":{"type":"string"}},"identifiers":{"type":"object","additionalProperties":{"type":"string"},"description":"Merged with the metadata identifiers (explicit spellings normalize)"},"publisher":{"type":["string","null"]},"year":{"type":["integer","null"]},"platform":{"type":["string","null"],"description":"Overrides the provider platform (video_game) when present"},"cover_url":{"type":["string","null"]},"parent_id":{"type":["integer","null"]},"attributes":{"type":"object"},"external_refs":{"type":"object"},"notes":{"type":["string","null"]}}},"ImportRow":{"type":"object","required":["row","status"],"properties":{"row":{"type":"integer","description":"1-based data-row number (header excluded)"},"status":{"type":"string","enum":["created","duplicate","error"]},"work_id":{"type":"integer","description":"Present for created rows (dry_run ids are rolled back, nothing persists)"},"duplicate_of":{"$ref":"#\/components\/schemas\/DuplicateOf"},"error":{"type":"string","description":"Present for error rows"}}},"ImportReport":{"type":"object","required":["summary","rows"],"properties":{"summary":{"type":"object","required":["total","created","duplicates","errors"],"properties":{"total":{"type":"integer"},"created":{"type":"integer"},"duplicates":{"type":"integer"},"errors":{"type":"integer"}}},"rows":{"type":"array","items":{"$ref":"#\/components\/schemas\/ImportRow"}}}},"MetadataResult":{"type":"object","required":["kind","identifier","title","identifiers","source"],"properties":{"kind":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"],"description":"Built-in kinds plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)"},"identifier":{"type":"string","description":"Canonical identifier (ISBN-13, BGG id, barcode, or game id)"},"title":{"type":"string"},"subtitle":{"type":["string","null"]},"creators":{"type":"array","items":{"type":"string"}},"publisher":{"type":["string","null"]},"year":{"type":["integer","null"]},"cover_url":{"type":["string","null"]},"identifiers":{"type":"object","additionalProperties":{"type":"string"}},"source":{"type":"string","description":"Provider that answered (open_library, google_books, boardgamegeek, musicbrainz, discogs, igdb)"},"attributes":{"type":"object","description":"Kind-specific extras (e.g. cd track_count, video_game genre)"},"platform":{"type":["string","null"],"description":"Game platform for video_game results"}}},"Copy":{"type":"object","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"work_id":{"type":"integer"},"owner_id":{"type":"integer"},"location_id":{"type":["integer","null"]},"format":{"type":"string"},"status":{"type":"string","enum":["available","loaned","lost","sold","broken","retired"]},"lending_model":{"type":"string","enum":["physical","account_bound","shareable_digital"]},"platform":{"type":["string","null"]},"components_missing":{"type":["string","null"]},"condition":{"type":["string","null"],"description":"Physical condition. For jewelry insurance records this can carry a description reference of the piece"},"acquired_at":{"type":["string","null"],"format":"date"},"notes":{"type":["string","null"],"description":"Free-form notes. For jewelry insurance records this can carry photo\/description references alongside the work cover_url"},"created_at":{"type":"string","format":"date-time"},"last_maintenance":{"type":["object","null"],"description":"Latest maintenance record (kind + date), or null when none logged. Present on GET \/api\/copies\/{id} only","properties":{"kind":{"type":"string"},"performed_at":{"type":"string","format":"date"}}}}},"QrMint":{"type":"object","properties":{"qr_token":{"type":"string","description":"Unguessable 48-hex-char label secret (rotated on every mint)"},"lookup_url":{"type":"string","description":"Absolute scan lookup URL built from the request host"}}},"CopyLabel":{"type":"object","properties":{"qr_token":{"type":"string"},"qr_svg":{"type":"string","description":"QR code SVG encoding the token, starting with \u003Csvg \u2014 embed in label printers \/ HTML"},"lookup_url":{"type":"string"},"title":{"type":"string"},"kind":{"type":"string"},"location":{"type":["string","null"],"description":"Human location path, e.g. \u0022House \u003E Garage Shelf\u0022, or null"},"copy_id":{"type":"integer"}}},"ScanResult":{"type":"object","description":"Scan-to-item payload from GET \/api\/copies\/by-qr\/{token}","properties":{"copy":{"$ref":"#\/components\/schemas\/Copy"},"work":{"type":"object","properties":{"id":{"type":"integer"},"title":{"type":"string"},"kind":{"type":"string"},"attributes":{"type":"object"}}},"location":{"type":["array","null"],"description":"Location path root-first (house \u2192 room \u2192 shelf), or null","items":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"}}}},"status":{"type":"string"},"active_loan":{"anyOf":[{"$ref":"#\/components\/schemas\/Loan"},{"type":"null"}]}}},"Attachment":{"type":"object","description":"Copy attachment record (metadata only \u2014 download bytes via GET \/api\/attachments\/{id})","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"copy_id":{"type":"integer"},"kind":{"type":"string","enum":["photo","receipt","warranty","manual","other"]},"original_filename":{"type":"string"},"mime":{"type":"string"},"size_bytes":{"type":"integer"},"uploaded_at":{"type":"string","format":"date-time"}}},"MaintenanceRecord":{"type":"object","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"copy_id":{"type":"integer"},"kind":{"type":"string","enum":["cleaned","sharpened","oiled","calibrated","repaired","replaced_part","inspected","other"]},"performed_at":{"type":"string","format":"date"},"notes":{"type":["string","null"]},"cost_cents":{"type":["integer","null"]}}},"SharedWork":{"type":"object","description":"Grantee view of a work via \/api\/shared\/works \u2014 identical to Work except owner-private notes are never exposed","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"kind":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"],"description":"Built-in kinds plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)"},"title":{"type":"string"},"subtitle":{"type":["string","null"]},"creators":{"type":"array","items":{"type":"string"}},"identifiers":{"type":"object","additionalProperties":{"type":"string"}},"publisher":{"type":["string","null"]},"year":{"type":["integer","null"]},"platform":{"type":["string","null"],"description":"Game platform for video_game works (e.g. PS5, Switch, PC) \u2014 one title on one platform is one work"},"cover_url":{"type":["string","null"],"description":"Cover\/photo URL (http\/https). For jewelry insurance records this can carry a photo reference of the piece"},"parent_id":{"type":["integer","null"]},"attributes":{"type":"object","description":"Kind-specific extras. Conventions: book {genre (one of the curated book genres, see GET \/api\/works\/genres)}; jewelry {estimated_value (USD number), appraisal_date (YYYY-MM-DD), serial_number}; spice {expiry_date, opened_date (YYYY-MM-DD)}; tool {brand, model, power_source (manual|battery|corded|gas, validated), purchase_year (1000-2100, validated), serial_number (validated)}; outdoor_recreation {brand, size}; cd {track_count, ...}; video_game {genre, ...}"},"external_refs":{"type":"object"},"created_at":{"type":"string","format":"date-time"}}},"SharedCopy":{"type":"object","description":"Grantee view of a copy via \/api\/shared\/works \u2014 identical to Copy except owner-private notes are never exposed","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"work_id":{"type":"integer"},"owner_id":{"type":"integer"},"location_id":{"type":["integer","null"]},"format":{"type":"string"},"status":{"type":"string","enum":["available","loaned","lost","sold","broken","retired"]},"lending_model":{"type":"string","enum":["physical","account_bound","shareable_digital"]},"platform":{"type":["string","null"]},"components_missing":{"type":["string","null"]},"condition":{"type":["string","null"]},"acquired_at":{"type":["string","null"],"format":"date"},"created_at":{"type":"string","format":"date-time"}}},"Loan":{"type":"object","properties":{"id":{"type":"integer"},"tenant_id":{"type":"integer"},"copy_id":{"type":"integer"},"borrower_id":{"type":"integer"},"loaned_at":{"type":"string","format":"date-time"},"due_at":{"type":["string","null"],"format":"date-time"},"returned_at":{"type":["string","null"],"format":"date-time"},"open":{"type":"boolean"},"overdue":{"type":"boolean"},"notes":{"type":["string","null"]}}},"Stats":{"type":"object","properties":{"works_by_kind":{"type":"object","additionalProperties":{"type":"integer"}},"copies_by_format":{"type":"object","additionalProperties":{"type":"integer"}},"on_loan":{"type":"integer"},"overdue":{"type":"integer"},"recently_added":{"type":"array","items":{"$ref":"#\/components\/schemas\/Work"}}}},"Analytics":{"type":"object","description":"M9 usage analytics (GET \/api\/analytics, MCP get_analytics). Aggregates only \u2014 no request bodies, IPs, or personal data.","properties":{"range":{"type":"object","required":["from","to"],"properties":{"from":{"type":"string","format":"date"},"to":{"type":"string","format":"date"}}},"api_calls":{"type":"object","properties":{"total":{"type":"integer"},"by_endpoint":{"type":"array","description":"Top 200 endpoints by calls, desc","items":{"type":"object","required":["endpoint","calls"],"properties":{"endpoint":{"type":"string","example":"\/api\/works\/{id}"},"scope":{"type":["string","null"],"example":"inventory:read"},"calls":{"type":"integer"}}}}}},"mcp_calls":{"type":"object","properties":{"total":{"type":"integer"},"by_tool":{"type":"array","description":"Top 200 tools by calls, desc","items":{"type":"object","required":["tool","calls"],"properties":{"tool":{"type":"string","example":"lookup_copy_by_qr"},"calls":{"type":"integer"}}}}}},"active":{"type":"object","properties":{"daily":{"type":"object","required":["agent_keys","human_users","date"],"properties":{"agent_keys":{"type":"integer"},"human_users":{"type":"integer"},"date":{"type":"string","format":"date"}}},"weekly":{"type":"object","required":["agent_keys","human_users"],"properties":{"agent_keys":{"type":"integer"},"human_users":{"type":"integer"}}},"monthly":{"type":"object","required":["agent_keys","human_users"],"properties":{"agent_keys":{"type":"integer"},"human_users":{"type":"integer"}}}}},"totals":{"type":"object","properties":{"works":{"type":"integer"},"copies":{"type":"integer"},"on_loan":{"type":"integer"},"overdue":{"type":"integer"}}},"signups":{"type":"array","description":"New users per day, zero-filled over the range","items":{"type":"object","required":["date","new_users"],"properties":{"date":{"type":"string","format":"date"},"new_users":{"type":"integer"}}}},"works_by_kind":{"type":"object","additionalProperties":{"type":"integer"}},"copies_created_by_kind":{"type":"array","description":"Copies created per day per work-kind (sparse \u2014 only days with creations)","items":{"type":"object","required":["date","kind","count"],"properties":{"date":{"type":"string","format":"date"},"kind":{"type":"string"},"count":{"type":"integer"}}}},"daily_calls":{"type":"array","description":"Per-day call series behind the dashboard chart (zero-fill missing days client-side)","items":{"type":"object","required":["date","api","mcp"],"properties":{"date":{"type":"string","format":"date"},"api":{"type":"integer"},"mcp":{"type":"integer"}}}}}},"ApiKey":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string","enum":["inventory:read","inventory:write","loans:write","keys:manage","sharing:manage"]}},"request_count":{"type":"integer","description":"Lifetime requests authenticated with this key (M6)"},"last_used_at":{"type":["string","null"],"format":"date-time"},"expires_at":{"type":["string","null"],"format":"date-time"},"revoked_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"Invite":{"type":"object","properties":{"id":{"type":"integer"},"type":{"type":"string","enum":["signup","household"],"description":"household = redeemer joins the inviter household as co-manager; signup is a legacy value from before open registration"},"email":{"type":["string","null"],"format":"email","description":"Bound address, or null when anyone may redeem"},"created_at":{"type":"string","format":"date-time"},"expires_at":{"type":"string","format":"date-time"},"used_at":{"type":["string","null"],"format":"date-time","description":"First redemption time, null until first use"},"revoked_at":{"type":["string","null"],"format":"date-time"},"max_uses":{"type":"integer","description":"Redemptions allowed (default 10)"},"use_count":{"type":"integer","description":"Redemptions consumed so far"},"remaining_uses":{"type":"integer","description":"Redemptions left"}}},"HouseholdMember":{"type":"object","properties":{"id":{"type":"integer"},"email":{"type":"string","format":"email"},"tenant_id":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"is_self":{"type":"boolean"}}},"LibraryGrant":{"type":"object","properties":{"id":{"type":"integer"},"owner_tenant":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer"},"name":{"type":"string"}}},"grantee_email":{"type":"string","format":"email"},"kinds":{"type":"array","items":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"],"description":"Built-in kinds plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)"}},"created_at":{"type":"string","format":"date-time"},"revoked_at":{"type":["string","null"],"format":"date-time"}}},"LoanRequest":{"type":"object","properties":{"id":{"type":"integer"},"status":{"type":"string","enum":["pending","approved","declined","cancelled"]},"copy_id":{"type":"integer"},"work_title":{"type":"string"},"work_kind":{"type":"string","enum":["book","board_game","cd","video_game","tool","outdoor_recreation","spice","jewelry"],"description":"Built-in kinds plus this tenant\u0027s custom kinds (see GET \/api\/custom-kinds)"},"requested_by_email":{"type":["string","null"],"format":"email"},"owner_tenant":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer"},"name":{"type":"string"}}},"due_at":{"type":["string","null"],"format":"date-time"},"notes":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"decided_at":{"type":["string","null"],"format":"date-time"}}},"KeyUsage":{"type":"object","required":["key","total_30d","usage"],"properties":{"key":{"$ref":"#\/components\/schemas\/ApiKey"},"total_30d":{"type":"integer","description":"Requests in the last 30 days (inclusive)"},"usage":{"type":"array","description":"Per-day counts, newest first; only days with traffic appear","items":{"type":"object","required":["day","requests"],"properties":{"day":{"type":"string","format":"date","example":"2026-09-17"},"requests":{"type":"integer","example":42}}}}}}}}}