# Signalbound CIAG agent access

CIAG accepts external agents over HTTPS. Identity enrollment, signing-authority checks, signed-document checks, hosted file comparisons, incident reports, manual freezes and recovery each cost **0.10 USDC on Base**. A file comparison returns an answer for both matching and differing files. Rejected recovery evidence and rejected signatures consume zero credits. The public record, bulletin, local key generation and offline verification remain independently accessible. File contents and private keys stay on the client.

## Fund a wallet

Read `GET https://api.signalbound.art/api/ciag-billing` for the current merchant and unit price. The browser accepts 1 to 1,000 credits in one payment; each credit costs 0.10 USDC. External wallets can call `paymentTerms(credits)` from the SDK and send its exact `transaction` on Base mainnet from the wallet that will authorize service requests. Larger balances can be built with additional payments. The wallet shows the total and network fee before approval. CIAG v1 accepts only transfers with the exact CIAG memo, merchant and whole-credit amount. Ordinary USDC transfers and payments for other Signalbound services do not qualify.

Submit `{"tx":"<public Base transaction hash>"}` to `POST /api/ciag-billing` once Base marks its block safe. The response returns `creditsAdded` and the wallet's resulting `balance`. Retrying the same hash never adds the credits twice. If confirmation is delayed, retry the same hash. A server outage after the transfer can be recovered with the same hash.

## Make a paid request

Import `/js/ciag-agent.mjs` and `/js/ciag-fee.mjs` together. The JavaScript SDK works from Node.js and TypeScript. Keep signing in the application's wallet or hardware signer. For example, the following function compares two SHA-256 digests with a viem-compatible account. Give the caller a durable order ID from `newOrder()` before the first attempt.

```js
import {callCiag, newOrder} from "./ciag-agent.mjs";

export {newOrder};
export async function compare(account, order, actual, expected, actualBytes, expectedBytes) {
  return callCiag({
    target: "ciag-file-check", action: "compare", payer: account.address, order,
    proof: {actual, expected, actualBytes: String(actualBytes), expectedBytes: String(expectedBytes)},
    signTypedData: typed => account.signTypedData(typed)
  });
}
```

Use a random 32-byte hexadecimal order ID with a 0x prefix. Persist the order ID and exact public proof until a response arrives. Reusing that order and request retrieves the original result. An order cannot authorize a different action or payload. Start a fresh order for a new check. A wallet signature authorizes spending one service credit and expires within 15 minutes. The service stores the result and debit atomically.

Python clients can call the same API. Use `payment_terms()["transaction"]` to prepare funding, `claim_credit(tx)` to claim it and `new_order()` to allocate an order. The client computes the request hash as follows.

The downloadable [Python client](/references/ciag_client.py) supplies the EIP-712 envelope and accepts a wallet signing callback. The [JavaScript client](/js/ciag-agent.mjs) uses the same fields with the [fee module](/js/ciag-fee.mjs).

```python
payload = json.dumps([target, action, proof], sort_keys=True, separators=(",", ":"), ensure_ascii=False)
request_hash = "0x" + hashlib.sha256(payload.encode("utf-8")).hexdigest()
```

Sign the EIP-712 schema exported by `typedRequest` in `ciag-fee.mjs` with the payer's wallet. POST `{action, proof, billing: {payer, order, expires, signature}}` to `/api/ciag-recovery/{id}` or `/api/ciag-file-check`. HTTP 402 indicates that payment authorization or a credit is required. HTTP 403 indicates an invalid signature, 409 a conflicting order or identity phase, and 429 a temporary rate limit. An unchanged retry can retrieve a completed order after an interrupted response.

## Discover public tools

Connect a Streamable HTTP MCP client to `https://api.signalbound.art/api/ciag-mcp`. The server provides `ciag_service_terms` and `ciag_identity_status`. Wallet authorization for paid actions belongs in the client application.

## Track accepted documents

Select the tracking option when checking a signed document, or include `watch: true` in the `verify-file` proof. Successful verification can save the identity, digest and phase in the paying wallet's private list for 30 days. Each wallet can track 100 documents. Open **Agent access** to inspect affected documents, remove entries or export the list. Signed `watchlist` and `watch-remove` requests to the billing endpoint use a zero fee in the typed message. An agent can inspect each exported identity's public receipt, verify it with `verifyReceipt` and compare its phase with the saved phase. A different phase flags the document for review. An unreachable registry leaves the status unknown.

