Reference

HTTP API

Every endpoint, with its request and its answer.

The API is JSON over HTTP. This page covers contract version 0.1.0, which every response names in its X-Contract-Version header. In the examples, $WRIT_API is the API's address.

Conventions

Bodiesapplication/json in both directions. Request bodies are strict: an unknown key is a VALIDATION_ERROR.
AmountsBase units as decimal strings, never JSON numbers.
Addresses and signaturesBase58.
TimesISO 8601 in UTC.
FailuresOne envelope for every failed request. Errors lists the codes.
Request idEvery response carries X-Request-Id.
Rate limitsPOST /auth/verify 20 a minute, POST /v1/intents 60 a minute, POST /v1/chat/messages 30 a minute. Past the limit the answer is RATE_LIMITED.

Responses can gain fields and enum values in later versions. A client should ignore keys it does not know.

Authentication

There are two kinds of token, both sent as Authorization: Bearer <token>.

TokenWho holds itWhat it opens
Session tokenthe owner, after signing inevery /v1 endpoint except POST /v1/intents
Agent tokenan outside agentPOST /v1/intents only

A session starts with Sign-In With Solana: fetch the sign-in input from GET /auth/nonce, have the owner's wallet sign it, and send the signed bytes to POST /auth/verify. A session lasts until its expiresAt. A call to an owner endpoint without one answers UNAUTHORIZED. An agent token is created by the owner with POST /v1/agents/tokens.

Intents

POST /v1/intentsagent token

Sends one intent for the agent wallet the token belongs to. The body is the TIS itself.

bash
curl -X POST "$WRIT_API/v1/intents" \
  -H "Authorization: Bearer $WRIT_AGENT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tis":"1","action":"transfer","params":{"asset":"SOL","to":"CvaC1sSWgsG9UZT3fU8R2TRhrFcpxa1d2mR6pU3mTdgv","amount":"0.5"},"reason":"User asked to pay Maya 0.5 SOL for design work."}'

The answer has three fields.

pdrPDR or null

The record. null for an intent with action: "none".

replystring or null

The reply of a none intent, otherwise null.

transactiontransaction or null

The transaction of the record. null when there is no record.

An allowed intent, answered at sent:

200
{
  "pdr": {
    "id": "1ab45685-fd95-4350-894d-9b132332dd87",
    "pdr": "1",
    "tis": {
      "tis": "1",
      "action": "transfer",
      "params": {
        "to": "CvaC1sSWgsG9UZT3fU8R2TRhrFcpxa1d2mR6pU3mTdgv",
        "asset": "SOL",
        "amount": "0.5"
      },
      "reason": "User asked to pay Maya 0.5 SOL for design work."
    },
    "checks": [
      {
        "rule": "schema",
        "detail": "valid TIS v1, compiled to 3 instructions",
        "result": "pass"
      },
      {
        "rule": "paused",
        "detail": "wallet is active",
        "result": "pass"
      },
      {
        "rule": "program_allowlist",
        "detail": "System allowed; ComputeBudget always permitted",
        "result": "pass"
      },
      {
        "rule": "daily_spend",
        "detail": "0 + 0.500005001 of 2 SOL in 24h",
        "result": "pass"
      },
      {
        "rule": "token_limits",
        "detail": "moves no tokens",
        "result": "n/a"
      },
      {
        "rule": "no_unlimited_approval",
        "detail": "grants no approval",
        "result": "n/a"
      }
    ],
    "source": "agent_token",
    "wallet": "BrpKxDbVNo9KmzXy6TULJACV2oh7msEKUXeGurFaLihv",
    "outflow": {
      "source": "simulation",
      "tokens": [],
      "unknown": [],
      "lamports": "500005001"
    },
    "decision": "allow",
    "programs": [
      "11111111111111111111111111111111",
      "ComputeBudget111111111111111111111111111111"
    ],
    "approvals": [],
    "created_at": "2026-11-28T22:44:18.476Z",
    "tis_digest": "ffabb16b1b92d9f5ce521536c52cb893370290896c830c7b76cb7e601ef8deac",
    "policy_digest": "c958b5c7f8fd5818451f8abcc30a0f2494302e935ce5e1a1bcde9ddea57b2293",
    "message_digest": "fb8c79878cc6228eb9b81cbf3646af13151b32f0a420ca03324b80e74f88e39e",
    "policy_version": 1
  },
  "reply": null,
  "transaction": {
    "state": "sent",
    "signature": "2h248HruM2rC3HJgWU4gqKyRBrWxbEg14KZaMGPYy2pHw3tfV5neaAKdpXxMnnMAGhxRtEEDU4CbjjE1tZYG31z5",
    "explorerUrl": "<link to the signature's page>",
    "error": null,
    "updatedAt": "2026-11-28T22:44:18.575Z"
  }
}

