Skip to main content

Contents Capture integration

Contents Capture is the field-capture platform (an iOS app backed by a Cloudflare Workers API, D1 metadata database, and a private R2 media bucket). ContentsVision integrates with it as a pull-based media source: users browse a connected Capture org like a folder tree and import selected media into claims.

Architecture​

ContentsVision PULLS media. All Capture traffic is server-to-server from the backend; the browser never talks to the Capture API and never sees the org token.

ContentsVision UI
| /api/integrations/... (team-scoped)
ContentsVision backend --Bearer cci_ token--> Contents Capture API
| |
| <-- short-lived presigned R2 GET URLs ------+
+--> downloads bytes, creates claims/rooms/jobs

Contents Capture API --signed webhook POST--> ContentsVision backend
(submission.created, /api/integrations/contents-capture/webhook
media.synced, -> auto-imports the submitted media into a claim
media.updated, -> with automatic processing on: imports and
media.deleted) processes, and keeps changes in step

Key properties:

  • Org-level access. A Contents Capture org admin mints an org integration token (cci_...) in the Capture admin console. A ContentsVision team admin pastes it under Settings, then Integrations. The token is read-only on the Capture side (its principal is an org-wide observer) and is validated against GET /integrations/whoami before it is stored. Teams set up through ContentsEstimation skip the paste: ContentsEstimation provisions the connection for them (see Automatic connection from ContentsEstimation).
  • The Capture API is the source of truth. Only media with syncState == "synced" has its original durably stored; browse and import filter on it. ContentsVision holds no R2 credentials: bytes are fetched through presigned GET URLs the Capture API signs per media id (1 hour TTL, signed in batches immediately before download).
  • Entity mapping. Capture assignment -> claim (the assignment reference becomes the claim number), location -> room (matched by name, created when missing), group -> staged photo group_index (grouping arrives pre-done), photo -> StagedPhoto in one photo job per room, video/audio -> one job per file.
  • Billing is never bypassed. Imported photo jobs park at awaiting_grouping and video/audio jobs at awaiting_confirmation; the user starts them through the normal quote/process step. The one exception is automatic processing, which starts jobs through the very same service (services/job_start.py), so charging and the enterprise exemption are identical.

Data model​

Four tables, declared in backend/app/models/integration.py and registered in database.py:init_db() (whole new tables, so no ALTER lines):

TablePurpose
storage_connectionsOne configured provider per team (kind = contents_capture). Holds the Capture org id (external_account_id) and the org token (api_token, following the Team.team_token precedent; secret_ref is the upgrade path to a secret manager).
uploadsOne piece of source media with provenance: (connection_id, external_media_id, claim_id) plus a still-existing job_id is the idempotency key (rows outlive deletes, so the job must still exist), sha256/size_bytes come from the Capture variant record, meta snapshots the capture tree (assignment/location/group ids) plus the media's tags and its capture intent (intent, groupIntent, marks). Lifecycle: `registered -> importing -> ready
import_batchesOne user-initiated import run: the selection manifest verbatim, progress counters (total/imported/skipped/failed), the claim it landed in, and the job ids it created. The UI polls this row. Also used by the claim-level contents-list PDF import, which has no connection and leaves connection_id blank, so both imports share one progress endpoint.
capture_auto_eventsAutomatic processing queue: one row per synced Capture media item waiting for its room to settle (connection_id, assignment_id, location_id, media_id, media_type, received_at). pending -> consumed (imported in batch_id) or dropped (deleted in Capture first).

Provider layer​

backend/app/services/integrations/ holds the adapter layer:

  • base.py defines the StorageProvider interface (browse a virtual tree, stat one item, stream its bytes) plus ProviderCapabilities, so future providers (S3, Dropbox, ...) plug in without touching callers.
  • registry.py maps StorageConnection.kind to a provider class via @register_provider / build_provider.
  • contents_capture.py implements the Capture provider: CaptureClient is a thin async httpx client over the Capture read API (same house style as adjust_square.py), and ContentsCaptureProvider is registered under contents_capture.
  • importer.py is the import engine (see below).

API endpoints​

All under /api/integrations, team-scoped via get_unlocked_actor (backend/app/api/routes/integrations.py): the standard Actor dependency, plus a 403 training_required refusal while required training locks the user:

