API reference
Record a witness observation
Records one assembly or delivery observation for a pair; an identical replay returns 200 with duplicate true, and different content for a stage already recorded returns 409.
POST/v1/witnessSandbox and Production differ
Overview #
Records one assembly or delivery observation for a pair; an identical replay returns 200 with duplicate true, and different content for a stage already recorded returns 409.
Authenticate with an environment API key in the Authorization: Bearer header. See Authentication.
Environments. Production: each newly accepted observation is one billed Verification Pass. Sandbox: recorded and counted, never billed.
curl -X POST https://attestinfra.com/v1/witness \
-H "Authorization: Bearer $ATTEST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"pairId": "pr_9c1d4e7a2b5f8e30",
"stage": "assembly",
"eventType": "transfer.requested",
"eventId": "transfer_82",
"timestamp": "2026-10-19T14:03:07.120Z",
"source": "checkout",
"destination": "payments",
"action": "transfer",
"outcome": "ok",
"evidence": {
"actionId": "transfer_82",
"amount": 500,
"currency": "USD"
}
}'const response = await fetch("https://attestinfra.com/v1/witness", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ATTEST_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"pairId": "pr_9c1d4e7a2b5f8e30",
"stage": "assembly",
"eventType": "transfer.requested",
"eventId": "transfer_82",
"timestamp": "2026-10-19T14:03:07.120Z",
"source": "checkout",
"destination": "payments",
"action": "transfer",
"outcome": "ok",
"evidence": {
"actionId": "transfer_82",
"amount": 500,
"currency": "USD"
}
}),
});
console.log(response.status, await response.json());import json, os, urllib.request
request = urllib.request.Request(
"https://attestinfra.com/v1/witness",
method="POST",
headers={
"Authorization": "Bearer " + os.environ["ATTEST_API_KEY"],
"Content-Type": "application/json",
},
data=json.dumps({
"pairId": "pr_9c1d4e7a2b5f8e30",
"stage": "assembly",
"eventType": "transfer.requested",
"eventId": "transfer_82",
"timestamp": "2026-10-19T14:03:07.120Z",
"source": "checkout",
"destination": "payments",
"action": "transfer",
"outcome": "ok",
"evidence": {
"actionId": "transfer_82",
"amount": 500,
"currency": "USD",
},
}).encode(),
)
with urllib.request.urlopen(request) as response:
print(response.status, json.loads(response.read()))Parameters #
| Name | Type | Required | Description |
|---|---|---|---|
pairId | string (body) | Required | Client-generated identifier shared by both observations of one boundary crossing. pattern ^[A-Za-z0-9_-]{16,128}$ |
stage | assembly | delivery (body) | Required | assembly before the operation crosses the boundary, delivery after. |
eventType | string (body) | Required | Classification of the operation. Must match across stages to reconcile as matched. 1–255 characters |
eventId | string (body) | Required | Your identifier for the operation. 1–255 characters |
timestamp | string (body) | Required | When the observation was made, in UTC. Part of the observation's identity: a retry must reuse it exactly. |
source | string (body) | Optional | Where the observation was made. On delivery, compared with the assembly destination. 1–255 characters |
destination | string (body) | Optional | Where the operation is headed. On assembly, compared with the delivery source. 1–255 characters |
action | string (body) | Required | The operation. Must match across stages to reconcile as matched. 1–255 characters |
outcome | string (body) | Optional | Result reported by the observer. Not compared during reconciliation. 1–255 characters |
evidence | object (body) | Required | The boundary invariants you want compared, for example an action ID and amount. Must match across stages to reconcile as matched. |
Response #
200 An identical observation was already recorded for this stage. No new Verification Pass.
201 A new observation was accepted.
Response fields #
| Field | Type | Description |
|---|---|---|
pairId | string | The pair identifier. |
lifecycle | OPEN | FINALIZED | OPEN until finalize is called. |
reconciliationStatus | matched | divergent | incomplete | orphaned | null while OPEN with one stage. Fixed once FINALIZED. |
assemblyObserved | boolean | attest holds an assembly observation. |
deliveryObserved | boolean | attest holds a delivery observation. false does not mean the operation failed or did not run. |
finalized | boolean | true once finalize has been called. |
executionState | unknown | Always unknown. Observations cannot prove whether your operation executed. |
divergences | array | Each compared field that differs between stages. |
assembly | object | null | |
delivery | object | null | |
finalizedAt | string | null | When the pair was finalized. |
reconciliationFormat | attest-witness-reconciliation-v1 | Format of the finalized reconciliation record. |
reconciliationDigest | string | null | SHA-256 of the canonical finalized reconciliation record. |
accepted | boolean | Always true on success. |
duplicate | boolean | true if this exact observation was already recorded. |
{
"pairId": "pr_9c1d4e7a2b5f8e30",
"lifecycle": "OPEN",
"reconciliationStatus": null,
"assemblyObserved": true,
"deliveryObserved": false,
"finalized": false,
"executionState": "unknown",
"divergences": [],
"assembly": {
"accepted": true,
"evidenceHash": "ee76c475080687b51e6b4cc3cfb3846e985db8d88b4c26afd33fdb8963be5248",
"receiptId": "moni_wit_25920e7d-f381-4205-ad6a-85656cb4d60a",
"outcome": "ok"
},
"delivery": null,
"finalizedAt": null,
"reconciliationFormat": null,
"reconciliationDigest": null,
"accepted": true,
"duplicate": true
}{
"pairId": "pr_9c1d4e7a2b5f8e30",
"lifecycle": "OPEN",
"reconciliationStatus": null,
"assemblyObserved": true,
"deliveryObserved": false,
"finalized": false,
"executionState": "unknown",
"divergences": [],
"assembly": {
"accepted": true,
"evidenceHash": "ee76c475080687b51e6b4cc3cfb3846e985db8d88b4c26afd33fdb8963be5248",
"receiptId": "moni_wit_25920e7d-f381-4205-ad6a-85656cb4d60a",
"outcome": "ok"
},
"delivery": null,
"finalizedAt": null,
"reconciliationFormat": null,
"reconciliationDigest": null,
"accepted": true,
"duplicate": false
}Errors #
| Status | error | code | Meaning |
|---|---|---|---|
400 | pairId is malformed | INVALID_WITNESS_OBSERVATION | The observation failed validation. |
400 | timestamp must be an ISO-8601 UTC string | WITNESS_INVALID_TIMESTAMP | The observation failed validation. |
400 | evidence must be a plain object | WITNESS_INVALID_EVIDENCE | The observation failed validation. |
401 | Invalid API key | — | The API key is missing, unknown, revoked, or belongs to an environment that is not active. |
409 | conflicting duplicate witness observation | WITNESS_CONFLICT | The stage already holds a different observation, or the pair is finalized. |
409 | witness pair is finalized | WITNESS_FINALIZED | The stage already holds a different observation, or the pair is finalized. |
413 | JSON payload exceeds the configured limit | — | The request body is larger than 1 MB. |
500 | Witness observation failed | — | The observation could not be recorded. |
All error bodies and their causes are listed in Errors.
{
"error": "pairId is malformed",
"code": "INVALID_WITNESS_OBSERVATION"
}{
"error": "timestamp must be an ISO-8601 UTC string",
"code": "WITNESS_INVALID_TIMESTAMP"
}{
"error": "evidence must be a plain object",
"code": "WITNESS_INVALID_EVIDENCE"
}{
"error": "Invalid API key"
}