# CreationLoop run reporting, version 1: the reference

Version **2.2.0** of the instructions. The short method is at https://creationloop.ai/connect.md, and this page holds every detail of it.
Anyone can build the method from this page alone. No file from CreationLoop is needed.
Nothing here asks or depends on what the agent is built with.

## What it is

The agent tells CreationLoop three things about each job: it started, it reached a gate the owner chose, and it ended.
CreationLoop records each report, seals it and links it to the one before.
The owner approves a result, and publishes it to a public Trust Card, with their own passkey.

## What you need

1. A key. The owner makes it at https://creationloop.ai/connect/setup with the button that makes a key.
2. One place that can send an HTTPS POST with a header, or a connection to the tool server below, by a header or by `OAuth`.

The key starts with `clk_`. It reports for one agent, one saved set of gates and one phase, Test or Live.
The owner's browser saves the key file in their download folder. Whoever sets up the agent moves that file into the agent's folder, which git ignores. The agent reads the setting on the next line from it.
`CREATIONLOOP_KEY`
Never put the key in a prompt, a chat, a repository, a log or an address.
Nobody copies, types, pastes or exports the key. With a tool server, the key goes in the tool server's header field.

The setup page shows one key. It works from the first call: its reports are Test reports until the owner turns on Live, and Live reports after.
Records and the tool server do that with a Test key they make from the key, so no client needs to make it. This is how they make it.
The Test key is `clk_` and then a SHA-256 in base64url (RFC 4648, section 5), with no `=` at the end. That SHA-256 is of these bytes: the text `creationloop test key v1`, one line feed, and the 47 characters of the key.

## Every call

The next three lines are the request line and the two headers of every call.
```text
POST https://events.creationloop.ai/v1/runs/<call>
Authorization: Bearer <key>
Content-Type: application/json
```
The body is one flat JSON object of at most 262,144 bytes. Unknown fields are refused.

## The four calls

### describe

The body is `{}`. The call answers the gate version, the phase and the gates. It writes nothing.
The answer holds `loopName`, `gateVersion`, `phase`, `gates` and `next`. The phase is `test` or `live`.
Each gate holds `id`, `name` and `required`.

### start

The call opens the run.
- `runId` is required.
- One of `inputSha256` or `inputText` is required.
- `agentVersion` is optional. It has 1 to 128 characters, the same ones as a run ID.

### gate

The call records that the run reached one gate. Report only gates the agent really reached.
- `runId` is required.
- `gateId` is required. It is the `id` of one gate that `describe` answered. Any other gate ID gets a 400 that names this field.
- One of `artifactSha256` or `artifactText` is optional.

### end

The call closes the run. Nothing is taken for the run after it.
- `runId` is required.
- `status` is required. It is `delivered` or `failed`.
- A delivered run needs one of three fields. The next line names them.
- `outputSha256`, `outputText`, or `outputNotFingerprinted` with the value `true`.
- `knownCostCents` is optional. It is a whole number of cents, zero or more.

## Run IDs

The agent makes the run ID. It has 1 to 128 characters from the set on the next line.
`A-Z a-z 0-9 . _ : -`

- Make a new random one for every job, for example the date and time plus random letters.
- Use it on every call and every resend of that job.
- Never use one twice: not for another job, not across Test and Live, not after the owner saves new gates.
- A run ID that comes again with the same input is taken as the same job, and nothing new is recorded.
- A run ID that comes again with other content is refused.
- Put no personal data in a run ID. It is shown on the receipt.

## Fingerprints

A fingerprint is the SHA-256 of the exact bytes, as 64 lower case hex characters, made with a tool.
Never guess a fingerprint and never retype one.
The fingerprint of the five bytes of the word hello, in lower case, is on the next line. Use it to test your tool.
`2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824`

An agent that cannot make a fingerprint has two other ways.

- For text it holds, it sends the text in `inputText`, `artifactText` or `outputText`.
- CreationLoop makes the fingerprint on arrival and does not store the text.
- The fingerprint is shown on the receipt. Anyone who guesses the exact text can match it, so do not send secret short text this way.
- For a file it cannot fingerprint, such as a video or an image, it ends the run with `outputNotFingerprinted`.
- The receipt then says plainly that no file is tied to the run.

## Order, waits and resends