EndpointPurpose
GET /integrations/connectionsThe team's connections plus contents_capture_available (false when the server has no base URL configured, which hides the integration in the UI).
POST /integrations/contents-capture/connectValidate a pasted cci_ token via whoami and store/replace the team's connection.
POST /integrations/contents-capture/provisionMachine-to-machine: ContentsEstimation connects a team automatically. No Actor; authenticated by Authorization: Bearer <CONTENTS_CAPTURE_PROVISIONING_SECRET>. See below.
DELETE /integrations/connections/{id}Disconnect.
GET .../connections/{id}/teams, .../teams/{tid}/assignments, .../assignments/{aid}/tree, .../assignments/{aid}/mediaBrowse proxy over the Capture read API. The media page passes Capture's presigned thumbnail URLs through to the grid.
POST .../connections/{id}/importSave a selection manifest on an ImportBatch and enqueue run_capture_import.
GET /integrations/imports/{batch_id}Poll import progress.
GET /integrations/contents-capture/arrivalsContentsCapture media the team has been sent that is still waiting to settle, one entry per Capture room (see Showing the wait).
POST /integrations/contents-capture/webhookPublic endpoint for Capture webhook deliveries (no Actor; the per-delivery HMAC signature authenticates it). A submission.created event auto-imports the submitted media. assignment.status_changed and assignment.archived update the Capture assignment status on the claims that assignment feeds (see Capturing status), whatever the automation flag. media.synced, media.updated and media.deleted drive automatic processing for teams that have it on. Everything else is accepted and ignored.

Automatic connection from ContentsEstimation​

ContentsCapture creates a company for each ContentsEstimation team and mints that company's read-only cci_ token. ContentsEstimation fetches the token and immediately hands it to POST /api/integrations/contents-capture/provision (it never stores it), so nobody pastes a token by hand. The manual paste still works for everyone else, and both routes share one helper (_save_capture_connection) so they run the same whoami check and keep one connection per team.

  • Auth. Authorization: Bearer <secret>, compared with hmac.compare_digest against CONTENTS_CAPTURE_PROVISIONING_SECRET. Unset secret: 503 (fail closed). Missing or wrong: 401. A user session is never accepted. ContentsEstimation holds the same value.
  • Body. {"ce_team_id": int, "team_name": str, "token": str}.
  • Team. Found by Team.external_id == ce_team_id, the same _find_or_create_team lookup SSO login uses. If nobody from that team has logged in yet, a placeholder team (that external_id and name, empty team_token) is created; the first login finds it, fills in the team token and CE key (and the name if it was blank), and never creates a second team. If whoami rejects the token, the placeholder is rolled back with it.
  • Rules. No connection yet: created. Same Capture org: the token is replaced in place (key rotation), keeping the row id so import history stays attached. Different Capture org: 409 and nothing changes (someone connected another org on purpose; sort it out by hand). Same input again: unchanged, no write and no activity row.
  • Response. {team_id, connection_id, capture_org_id, result} with result in created | updated | unchanged.
  • Attribution. Activity rows are written by a synthetic actor named "ContentsEstimation (automatic)" with an empty user id, and the connection's created_by_user_id is empty, so webhook auto-imports on a provisioned connection have no creator either. The token is never logged.

Automatic import on submission (webhooks)​

Manual import is the pull path. The push path removes the button entirely: when the field team submits an assignment in Capture, the media imports itself and a claim appears in ContentsVision.

Setup (one time, per Capture org):

  1. Set CONTENTS_CAPTURE_WEBHOOK_SECRET on the backend to a long random string and restart. Empty disables the endpoint: it answers 503 and manual import keeps working.
  2. In Contents Capture, register the endpoint (org admin with webhook.manage): POST /orgs/:id/webhook-endpoints with url = https://<contentsvision-host>/api/integrations/contents-capture/webhook, subscriptions = ["submission.created"], and secret set to the same value. Capture signs every delivery with it (X-CC-Signature: sha256=<hex HMAC-SHA256 of the raw body>).

What happens on each submission:

  1. Capture emits submission.created (data carries assignmentId and the exact mediaIds submitted) and its queue consumer POSTs the signed event to the endpoint, at-least-once with retries on non-2xx.
  2. The endpoint verifies the signature (401 on mismatch, which Capture retries and then logs as a terminal delivery failure), resolves the team's connection by the event's org id, and ignores deliveries for orgs with no active connection (202, so stale endpoints drop instead of retrying).
  3. A submission.created event becomes an ImportBatch whose manifest selects exactly the submitted media (submitted_only as a belt-and-braces filter) and is run by the same run_capture_import engine as a manual import. The batch's manifest.auto records the event/submission/delivery ids.
  4. Targeting: the first submission of an assignment creates a new claim (numbered from the assignment reference, as always). If an earlier import for the same assignment and connection already landed in a claim, manual or automatic, follow-up submissions append into that claim (existing_claim mode), so supplemental submissions extend the original claim instead of minting duplicates.
  5. Replay safety: a redelivered event id, or a new event id for the same submission id, returns the batch the first delivery created. Media-level idempotency in the import engine covers everything below that.

