Δ Diff Review Kit
Contract page

API Contract

The contract intentionally exposes version state and idempotency semantics. Clients can render pending states, retry safely, and query a stable document URL while workers finish asynchronous rendering.

POST/v1/documents

Create or update a document by slug and create a new immutable version.

Headers:
  Authorization: Bearer <token>
  Idempotency-Key: pub_01HV7PS1YF6...

Request:
{
  "slug": "q2-product-review",
  "format": "html",
  "content": "<main>...</main>",
  "access": {
    "visibility": "invite",
    "commentPolicy": "authenticated"
  }
}

Response 202:
{
  "documentId": "doc_8xK",
  "versionId": "ver_2BT",
  "slug": "q2-product-review",
  "state": "accepted",
  "url": "https://app.example/@nate/q2-product-review"
}

GET/v1/documents/{documentId}/versions/{versionId}

Return version state, source hash, render artifact, and diagnostics.

Response 200:
{
  "documentId": "doc_8xK",
  "versionId": "ver_2BT",
  "sourceHash": "sha256:3bb7...",
  "rendererVersion": "renderer-html-2026.06",
  "state": "ready",
  "artifact": {
    "url": "https://cdn.example/rendered/3bb7/renderer-html-2026.06.html",
    "immutable": true
  },
  "traceId": "trc_01HV7Q..."
}

PATCH/v1/documents/{documentId}/access

Update projected access state independently from document content.

Request:
{
  "visibility": "domain",
  "allowedDomains": ["company.com"],
  "commentPolicy": "authenticated"
}

Response 200:
{
  "documentId": "doc_8xK",
  "projectionVersion": 42,
  "state": "projected"
}
Error HTTP Retry Client behavior
invalid_content 422 No Show validation errors and keep editor draft local.
duplicate_idempotency_key 409 No Fetch existing resource associated with the key.
render_failed_retryable 200 Server-side Show pending/error state; do not ask user to republish.
quota_exceeded 429 After reset Display reset time and avoid background retries.