POST /v1/agent-events with traces:write. Put the record in a code_attribution observation inside a standard event batch.agentTraceRecordBatch(record) uses the record ID for the session, event, and attempt IDs, sets segment to coding, sets task to code-attribution, and uses the record timestamp for at. sendAgentTraceRecord(options, record) sends this batch to /v1/agent-events.curl https://app.halfspan.com/v1/agent-events \ -H "Authorization: Bearer $HALFSPAN_API_KEY" \ -H 'Content-Type: application/json' \ --data '{ "version": 1, "session": "ba91ae2d-dcdc-4ea7-8cc4-41ac379d0eb6", "segment": "coding", "events": [{ "id": "ba91ae2d-dcdc-4ea7-8cc4-41ac379d0eb6", "task": "code-attribution", "attempt": "ba91ae2d-dcdc-4ea7-8cc4-41ac379d0eb6", "at": "2026-11-25T15:00:00Z", "observation": { "kind": "code_attribution", "record": { "version": "0.1.0", "id": "ba91ae2d-dcdc-4ea7-8cc4-41ac379d0eb6", "timestamp": "2026-11-25T15:00:00Z", "vcs": {"type": "git", "revision": "abc123"}, "tool": {"name": "my-agent", "version": "1.0"}, "files": [{ "path": "src/checkout.ts", "conversations": [{ "contributor": {"type": "ai", "model_id": "example-model"}, "ranges": [{"start_line": 10, "end_line": 18}] }] }] } } }] }'
200 for a new session:1{"inserted":1,"total":1}
| Field | Contract |
version | Required; "0.1" or "0.1.0". |
id | Required; UUID string of exactly 36 characters. |
timestamp | Required; RFC 3339 timestamp, with optional fractional seconds. |
files | Required array of file objects. Each requires string path and array conversations. |
vcs | Optional object requiring type (git, jj, hg, or svn) and string revision. |
tool | Optional object with optional string name and version. |
metadata | Optional object. |
ranges array. Optional url must be an absolute URI. Optional related entries require string type and absolute-URI url. Each range requires positive integer start_line and end_line, and may include string content_hash.contributor object. Its required type is human, ai, mixed, or unknown; optional string model_id is limited to 250 Unicode characters. Extension fields inside the record are preserved. The enclosing batch, event, and observation still reject unknown fields.409; use a new record ID for a new attribution record.