docs(valuation): POST /api/valuation accepts an optional organization_id owner (chat#1938)

Merged
SW
4mo ago
+16-1

Contract for the valuation half of recoupable/chat#1938. Docs lead the api PR.

Why this exists

chat#1938 flagged an open design question: should POST /api/valuation also take organization_id? Resolved yes (decision recorded on the issue 2026-08-05). A valuation run is how catalogs actually get created, so shipping org-owned catalogs on POST /api/catalogs alone would leave every valuation-created catalog account-owned and reproduce the exact bug one layer up.

The related work on this endpoint was tracked on chat#1937, which was closed 2026-08-05 with its valuation items deliberately dropped — nothing else is picking this up.

What this documents

organization_id (optional, uuid) on RunValuationRequest. When present, the resulting catalog is owned by that organization, so every member sees it via Get Catalogs. The caller must be a member; otherwise 403.

The ownership boundary is stated explicitly, because it is easy to get wrong:

Account
Owns the resulting catalogthe organization
Spends the creditsthe calling account
Gets the searched artist on its rosterthe calling account

Also:

  • the operation description no longer says the endpoint "materializes an account-owned catalog"; the owner is now conditional
  • spotify_artist_id remains the only required field — omitting organization_id is byte-identical to today
  • new 403 response. The endpoint documented 400/401/402/404/504 but no 403; it will now return one for a non-member, so the contract needed it. Added rather than left as an undocumented-but-real code.

Sequencing

Last of the three docs contracts on chat#1938. The read half (docs#288 → api#815) lands first, then POST /api/catalogs (docs#289 → api#816), then this pair.

Verification

releases.json parses and still carries all 18 paths. /api/valuation now documents 200, 400, 401, 402, 403, 404, 504; organization_id is present on RunValuationRequest and required is still ["spotify_artist_id"]. valuation-run.mdx stays frontmatter-only per the repo convention.


Summary by cubic

Add optional organization_id to POST /api/valuation so runs can create organization-owned catalogs, matching POST /api/catalogs and closing the visibility gap noted in chat#1938.

  • New Features
    • RunValuationRequest accepts organization_id (uuid). Default stays account-owned; org-owned catalogs are visible to all members.
    • Ownership boundary: organization owns the catalog; calling account spends credits; searched artist is linked to the caller's roster.
    • Docs add 403 Forbidden when the caller is not a member of the named organization; endpoint description updated to reflect conditional ownership.

Summary by CodeRabbit

  • New Features

    • Valuations can now optionally assign the resulting catalog to an organization.
    • Added support for specifying an organization by UUID when submitting a valuation.
  • Bug Fixes

    • Added documentation for forbidden responses when the caller lacks organization access.
    • Clarified credit usage and artist roster behavior for organization-owned catalogs.