The provider layer advertises this as has_events=True on ContentsCaptureProvider; handle_webhook verifies the signature, binds the event's org to the connection, and normalizes the payload into an IngestEvent.

The selection manifest​

The import request is selector-based, never a flat list of media ids, so selecting "everything" stays a tiny request and the server expands it:

{
"assignment_id": "...",
"target": {"mode": "new_claim" | "existing_claim" | "room", "claim_id": "...", "room_id": "..."},
"select": [{"scope": "assignment"} , {"scope": "location", "id": "..."},
{"scope": "group", "id": "..."}, {"scope": "media", "ids": ["..."]}],
"exclude": [ ...same shapes... ],
"filters": {"types": ["photo"], "submitted_only": false}
}

The import job​

run_capture_import runs on the ARQ worker in production (REDIS_URL set) or as a BackgroundTask locally, registered in worker.py and core/queue.py. Per batch it:

  1. expands the manifest against the Capture API (synced media only, cursor-paginated), applies excludes and filters, deduplicates;
  2. resolves the target claim first (a retried new-claim batch reuses the claim it made), then skips only media already imported into THAT claim whose upload job still exists (_already_in_claim), counting them as skipped. Upload rows are never removed when an upload, room or claim is deleted, so before 2026-10-22 the check covered every claim on the connection: a new-claim re-import landed 0 rooms and 0 media ("N already imported earlier") and the Capture link then pointed at that empty claim;
  3. maps rooms only for the media being imported, creating missing ones by name;
  4. signs original URLs in batches of 200 immediately before downloading (bounded concurrency, CONTENTS_CAPTURE_IMPORT_CONCURRENCY), normalizes photos to JPEG with the EXIF orientation baked into the pixels (Capture keeps its originals untouched, tag included, so a portrait phone photo arrives as landscape pixels plus a "rotate me" tag; upright_rgb in services/image_encode.py turns them before the re-encode drops the tag), falling back to the Capture proxy variant when the original is not Pillow-readable (e.g. HEIC), seeds staged_photos with group indices carried over from Capture groups, and with each photo's capture intent and marks;
  5. updates the batch counters as it goes and finishes complete, partial (some files failed; re-running the import retries just those), or failed.
  6. reports the claim back to Capture (PUT /assignments/{id}/links/contentsvision with {claimId, claimNumber, appUrl}, via CaptureClient.link_claim), so the Capture admin console links from the assignment to this claim. appUrl is this instance's own origin (own_app_origin(): PUBLIC_APP_BASE_URL, else the first CORS origin, https only), so a claim on the sgk instance opens sgk.contentsvision.com, not the main app. Capture accepts only origins on its CONTENTSVISION_APP_URLS list and refuses others with a 400; it builds the URL itself. The most recent import wins. Best effort: report_claim_link never fails the import, but a miss is logged AND reported to Sentry (flow=contents_capture_claim_link, with status_code, message, response_body, app_url, assignment_id, claim_id). It used to be a log line only, and the sgk instance sent a non-allowlisted origin for three weeks with Capture answering 400 every time before anyone noticed.

Imports that ran before the back link existed are reported by a one-time backfill, backend/scripts/backfill_capture_claim_links.py (dry run by default, --commit to report). It picks each assignment's most recent finished import (latest_claim_per_assignment), skips deleted claims, and calls Capture with that connection's own token, so re-running it is harmless. Run it on every instance (main and sgk): each one only knows its own claims and reports its own origin. A new ContentsVision instance must also be added to Capture's CONTENTSVISION_APP_URLS (services/api/wrangler.toml) or its links are refused.

Automatic processing (off by default)​

