← Files Grid CatalogARCHIVED FILE
docs/api/catalog-source-media/README.md
9.68 KB · Nov 30, 2026 · 00:26 UTC
# Existing catalog source media
Implementation for #6973. **Not a deployment claim:** the media migrations, including the evidence-storage forward repair, and Edge Function must roll out together. Verify live MCP discovery and an authorized read before promising that saved research image gaps can be applied. No live listing changes are part of this implementation.
REST and MCP use the same typed request, pure media planner, authorized snapshot and transaction. This operation changes selected images on one existing source listing. Repeat [source imports](../catalog-source-import/README.md) remain create-or-reuse only. Canonical products, source UUID/hash, authored names/specifications, ownership and manufacturer/vendor matches remain unchanged. No generic company attachment workaround is supported.
| REST POST | MCP | Scopes |
| --- | --- | --- |
| `/api/v1/catalog-source-media/read` | `grid.get_catalog_source_media` | `grid:read` |
| `/api/v1/catalog-source-media/preview` | `grid.preview_catalog_source_media_update` | `grid:read` |
| `/api/v1/catalog-source-media/apply` | `grid.apply_catalog_source_media_update` | `grid:read grid:write` |
Every operation additionally requires current catalog-company administration and an active source row owned by that company. A source's public visibility grants no editing authority. Supply `company_id` and `source_item_id` for read. It returns source identity, original import provenance, media-update attribution history and current primary/gallery/variants.
Existing gallery entries may contain only a URL. Missing descriptive metadata stays absent; existing attribution is preserved, and an explicit gallery reorder updates positions. New image bindings still require their full reviewed metadata.
For new bytes, reuse `grid.request_catalog_source_image_upload` or REST `/api/v1/catalog-source-import/image-uploads` with the company, original image/document URL, SHA-256, MIME and byte count. PUT original bytes to its signed private upload URL outside the model. Grants require read/write scope and current company administration. Preview and apply verify the immutable staged bytes, including MIME, size and SHA-256; they never refetch the original source. Existing catalog import does not offer remote fetching, so this operation adds none. HTTP 403/429 acquisitions stay explicit research failures; do not bypass them or substitute placeholders.
Example preview envelope:
```json
{
"company_id": "11111111-1111-4111-8111-111111111111",
"source_item_id": "22222222-2222-4222-8222-222222222222",
"changes": {
"gallery": ["capture:reviewed-v3-photo"],
"primary_image_url": "capture:reviewed-v3-photo",
"variant_images": [{ "index": 0, "image_url": "capture:reviewed-v3-photo" }]
},
"expected_image_count": 1,
"image_bindings": [{
"client_url": "capture:reviewed-v3-photo",
"source_url": "https://manufacturer.example/model.pdf",
"sha256": "REPLACE_WITH_64_LOWERCASE_HEX_CHARACTERS",
"image_evidence": "REPLACE_WITH_RETURNED_STAGING_PROOF",
"alt_text": "Visually reviewed Model V3 configuration",
"source": "pdf",
"attribution": {
"evidence_kind": "manufacturer",
"association_note": "Exact model and configuration visually verified against the source",
"document_url": "https://manufacturer.example/model.pdf",
"page": 4,
"crop": [0.1, 0.2, 0.8, 0.9],
"rights_note": "Record known rights information; accessibility alone grants no rights"
}
}]
}
```
Replace illustrative evidence and IDs with reviewed actual values. Omit `variant_images` when the listing has no corresponding existing variant. A matching page SKU does not verify a photo: the Filmtools Studio 5X8-V3 listing's photo visibly says V2 and must remain excluded. Seller offering photos use `evidence_kind: seller`, even when the product brand is known. `association_note` records the user's reviewed association; the service does not visually verify the model or grant usage rights.
`gallery` is the complete intended gallery in order. It adds/removes/reorders references and preserves existing image objects/provenance except for position. `[]` clears gallery only; primary and variants remain independently selected. `primary_image_url: null` clears primary; `variant_images[].image_url: null` clears that variant's image. Omitted fields remain unchanged. Variant indices are zero-based indices from readback; variants cannot be created or their SKU/options/price changed. New references require explicit binding/provenance. Existing references can be reused from primary/gallery or explicitly addressed variants. Unused bindings, unknown references, duplicate gallery references and duplicate variant indices fail. Distinct capture references with identical SHA-256 are reported as duplicates and share one verified copy per attempt.
Bounds: one existing listing, 20 gallery references/new image bindings, 50 affected variants, 100,000 UTF-8 JSON bytes including confirmation, and 32 MiB total staged image bytes. Supported raster MIME types and minimum image size follow the existing upload contract. Page is one-based; crop is normalized `[left, top, right, bottom]` with positive area.
Show preview's current/proposed primary, gallery and variant references, removals, source attribution, exact staged copy intent, duplicate checksums and warnings before asking for explicit confirmation. Preview expires after 30 minutes. Apply sends the unchanged original envelope plus `preview_token`, a stable UUID `request_id`, and `confirm_preview: true`.
The signed intent binds actor, target and complete normalized request. Relevant revisions cover current primary/gallery and affected variants. Unrelated names, specifications, timestamps, catalog telemetry and untargeted variant edits do not invalidate the review. SQL patches the canonical `evidence` bag under the current spine schema, preserving unrelated evidence keys. It locks the target row and current authorization, then rechecks the revision and copy ownership before one atomic media/history/receipt write. Only targeted variant image keys change; concurrent unrelated variant facts survive. Original provenance is preserved; new evidence is appended under `raw_summary.media_updates` and in the durable receipt. No source facts or relationships are replaced.
All public copies must verify before metadata commits. Cleanup is tracked by the existing action storage ledger before copying; failed/losing attempts retain cleanup obligations. Removed references do not immediately delete storage that other references may still use. A timeout does not prove rollback. Retry identical arguments and request ID to recover the same saved outcome before expiry/media checks, after current authorization. Changed intent or a reused ID with different arguments fails. Do not delete potentially committed paths or claim failed copies succeeded. The receipt returns source identity, previous/current media, saved copy identities/checksums and attribution; authorized readback returns resulting media. Automatic reversal is not exposed: a correction is another explicitly reviewed media update; existing local app history is unchanged.
REST errors: 400 malformed JSON, 413 oversized HTTP body, 422 invalid fields/counts, 403 missing scope/source/company authority, 409 stale/expired preview or evidence/request conflict, 503 schema/upstream failure. MCP maps invalid input to `-32602`, authorization to `-32001`, review conflicts to `-32009`. Use [OpenAPI](openapi.json) for exact schemas.
## Shared Grid product image selection
This separate operation selects a shared image asset on a canonical Grid product. It reuses already verified Grid-stored originals from a matched source listing; no new bytes are fetched or copied. Available source gallery images become shared choices. Edits to a chosen asset's cutout appear wherever that asset is used, including manufacturer listings. Legacy scalar images stay readable.
| REST POST | MCP | Scopes |
| --- | --- | --- |
| `/api/v1/catalog-product-images/preview` | `grid.preview_catalog_product_image_selection` | `grid:read` |
| `/api/v1/catalog-product-images/apply` | `grid.apply_catalog_product_image_selection` | `grid:read grid:write` |
Both interfaces invoke the same guarded selection service and transaction and require current platform administration. Preview supplies `catalog_item_id` (UUID), `source_item_id` (matched source UUID, or `null` to clear), `representative` (boolean), and a nonblank `evidence_note` (at most 2,000 characters). A kit component source photo requires `representative: true`; this changes neither kit composition nor shared brush state. HTTP request bodies are limited to 16,000 bytes. Exact request/result schemas are in [OpenAPI](openapi.json).
Present current/proposed selection, available images, attribution and warnings for explicit review. Apply sends the unchanged intent plus `preview_token`, stable UUID `request_id`, and `confirm_preview: true`. The signed preview binds actor, exact intent, relevant product/source/asset revision and expiry. Atomic persistence rechecks current authority and revision and records an idempotent receipt. An identical retry recovers that receipt before checking expiry or now-unavailable source data. Changed intent/request reuse fails. To undo a selection, preview and confirm the previous selection; there is no automatic reversal. Mask edits remain owned by the app's local-first asset editor.
REST errors: 403 insufficient scopes/platform authority, 422 invalid intent/confirmation or unavailable product/source, 409 changed/expired preview or request conflict, 503 upstream/schema failure; malformed/oversized HTTP bodies use 400/413. MCP maps validation to `-32602`, authority to `-32001`, conflicts to `-32009`. No product associations are applied by this implementation or its tests.
SHA-256: 49d249caf8713d1f932b6b4f3f62e47fe55c3f3745ce726ac07bf491e1399f9d