The agent token cannot read records. To follow the transaction to confirmed, an outside agent reads the signature's status from the cluster. The owner reads the same record with GET /v1/records/{id}.

A denied intent is also a 200. The record says which rule failed and the transaction is sealed:

from the answer to a 3 SOL transfer
{
  "decision": "deny",
  "failed": [
    {
      "rule": "daily_spend",
      "detail": "0.500005001 + 3.000005001 of 2 SOL in 24h",
      "result": "fail"
    }
  ],
  "transaction": {
    "state": "sealed",
    "signature": null,
    "explorerUrl": null,
    "error": null,
    "updatedAt": "2026-11-28T22:44:20.247Z"
  }
}

Any JSON object is accepted as a body. One that is not a valid TIS is recorded and denied by the schema rule; it is not a VALIDATION_ERROR.

Errors: UNAUTHORIZED without an agent token or with one the API does not know, TOKEN_REVOKED, WALLET_REQUIRED when the owner has no agent wallet, RATE_LIMITED.

401
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Send an agent token as Authorization: Bearer writ_….",
    "retryable": false,
    "stage": "auth"
  }
}

Sign-in

GET /auth/nonce

Returns the Sign-In With Solana input for the owner's wallet to sign, and a nonceToken to send back with the proof.

inputobject

domain, statement, uri, version, chainId, nonce, issuedAt, expirationTime. Pass it to the wallet's signIn unchanged.

nonceTokenstring

Send it with POST /auth/verify.

POST /auth/verify

Checks the signed message and opens a session.

publicKeystring (base58)required

The owner's wallet address.

signedMessagestring (base64), at most 8192 charactersrequired

The exact bytes the wallet signed, as the wallet returned them.

signaturestring (base64)required

The ed25519 signature over those bytes.

nonceTokenstring

The value from GET /auth/nonce.