Requested by our enterprise customer (on terms, no prepaid credits): ContentsCapture media is identified without anyone pressing Process. Code: backend/app/services/integrations/capture_auto.py. Two switches must both be on:

  1. ContentsVision, per team: the capture_auto_process component flag (admin Teams tab, component_visibility, default off). Turn on enterprise for the same team so no credits are charged; without it the normal charge applies (and a team short on credits keeps its jobs parked).
  2. ContentsCapture, per org: a workflow with the Send to ContentsVision action. It POSTs the triggering event to this endpoint, signed exactly like a webhook endpoint delivery (X-CC-Signature, with Capture's CONTENTSVISION_WEBHOOK_SECRET equal to our CONTENTS_CAPTURE_WEBHOOK_SECRET), with one extra field: {"event": ..., "deliveryId": "<runId>:<nodeId>", "signedAt": ..., "automation": {"autoProcess": true, "workflowId": ..., "runId": ...}}. The workflow's trigger picks the timing. Capture ships two presets: identify media as it syncs (trigger media.synced) and identify media when a room or assignment is submitted (trigger submission.created), both also firing on media.updated and media.deleted so changes stay in step.

Per event:

EventWith automation and the flag on
submission.createdThe normal auto-import, with manifest.auto.process = true. At the end of _run the importer starts every job it created (if the flag is still on). A duplicate of a submission first imported by a plain endpoint upgrades that batch and starts its parked jobs.
media.syncedA capture_auto_events row (pending). Photos wait until their room (Capture location) has had no new synced photo for CONTENTS_CAPTURE_AUTO_SETTLE_SECONDS (default 180), so a group shot over a minute or two is identified together; video and audio settle at once. run_capture_auto_settle (deferred ARQ job, re-deferred while photos keep arriving) turns the room's rows into one ImportBatch (auto.process = true, target = the assignment's earlier claim or a new one) and runs it inline under a per-assignment lock, so two rooms cannot both create the claim. The 202 response carries settlesAt (UTC ISO 8601 with a Z: when that room's settle check will import, i.e. the newest pending photo plus the window, or now for video and audio; a redelivery reports the same moment) and settleSeconds (the window that applies: CONTENTS_CAPTURE_AUTO_SETTLE_SECONDS for photos, 0 for video and audio), so ContentsCapture can show a countdown.
media.updated / media.deletedAuto-sync (only the flag is required). See below.

Showing the wait in ContentsVision. capture_auto.pending_arrivals groups the pending rows by Capture room and reports photo/video/audio counts, settles_at, the claim they will import into (target_for_assignment, or null when the assignment has no claim yet) and the claim room an earlier import mapped that Capture location to (from uploads.meta.locationId). Two endpoints expose it as {arrivals: [...], settle_seconds}: GET /api/claims/{id}/capture-arrivals (team-scoped) drives a notice on the claim page ("3 photos arriving from ContentsCapture for Kitchen, importing in 2:10", live countdown, components/CaptureArrivalsNotice.tsx), polled every 20 s while the claim is Capturing or something is waiting; and GET /api/integrations/contents-capture/arrivals (the whole team) drives the same notice on the Dashboard for assignments with no claim yet ("for a new claim"), polled every 30 s while the team has an active Capture connection. When a countdown reaches zero the page reloads a few seconds later to pick up the import.

Auto-sync, by where the media is:

  • Still settling: a delete marks the row dropped; a move updates its location and restarts that room's window.
  • Imported, not processed (awaiting_* / error): delete soft-deletes the StagedPhoto (Upload.status = source_deleted); move or replaced content soft-deletes it and re-imports the media unprocessed (superseded); a group change moves it into the pile of its new Capture group. A parked job left with nothing is discarded. Video/audio: the parked job is discarded and replaced media re-imported.
  • Processed (complete): the items found in the photo's whole group (source_photo_path, photo_path or any ItemPhoto.path on one of the group's staged files), or every item of a video/audio job, are archived (restorable 30 days). The group's Uploads become superseded (the deleted one source_deleted) so the re-import is not skipped as already present, and the rest of the group (plus the changed media) is re-imported with process: true. Items with contents_estimation_sent_at or submitted are never archived.
  • Processing, or still being imported: the change is retried by run_capture_auto_change every CONTENTS_CAPTURE_AUTO_CHANGE_RETRY_SECONDS (default 60), up to 30 times. "Still being imported" means no ready Upload exists yet but an import naming the media is in flight (an Upload in pending/importing, or a pending/expanding/importing ImportBatch whose media selector lists it). Without this, a delete arriving seconds after a content change was ignored and the queued re-import brought the deleted media back (found on stage, 2026-11-11).
  • Tag and note changes only refresh Upload.meta, with one exception: capture intent. A change to intent or marks, or adding or removing the "scoping" tag, changes what is itemized. _intent_changed compares what the refreshed Upload.meta asks for with what the photo was staged with (StagedPhoto.intent, .marks) or, for a video, with ProcessingJob.intent. No difference is still metadata-only. A real difference is applied in place before processing (the staged photo, or the parked video job, takes the new values) and after processing it takes the processed path above: archive, supersede, re-import with process: true. Marks on a video and intent on audio are ignored.
  • media.updated names the changed fields (data.fields) but does not carry their new values. _changed_values uses a value when the event has one and otherwise reads the media from the Capture API (GET /media/{id}, one call per event, only for events naming tags, notes, intent or marks). If that read fails the change is logged and treated as "nothing changed".
  • A group's intent flipping. ContentsCapture sends one media.updated per live media item in the group, with fields: ["intent"], via: "group" and groupIntent: "scoping" | "items". The media body does not change in that case, so no read is made: _group_intent_of takes groupIntent from the event into uploads.meta.groupIntent, and the photo is re-resolved from there (a photo that is scoping in its own right stays scoping). On a processed group the first photo's event archives and re-imports the whole pile; the other photos' events find that import in flight and retry until it lands, by which time they already match.

