{
  "openapi": "3.1.0",
  "info": {
    "title": "attest API",
    "version": "1.0.0",
    "summary": "Independent verification records for machine activity.",
    "description": "REST API that accepts machine activity events and paired boundary observations, verifies and signs them, and holds the resulting records outside the originating system. Requests and responses are JSON. Authenticate with an environment API key.",
    "license": { "name": "Proprietary" }
  },
  "servers": [
    { "url": "https://attestinfra.com", "description": "One base URL serves Sandbox and Production. The API key selects the environment." }
  ],
  "security": [ { "bearerAuth": [] }, { "apiKeyHeader": [] } ],
  "tags": [
    { "name": "Events", "description": "Submit machine activity for verification." },
    { "name": "Witness", "description": "Record and reconcile observations on both sides of a system boundary." },
    { "name": "Usage", "description": "Read Verification Pass totals." },
    { "name": "Verification", "description": "Public material for checking receipts without an account." },
    { "name": "Service", "description": "Service status." },
    { "name": "Legacy", "description": "Older ingestion routes kept for existing integrations." }
  ],
  "paths": {
    "/v1/events": {
      "post": {
        "operationId": "createEvent",
        "tags": ["Events"],
        "summary": "Verify an event",
        "description": "Verifies, signs, and records one machine activity event; an eventId already recorded in the same environment is acknowledged as a duplicate and creates no Verification Pass.",
        "x-attest": {
          "slug": "create-event",
          "environmentNote": "Production: each accepted event is one billed Verification Pass. Sandbox: recorded and counted, never billed.",
          "source": ["index.js:643-669,687-692", "adapters/native-json.js:28-52", "postgres-persistence.js:23-98", "persistence.js:150-187"]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/EventRequest" },
              "example": {
                "eventType": "ai.agent.tool_call",
                "eventId": "job_7f3c9a12",
                "source": "research-agent",
                "action": "search",
                "actorType": "agent",
                "model": "summarizer-v2",
                "outcome": "ok",
                "timestamp": "2026-10-19T14:03:07.120Z",
                "metadata": { "ticket": "SUP-1042", "region": "us-east-1" }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The event was accepted or recognized as a duplicate. Both responses include the signed receipt.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/EventResponse" },
                "examples": {
                  "accepted": {
                    "summary": "New event accepted",
                    "value": {
                      "accepted_spans": 1,
                      "duplicate_spans": 0,
                      "usage": { "customer_id": "79e99bf5-9836-496a-a846-9533be1c4a16", "environment_id": "1f7133e2-ec96-4c4c-89d1-ebdb7ca3dde3", "verification_passes": 1, "amount_usd": 0.001 },
                      "receipts": [ {
                        "status": "accepted",
                        "attestation_id": "otlp_d364c0280e22f7b0e183a71f187b0270",
                        "verified_at": "2026-10-19T14:03:07.214Z",
                        "payload": "{\"attestation_id\":\"otlp_d364c0280e22f7b0e183a71f187b0270\",...}",
                        "hash": "b74becb11d03de3606d4080f4be632ad6320da244cef20651d894a6ca2a8b7f5",
                        "signature": "M9U1o7wgXZnxB5KI/XZMJtZhASk22ZFDfkQYVYHKgcHC...",
                        "signer": { "fingerprint": "sha256:552054128c0ca6f3fe6b6ef38e062f22593705e2e10a648a20418434f53b5e12" }
                      } ],
                      "customer_id": "79e99bf5-9836-496a-a846-9533be1c4a16",
                      "environment_id": "1f7133e2-ec96-4c4c-89d1-ebdb7ca3dde3",
                      "event_type": "ai.agent.tool_call"
                    }
                  },
                  "duplicate": {
                    "summary": "Same eventId sent again: the original receipt",
                    "value": {
                      "accepted_spans": 0,
                      "duplicate_spans": 1,
                      "usage": { "customer_id": "79e99bf5-9836-496a-a846-9533be1c4a16", "environment_id": "1f7133e2-ec96-4c4c-89d1-ebdb7ca3dde3", "verification_passes": 1, "amount_usd": 0.001 },
                      "receipts": [ {
                        "status": "duplicate",
                        "attestation_id": "otlp_d364c0280e22f7b0e183a71f187b0270",
                        "verified_at": "2026-10-19T14:03:07.214Z",
                        "payload": "{\"attestation_id\":\"otlp_d364c0280e22f7b0e183a71f187b0270\",...}",
                        "hash": "b74becb11d03de3606d4080f4be632ad6320da244cef20651d894a6ca2a8b7f5",
                        "signature": "M9U1o7wgXZnxB5KI/XZMJtZhASk22ZFDfkQYVYHKgcHC...",
                        "signer": { "fingerprint": "sha256:552054128c0ca6f3fe6b6ef38e062f22593705e2e10a648a20418434f53b5e12" }
                      } ],
                      "customer_id": "79e99bf5-9836-496a-a846-9533be1c4a16",
                      "environment_id": "1f7133e2-ec96-4c4c-89d1-ebdb7ca3dde3",
                      "event_type": "ai.agent.tool_call"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body is not valid JSON or an event field failed validation. The error string names the field.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "examples": {
              "unknownField": { "summary": "Field not in the allowed list", "value": { "error": "unknown event field" } },
              "eventType": { "summary": "eventType missing or invalid", "value": { "error": "invalid eventType" } },
              "metadataSize": { "summary": "metadata over 8 KB", "value": { "error": "metadata exceeds 8KB" } },
              "malformed": { "summary": "Body is not JSON", "value": { "error": "Malformed JSON payload" } }
            } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "413": { "$ref": "#/components/responses/PayloadTooLarge" },
          "500": {
            "description": "The event could not be recorded.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "Event ingestion failed" } } }
          },
          "503": {
            "description": "The signed record failed its own verification check and was not stored.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "Attestation verification failed" } } }
          }
        }
      }
    },
    "/v1/witness": {
      "post": {
        "operationId": "recordWitnessObservation",
        "tags": ["Witness"],
        "summary": "Record a witness observation",
        "description": "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.",
        "x-attest": {
          "slug": "record-witness-observation",
          "environmentNote": "Production: each newly accepted observation is one billed Verification Pass. Sandbox: recorded and counted, never billed.",
          "source": ["index.js:683", "witness-protocol.js:33-56", "witness-evidence.js:4", "postgres-persistence.js:86-104"]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/WitnessObservation" },
              "example": {
                "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" }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "A new observation was accepted.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/WitnessObservationResponse" }, "example": {
              "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
            } } }
          },
          "200": {
            "description": "An identical observation was already recorded for this stage. No new Verification Pass.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/WitnessObservationResponse" }, "example": {
              "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
            } } }
          },
          "400": {
            "description": "The observation failed validation.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CodedError" }, "examples": {
              "observation": { "summary": "Invalid field", "value": { "error": "pairId is malformed", "code": "INVALID_WITNESS_OBSERVATION" } },
              "timestamp": { "summary": "Invalid timestamp", "value": { "error": "timestamp must be an ISO-8601 UTC string", "code": "WITNESS_INVALID_TIMESTAMP" } },
              "evidence": { "summary": "Invalid evidence", "value": { "error": "evidence must be a plain object", "code": "WITNESS_INVALID_EVIDENCE" } }
            } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "409": {
            "description": "The stage already holds a different observation, or the pair is finalized.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CodedError" }, "examples": {
              "conflict": { "summary": "Different content for a recorded stage", "value": { "error": "conflicting duplicate witness observation", "code": "WITNESS_CONFLICT" } },
              "finalized": { "summary": "Pair already finalized", "value": { "error": "witness pair is finalized", "code": "WITNESS_FINALIZED" } }
            } } }
          },
          "413": { "$ref": "#/components/responses/PayloadTooLarge" },
          "500": {
            "description": "The observation could not be recorded.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CodedError" }, "example": { "error": "Witness observation failed" } } }
          }
        }
      }
    },
    "/v1/witness/{pairId}/finalize": {
      "post": {
        "operationId": "finalizeWitnessPair",
        "tags": ["Witness"],
        "summary": "Finalize a witness pair",
        "description": "Closes a pair and fixes its reconciliation status permanently; calling it again returns the same finalized pair and creates no Verification Pass.",
        "x-attest": {
          "slug": "finalize-witness-pair",
          "setup": "witness-pair",
          "source": ["index.js:682,684", "witness-protocol.js:58-67", "postgres-persistence.js:109-115"]
        },
        "parameters": [ { "$ref": "#/components/parameters/PairId" } ],
        "requestBody": {
          "required": false,
          "content": { "application/json": { "schema": { "type": "object", "additionalProperties": false, "description": "Send an empty object. The body is ignored." }, "example": {} } }
        },
        "responses": {
          "200": {
            "description": "The finalized pair.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/WitnessPair" }, "example": {
              "pairId": "pr_9c1d4e7a2b5f8e30", "lifecycle": "FINALIZED", "reconciliationStatus": "matched",
              "assemblyObserved": true, "deliveryObserved": true, "finalized": true, "executionState": "unknown", "divergences": [],
              "assembly": { "accepted": true, "evidenceHash": "ee76c475080687b51e6b4cc3cfb3846e985db8d88b4c26afd33fdb8963be5248", "receiptId": "moni_wit_25920e7d-f381-4205-ad6a-85656cb4d60a", "outcome": "ok" },
              "delivery": { "accepted": true, "evidenceHash": "ee76c475080687b51e6b4cc3cfb3846e985db8d88b4c26afd33fdb8963be5248", "receiptId": "moni_wit_14c76ce2-ce0f-4f63-9e3a-10998b6e821a", "outcome": "ok" },
              "finalizedAt": "2026-10-19T14:03:08.311Z", "reconciliationFormat": "attest-witness-reconciliation-v1",
              "reconciliationDigest": "1b6aedbc1fde62f88d103df093cf26e60fc173d878825aea2ffd18a05dd7b9d1"
            } } }
          },
          "400": {
            "description": "The pairId in the path is malformed.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CodedError" }, "example": { "error": "pairId is malformed" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": {
            "description": "No pair with this pairId exists in the key's environment.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "Witness pair not found" } } }
          },
          "500": {
            "description": "The pair could not be finalized.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CodedError" }, "example": { "error": "Witness finalization failed" } } }
          }
        }
      }
    },
    "/v1/witness/{pairId}": {
      "get": {
        "operationId": "getWitnessPair",
        "tags": ["Witness"],
        "summary": "Retrieve a witness pair",
        "description": "Returns the current state of a pair in the key's environment; reading never changes the pair and creates no Verification Pass.",
        "x-attest": {
          "slug": "get-witness-pair",
          "setup": "witness-pair",
          "source": ["index.js:685", "witness-protocol.js:118-135"]
        },
        "parameters": [ { "$ref": "#/components/parameters/PairId" } ],
        "responses": {
          "200": {
            "description": "The pair. Before finalization, reconciliationStatus is computed from the observations present and can still change.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/WitnessPair" }, "example": {
              "pairId": "pr_9c1d4e7a2b5f8e30", "lifecycle": "OPEN", "reconciliationStatus": "matched",
              "assemblyObserved": true, "deliveryObserved": true, "finalized": false, "executionState": "unknown", "divergences": [],
              "assembly": { "accepted": true, "evidenceHash": "ee76c475080687b51e6b4cc3cfb3846e985db8d88b4c26afd33fdb8963be5248", "receiptId": "moni_wit_25920e7d-f381-4205-ad6a-85656cb4d60a", "outcome": "ok" },
              "delivery": { "accepted": true, "evidenceHash": "ee76c475080687b51e6b4cc3cfb3846e985db8d88b4c26afd33fdb8963be5248", "receiptId": "moni_wit_14c76ce2-ce0f-4f63-9e3a-10998b6e821a", "outcome": "ok" },
              "finalizedAt": null, "reconciliationFormat": null, "reconciliationDigest": null
            } } }
          },
          "400": {
            "description": "The pairId in the path is malformed.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "pairId is malformed" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": {
            "description": "No pair with this pairId exists in the key's environment.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "Witness pair not found" } } }
          }
        }
      }
    },
    "/usage": {
      "get": {
        "operationId": "getUsage",
        "tags": ["Usage"],
        "summary": "Retrieve usage",
        "description": "Returns the all-time Verification Pass total and accrued amount for the key's environment.",
        "x-attest": {
          "slug": "get-usage",
          "environmentNote": "Sandbox amounts accrue at the unit price for visibility but are never billed.",
          "source": ["index.js:687", "postgres-persistence.js:118-123"]
        },
        "responses": {
          "200": {
            "description": "Usage totals.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Usage" }, "example": {
              "customer_id": "79e99bf5-9836-496a-a846-9533be1c4a16", "environment_id": "1f7133e2-ec96-4c4c-89d1-ebdb7ca3dde3", "verification_passes": 3, "amount_usd": 0.003
            } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/.well-known/attest-signing-key": {
      "get": {
        "operationId": "getSigningKey",
        "tags": ["Verification"],
        "summary": "Retrieve the signing key",
        "description": "Returns the public key that currently signs receipts, with its SHA-256 fingerprint; no API key is required.",
        "security": [],
        "x-attest": {
          "slug": "get-signing-key",
          "source": ["index.js:179-182", "proof-export.js:8-20"]
        },
        "responses": {
          "200": {
            "description": "The current signer.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SigningKey" }, "example": {
              "public_key": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAunPmbxD3V6ArXURVlF+6\n...\n-----END PUBLIC KEY-----\n",
              "fingerprint": "sha256:552054128c0ca6f3fe6b6ef38e062f22593705e2e10a648a20418434f53b5e12",
              "fingerprint_algorithm": "sha256-spki-der",
              "signature_scheme": "RSA-SHA256",
              "trust": "Confirm this fingerprint through a separately authenticated channel before trusting signer provenance.",
              "status": "current_key",
              "historical_keys": "Request historical signer keys through support when a receipt does not verify under this key."
            } } }
          }
        }
      }
    },
    "/proof-verifier/attest-proof-inspector-v1.html": {
      "get": {
        "operationId": "downloadProofInspector",
        "tags": ["Verification"],
        "summary": "Download the proof inspector",
        "description": "Downloads a self-contained HTML file that checks a receipt in the browser without an account or network call; no API key is required.",
        "security": [],
        "x-attest": {
          "slug": "download-proof-inspector",
          "source": ["index.js:170-175", "proof-inspector.js"]
        },
        "responses": {
          "200": {
            "description": "The inspector, sent as an attachment named attest-proof-inspector-v1.html.",
            "content": { "text/html": { "schema": { "type": "string" }, "example": "<!doctype html>..." } }
          }
        }
      }
    },
    "/proof-verifier/attest-proof-inspector-v1.sha256": {
      "get": {
        "operationId": "getProofInspectorChecksum",
        "tags": ["Verification"],
        "summary": "Retrieve the inspector checksum",
        "description": "Returns the SHA-256 digest of the inspector file in sha256sum format, so a downloaded copy can be checked; no API key is required.",
        "security": [],
        "x-attest": {
          "slug": "get-proof-inspector-checksum",
          "source": ["index.js:176-178"]
        },
        "responses": {
          "200": {
            "description": "One line: the hex digest, two spaces, and the file name.",
            "content": { "text/plain": { "schema": { "type": "string" }, "example": "5ef3b43046014a12fcfbc9538d5075f3e6f0a0a376d8710e170ff55da4f597d6  attest-proof-inspector-v1.html\n" } }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getHealth",
        "tags": ["Service"],
        "summary": "Check service health",
        "description": "Reports whether signing and persistence are ready; no API key is required.",
        "security": [],
        "x-attest": {
          "slug": "get-health",
          "source": ["index.js:689-692", "operational-diagnostics.js:14-19"]
        },
        "responses": {
          "200": {
            "description": "Signing and persistence are ready.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Health" }, "example": { "status": "ok", "signing": "ready", "persistence": "ready" } } }
          },
          "503": {
            "description": "Signing or persistence is unavailable.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Health" }, "example": { "status": "unhealthy", "signing": "ready", "persistence": "unavailable" } } }
          }
        }
      }
    },
    "/v1/traces": {
      "post": {
        "operationId": "ingestTraces",
        "tags": ["Legacy"],
        "summary": "Ingest OTLP traces",
        "description": "Verifies each span in an OTLP/HTTP JSON trace export as one event; new integrations should use POST /v1/events.",
        "x-attest": {
          "slug": "ingest-traces",
          "legacy": true,
          "replacement": "create-event",
          "environmentNote": "Production: each accepted span is one billed Verification Pass. Sandbox: recorded and counted, never billed.",
          "source": ["index.js:643-670,682-685", "adapters/otlp.js:37-71"]
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/OtlpTraces" },
              "example": {
                "resourceSpans": [ { "scopeSpans": [ {
                  "scope": { "name": "my-service", "version": "1.4.0" },
                  "spans": [ {
                    "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
                    "spanId": "00f067aa0ba902b7",
                    "name": "chat",
                    "startTimeUnixNano": "1760882587120000000",
                    "endTimeUnixNano": "1760882587940000000",
                    "status": { "code": "STATUS_CODE_OK" },
                    "attributes": [
                      { "key": "gen_ai.operation.name", "value": { "stringValue": "chat" } },
                      { "key": "gen_ai.request.model", "value": { "stringValue": "summarizer-v2" } }
                    ]
                  } ]
                } ] } ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Spans were accepted or recognized as duplicates.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TracesResponse" }, "example": {
              "accepted_spans": 1, "duplicate_spans": 0,
              "usage": { "customer_id": "79e99bf5-9836-496a-a846-9533be1c4a16", "environment_id": "1f7133e2-ec96-4c4c-89d1-ebdb7ca3dde3", "verification_passes": 1, "amount_usd": 0.001 },
              "receipts": [ {
                "status": "accepted",
                "attestation_id": "otlp_82fca850a093a09199a489ef965b5887",
                "verified_at": "2026-10-19T14:03:07.940Z",
                "payload": "{\"attestation_id\":\"otlp_82fca850a093a09199a489ef965b5887\",...}",
                "hash": "c6aacc35c6d43991c8604a21e4e20b9e12e75ca7282e66b3d9316f82f45037fd",
                "signature": "evb76MYMeNM8kbzSx5Dr4zEHu+sD655R1Tt3YAyw7RL/...",
                "signer": { "fingerprint": "sha256:552054128c0ca6f3fe6b6ef38e062f22593705e2e10a648a20418434f53b5e12" }
              } ]
            } } }
          },
          "400": {
            "description": "The body is not a valid OTLP trace export.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "Invalid OTLP payload" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "413": { "$ref": "#/components/responses/PayloadTooLarge" },
          "500": {
            "description": "The spans could not be recorded.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "Trace ingestion failed" } } }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer", "description": "Authorization: Bearer <API key>. Keys start with att_test_ (Sandbox) or att_live_ (Production)." },
      "apiKeyHeader": { "type": "apiKey", "in": "header", "name": "x-api-key", "description": "Alternative to the Authorization header. Used only when no Bearer header is sent." }
    },
    "parameters": {
      "PairId": {
        "name": "pairId",
        "in": "path",
        "required": true,
        "description": "The pair identifier sent with the observations.",
        "schema": { "type": "string", "pattern": "^[A-Za-z0-9_-]{16,128}$" },
        "example": "pr_9c1d4e7a2b5f8e30"
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "The API key is missing, unknown, revoked, or belongs to an environment that is not active.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "Invalid API key" } } }
      },
      "PayloadTooLarge": {
        "description": "The request body is larger than 1 MB.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "JSON payload exceeds the configured limit" } } }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": { "error": { "type": "string", "description": "Human-readable reason." } }
      },
      "CodedError": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": { "type": "string", "description": "Human-readable reason." },
          "code": { "type": "string", "description": "Stable error code, when one applies.", "enum": ["INVALID_WITNESS_OBSERVATION", "WITNESS_INVALID_EVIDENCE", "WITNESS_INVALID_TIMESTAMP", "WITNESS_CONFLICT", "WITNESS_FINALIZED"] }
        }
      },
      "EventRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": ["eventType"],
        "properties": {
          "eventType": { "type": "string", "maxLength": 255, "pattern": "^[A-Za-z0-9._:/-]+$", "description": "Your classification of the activity, for example ai.agent.tool_call." },
          "eventId": { "type": "string", "maxLength": 256, "pattern": "^[A-Za-z0-9._:/-]+$", "description": "Your identifier for this event. The duplicate key within an environment. If omitted, a random ID is used and the event can never be detected as a duplicate." },
          "source": { "type": "string", "maxLength": 128, "pattern": "^[A-Za-z0-9._:/-]+$", "description": "The system that produced the event." },
          "action": { "type": "string", "maxLength": 128, "pattern": "^[A-Za-z0-9._:/-]+$", "description": "The source's own name for the action. Recorded as unknown if omitted." },
          "actorType": { "type": "string", "maxLength": 128, "pattern": "^[A-Za-z0-9._:/-]+$", "description": "What kind of actor performed the action. Recorded as unknown if omitted." },
          "model": { "type": "string", "maxLength": 128, "pattern": "^[A-Za-z0-9._:/-]+$", "description": "Model involved. If both model and tool are sent, only model is recorded." },
          "tool": { "type": "string", "maxLength": 128, "pattern": "^[A-Za-z0-9._:/-]+$", "description": "Tool involved. Recorded only when model is absent." },
          "outcome": { "type": "string", "enum": ["ok", "error", "unset", "unknown"], "description": "Result reported by the source. Recorded as unknown if omitted." },
          "timestamp": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$", "description": "When the source says the event occurred, in UTC. Recorded as sent; attest adds its own verification time." },
          "metadata": { "type": "object", "maxProperties": 32, "description": "Your context. At most 32 top-level keys, 8 KB serialized, 2 levels of nesting below the top level, and keys of 1-128 characters." }
        }
      },
      "Usage": {
        "type": "object",
        "required": ["customer_id", "verification_passes", "amount_usd"],
        "properties": {
          "customer_id": { "type": "string", "description": "Your account identifier." },
          "environment_id": { "type": "string", "description": "The environment the key belongs to." },
          "verification_passes": { "type": "integer", "description": "All-time Verification Passes in this environment." },
          "amount_usd": { "type": "number", "description": "verification_passes multiplied by the unit price, rounded to 4 decimal places." }
        }
      },
      "EventResponse": {
        "type": "object",
        "required": ["accepted_spans", "duplicate_spans", "usage", "receipts", "customer_id", "environment_id", "event_type"],
        "properties": {
          "accepted_spans": { "type": "integer", "enum": [0, 1], "description": "1 if this request created a new record." },
          "duplicate_spans": { "type": "integer", "enum": [0, 1], "description": "1 if the eventId was already recorded in this environment." },
          "usage": { "$ref": "#/components/schemas/Usage" },
          "receipts": { "type": "array", "items": { "$ref": "#/components/schemas/Receipt" }, "description": "The signed receipt for the event, as one entry. For a duplicate it is the receipt of the original acceptance." },
          "customer_id": { "type": "string", "description": "Your account identifier." },
          "environment_id": { "type": "string", "description": "The environment the key belongs to." },
          "event_type": { "type": "string", "description": "The eventType you sent." }
        }
      },
      "TracesResponse": {
        "type": "object",
        "required": ["accepted_spans", "duplicate_spans", "usage", "receipts"],
        "properties": {
          "accepted_spans": { "type": "integer", "description": "Spans that created a new record." },
          "duplicate_spans": { "type": "integer", "description": "Spans already recorded in this environment." },
          "usage": { "$ref": "#/components/schemas/Usage" },
          "receipts": { "type": "array", "items": { "$ref": "#/components/schemas/Receipt" }, "description": "One signed receipt per span, in request order. For a duplicate span it is the receipt of the original acceptance." }
        }
      },
      "Receipt": {
        "type": "object",
        "required": ["status", "attestation_id", "verified_at", "payload", "hash", "signature", "signer"],
        "properties": {
          "status": { "type": "string", "enum": ["accepted", "duplicate"], "description": "accepted: this request created the record. duplicate: an earlier request created it, and this is that original receipt." },
          "attestation_id": { "type": "string", "description": "Record identifier, taken from the signed payload. The same value as receipt_id in an exported receipt." },
          "verified_at": { "type": "string", "format": "date-time", "description": "When attest accepted the record (ISO 8601, UTC). For a duplicate, the time of the original acceptance." },
          "payload": { "type": "string", "description": "The signed canonical JSON string, exactly as stored. Verify these exact bytes and do not re-serialize them." },
          "hash": { "type": "string", "description": "SHA-256 of payload (UTF-8), lowercase hex." },
          "signature": { "type": "string", "description": "Base64 RSA-SHA256 signature over the UTF-8 bytes of hash." },
          "signer": { "type": "object", "required": ["fingerprint"], "properties": { "fingerprint": { "type": ["string", "null"], "description": "Fingerprint of the current signing key when that key verifies this receipt; null when an earlier key signed it." } }, "description": "Identifies the signing key. No key material is included." }
        }
      },
      "WitnessObservation": {
        "type": "object",
        "required": ["pairId", "stage", "eventType", "eventId", "timestamp", "action", "evidence"],
        "properties": {
          "pairId": { "type": "string", "pattern": "^[A-Za-z0-9_-]{16,128}$", "description": "Client-generated identifier shared by both observations of one boundary crossing." },
          "stage": { "type": "string", "enum": ["assembly", "delivery"], "description": "assembly before the operation crosses the boundary, delivery after." },
          "eventType": { "type": "string", "minLength": 1, "maxLength": 255, "description": "Classification of the operation. Must match across stages to reconcile as matched." },
          "eventId": { "type": "string", "minLength": 1, "maxLength": 255, "description": "Your identifier for the operation." },
          "timestamp": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$", "description": "When the observation was made, in UTC. Part of the observation's identity: a retry must reuse it exactly." },
          "source": { "type": "string", "minLength": 1, "maxLength": 255, "description": "Where the observation was made. On delivery, compared with the assembly destination." },
          "destination": { "type": "string", "minLength": 1, "maxLength": 255, "description": "Where the operation is headed. On assembly, compared with the delivery source." },
          "action": { "type": "string", "minLength": 1, "maxLength": 255, "description": "The operation. Must match across stages to reconcile as matched." },
          "outcome": { "type": "string", "minLength": 1, "maxLength": 255, "description": "Result reported by the observer. Not compared during reconciliation." },
          "evidence": { "type": "object", "description": "The boundary invariants you want compared, for example an action ID and amount. Must match across stages to reconcile as matched." }
        }
      },
      "WitnessStage": {
        "type": ["object", "null"],
        "properties": {
          "accepted": { "type": "boolean", "description": "Always true when the stage is present." },
          "evidenceHash": { "type": "string", "description": "SHA-256 of the canonical evidence." },
          "receiptId": { "type": "string", "description": "Identifier of the signed receipt for this observation." },
          "outcome": { "type": ["string", "null"], "description": "The outcome sent with the observation." }
        }
      },
      "WitnessPair": {
        "type": "object",
        "required": ["pairId", "lifecycle", "reconciliationStatus", "assemblyObserved", "deliveryObserved", "finalized", "executionState", "divergences", "assembly", "delivery", "finalizedAt", "reconciliationFormat", "reconciliationDigest"],
        "properties": {
          "pairId": { "type": "string", "description": "The pair identifier." },
          "lifecycle": { "type": "string", "enum": ["OPEN", "FINALIZED"], "description": "OPEN until finalize is called." },
          "reconciliationStatus": { "type": ["string", "null"], "enum": ["matched", "divergent", "incomplete", "orphaned", null], "description": "null while OPEN with one stage. Fixed once FINALIZED." },
          "assemblyObserved": { "type": "boolean", "description": "attest holds an assembly observation." },
          "deliveryObserved": { "type": "boolean", "description": "attest holds a delivery observation. false does not mean the operation failed or did not run." },
          "finalized": { "type": "boolean", "description": "true once finalize has been called." },
          "executionState": { "type": "string", "enum": ["unknown"], "description": "Always unknown. Observations cannot prove whether your operation executed." },
          "divergences": { "type": "array", "items": { "$ref": "#/components/schemas/Divergence" }, "description": "Each compared field that differs between stages." },
          "assembly": { "$ref": "#/components/schemas/WitnessStage" },
          "delivery": { "$ref": "#/components/schemas/WitnessStage" },
          "finalizedAt": { "type": ["string", "null"], "description": "When the pair was finalized." },
          "reconciliationFormat": { "type": ["string", "null"], "enum": ["attest-witness-reconciliation-v1", null], "description": "Format of the finalized reconciliation record." },
          "reconciliationDigest": { "type": ["string", "null"], "description": "SHA-256 of the canonical finalized reconciliation record." }
        }
      },
      "WitnessObservationResponse": {
        "allOf": [
          { "$ref": "#/components/schemas/WitnessPair" },
          { "type": "object", "required": ["accepted", "duplicate"], "properties": {
            "accepted": { "type": "boolean", "description": "Always true on success." },
            "duplicate": { "type": "boolean", "description": "true if this exact observation was already recorded." }
          } }
        ]
      },
      "Divergence": {
        "type": "object",
        "properties": {
          "field": { "type": "string", "enum": ["event_type_relationship", "routing_continuity", "action", "evidence"], "description": "What differed." },
          "assembly_value": { "description": "Value from the assembly observation." },
          "delivery_value": { "description": "Value from the delivery observation." },
          "classification": { "type": "string", "enum": ["material_mismatch"], "description": "Always material_mismatch." }
        }
      },
      "SigningKey": {
        "type": "object",
        "properties": {
          "public_key": { "type": "string", "description": "PEM-encoded SPKI public key." },
          "fingerprint": { "type": "string", "description": "sha256: followed by the SHA-256 of the DER-encoded key." },
          "fingerprint_algorithm": { "type": "string", "enum": ["sha256-spki-der"], "description": "How the fingerprint is computed." },
          "signature_scheme": { "type": "string", "enum": ["RSA-SHA256"], "description": "Signature algorithm." },
          "trust": { "type": "string", "description": "Instruction for establishing trust in the key." },
          "status": { "type": "string", "enum": ["current_key"], "description": "This is the key signing new receipts." },
          "historical_keys": { "type": "string", "description": "How to obtain earlier keys." }
        }
      },
      "Health": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "enum": ["ok", "unhealthy"], "description": "ok only when both components are ready." },
          "signing": { "type": "string", "enum": ["ready", "unavailable"], "description": "Signing key check." },
          "persistence": { "type": "string", "enum": ["ready", "unavailable"], "description": "Database check." }
        }
      },
      "OtlpTraces": {
        "type": "object",
        "required": ["resourceSpans"],
        "description": "OTLP/HTTP JSON trace export. Each span requires traceId and spanId.",
        "properties": { "resourceSpans": { "type": "array", "items": { "type": "object" } } }
      }
    }
  }
}
