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 againstGET /integrations/whoamibefore 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
referencebecomes the claim number), location -> room (matched by name, created when missing), group -> staged photogroup_index(grouping arrives pre-done), photo ->StagedPhotoin one photo job per room, video/audio -> one job per file. - Billing is never bypassed. Imported photo jobs park at
awaiting_groupingand video/audio jobs atawaiting_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):
| Table | Purpose |
|---|---|
storage_connections | One 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). |
uploads | One 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_batches | One 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_events | Automatic 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.pydefines theStorageProviderinterface (browse a virtual tree, stat one item, stream its bytes) plusProviderCapabilities, so future providers (S3, Dropbox, ...) plug in without touching callers.registry.pymapsStorageConnection.kindto a provider class via@register_provider/build_provider.contents_capture.pyimplements the Capture provider:CaptureClientis a thin async httpx client over the Capture read API (same house style asadjust_square.py), andContentsCaptureProvideris registered undercontents_capture.importer.pyis 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:
| Endpoint | Purpose |
|---|---|
GET /integrations/connections | The 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/connect | Validate a pasted cci_ token via whoami and store/replace the team's connection. |
POST /integrations/contents-capture/provision | Machine-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}/media | Browse proxy over the Capture read API. The media page passes Capture's presigned thumbnail URLs through to the grid. |
POST .../connections/{id}/import | Save a selection manifest on an ImportBatch and enqueue run_capture_import. |
GET /integrations/imports/{batch_id} | Poll import progress. |
GET /integrations/contents-capture/arrivals | ContentsCapture 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/webhook | Public 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 withhmac.compare_digestagainstCONTENTS_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_teamlookup SSO login uses. If nobody from that team has logged in yet, a placeholder team (thatexternal_idand name, emptyteam_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}withresultincreated | 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_idis 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):
- Set
CONTENTS_CAPTURE_WEBHOOK_SECRETon the backend to a long random string and restart. Empty disables the endpoint: it answers 503 and manual import keeps working. - In Contents Capture, register the endpoint (org admin with
webhook.manage):POST /orgs/:id/webhook-endpointswithurl = https://<contentsvision-host>/api/integrations/contents-capture/webhook,subscriptions = ["submission.created"], andsecretset 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:
- Capture emits
submission.created(data carriesassignmentIdand the exactmediaIdssubmitted) and its queue consumer POSTs the signed event to the endpoint, at-least-once with retries on non-2xx. - 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).
- A
submission.createdevent becomes anImportBatchwhose manifest selects exactly the submitted media (submitted_onlyas a belt-and-braces filter) and is run by the samerun_capture_importengine as a manual import. The batch'smanifest.autorecords the event/submission/delivery ids. - 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_claimmode), so supplemental submissions extend the original claim instead of minting duplicates. - 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:
- expands the manifest against the Capture API (synced media only, cursor-paginated), applies excludes and filters, deduplicates;
- 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; - maps rooms only for the media being imported, creating missing ones by name;
- 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_rgbinservices/image_encode.pyturns 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), seedsstaged_photoswith group indices carried over from Capture groups, and with each photo's capture intent and marks; - updates the batch counters as it goes and finishes
complete,partial(some files failed; re-running the import retries just those), orfailed. - reports the claim back to Capture (
PUT /assignments/{id}/links/contentsvisionwith{claimId, claimNumber, appUrl}, viaCaptureClient.link_claim), so the Capture admin console links from the assignment to this claim.appUrlis 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 openssgk.contentsvision.com, not the main app. Capture accepts only origins on itsCONTENTSVISION_APP_URLSlist and refuses others with a 400; it builds the URL itself. The most recent import wins. Best effort:report_claim_linknever fails the import, but a miss is logged AND reported to Sentry (flow=contents_capture_claim_link, withstatus_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:
- ContentsVision, per team: the
capture_auto_processcomponent flag (admin Teams tab,component_visibility, default off). Turn onenterprisefor the same team so no credits are charged; without it the normal charge applies (and a team short on credits keeps its jobs parked). - 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'sCONTENTSVISION_WEBHOOK_SECRETequal to ourCONTENTS_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 (triggermedia.synced) and identify media when a room or assignment is submitted (triggersubmission.created), both also firing onmedia.updatedandmedia.deletedso changes stay in step.
Per event:
| Event | With automation and the flag on |
|---|---|
submission.created | The 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.synced | A 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.deleted | Auto-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 theStagedPhoto(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_pathor anyItemPhoto.pathon one of the group's staged files), or every item of a video/audio job, are archived (restorable 30 days). The group's Uploads becomesuperseded(the deleted onesource_deleted) so the re-import is not skipped as already present, and the rest of the group (plus the changed media) is re-imported withprocess: true. Items withcontents_estimation_sent_atorsubmittedare never archived. - Processing, or still being imported: the change is retried by
run_capture_auto_changeeveryCONTENTS_CAPTURE_AUTO_CHANGE_RETRY_SECONDS(default 60), up to 30 times. "Still being imported" means noreadyUpload exists yet but an import naming the media is in flight (an Upload inpending/importing, or apending/expanding/importingImportBatch 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 tointentormarks, or adding or removing the "scoping" tag, changes what is itemized._intent_changedcompares what the refreshedUpload.metaasks for with what the photo was staged with (StagedPhoto.intent,.marks) or, for a video, withProcessingJob.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 withprocess: true. Marks on a video and intent on audio are ignored. media.updatednames the changed fields (data.fields) but does not carry their new values._changed_valuesuses 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 namingtags,notes,intentormarks). If that read fails the change is logged and treated as "nothing changed".- A group's intent flipping. ContentsCapture sends one
media.updatedper live media item in the group, withfields: ["intent"],via: "group"andgroupIntent: "scoping" | "items". The media body does not change in that case, so no read is made:_group_intent_oftakesgroupIntentfrom the event intouploads.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.
| Field | On | Values |
|---|---|---|
intent | media and group bodies | "items" (default) or "scoping" |
marks | media bodies | List 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
intentisscoping, when its group'sintentisscoping, 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.markskeeps what was sent;staged_photos.marksis 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
intentand nomarksisitemswith no marks, which is exactly the behaviour before the fields existed.
Where it is stored.
| Place | What |
|---|---|
uploads.meta.intent | The media's own intent as stated (items when absent) |
uploads.meta.groupIntent | What its group asked for at import, from the group body in the assignment tree (intent or the tag) |
uploads.meta.marks | The marks list as sent ([] when absent) |
staged_photos.intent | The resolved intent the pipeline reads |
staged_photos.marks | The marks as JSON text, blank while the photo is scoping. Read by the photo pipeline for a lone photo (see marked photos) |
processing_jobs.intent | scoping 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_pipelinetakes scoping photos out before grouping._job_estimate_creditsleaves 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_pipelinefinishes it at once (_complete_scoping_video): no extraction, no transcription, no AI call. - It is kept. The
StagedPhotorow 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 withintent = 'scoping'anddeleted = falseon the room's photo jobs, plus the room's video jobs withintent = 'scoping'. Who took it and when is on the matchinguploadsrow (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 has | What ContentsVision does | Prompt |
|---|---|---|
| Any include mark | Only 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 marks | The 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 marks | Unchanged. | 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.
| What | Where |
|---|---|
| The tab's data | GET /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 data | cover_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 tab | components/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 cover | components/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_creatorreadsassignment.createdByName/createdByEmailfrom the assignment tree (Capture PR #117; a nestedcreatedBy {name, email}is tolerated). Fallback: the actor of the event that started the import (event.actor{userId, email, name}, stored asmanifest.auto.actorby thesubmission.createdpath;media.syncedbatches 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._runcalls it throughclaim_source.credit_assignment_claimsfor 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) becomescreated_by_user_id; otherwise the owner stays as the technical owner andcreated_by_external_name/_emailare 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_inserthook onClaim), 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(orevent.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 blankuser_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(pluscapture_status_at), the assignment's status as last heard from Capture. Capture's statuses aredraft,active,in_review,submitted,completed,archived;draftandactivemean "still capturing" (claim_source.CAPTURE_IN_PROGRESS). - Where it comes from:
- every import (
importer._run) readsassignment.statusfrom the assignment tree it already fetches and applies it to every claim the assignment feeds (claim_source.record_capture_status, which finds them throughimport_batches.claim_id), including imports that bring nothing new; assignment.status_changed(data.to) andassignment.archivedwebhook events, applied the same way, ignoring an event older than the storedcapture_status_at. Capture emitsassignment.status_changedwithto: "submitted"when a submission covers every remaining media, andto: "active"when new media arrives after that (so Capturing comes back). There is noassignment.submittedevent;submission.createdalone does not say whether the whole assignment is done, but the import it triggers re-reads the status.
- every import (
- Status rule:
capturingranks right afterneeds_attentionand aboveprocessing(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.syncedpreset 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: addassignment.status_changed(andassignment.archived) to that workflow'salsoOn, 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
| Setting | Meaning |
|---|---|
CONTENTS_CAPTURE_API_BASE_URL | The Capture API base URL. Empty (default) disables the integration entirely. Dev/stage: https://contents-capture-api.dev-908.workers.dev. |
CONTENTS_CAPTURE_WEBHOOK_SECRET | HMAC 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_CONCURRENCY | Parallel downloads per import run (default 4). |
CONTENTS_CAPTURE_AUTO_SETTLE_SECONDS | Automatic 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_SECONDS | Automatic 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 infrontend/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 whosecapture_adminswitch 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.