1. Send the calls of one run one at a time, in order: start, then each gate, then end. Send each after the one before was answered.
2. Different runs can report at the same time.
3. The reports of one key are recorded one after another, across all its runs. Plan on about two a second for each key.
4. One key can make at most 120 calls a minute, resends included.
5. Wait up to 30 seconds for an answer.
6. With no answer, or a 429 or a 503, send the exact same body again.
7. Wait first for the seconds in the header `Retry-After`, if the answer has it. If not, wait 2, then 4, then 8 seconds.
8. Make at most 4 tries in all. Never resend after any other 4xx.
9. A resend of the same body is safe. It gets 200 and the first answer, and records nothing new.
10. Reporting never stops or changes the job. If your tool stops a job when one of its actions fails, set the report calls to carry on after a failure.

## Answers

Each answer is JSON. An answer that refuses a call holds `code`, and for a wrong field also `field`.

- **201** means recorded. The body holds `runId`, `receiptId`, `messageId`, `recordedAt` and `next`. Go on.
- **200** means recorded earlier, with the same body. The body is the first answer. Go on.
- **400** means a field is wrong, and the body names it. Fix it. Do not resend the same body.
- **401** means the key is missing or not known. Stop reporting and tell the owner in one line. Ask them nothing about the key.
- **403** means the key cannot report here. Stop reporting and tell the owner in one line.
- **409** means the call does not fit the run. The codes below say what to do.
- **413** means the body is too large. Send a fingerprint in place of text.
- **429** and **503** mean too many calls, or busy. Wait, then send the same body again.

The codes of a 401 are these two.
- `key_required` means the call has no key, or the key has the wrong form.
- `key_not_recognized` means no such key is registered.

The codes of a 403 are these two.
- `key_not_active` means the key is stopped, expired or revoked.
- `key_out_of_scope` means a wrong phase or gate version, or a run ID that was used before in another phase or gate version.

Any other code of a 403 means that the workspace of the owner cannot report now.

The codes of a 409 are these four.
- `run_exists` means the run ID holds a start with other content. Make a new run ID for a new job.
- `gate_conflict` means this gate of the run holds other content. Make a new run ID for a new job.
- `run_ended` means the run has ended. Make a new run ID for a new job.
- `run_not_started` means the run has no start. Send the start, then send this call again.

The field `next` of a 201 is one plain sentence that says which call can come next.

## Worked examples of each call

The examples use curl. Any tool that can send the same request works the same way.
The key is read from the secret setting and is never typed into the command.

The first example sends `describe`. Its answer is the line after the command.
```sh
curl -sS -m 30 -X POST https://events.creationloop.ai/v1/runs/describe \
  -H "Authorization: Bearer $CREATIONLOOP_KEY" -H 'Content-Type: application/json' --data '{}'
```
```json
{"loopName":"Ticket replies","gateVersion":2,"phase":"test","gates":[{"id":"draft-written","name":"Draft written","required":true}],"next":"Send /v1/runs/start with a new run ID before the work."}
```

The second example sends `start` with a fingerprint of the input. Its answer has the status 201.
```sh
curl -sS -m 30 -X POST https://events.creationloop.ai/v1/runs/start \
  -H "Authorization: Bearer $CREATIONLOOP_KEY" -H 'Content-Type: application/json' \
  --data '{"runId":"20261127T1702-k7qz","inputSha256":"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"}'
```
```json
{"runId":"20261127T1702-k7qz","receiptId":"...","messageId":"...","recordedAt":"...","next":"Send /v1/runs/gate for each gate the run reaches, then /v1/runs/end."}
```

The third example sends `gate` for the gate that the first answer listed.
```sh
curl -sS -m 30 -X POST https://events.creationloop.ai/v1/runs/gate \
  -H "Authorization: Bearer $CREATIONLOOP_KEY" -H 'Content-Type: application/json' \
  --data '{"runId":"20261127T1702-k7qz","gateId":"draft-written"}'
```

The fourth example sends `end` with a fingerprint of the output.
```sh
curl -sS -m 30 -X POST https://events.creationloop.ai/v1/runs/end \
  -H "Authorization: Bearer $CREATIONLOOP_KEY" -H 'Content-Type: application/json' \
  --data '{"runId":"20261127T1702-k7qz","status":"delivered","outputSha256":"486ea46224d1bb4fb680f34f7c9ad96a8f24ec88be73ea8e5a6c65260e9cb8a7"}'
```

The fifth example is the body of an `end` for a video that the agent cannot fingerprint. It belongs to another run.
```json
{"runId":"20261127T1703-p2wd","status":"delivered","outputNotFingerprinted":true}
```

