# Cases

[Open your cases in TraceFast →](https://tracefast.xyz/cases)

A [case](/cases) is one investigation written down as a graph: on-chain nodes
that point at TraceFast objects, off-chain nodes in the author's words, the
author's links between them, and the evidence behind each link. These eight
methods let a program or an AI agent work on **your own** cases — the same
operations the canvas in TraceFast uses, so what an agent did and what you did
land in one history.

| What | Method and path | MCP tool |
|---|---|---|
| [List your cases](#list-your-cases) | `GET /cases` | `list_cases` |
| [Create a case](#create-a-case) | `POST /cases` | `create_case` |
| [Read a case](#read-a-case) | `GET /cases/{case_id}` | `get_case` |
| [Edit a case](#edit-a-case) | `POST /cases/{case_id}/ops` | `apply_case_ops` |
| [Who changed a case](#who-changed-a-case) | `GET /cases/{case_id}/log` | `get_case_log` |
| [Preview a publication](#preview-a-publication) | `GET /cases/{case_id}/publication-preview` | `preview_case_publication` |
| [Withdraw a publication](#withdraw-a-publication) | `POST /cases/{case_id}/unpublish` | `unpublish_case` |
| [Delete a case](#delete-a-case) | `DELETE /cases/{case_id}` | `delete_case` |

The paths continue `https://tracefast.xyz/api/v1` — there is no chain in them:
a case is your document, not chain data.

**Access** — an [API key](/api/authentication) on the **Investigation** plan or higher ([plans](/api/authentication#plans)). Not sold over [x402](/api/x402): these methods act as your own account. As tools for AI agents on the [MCP server](/api/mcp-server): `apply_case_ops`, `create_case`, `delete_case`, `get_case`, `get_case_log`, `list_cases`, `preview_case_publication`, `unpublish_case`. **Beta** — the shape may still change; see [stability](/api/conventions#stability).

## Who a case belongs to

* **The caller's account, always.** A case method acts as the account behind
  the API key, or behind the agent's sign-in. Nothing in a request names the
  owner. A case of another account answers the same `404` as one that does not
  exist.
* **Keys.** A key needs the **Cases API** permission, chosen when the key is
  created ([managing keys](/api/keys)). A key without it is refused with
  `403 key_scope_missing`; rotate it with the permission.
* **Agents that sign in** need the cases permission on the consent screen —
  see [Connect an AI agent](/api/mcp-server#cases).
* **No method publishes.** A person publishes a case in TraceFast, after seeing
  the preview. An agent can [preview](#preview-a-publication) and
  [withdraw](#withdraw-a-publication) a publication.
* Answers carry `Cache-Control: no-store`, and a case's texts travel only in
  request and response bodies, never in a URL.

## What a case holds

| Object | What it is |
|---|---|
| Case | `id`, `title`, `summary`, `status` (`open` | `closed`), `visibility`, `version`, `publication`, and a `privateNote` |
| On-chain node | `{type: onchain, ref, caption?}` — `ref` is a TraceFast reference, `{type, chainId?, id}`, with `type` one of `entity`, `transaction`, `block`, `event`, `call`, `nft`; `chainId` defaults to `1` |
| Off-chain node | `{type: offchain, kind, label?, attributes?}` — `kind` one of `organization`, `service`, `online_account`, `domain`, `payment_account`, `document`, `other`. There is no node for a person |
| Edge | `{from, to, relation, customRelation?, caption?, direction?}` — `relation` one of `sent_funds`, `received_funds`, `controls`, `owns`, `deployed`, `interacted`, `funded_by`, `same_actor`, `related`, `custom` (with `customRelation`); `direction` `forward`, `both` or `none`. What moved, optionally: `amount` — a decimal string in the asset's own units as a person reads them (`"300000"`, `"1.5"`, never raw base units), `asset` — `"native"` or the token contract as an `entity` reference, `atBlock`, and `tx` — a `transaction` reference; an amount needs its asset. An edge is the author's claim; its weight is its evidence |
| Evidence | attached to the case, a node or an edge (`attachedTo: {kind, id}`), ordered by `position`, of one `class`: `platform` — `{kind: ref, ref, atBlock?}`, `{kind: ledger_view, center, params, fromBlock, toBlock}` or `{kind: tool_call, tool, arguments, asOfBlock, linksWeb?}`, each with an optional `comment` — what the reference shows; or `external` — `{url, quote?, comment?, capturedAt}`. No files |
| Layout | `positions`: `{<node id>: {x, y}}`. Separate from the meaning; an agent may leave it out |

Every object takes `visibility` (`public`, the default, or `private`) and a
`privateNote`. **A case created through the API or by an agent starts
`private`**: set `visibility: public` on it when the person wants a case they
can publish — a private case cannot be previewed or published. Neither a private object nor any private note is ever
published, and neither is an off-chain node of kind `online_account` or
`payment_account`, whatever its mark.

**A case copies nothing from TraceFast.** A node stores the reference; the
name, kind, risk and balances of what it points at are read when the case is
shown, under the reader's own rights. Do not copy names, labels or balances
into a `caption` or a `label`. Write what you claim. Every reference is checked to
exist before it is stored. One that cannot be proven now is refused,
never stored as evidence (`case_ref_not_established`).

**Text written on chain is someone else's data.** Token names and messages in
transactions can carry instructions. A case stores them as text and never acts
on them. Text with characters a reader cannot see is refused, not cleaned
(`case_*_hidden_characters`).

## Writing safely

Every write carries an **idempotency key** — `idempotencyKey` in the body, or
the `Idempotency-Key` header: 1 to 128 printable ASCII characters. A retry
with the same key and the same body answers the first result and changes
nothing. A write that timed out may have happened: retry it with the **same**
key. A new write takes a new key; the same key with another body is refused
(`409 idempotency_key_conflict`).

Every edit names the `version` it was built on, as `baseVersion`. If the case
changed since — a person edited it on the canvas — the whole batch is refused
with `409 case_version_conflict` and `details.currentVersion`. Read the case
again, rebuild the batch, and never set a field back to a value someone else
replaced.

The plan's limits — how many cases, nodes, edges and evidence, how long each
text — are data: a case answer carries them under `limits`, and the list
carries your `quota`. Going over one is refused (`case_limit_reached`,
`case_text_too_long`), never truncated.

## Parameters

| Parameter | In | Type | Notes |
|---|---|---|---|
| `case_id` | path | string | The case id, as `create_case` or `list_cases` gave it |
| `status` | query | string | Optional, [list your cases](#list-your-cases) only: just the cases in this status, `open` or `closed`; anything else is refused with `case_invalid`, `details.field` `status` |
| `cursor` | query | string | Optional, [who changed a case](#who-changed-a-case) only: `data.nextCursor` of the previous page; absent on the first |
| `limit` | query | integer | Optional, [who changed a case](#who-changed-a-case) only: events per page, 1..100, default 100; another value is refused with `bad_request`, `details.reason` `limit_out_of_range` and `details.maxLimit` |
| `baseVersion` | query | integer | Required by [preview a publication](#preview-a-publication): the case `version` the preview is of; another version is refused with `case_version_conflict` |

The writes take JSON bodies, described with each method below.

## Methods

### List your cases

```
GET https://tracefast.xyz/api/v1/cases
```

**MCP tool** — `list_cases`

Your cases, the most recently changed first: each with its `id`, `title`,
`status`, `visibility`, `version`, the `counts` of its nodes, edges and
evidence, and its `publication` state — `unpublished`, `published` or
`withdrawn`. Also `total` (after the `status` filter), `asOf` and your
`quota` — `limit`, `used` and `left`, `null` without the cases permission. Use
it to find a case by title; for one case whole, read it.

### Create a case

```
POST https://tracefast.xyz/api/v1/cases
```

**MCP tool** — `create_case`

A new, empty case in your account, returned whole with its `id` and
`version` `1`, and `warnings`: `[{code: same_title, caseIds}]` when you already
have a case with this title — ask the person whether to continue that one
instead.

```json
{
  "title": "USDC on Ethereum — who can change the token",
  "summary": "The proxy people hold, the implementations behind it and who deployed it.",
  "privateNote": "Next: read the admin slot.",
  "idempotencyKey": "usdc-case-create-1"
}
```

`title` and `idempotencyKey` are required. `status` is `open` by default.
`visibility` is `private` by default here — what a later publication may show.

### Read a case

```
GET https://tracefast.xyz/api/v1/cases/{case_id}
```

**MCP tool** — `get_case`

One case whole: `nodes`, `edges`, `evidence`, `layout` and every id, the
`version` an edit needs, its `publication` and the plan's `limits`. Read it
before every edit.

### Edit a case

```
POST https://tracefast.xyz/api/v1/cases/{case_id}/ops
```

**MCP tool** — `apply_case_ops`

One batch of 1 to 500 operations, applied **all or none** on top of
`baseVersion`. Keep a batch well under 1 MB.

```json
{
  "baseVersion": 1,
  "idempotencyKey": "usdc-case-batch-1",
  "ops": [
    {"op": "add", "target": "node", "tempId": "usdc",
     "node": {"type": "onchain", "ref": {"type": "entity", "chainId": 1, "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}, "caption": "The token contract people hold"}},
    {"op": "add", "target": "node", "tempId": "deployer",
     "node": {"type": "onchain", "ref": {"type": "entity", "chainId": 1, "id": "0x95ba4cf87d6723ad9c0db21737d862be80e93911"}}},
    {"op": "add", "target": "node", "tempId": "issuer",
     "node": {"type": "offchain", "kind": "organization", "label": "Circle"}},
    {"op": "add", "target": "edge", "tempId": "e1",
     "edge": {"from": "deployer", "to": "usdc", "relation": "deployed"}},
    {"op": "add", "target": "evidence", "tempId": "ev1",
     "evidence": {"attachedTo": {"kind": "edge", "id": "e1"}, "class": "platform",
       "platform": {"kind": "tool_call", "tool": "get_contract", "arguments": {"address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}, "asOfBlock": 26390341}}},
    {"op": "add", "target": "edge", "tempId": "e2",
     "edge": {"from": "issuer", "to": "usdc", "relation": "custom", "customRelation": "issues"}},
    {"op": "add", "target": "evidence", "tempId": "ev2",
     "evidence": {"attachedTo": {"kind": "edge", "id": "e2"}, "class": "external",
       "external": {"url": "https://www.circle.com/usdc", "comment": "Circle presents USDC as its stablecoin.", "capturedAt": "2026-11-26T12:00:00Z"}}}
  ]
}
```

The operations:

* `{op: add, target: node | edge | evidence, tempId, node | edge | evidence: {…}}`
  — `tempId` (`[A-Za-z0-9_-]{1,64}`) names the new object within the batch;
  an edge's `from` and `to`, and evidence's `attachedTo.id`, may be a `tempId`
  of the same batch. Add nodes first, then edges, then evidence.
* `{op: update, target: case | node | edge | evidence, id, set: {field: value}}`
  — partial; `null` clears an optional field. `target: case` sets the case's
  `title`, `summary`, `status`, `visibility` and `privateNote`.
* `{op: move, target: evidence, id, position}` reorders evidence.
* `{op: remove, target, id}` — a node takes its edges and their evidence
  with it.
* `{op: set_layout, positions: {id: {x, y}}}` and `{op: clear_layout, ids: […]}`.
  Positions are optional: placed nodes stay where they are, a node without a
  position is set beside the nodes it is linked to, and a case with no
  positions at all is laid out whole.

`visibility` and `privateNote` go **inside** the object
(`node: {…, visibility: private}`), never beside `op`.

The answer gives the new `version`, `ids` — each `tempId` mapped to the
case's id — and `removed`. Use those ids in later batches.

For `tool_call` evidence, `asOfBlock` is the answer's `meta.asOfBlock` or,
for a tool whose answer states none, the block of the row that showed the
fact. Pin a `fromBlock`/`toBlock` window in `arguments`, so that the call shows
the same rows later.

### Who changed a case

```
GET https://tracefast.xyz/api/v1/cases/{case_id}/log
```

**MCP tool** — `get_case_log`

The changes to a case, newest first, up to 100 per page (`limit`): when
(`at`), the case `version` after the change, who — `reader` (you, on the web), `key:<id>` (an API key),
`agent:<id>` (a signed-in agent) or `owner` (TraceFast) — the operation
(`create`, `apply_ops`, `publish`, `unpublish`, `withdraw`, `reinstate`), the
`objectIds` it touched and, for an edit, a `summary` of counts — `version` and
`summary` are `null` on changes made before 2026-11-26. **No texts.**
Continue with `data.nextCursor` passed back as `cursor` while `data.hasMore`.
Use it when you come back to a case: read what the person changed, then read
those objects in the case.

### Preview a publication

```
GET https://tracefast.xyz/api/v1/cases/{case_id}/publication-preview?baseVersion=3
```

**MCP tool** — `preview_case_publication`

The copy that publishing version `baseVersion` would show, built exactly as a
publication is (`preview`), and `omitted`: how many private notes, nodes,
edges and evidence it leaves out, and each left-out object with the `reason`
— `private_note`, `private`, `online_account`, `payment_account`, or
`hangs_on` (with `via`: the object it hung on). A private case is refused (`409 case_publish_refused`, `details.reason`
`case_marked_private`). `preview.headBlock` is `null` in a preview; on a
published copy it is the block the copy is stated as of. Nothing is published
or written. Show it to the person, and send them to
`https://tracefast.xyz/cases/<id>` to publish.

### Withdraw a publication

```
POST https://tracefast.xyz/api/v1/cases/{case_id}/unpublish
```

**MCP tool** — `unpublish_case`

Takes the published copy down: its content is erased at once and its link
stops answering within a minute. The case itself is kept. Only its author can
publish it again, in TraceFast. Answers `publication.state` `unpublished`.

### Delete a case

```
DELETE https://tracefast.xyz/api/v1/cases/{case_id}
```

**MCP tool** — `delete_case`

Deletes the case, its log and its published copy at once, for good. Answers
`outcome` `deleted` with the counts of what went. Over MCP, TraceFast first
asks the person to type the case's title, in the client; nothing is deleted
without it. The refusal is `409 confirmation_required` with
`details.reason`: `title_mismatch`, `declined`, or `client_cannot_confirm` —
the client cannot show the question, so delete the case in TraceFast instead.

## Response

`200 application/json`, the [usual envelope](/api/conventions#responses):
`data` is the case, the list or the result, in camelCase — except the keys of
opaque maps, kept as written: `attributes`, `params`, `arguments`,
`positions`, `ids`. A refusal's `details` never holds a `null`. `meta` states no
block — a case is written by its author, not read from the chain — and
`version` moves with every change. A case, as [read a case](#read-a-case)
answers it:

```json
{
  "data": {
    "case": {
      "id": "01a217b9-1855-77e3-8653-fdb0a7658358",
      "title": "USDC on Ethereum — who can change the token",
      "summary": "The proxy people hold, the implementations behind it and who deployed it.",
      "privateNote": "Next: read the admin slot.",
      "status": "open",
      "visibility": "public",
      "version": 2,
      "publication": {"state": "unpublished"},
      "createdAt": "2026-11-26T12:00:00.085458Z",
      "updatedAt": "2026-11-26T12:00:00.109155Z",
      "nodes": [
        {"id": "01a217b9-186c-70f0-b290-08efdaa24284", "type": "onchain",
         "ref": {"type": "entity", "chainId": 1, "id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"},
         "caption": "The token contract people hold", "visibility": "public", "privateNote": null},
        {"id": "01a217b9-186c-70f0-b290-08f126181930", "type": "onchain",
         "ref": {"type": "entity", "chainId": 1, "id": "0x95ba4cf87d6723ad9c0db21737d862be80e93911"},
         "caption": null, "visibility": "public", "privateNote": null},
        {"id": "01a217b9-186c-70f0-b290-090c15e33088", "type": "offchain", "kind": "organization",
         "label": "Circle", "attributes": {}, "visibility": "public", "privateNote": null}
      ],
      "edges": [
        {"id": "01a217b9-186c-70f0-b290-0922cd77285f", "from": "01a217b9-186c-70f0-b290-08f126181930",
         "to": "01a217b9-186c-70f0-b290-08efdaa24284", "relation": "deployed", "customRelation": null,
         "caption": null, "direction": "forward", "amount": null, "asset": null, "atBlock": null, "tx": null,
         "evidenceCount": 1, "visibility": "public", "privateNote": null}
      ],
      "evidence": [
        {"id": "01a217b9-186c-70f0-b290-095e716f5583", "attachedTo": {"kind": "edge", "id": "01a217b9-186c-70f0-b290-0922cd77285f"},
         "class": "platform", "position": 0, "external": null, "visibility": "public", "privateNote": null,
         "platform": {"kind": "tool_call", "tool": "get_contract",
           "arguments": {"address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}, "asOfBlock": 26390341, "comment": null,
           "linksWeb": "https://tracefast.xyz/entity/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}}
      ],
      "layout": {"positions": {}},
      "limits": {"enabled": true, "limits": {"…": "the plan's limits"}}
    }
  },
  "meta": {"cached": false, "chain": "ethereum", "timestamp": 1795694853107, "docs": "https://docs.tracefast.xyz/api/cases"}
}
```

An edit answers `{"caseId": "…", "version": 3, "ids": {"usdc": "…", "e1": "…"}, "removed": []}`;
a log page `{"events": [{"at": "…", "actor": "agent:…", "op": "apply_ops", "version": 3, "objectIds": ["…"], "summary": {…}}], "hasMore": false, "nextCursor": null}`;
a deletion `{"id": "…", "outcome": "deleted", "deleted": {"nodes": 3, "edges": 1, "evidence": 1, "logEvents": 2}, "publication": {"state": "withdrawn"}}`.

## Errors

| Status | When |
|---|---|
| 400 | `case_invalid` — the request is outside the contract: `details.field` (the path into the request, such as `ops[3].edge.from`) and `details.reason` (`unknown_id`, `empty`, `too_large`, `bad_ref`, `amount_needs_asset`, …), or `details.accepted` for a value outside a closed set; `details.errors[]` lists every problem found. `case_text_too_long` — a text is over its limit: `details.field`, `details.length`, `details.limit`. `case_*_hidden_characters` (`case_label_hidden_characters`, …) — a text carries characters a reader cannot see: refused, never cleaned; `details.field`, `details.class`. `bad_request` — a body that is not a JSON object, or an `idempotencyKey` that is not 1–128 printable ASCII characters (`invalid_idempotency_key`), a missing `baseVersion`, or a `limit` outside 1..100 (`limit_out_of_range`) |
| 401 | `session_required` — the call reached the case store without an account behind it. Send a key, or sign in |
| 403 | The [key check](/api/authentication#when-a-key-is-refused) answers first: `plan_scope_missing` below Investigation, `key_scope_missing` for a key without the case methods. The case store's own lock says the same as `cases_not_in_plan` and `cases_not_on_key` |
| 404 | `not_found` — no such case, or a case of another account |
| 409 | `case_version_conflict` — the case changed since `baseVersion`; `details.currentVersion`. `idempotency_key_conflict` — the key was used with another body. `case_limit_reached` — a plan limit is reached: `details.what`, `details.limit`, `details.count`. `case_publish_refused` — the case cannot be previewed or published now: `details.reason` `case_marked_private` (make it public first) or `withdrawn`. `confirmation_required` — MCP `delete_case` without the person's confirmation |
| 422 | `case_ref_invalid` — a reference is malformed: `details.field`, `details.reason`. `case_ref_not_established` — a reference could not be proven to exist **now**, never "it does not exist": `details.reason` — `tx_not_known`, `coverage_gap` (retry later; `details.details.maxAvailableBlock`), `position_not_proven`, `address_not_seen`, `block_not_available`, `collection_too_large`, `token_not_seen`, `read_failed`. The whole batch is refused; `details.field` names the op |
| 429 | Too many requests or case writes; wait `Retry-After` |
| 503 | `case_ref_check_unavailable` — references cannot be checked right now; nothing was written. `case_encryption_unavailable` — cases cannot be read or written right now. Retry with backoff |

The key check's own `401`/`403`/`429`/`503` are the same for every method —
see [API keys](/api/authentication#when-a-key-is-refused). Over MCP a refusal
is a tool result with `isError: true` and the same `error` — see
[refusals](/api/mcp-server#refusals).

## Related pages

* [Cases](/cases) — the canvas, private parts and publishing, in TraceFast
* [Connect an AI agent over MCP](/api/mcp-server#cases) — sign-in with the cases permission
* [API keys](/api/authentication) — plans and key refusals
* [Conventions](/api/conventions) — the envelope, errors and stability
* [All methods](/api/methods) — every method on one page
