From an API key to a verified action in ten minutes
Five calls. Everything below runs on the free Developer plan against https://api.commitlayer.ai. The same flow is guided step by step inside the app after you sign in.
1Get two API keys
Start free, then open Settings → API keys and create one key per side of the line: a Runtime recorder key for the agent (it records actions and can do nothing else) and an Evidence key for the pipeline that relays your systems of record (it pushes facts for the sources you bind it to and cannot record). The key that records an action can never also supply the facts that verify it. Each key is shown once; send it as X-API-Key. Refund setup in the app makes both for you.
export COMMITLAYER_RECORDER_KEY=spk_... # Runtime recorder: the agent's side export COMMITLAYER_EVIDENCE_KEY=spk_... # Evidence, bound to stripe, shopify, zendesk: the pipeline's side curl https://api.commitlayer.ai/v1/contracts -H "X-API-Key: $COMMITLAYER_RECORDER_KEY"
2Install the first-run contract and verify its sources
A contract says what a valid action looks like: the limits on its parameters, the effects that must appear in your systems within a window, the effects that must never appear, and the later records that undo it. The first run uses one contract everywhere: scop_refund_order, the Stripe Customer Operations pack's refund workflow, on every plan. Refund setup in the app installs it from your answers (or install the pack under Workflow packs). Its window is 1h: the longest the verdict waits, not a delay; a PASS comes as soon as every record is in. Each expected effect accepts backend_attested evidence or stronger: a record CommitLayer reads with its own read-only connector, or one your backend pushes with the evidence key once an Owner or Admin has verified that source (in Refund setup, when you connect your real workflow). A record the agent or its key sent is agent_reported and never counts. The library also ships refund_workflow, a 15-minute template to copy and edit; it is not the first-run contract.
# the parts that matter (full YAML under Contracts once installed: scop_refund_order, version 1)
action:
window: "1h"
limits:
- param_max: {param: amount, max: 250}
expected_effects:
- effect_observed: {source: stripe, type: refund, min_trust_class: backend_attested} # on the order's payment
- effect_observed: {source: shopify, type: order_cancelled, min_trust_class: backend_attested}
- effect_observed: {source: zendesk, type: status_change, where: {to: solved}, min_trust_class: backend_attested}
forbidden_effects:
- effect_count_exceeds: {source: stripe, type: refund, max: 1}
- effect_attr_differs: {source: stripe, type: refund, attr: amount, equals_param: amount}
- effect_observed: {source: shopify, type: fulfillment_created}
# Accepted evidence, per effect:
# payment Backend-attested Stripe evidence; CommitLayer Stripe connector evidence
# order Backend-attested Shopify/order evidence; CommitLayer Shopify connector evidence
# support Backend-attested Zendesk/support evidence; CommitLayer Zendesk connector evidence
# Customer notified: not included in this workflow (added when a messaging system is selected: messaging.customer_notified)3Record the action
Call this where your agent performs the refund, with the agent's own parameters. It is idempotent on action_id, so retries are safe. The response carries a provisional verdict; the final one comes as soon as every record is in, and at the latest when the window closes.
curl -X POST https://api.commitlayer.ai/v1/actions \
-H "X-API-Key: $COMMITLAYER_RECORDER_KEY" -H "Content-Type: application/json" \
-d '{
"action_id": "refund:order_10231",
"contract_id": "scop_refund_order",
"agent_id": "support-agent",
"action_type": "refund_order",
"subject_id": "order_10231",
"subject_kind": "order",
"params": {"amount": 180.0, "currency": "USD"}
}'4Publish evidence from your systems
Facts are what actually happened, read from the systems of record, never from the agent. Publish them as one atomic batch: the links that join the payment and the case to the order, the records, and a checkpoint (observed_through) for every source you scanned. The whole batch is validated first and stored together or not at all: one invalid item rejects it with a structured error (the invalid source, the allowed sources, the invalid fact type, the failed link, the failed checkpoint) and nothing is written. Use the exact source ids your workspace configured: these are the canonical ones; a workspace whose backend sends its orders uses orders, not shopify. The setup's evidence step shows complete Python, TypeScript and REST programs with your own ids. The answer has one result per item. Facts are never metered.
curl -X POST https://api.commitlayer.ai/v1/evidence/batches \
-H "X-API-Key: $COMMITLAYER_EVIDENCE_KEY" -H "Content-Type: application/json" \
-d '{
"contract_id": "scop_refund_order",
"facts": [
{"source": "stripe", "subject_id": "pi_10231", "subject_kind": "payment", "fact_type": "refund", "occurred_at": "2026-10-01T10:42:07Z", "attributes": {"amount": 180.0, "currency": "usd"}},
{"source": "shopify", "subject_id": "order_10231", "subject_kind": "order", "fact_type": "order_cancelled", "occurred_at": "2026-10-01T10:42:09Z"},
{"source": "zendesk", "subject_id": "tk_552", "subject_kind": "ticket", "fact_type": "status_change", "occurred_at": "2026-10-01T10:42:11Z", "attributes": {"to": "solved"}}
],
"links": [
{"subject_id": "pi_10231", "source": "stripe", "linked_subject_id": "order_10231", "linked_source": "shopify", "link_type": "payment_to_order"},
{"subject_id": "tk_552", "source": "zendesk", "linked_subject_id": "order_10231", "linked_source": "shopify", "link_type": "ticket_to_order"}
],
"observed_through": {"stripe": "2026-10-01T10:43:00Z", "shopify": "2026-10-01T10:43:00Z", "zendesk": "2026-10-01T10:43:00Z"}
}'
# → 201 {"status": "committed", "written": true, "counts": {"links": 2, "facts": 3, "checkpoints": 3, ...},
# "facts": [{"fact_id": "...", "accepted": true, "status": "stored", "computed_trust_class": "backend_attested", ...}],
# "checkpoints": [{"source": "stripe", "accepted": true, "status": "advanced", ...}], "reverify_scheduled": true, ...}
# → 403 or 422 {"error": {"code": "batch_rejected", "details": {"written": false, "summary": ["invalid source: ...", "allowed sources: ..."], ...}}}5Read the verdict
Two lenses: outcome (did the intended change land?) and policy (was the action valid and within limits?). Each carries reason codes that name the missing or forbidden effect, the facts that decided it, and a hash chained to the previous verdict. UNKNOWN means the evidence to decide is not there yet; it is never counted as a failure. Records that arrived but are not eligible are counted as received, never as missing.
curl https://api.commitlayer.ai/v1/actions/refund:order_10231 -H "X-API-Key: $COMMITLAYER_RECORDER_KEY"
{
"status": "settled",
"lenses": {
"outcome": {"verdict": "PASS", "reason_codes": ["effect_observed:stripe.refund", "effect_observed:shopify.order_cancelled", "effect_observed:zendesk.status_change"], ...},
"policy": {"verdict": "PASS", ...}
},
"evidence_counts": {"received_sources": 3, "eligible_sources": 3, "expected": 3, "satisfied": 3, ...},
"checks": {
"limits": [{"description": "amount above 250", "ok": true, ...}],
"expected_effects": [{"code": "effect_observed:stripe.refund", "ok": true, "evidence_state": "eligible_matched", ...}, ...],
"forbidden_effects": [{"code": "duplicate_effect:stripe.refund", "ok": true, ...}, ...]
},
"summary": {"headline": "PASS — ..."}
}Next
After the first verdict: dry runs, webhooks, the completion gate and settlement. Then the API reference for every endpoint.