The sixth example is the body of a `start` that sends text for CreationLoop to fingerprint.
```json
{"runId":"20261127T1704-m3vx","inputText":"Reply to ticket 4411: the customer asks for a refund."}
```

## The same calls as tools

Add one tool server. Its address is on the next line.
`https://creationloop.ai/claim/mcp/report`

Sign in with the same header as a call. The key goes in the header field of the tool server and nowhere else.
`Authorization: Bearer <key>`

Add the server one time, with the key the setup page showed. That one add serves Test and Live.
Before "Turn on Live", the tool server reports with the Test key it makes from that key, and after it with the key itself.
A run ID used in Test is refused in Live. The tool's answer then says to start a new run with a new run ID.

A tool client that cannot set a header signs in by `OAuth`.
The owner picks the workspace, the gate version and the phase, and approves with a passkey.
On that way one connection serves one phase, so such a client connects once for Test and once for Live. One connection for both phases comes in a later version.
The access token works only on this tool server. CreationLoop holds the reporting key of that connection.

- The four tools are `report_describe`, `report_run_start`, `report_gate` and `report_run_end`.
- They take the same fields as the four calls and give the same answers.
- The tool `report_gate` lists the gate IDs of the owner.
- No tool takes the key as an argument.
- Calls from a web page are accepted when they carry the header or the access token. No cookie is ever used.

The tool server sends the exact same call again for you when the reporting service does not answer, for up to 45 seconds.
So the agent does not send a tool call again by itself, with one exception.
When a tool answers with the code on the next line, the agent repeats the call with exactly the same arguments.
`reporting_unavailable`

Some hosts ask the person to allow each tool call. If the host offers to always allow these calls, the owner can choose that.
If the host does not offer it, each report waits for that click.

## Worked examples of each tool

Each line below is the request that a tool client sends for one tool call.
```json
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"report_describe","arguments":{}}}
{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"report_run_start","arguments":{"runId":"job-20261127-a1x9","inputText":"Reply to ticket 4411: the customer asks for a refund."}}}
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"report_gate","arguments":{"runId":"job-20261127-a1x9","gateId":"draft-written"}}}
{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"report_run_end","arguments":{"runId":"job-20261127-a1x9","status":"delivered","outputText":"Dear customer, ..."}}}
```
The HTTP request of each tool call carries the header with the key, or the access token of an `OAuth` sign in.

## A described API

A description of the four calls in plain `OpenAPI` is at https://creationloop.ai/connect/openapi.json.
It is for tools that build actions or function tools from a description.

## Signed reports (optional)

An owner whose systems can make Ed25519 signatures can sign each report themselves.
The format, with test vectors, is at https://creationloop.ai/connect/signed.md.
A signed report carries a signature and never the key that made it.
The receipt reads the same for both ways of reporting. CreationLoop does not check who holds a key.

## What CreationLoop keeps

- CreationLoop keeps the report fields, the fingerprints, the times, the order and its own seal.
- CreationLoop does not keep the text that was sent for a fingerprint.
- The code of CreationLoop does not log request bodies or keys.
- The network of the hosting provider carries the requests. CreationLoop does not control the logs of that network.
- CreationLoop does not check the quality of the work.

## Stop

The owner can stop any key, or all keys of an agent, on the setup page with a passkey.
A stopped key gets the status 403 at once. Receipts that were recorded before are not changed.

## The least an agent must be able to do

One of these two is enough.
- It sends an HTTPS POST with one header from a secret setting.
- It makes a tool call on a remote tool server that is signed in by a header or by `OAuth`.

The agent can do this itself, or anything that runs the agent can do it.
The agent must also make a new ID for each job, call in order, and resend the same body when no answer comes.

## Kinds of agent this method cannot serve

1. An agent with no way to reach the internet, whose host has none either. Only a person could forward its reports for each run.
2. An agent that can only fetch a page for reading. A page fetch never writes.
3. A tool client that accepts only tool servers with no sign in. A key in an address or in the arguments of a model is refused.
4. An agent behind a network that blocks the two CreationLoop hosts, until its administrator allows them.
5. An agent that lives only in a browser and cannot hold a secret. A person would have to type the key for every run.

Served at a weaker level, which the receipt says: an agent whose output is a file it cannot fingerprint. No file is tied to that run.

## Versions

This page is part of version 2.2.0. Its permanent copy and the checksums of this version are at the two addresses below.
- `https://creationloop.ai/connect/v2.2.0/reference.md`
- `https://creationloop.ai/connect/v2.2.0/SHA256SUMS`