Every automatic action writes the activity log (capture_auto_process, capture_auto_sync). Tests: backend/tests/test_capture_auto_process.py.

Capture intent: scoping photos and videos​

ContentsCapture records what the field specialist meant each photo to be, and ContentsVision follows it (AS-1585, epic AS-1584). The field names are a contract with ContentsCapture's shared schema and are read as sent.

FieldOnValues
intentmedia and group bodies"items" (default) or "scoping"
marksmedia bodiesList of pins and boxes drawn on the photo: {id, kind: include or exclude, shape: {type: "point", x, y} or {type: "box", x, y, w, h} with x, y the top-left corner, source, createdBy, createdAt}, coordinates 0..1 from the top-left of the upright photo. Both fields are always present on GET /media/{id} from a current Capture API

The rules (all in services/capture_intent.py, pure functions):

  • A group is one item. An ungrouped photo holds one or more items. A scoping photo or video holds no items: it documents the room.
  • A photo is scoping when its own intent is scoping, when its group's intent is scoping, or when it or its group carries a tag named "scoping" in any letter case (the habit some teams already had, and the way an older app version can use the feature).
  • A value this version does not know is treated as items, so it can never stop a photo from being itemized.
  • Marks are ignored whenever the resolved intent is scoping. Capture refuses marks on media whose own intent is scoping, but a marked photo can sit in a scoping group. uploads.meta.marks keeps what was sent; staged_photos.marks is blank while the photo is scoping (meta_marks_json), and comes back if the photo stops being scoping.
  • A room can hold several scoping groups (two phones offline can each create one). Every group is judged on its own body; nothing assumes one per room.
  • Media with no intent and no marks is items with no marks, which is exactly the behaviour before the fields existed.

Where it is stored.

PlaceWhat
uploads.meta.intentThe media's own intent as stated (items when absent)
uploads.meta.groupIntentWhat its group asked for at import, from the group body in the assignment tree (intent or the tag)
uploads.meta.marksThe marks list as sent ([] when absent)
staged_photos.intentThe resolved intent the pipeline reads
staged_photos.marksThe marks as JSON text, blank while the photo is scoping. Read by the photo pipeline for a lone photo (see marked photos)
processing_jobs.intentscoping on a scoping video job. Photo jobs stay items (their intent is per photo). Audio is never scoping

Group bodies arrive in GET /assignments/{id}/tree (groups[].group), which the importer already fetches, so resolving a group's intent costs no extra call. A scoping photo inside an ordinary (non-scoping) group is staged in a pile of its own, so it is not sent as one of that item's angles.