For continuous monitoring, save the [monitor](/js/ciag-monitor.mjs), [protocol module](/js/ciag-recovery-protocol.mjs) and [verification dependency](/js/ciag-ml-dsa65.mjs) in the same directory. Run `node ciag-monitor.mjs ciag-watchlist.json --follow` with Node.js 22 or later. The monitor checks once a minute and emits JSON Lines on the first observation and on changes. Your existing alerting service can consume that stream.

## Share a team watchlist

All four requests below target `ciag-billing`, require a wallet signature and cost zero credits. The owner first tracks a successfully verified signed document. An invitation shares the full list, including documents added while the grant is active. Give the viewer the owner's public address. The viewer signs each read with their own wallet.

| Action | Proof | Result |
| --- | --- | --- |
| `watchlist` | `{}` | Owner, version, items and active members with expiration times |
| `team-grant` | `{owner, viewer, version}` | Grants or renews read access for 30 days |
| `team-read` | `{owner}` | Items visible to this authorized viewer |
| `team-revoke` | `{owner, viewer, version}` | Ends future reads for the viewer |

Use the version returned by the most recent owner read or update. A 409 means refresh before retrying. Up to 12 viewers can hold access. Viewers can export the list. Their existing exports are independent copies.

## Operation inputs

Post to `ciag-recovery/{id}` with the signed billing envelope described above. The browser protocol module constructs the identity proofs. The identity ID and SHA-256 file digests are 64 lowercase hexadecimal characters.

| Action | Public proof fields |
| --- | --- |
| `enroll` | key, commitment, signature |
| `verify` | nonce, signature |
| `verify-file` | digest, statement and optional boolean watch |
| `report` | first and second signed statements |
| `freeze` | key, signature |
| `recover` | key, signature, replacement, acceptance |

A statement contains id, slot, digest and signature. Each hosted operation costs one credit. Read a public receipt with GET on the same URL. The protocol and offline receipt verification example are in the [recovery reference](/references/ciag-recovery.md).

For a private balance use `ciag-billing`, action `balance`, proof `{}`. Remove a personal watch entry with action `watch-remove` and proof `{id,digest}`. A pending funding receipt can return 425 or 503. Retry with the same transaction hash. A 422 means the transfer did not meet the funding terms.

## Release drills

POST signed requests to `/api/ciag-drills` with SDK target `ciag-drills`. Opening a training round consumes one service credit (0.10 USDC). A signed wallet without a paid round cannot access evidence or file decisions. Each wallet has one active round at a time.

| Action | Proof | Result |
| --- | --- | --- |
| `drill-open` | `{}` or `{"tokenId":123}` | Three generated files, or five when the paying wallet owns the specified Signalbound NFT on Ethereum |
| `drill-resume` | `{}` or `{"id":"<round UUID>"}` | Latest or specified purchased packet and its report |
| `drill-file` | `{"id":"<round UUID>","decisions":[...]}` | Final report with per-file decisions, independent checks, score and cumulative completed and perfect reviews |

Use the same order for an interrupted purchase. Reading and filing are included in that purchase and use a zero-price wallet signature. The first complete submission is final. Entries are scoped to the paying wallet.

The evidence module at `/js/ciag-drill-evidence.mjs` exports `inspectRelease(packet)`. It hashes each UTF-8 file and verifies the P-256 manifest signature over the round ID, filename and expected SHA-256. Send decisions in packet order: `escalate` for an unverified signer, `quarantine` for changed bytes under a verified manifest, or `publish` for a verified match. Round authorities are generated for exercises. Progress has no cash redemption.

## Recovery lab

Use SDK target ciag-lab. The exercise demonstrates a previously committed ML-DSA-65 recovery authority replacing a compromised P-256 operating key under CIAG identity rules.

- lab-open accepts {} or {"tokenId":123} and consumes one 0.10 USDC credit. The response contains a session ID and public evidence packet. Standard exercises have six stages. Verified Signalbound NFT owners receive two extra attack checks.
- lab-resume accepts {} for the latest purchase or {"id":"<session UUID>"}. A zero-price wallet signature retrieves evidence already purchased by that wallet.
- Keep the same order and proof when retrying a purchase.

Save ciag-lab-proof.mjs, ciag-recovery-protocol.mjs and ciag-ml-dsa65.mjs from /js/ together. Call inspectLab(download.packet) to verify enrollment, the compromised signer's accepted signature, conflict evidence, freeze, rejection of a different recovery authority, replacement and rejection of the original operating key. Holder packets additionally test a changed recovery challenge and modified enrollment commitment.

The exercise uses generated training keys. Downloads contain public proofs. Each CIAG identity supports one recovery. The replacement operating key uses P-256. The exercise governs CIAG signing identities, with blockchain balances and consensus outside its scope.
