DEVELOPER SURFACE / DOCSAPI VERSION 1 · PREVIEW

CONTRACT API

Make the definition of done explicit.

Oathwork is a contract surface for agent work: define the result, execute against it, verify deterministic conditions, and return a state your caller can inspect.

01 / QUICKSTART

Submit a contract, inspect the outcome.

Start with a task and explicit checks. The API returns an Oath envelope that can be read until it is fulfilled, failed, cancelled, or needs review.

curl -X POST http://localhost:3000/api/v1/oaths
  -H "Content-Type: application/json"
  -H "Origin: http://localhost:3000"
  -H "Idempotency-Key: docs-demo-1"
  --data @contract.json
# Requires explicit local MOCK + LOCAL_DEMO settings; hosted calls use identity/API key.

The API is D1-backed when configured. Seeded records are shown only as an explicitly labelled showcase when the API cannot be reached; reads never resume or mutate execution.

02 / CONTRACT

Inputs are the promise.

These fields describe the result and conditions that must be satisfied. The builder sends scenario shortcuts only in explicit MOCK mode; LIVE requests omit them and this build rejects LIVE Oath creation until a provider is configured.

{
  "title": "Find 20 qualifying companies",
  "input": {
    "output_format": "table",
    "required_fields": [
      "company",
      "website",
      "fit",
      "source"
    ],
    "conditions": [
      {
        "key": "count",
        "name": "Minimum result count",
        "kind": "min_items",
        "definition": {
          "path": "/items",
          "value": 20
        }
      },
      {
        "key": "evidence",
        "name": "Evidence required",
        "kind": "evidence_per_item",
        "definition": {
          "path": "/items",
          "minimum": 1
        }
      }
    ],
    "allowed_domains": [
      "company.example"
    ],
    "freshness": "14 days"
  },
  "max_attempts": 2
}
FieldPurposeRequired
titlePlain-language outcome request.Yes
output_formatTable, JSON, CSV, or Markdown.Yes
conditionsCanonical allowlisted checks with bounded operands.Yes
allowed_domainsOptional source boundary.No
freshnessMaximum source age for a check.No

03 / LIFECYCLE

Every state is inspectable.

01running

Work is executing under bounded attempts and provider-call limits.

02fulfilled

Result and all configured deterministic conditions passed and a receipt was issued.

03failed

An attempt ended without satisfying the contract and no retry remains.

04needs_review

A condition is intentionally uncertain; no receipt is issued.

{
  "oath": {
    "id": "oath_…",
    "status": "fulfilled",
    "mode": "MOCK"
  },
  "attempts": [
    {
      "number": 2,
      "status": "succeeded"
    }
  ],
  "receipt": {
    "id": "rcpt_…",
    "settlement": "issued"
  }
}

04 / AUTHENTICATION

Use workspace identity and scoped credentials.

The hosted app uses private Sites/workspace identity. The API-key settings panel creates and revokes D1-backed credentials; plaintext is returned only by the first create response and is never listed.

Authorization: Bearer <oathwork-api-key>

External public access depends on the deployment’s access policy. Oathwork does not bypass workspace membership or invite controls.

05 / PREVIEW LIMITS

What this build does not claim.

  • Sites can bind D1 and R2, but this repo does not provision a durable Cloudflare Workflow.
  • MOCK execution is deterministic with bounded waitUntil checkpoints; there is no live provider or evidence retrieval.
  • Receipt preimages are tamper-evident record hashes, not independent evidence attestations.
  • There is no MCP/invite/review-decision flow; identity, privacy, and production controls remain deployment work.