Save repeating section entries
Merge a DELTA into the entry roster for an inspection (spec section 3).
Roster shapes:
- sections: {"<section_key>": [{"index": 0}, {"index": 1}]} (array order = display order)
- groups: {"<group_key>": {"<parent_path>": [{"index": 0}, ...]}} where parent_path is a canonical instance_path of the PARENT container (depth 1 for a group directly in a section, depth 2 for a sub-group).
The body is a DELTA: only provided top-level keys change. The server computes
merged = {**stored, **delta}, validates every key present in the delta against the MERGED
candidate, persists merged, and returns the full merged roster. Absent keys are untouched,
so two offline participants writing different keys no longer clobber each other; a full-roster
payload (every key present) still works because each provided key is authoritative. Roster keys
are never removed via the delta by design.
Validation against the inspection's template_snapshot: section keys must name a repeatable
section within its max_instances; group keys must name a kind == "group" node, take the map
shape, carry canonical parent paths of the right depth whose parents exist in the merged
candidate, and stay within the group's max_instances per parent.
Org isolation + participant scope are enforced by the insp_inspector_update RLS policy (and insp_admin_write for admins) plus the explicit organization_id scope, the same path submit_response / write_intake rely on; no service/elevated session is used. The merge runs top-level-key shallow; the delta is passed as a Python dict (asyncpg jsonb codec) and cast $1::jsonb, never json.dumps'd (that would double-encode it into a string).
Co-inspection hardening (legacy-PUT retirement stage 1): with 2+ live participants each provided key is UNIONED per entry id instead of replaced (see _union_roster), under the same row lock the ops endpoint takes, so a stale pre-op-bundle device can no longer wipe entries a co-inspector added via ops. A solo inspection keeps replace semantics (the only writer's array is authoritative, so a legacy remove still sticks). The union may exceed a section's max_instances when both sides filled it independently; the delta itself is still validated against the cap, and the overflow is tolerated rather than 422-stalling the stale device's outbox head-of-line.
Authorization
OrgApiKey Organization API key. Send as Authorization: Bearer <key>. Create one in Admin > Settings > API keys.
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
curl -X PUT "https://api.auditmark.io/v1/inspections/497f6eca-6276-4993-bfeb-53cbbbba6f08/section-instances" \ -H "Content-Type: application/json" \ -d '{ "section_instances": {} }'null{ "detail": [ { "loc": [ "string" ], "msg": "string", "type": "string", "input": null, "ctx": {} } ]}