What a scoping photo or video does.

  • No AI call, no credit. run_grouped_photo_pipeline takes scoping photos out before grouping. _job_estimate_credits leaves them out of the quote, so nothing is charged up front either. A job whose photos are all scoping completes with zero items and a zero charge.
  • A scoping video is parked like any other video. Its quote is 0 credits, and run_pipeline finishes it at once (_complete_scoping_video): no extraction, no transcription, no AI call.
  • It is kept. The StagedPhoto row and its file (<storage>/<job_id>/photos/orig_####.jpg) stay on the room's photo job, and a scoping video keeps its job and file. A room's scoping media is therefore: staged photos with intent = 'scoping' and deleted = false on the room's photo jobs, plus the room's video jobs with intent = 'scoping'. Who took it and when is on the matching uploads row (meta.capturedBy, meta.capturedAt). No new table. The Room photos tab and room cover read from here, see Room photos and the room cover.
  • On the grouping screen a scoping photo carries a Scoping label and counts as free. In a room's Uploads table a scoping video carries a Scoping pill.

Tests: backend/tests/test_capture_intent.py.

Marked photos​

The specialist can mark a photo in ContentsCapture (AS-1586): numbered pins and boxes on the items they want (kind: include), or on what they do not want (kind: exclude). The marks arrive as marks on the media body and are stored on staged_photos.marks. Everything decided in code lives in services/photo_marks.py.

The photo hasWhat ContentsVision doesPrompt
Any include markOnly the marked items. One AI call with the untouched photo and a copy with the numbered include marks drawn on it.photo_marked
Only exclude marksThe normal all-items call, with a copy showing the excluded regions (red, crossed, numbered) and a text list of them. Afterwards items in an excluded region are discarded.photo_unmerged (or its edge variant)
No marksUnchanged.photo_unmerged

Numbering. A mark's number is its position in the list as sent (1 first, counting every mark), so the number drawn is the one the specialist saw. A mark that cannot be read is skipped and keeps its number.

Coordinates. A mark is 0..1 from the top-left of the upright photo: a point is x, y; a box is x, y, w, h with x, y its top-left corner. The AI's item boxes are x1, y1, x2, y2. Mark.as_box converts. The importer bakes EXIF orientation into the pixels, so the stored photo is the upright one the marks were drawn on.

The drawn copy. render_marked_copy writes marked_<filename> beside the photo in <storage>/<job_id>/photos/. The original is evidence and is only read. The same copy is what review shows.

Enforcement is in code, not in the prompt (enforce_include_marks), applied in the order the AI returned the items:

  • A number that is not one of the photo's include marks is ignored.
  • A mark belongs to at most one item: the first to name it keeps it.
  • An item left with no mark is discarded and counted in the job log and stage line.
  • An item keeping several marks is that many identical items: its quantity becomes the number of marks.
  • An include mark no item claimed is saved as a placeholder item, "Marked item, not identified", flagged (confidence 0), framed on the mark, carrying the mark's number. A mark is never silently lost.

Every kept item holds at least one mark no other item holds, so kept items plus placeholders never exceed the number of include marks: five marks cannot yield six items, whatever the model returns.

Exclude marks (drop_excluded_items): an exclude box drops an item when the centre of its returned box is inside the exclude box; an exclude pin drops the item whose returned box contains the pin. An item with only the whole-photo default box is kept (nothing says where it is).

Where marks are not used. A grouped photo (a group is one item, whichever prompt it uses), a drawn segment, an item the user named, and a scoping photo (its staged_photos.marks is blank, and it never reaches the AI). Include marks win when a photo has both kinds.

Failure modes. A failed AI call saves no placeholders: it is an outage, not an empty answer, and the job fails or bills as usual. If the copy cannot be drawn the photo counts as a failed request. A marked photo never reports "more items remain", because unclaimed marks are already placeholders; a photo with exclude marks can, and the read-the-rest pass keeps its exclusions.

Billing. One call per photo, however many marks. Unchanged.

On the item. inventory_items.mark_numbers (JSON list of mark numbers), marked_photo_path (URL of the drawn copy; also set for items from an exclude-only photo), and outside_marks (true for an item a desk user adds from a marked photo with "Add item from this photo", labelled "Outside the specialist's marks").

Review UI. The inventory table and Guided Review show Mark N (or Marks 1, 4) and the outside label. Guided Review shows the drawn copy as "Specialist's marks".

Changes. capture_auto.handle_change already re-runs a processed photo when its marks change (archive, re-import, process: true), which is now the right behaviour: the new marks decide what is kept.

Tests: backend/tests/test_marked_photos.py.

Room photos and the room cover​

Scoping media has a home in the review UI (AS-1588): a Room photos tab on the room page and a room cover wherever a room is listed. Both read the storage described above through one module, services/room_media.py. There is no new table and nothing is copied.

WhatWhere
The tab's dataGET /api/rooms/{id}/room-media (room_media.list_room_media): scoping photos, then scoping videos, each with a URL, captured_at, captured_by_id and captured_by_name
The cover's datacover_photos (up to four photo URLs) and room_media_count on every room response: GET /api/claims/{id}/rooms, GET /api/rooms/{id}, and the rename and archive responses. room_media.covers_for_rooms builds them for a whole claim in two queries
The tabcomponents/RoomPhotosTab.tsx, on app/rooms/[id]/page.tsx. Shown with a count, hidden when the room has no scoping media. Photos open in a full-screen viewer; a video plays in place
The covercomponents/RoomCover.tsx, a 2 by 2 grid. Used on the claim page's room cards and list (ClaimRoomViews.tsx), the room page header, and Send for Estimation's Pick Rooms step (SubmitClaimModal.tsx). It renders nothing for a room with no scoping photos, so that room looks as it always did

Order. Photos are ordered by photo job (oldest first), then by file name. The importer numbers a job's files in capture order (orig_0000.jpg is the earliest), so within one import this is the order the shots were taken. The cover is the first four photos of that same list. A room with only a scoping video has a Room photos tab but no cover, because a cover is made of photos.

Who and when. captured_at is uploads.meta.capturedAt, falling back to staged_photos.captured_at for a photo with no upload row. captured_by_id is uploads.meta.capturedBy, a ContentsCapture user id. ContentsCapture does not send a name with the media, and ContentsVision has no copy of Capture's user list, so captured_by_name can only be filled in from what an import recorded: the person who submitted a room, kept on the automatic import batch (ImportBatch.manifest.auto.actor, {user_id, name, email}). When the capturing user is one of those people on this claim, the name is returned. Otherwise it is blank and the tab reads "Captured in ContentsCapture". A claim imported by hand, or a photo taken on a second phone whose owner never submitted, therefore has no name. Closing that gap needs ContentsCapture to send the name on the media body (or expose a user lookup the integration token can read).

Clicking a cover opens /rooms/{id}?tab=room-photos. In Send for Estimation it opens in a new browser tab, so the send in progress is not lost.

The Uploads table still lists a scoping video. It is an upload like any other: a manually imported one waits there at Awaiting Confirmation with its Start processing button, and it counts as unprocessed media until started. Once finished, its row's action is View in Room photos instead of View Inventory, since it has no inventory. Scoping photos stay inside their photo upload's row, as before.

Never an item. Item totals, both exports, the Adjust Square quote and send, and the ContentsEstimation payload all read inventory_items. Scoping media has no row there, and _build_contents_estimation_payload declares only the rooms its items name, so a room holding nothing but scoping media is not even mentioned in a send. The room card's Photos count is a count of uploaded photos, not items, and does include scoping photos. The ContentsEstimation hand-off carries no room-level imagery: rooms is a list of names, and photos travel only on items (items[].photos, items[].image_url). The cover and the room photos therefore do not reach ContentsEstimation today. ContentsEstimation does have room photos of its own (a room_photos table filled by adjuster uploads on its Rooms tab, printed room by room in its Claim Photo Report), but its intake accepts only a room's name and kind, so sending scoping photos there would need a new field on their intake first.

Tests: backend/tests/test_room_media.py (the endpoint, the cover with 0, 1, 3, 4 and more photos, team scoping, and the rule that scoping media changes no total, export or send).

Who an auto-created claim is credited to​

An automatic import has no person pressing Import, and its ImportBatch carries the connection owner (StorageConnection.created_by_user_id, whoever connected the integration) as created_by_user_id. Claims used to be credited to that person, so a claim showed "Created by Kari" when Dan created the assignment in Capture.

  • Who the creator is: claim_source.capture_creator reads assignment.createdByName / createdByEmail from the assignment tree (Capture PR #117; a nested createdBy {name, email} is tolerated). Fallback: the actor of the event that started the import (event.actor {userId, email, name}, stored as manifest.auto.actor by the submission.created path; media.synced batches do not record it). Both are read defensively: older Capture builds send neither.
  • Crediting (claim_source.credit_capture_creator, only on claims whose first import batch was automatic and targeted a new claim, and only while the claim is still credited to the connection owner). importer._run calls it through claim_source.credit_assignment_claims for every claim the connection and assignment feed, right after it reads the assignment tree and BEFORE the "nothing new to import" return, on every import (automatic or manual); and once more for a claim the automatic import has just created: a ContentsVision user on the claim's team with the same email (case-insensitive) becomes created_by_user_id; otherwise the owner stays as the technical owner and created_by_external_name / _email are stored and shown as Created By (grid and claim header) with a ContentsCapture marker. No creator known: unchanged (the connection owner).
  • Assigned To is not corrected. A new claim starts assigned to its creator (the before_insert hook on Claim), which for an automatic import is the connection owner at insert time (unassigned on a provisioned connection, which has no owner); crediting changes only Created By, so reassign the claim by hand if needed.
  • Manual imports keep the person who pressed Import when they create the claim. A manual import into an auto-created claim corrects that claim's creator like any other import (the presser does not become the creator).
  • Requires ContentsCapture 1.2.1 or later in production. Until Capture sends createdByName / createdByEmail (or event.actor), nothing is known and every auto-created claim keeps the connection owner.
  • Existing claims: there is no backfill, because the creator is only known from the Capture API (an offline backfill cannot read it). A claim auto-created before this is corrected by the next import of its assignment, automatic or manual, even one that brings in no new media.
  • Activity log: automatic imports (capture_import_started, capture_import, capture_auto_process, capture_auto_sync) are logged as "ContentsCapture automation" with a blank user_id, never as the connection owner.

Tests: backend/tests/test_capture_claim_creator.py.

Source column​

Every claim records where it came from in claims.source (services/claim_source.py), shown as the Dashboard's sortable, filterable Source column (components/ClaimSourceBadge.tsx). A claim created by a Capture import is contents_capture, and importer._run re-stamps any non-training claim it lands media in (claim_source.mark_from_capture), so a hand-made claim that pulls Capture media reads ContentsCapture too. A training claim keeps training. Claims older than the column were backfilled once (claim_source_backfill_2026_11_11 in data_migrations) from import_batches.claim_id.

Capturing status​

A claim fed by Capture used to read Ready for review as soon as its first photo was processed, while the field adjuster was still taking photos. Now the claim shows Capturing until the assignment is handed off on the Capture side.

  • What is stored: claims.capture_assignment_status (plus capture_status_at), the assignment's status as last heard from Capture. Capture's statuses are draft, active, in_review, submitted, completed, archived; draft and active mean "still capturing" (claim_source.CAPTURE_IN_PROGRESS).
  • Where it comes from:
    1. every import (importer._run) reads assignment.status from the assignment tree it already fetches and applies it to every claim the assignment feeds (claim_source.record_capture_status, which finds them through import_batches.claim_id), including imports that bring nothing new;
    2. assignment.status_changed (data.to) and assignment.archived webhook events, applied the same way, ignoring an event older than the stored capture_status_at. Capture emits assignment.status_changed with to: "submitted" when a submission covers every remaining media, and to: "active" when new media arrives after that (so Capturing comes back). There is no assignment.submitted event; submission.created alone does not say whether the whole assignment is done, but the import it triggers re-reads the status.
  • Status rule: capturing ranks right after needs_attention and above processing (services/claim_status.py), so an upload a person has to act on still shows first, and auto-processing does not flicker the claim between Processing and Capturing. A status picked by hand still wins while the automatic one is unchanged, and like any hand status it is cleared once the claim moves on by itself (here: when capture ends). Capturing itself cannot be picked by hand.
  • Delivery gap to know about: a Capture org whose only ContentsVision workflow is the media.synced preset sends no event when the assignment is submitted, so its claims keep reading Capturing until another import or a status event arrives. Fix on the Capture side: add assignment.status_changed (and assignment.archived) to that workflow's alsoOn, or subscribe the plain webhook endpoint to them. Claims imported before this column existed have a blank status (never Capturing) until their next import or event.

Tests: backend/tests/test_claim_source_and_capturing.py.

Configuration​

SettingMeaning
CONTENTS_CAPTURE_API_BASE_URLThe Capture API base URL. Empty (default) disables the integration entirely. Dev/stage: https://contents-capture-api.dev-908.workers.dev.
CONTENTS_CAPTURE_WEBHOOK_SECRETHMAC secret verifying Capture webhook deliveries at the auto-import endpoint. Empty disables the endpoint (503); manual import works regardless. See "Automatic import on submission".
CONTENTS_CAPTURE_IMPORT_CONCURRENCYParallel downloads per import run (default 4).
CONTENTS_CAPTURE_AUTO_SETTLE_SECONDSAutomatic processing: how long a room must go without a newly synced photo before its photos are imported and processed together (default 180).
CONTENTS_CAPTURE_AUTO_CHANGE_RETRY_SECONDSAutomatic processing: how long a media change waits before retrying when its job is still processing (default 60).

Per-team org tokens live on storage_connections.api_token, not in the environment.

Frontend​

  • Integrations page (frontend/src/app/integrations/page.tsx, card in frontend/src/components/IntegrationsCard.tsx): connect (token paste + validate), connected state, disconnect. It sat under Settings until the Integrations page was added; the card itself is unchanged.
  • Import browser (frontend/src/components/CaptureImportModal.tsx): a folder-style explorer (assignment folders on the left, media grid on the right) with tri-state folder checkboxes, shift-click range select, type and submitted-only filters, selector-based selection, and a polling progress view. Opened from the Dashboard ("new claim" imports) and the claim page ("into this claim" imports); the buttons render only when the team has an active connection.
  • Room photos tab and room cover (components/RoomPhotosTab.tsx, components/RoomCover.tsx): where scoping photos and videos are shown, see Room photos and the room cover.
  • Arrivals notice (components/CaptureArrivalsNotice.tsx): the settle countdown on the claim page and the Dashboard, see Showing the wait.
  • Product switcher (components/ProductSwitcher.tsx): the brand block in the top left corner jumps to the ContentsCapture admin console (or ContentsEstimation), with links picked by hostname so each instance links to its own siblings. On an Enterprise deployment the ContentsCapture entry shows only for a person whose capture_admin switch is on. See frontend and product access.

Pointing an instance at a Capture environment​

Which Capture stack an instance talks to is configuration only: set CONTENTS_CAPTURE_API_BASE_URL to that environment's API host (the dev/stage host is above), have org admins mint tokens there (or let ContentsEstimation provision them), register the webhook endpoint with the same CONTENTS_CAPTURE_WEBHOOK_SECRET, and add the instance's origin to Capture's CONTENTSVISION_APP_URLS so the claim back link is accepted. No code changes.