# trail/witness/submit

https://toip.tools/spec/trail/witness/submit/0.1

A log's controller sends a witness KEL events or trail messages to witness. The witness verifies each one, keeps the first version it sees at each position, and returns receipts. If it refuses, it says why, and on duplicity it returns the version it saw first.

- **Sent**: log controller → witness
- **Kind**: Request and response. The response's type is `https://toip.tools/spec/trail/witness/submit/0.1#response`.
- **Envelope**: Signed by the issuer, addressed to one recipient, timestamped, and encrypted in a TSP Direct message. The signature and recipient binding prevent its use as a bearer token.
- **Defined in**: [`packages/eventlog/src/tasks.ts:12`](https://github.com/yourbuddyconner/toip-tools/blob/main/packages/eventlog/src/tasks.ts#L12) as `submit`
- **Handled in**: [`packages/eventlog/src/tasks.ts`](https://github.com/yourbuddyconner/toip-tools/blob/main/packages/eventlog/src/tasks.ts)
- **Design**: [9.2 What it does](https://github.com/yourbuddyconner/toip-tools/blob/main/projects/trail/docs/design.md#92-what-it-does) in `projects/trail/docs/design.md`

## Payload

As the handler declares it, in packages/eventlog/src/tasks.ts:

```ts
{ stream: string }
```

## Response payload

packages/eventlog/src/client.ts:6:

```ts
export type SubmitResult =
  | { ok: true; receipts: string }
  /** `receipts` holds receipts for messages before the refused one. (Additive.) */
  | { ok: false; refusal: Refusal; problems: Problem[]; firstSeen?: string; receipts?: string };
```

## Notes

The same operation is also served over HTTP (witnessHttpHandler).

## Document envelope

Every Trust Task uses this envelope. Replace `payload` with the structure shown above.

Shape of a document of this type:

```json
{
  "id": "urn:uuid:…",
  "type": "https://toip.tools/spec/trail/witness/submit/0.1",
  "issuer": "did:key:… (the sender)",
  "recipient": "did:key:… (the receiver)",
  "issuedAt": "2026-11-06T18:00:00.000Z",
  "payload": { … },
  "proof": {
    "type": "DataIntegrityProof",
    "cryptosuite": "eddsa-jcs-2022",
    "verificationMethod": "did:key:…#…",
    "proofPurpose": "assertionMethod",
    "proofValue": "z…"
  }
}
```

---

This is the Markdown version of https://toip.tools/spec/trail/witness/submit/0.1/. An index of the documentation for AI assistants is at https://toip.tools/llms.txt.