Answers wallet (the owner's address), expiresAt and token, the session token.

Errors: UNAUTHORIZED when the signature does not verify or the sign-in request expired, VALIDATION_ERROR, RATE_LIMITED.

GET /auth/sessionsession

Answers wallet and expiresAt for the session the token carries. UNAUTHORIZED when there is none.

POST /auth/logoutsession

Ends the session. Answers 204 with no body.

The agent wallet

GET /v1/walletsession

Answers wallet: the owner's agent wallet, or null if none was created.

addressaddress

The agent wallet's address. Send SOL or tokens here to fund it.

lamportsstring (base units)

Its SOL balance.

tokensarray

Its token balances: mint, symbol (or null), amount, decimals.

spendobject

What the wallet sent in the window against the caps. windowHours is 24. sol has used and cap in lamports. tokens has one entry per capped mint: mint, symbol, decimals, used, cap.

pausedboolean

Whether the policy in force is paused.

policyVersioninteger

The number of the policy version in force.

recentRecordsarray of record summaries

The latest records, newest first. Same shape as the items of GET /v1/records.

200, with one of the recent records
{
  "wallet": {
    "address": "BrpKxDbVNo9KmzXy6TULJACV2oh7msEKUXeGurFaLihv",
    "lamports": "4499994999",
    "tokens": [],
    "spend": {
      "windowHours": 24,
      "sol": {
        "used": "500005001",
        "cap": "2000000000"
      },
      "tokens": [
        {
          "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
          "cap": "50000000",
          "used": "0",
          "symbol": "USDC",
          "decimals": 6
        }
      ]
    },
    "paused": false,
    "policyVersion": 1,
    "recentRecords": [
      {
        "id": "6ed81770-138a-4d1b-bbb6-eab82fcfbfda",
        "kind": "intent",
        "decision": "deny",
        "action": "transfer",
        "summary": "20 USDC to Ab1X…mTTp",
        "amount": {
          "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
          "symbol": "USDC",
          "amount": "20000000",
          "decimals": 6
        },
        "source": "agent_token",
        "state": "sealed",
        "createdAt": "2026-11-28T22:44:20.410Z"
      }
    ]
  }
}
POST /v1/walletsession

Creates the owner's agent wallet and writes the default policy as version 1. The body is an empty object.

Answers 201 with the same shape as GET /v1/wallet:

201
{
  "wallet": {
    "address": "BrpKxDbVNo9KmzXy6TULJACV2oh7msEKUXeGurFaLihv",
    "lamports": "0",
    "tokens": [],
    "spend": {
      "windowHours": 24,
      "sol": {
        "used": "0",
        "cap": "2000000000"
      },
      "tokens": [
        {
          "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
          "cap": "50000000",
          "used": "0",
          "symbol": "USDC",
          "decimals": 6
        }
      ]
    },
    "paused": false,
    "policyVersion": 1,
    "recentRecords": []
  }
}

Errors: WALLET_EXISTS when the owner already has one, SIGNER_UNAVAILABLE.

POST /v1/withdrawalssession

Sends SOL, a token or both from the agent wallet to the owner's own address. The destination is not a parameter. A withdrawal is the owner's action: it is not judged by the rules and does not count toward the caps.

lamportsstring (u64, above zero) or "all"

How much SOL. "all" is the balance less the network fee.

tokenobject

mint, and amount in base units or "all".

At least one of the two is required. A token withdrawal opens the owner's associated token account if it does not exist, and "all" for SOL then also leaves that account's rent. Answers 201, usually at sent:

201
{
  "id": "cmx0zze4t00600jjylhz1nl3k",
  "to": "32cWD8vDdcUkZQEUxSwgUoA86RRjCTBo5ZZz6zq6bd7i",
  "lamports": "100000000",
  "token": null,
  "transaction": {
    "state": "sent",
    "signature": "rmrmNBkjy4BLN912Vm4tYse7VdFrSBdcsdbygakwdR8a5cFFn8MgZS4mzqrQLugbfKs8fvGU77j9BHW7uVbCMNS",
    "explorerUrl": "<link to the signature's page>",
    "error": null,
    "updatedAt": "2026-11-28T22:44:25.047Z"
  },
  "createdAt": "2026-11-28T22:44:25.037Z"
}

to is the owner's address. lamports and token are null when not withdrawn. The withdrawal also appears in GET /v1/records with kind: "withdrawal".

Errors: INSUFFICIENT_FUNDS, WALLET_REQUIRED, SIGNER_UNAVAILABLE, VALIDATION_ERROR.

Policy

GET /v1/policysession

Answers the policy in force. WALLET_REQUIRED before the agent wallet exists.

versioninteger

The version's number.

policyobject

The five fields.

digeststring, 64 hex characters

The policy's digest, the value records cite as policy_digest.

createdAtstring

When this version was saved.

200
{
  "version": 1,
  "policy": {
    "paused": false,
    "tokenLimits": {
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v": "50000000"
    },
    "dailySolLamports": "2000000000",
    "programAllowlist": [
      "11111111111111111111111111111111",
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
      "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
    ],
    "blockUnlimitedApprovals": true
  },
  "digest": "c958b5c7f8fd5818451f8abcc30a0f2494302e935ce5e1a1bcde9ddea57b2293",
  "createdAt": "2026-11-28T22:44:17.200Z"
}
POST /v1/policysession

Saves the whole policy as a new version. The body is the five fields, all required. Answers 201 with the new version in the shape of GET /v1/policy.

bash
curl -X POST "$WRIT_API/v1/policy" \
  -H "Authorization: Bearer $WRIT_SESSION" \
  -H "Content-Type: application/json" \
  -d '{"paused":false,"dailySolLamports":"5000000000","tokenLimits":{"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v":"50000000"},"programAllowlist":["11111111111111111111111111111111","TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"],"blockUnlimitedApprovals":true}'

Errors: VALIDATION_ERROR with fieldErrors, WALLET_REQUIRED.

POST /v1/policy/pausesession

Pauses or resumes the agent wallet. It writes a new policy version that differs only in paused. If the wallet is already in that state, it answers the current version and writes nothing.

pausedbooleanrequired

true to pause, false to resume.

Answers the new version:

200
{
  "version": 2,
  "policy": {
    "paused": true,
    "tokenLimits": {
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v": "50000000"
    },
    "dailySolLamports": "2000000000",
    "programAllowlist": [
      "11111111111111111111111111111111",
      "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
      "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
    ],
    "blockUnlimitedApprovals": true
  },
  "digest": "3800a9406d7b5d7fb8b3d80a06f0f86647d276f5d9a01cd77ffb1467e17f39cf",
  "createdAt": "2026-11-28T22:44:20.762Z"
}

Records

GET /v1/recordssession

Lists the agent wallet's records, newest first: every judged intent and every withdrawal.

decisionquery: allow or deny

Only records with that decision.

limitquery: integer, 1 to 100

Page size. 24 if omitted.

cursorquery: string

The page.nextCursor of the page before.

Answers items, page with nextCursor (or null) and hasMore, and asOf. Each item is a record summary:

idstring

The record's id.

kindstring

intent, a judged intent with a PDR, or withdrawal.

decisionstring

allow or deny.

actionstring

The intent's action, withdraw for a withdrawal, or invalid for an intent that failed the schema.

summarystring

One line describing it.

amountobject or null

asset (SOL or a mint), symbol (or null), amount in base units, decimals.

sourcestring

chat, agent_token or owner.

statestring

The transaction state.

createdAtstring

When it was written.

200
{
  "items": [
    {
      "id": "cmx0zze4t00600jjylhz1nl3k",
      "kind": "withdrawal",
      "decision": "allow",
      "action": "withdraw",
      "summary": "Withdraw to 32cW…bd7i",
      "amount": {
        "asset": "SOL",
        "symbol": "SOL",
        "amount": "100000000",
        "decimals": 9
      },
      "source": "owner",
      "state": "confirmed",
      "createdAt": "2026-11-28T22:44:25.037Z"
    },
    {
      "id": "cab665b5-9e62-4537-9eb4-56433702ab40",
      "kind": "intent",
      "decision": "allow",
      "action": "transfer",
      "summary": "0.5 SOL to CvaC…Tdgv",
      "amount": {
        "asset": "SOL",
        "symbol": "SOL",
        "amount": "500000000",
        "decimals": 9
      },
      "source": "chat",
      "state": "confirmed",
      "createdAt": "2026-11-28T22:44:22.564Z"
    }
  ],
  "page": {
    "nextCursor": "2",
    "hasMore": true
  },
  "asOf": "2026-11-28T22:44:26.170Z"
}
GET /v1/records/{id}session

Answers one record in full.

recordrecord summary

As in the list.

pdrPDR or null

The record the engine wrote. null for a withdrawal.

policypolicy version or null

The policy version the record ran under, in the shape of GET /v1/policy.

transactiontransaction

The transaction and its current state.

Errors: NOT_FOUND.

404
{
  "error": {
    "code": "NOT_FOUND",
    "message": "That record was not found.",
    "retryable": false,
    "stage": "read"
  }
}

Agent tokens

GET /v1/agents/tokenssession

Answers items, the owner's agent tokens, revoked ones included.

idstring

The token's id, used to revoke it.

namestring

The name the owner gave it.

prefixstring

The first nine characters of the value, to tell tokens apart.

createdAtstring

When it was created.

lastUsedAtstring or null

When it last sent an intent.

revokedAtstring or null

When it was revoked.

POST /v1/agents/tokenssession

Creates an agent token.

namestring, 1 to 64 charactersrequired

A name to recognise it by.

Answers 201 with token and value. value is the secret the agent sends. It is in this answer only; later calls return the prefix.

201
{
  "token": {
    "id": "cmx0zz8ny005i0jjycwpv8ng2",
    "name": "billing agent",
    "prefix": "writ_tHa1",
    "createdAt": "2026-11-28T22:44:17.950Z",
    "lastUsedAt": null,
    "revokedAt": null
  },
  "value": "writ_tHa1wfASwphUmpJNMUVnmlw94GD6rUdSOMASPEfOyfY"
}
POST /v1/agents/tokens/{id}/revokesession

Revokes an agent token. No body. Answers the token with revokedAt set. Calls made with a revoked token answer TOKEN_REVOKED. An unknown id answers NOT_FOUND.

200
{
  "id": "cmx0zz8ny005i0jjycwpv8ng2",
  "name": "billing agent",
  "prefix": "writ_tHa1",
  "createdAt": "2026-11-28T22:44:17.950Z",
  "lastUsedAt": "2026-11-28T22:44:20.393Z",
  "revokedAt": "2026-11-28T22:44:20.735Z"
}

Chat

GET /v1/chat/messagessession

Answers items, the owner's conversation with the chat agent, oldest first.

idstring

The message's id.

rolestring

owner or agent.

textstring

What was said.

createdAtstring

When.

tisobject or null

On an agent message, the intent of that turn, none included.

pdrPDR or null

The record for that intent.

transactiontransaction or null

The record's transaction.

POST /v1/chat/messagessession

Sends the owner's message and answers with the agent's turn.

textstring, 1 to 2000 charactersrequired

The message.

Answers message, the owner's message as stored, and reply, the agent's message with its tis, pdr and transaction. The intent goes through the same engine as POST /v1/intents, and its record has the source chat.

200, with the record left out
{
  "message": {
    "id": "cmx0zzbri005u0jjym0ugsn2b",
    "role": "owner",
    "text": "Send Maya 0.5 SOL",
    "createdAt": "2026-11-28T22:44:21.966Z",
    "tis": null,
    "pdr": null,
    "transaction": null
  },
  "reply": {
    "id": "cmx0zzcb8005x0jjyjyt6gzaq",
    "role": "agent",
    "text": "Writing a transfer of 0.5 SOL to CvaC1sSWgsG9UZT3fU8R2TRhrFcpxa1d2mR6pU3mTdgv. The policy allowed it.",
    "createdAt": "2026-11-28T22:44:22.676Z",
    "tis": {
      "tis": "1",
      "action": "transfer",
      "params": {
        "to": "CvaC1sSWgsG9UZT3fU8R2TRhrFcpxa1d2mR6pU3mTdgv",
        "asset": "SOL",
        "amount": "0.5"
      },
      "reason": "Owner asked: Send Maya 0.5 SOL"
    },
    "pdr": "the record, as in PDR v1",
    "transaction": {
      "state": "sent",
      "signature": "3epY5K746Uk9Z1AfZ6dwPX1mp3S5MxP5oYP7y5bWxAA12JtF9jbXJ2ZXsGaHjqV1MFwZrHw5Mp5JJCa3CQTkFo6D",
      "explorerUrl": "<link to the signature's page>",
      "error": null,
      "updatedAt": "2026-11-28T22:44:22.665Z"
    }
  }
}

Errors: AGENT_UNAVAILABLE when the agent could not answer, WALLET_REQUIRED, RATE_LIMITED.

Health

GET /health
statusstring

ok or waiting.

modestring

live, or fixture when the API serves fixtures.

agentstring

Which chat agent answers: claude or scripted.

clusterstring

The Solana cluster the API sends transactions to.

swapFeeobject or null

The platform fee on swaps: bps and the fee account. null when swaps carry no fee.

writMintaddress or null

The $WRIT mint. null while there is none.

contractVersionstring

The contract version.