> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyway.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Wallet Runtime API

> Authenticate agent-signed requests and use Agent Wallet runtime routes.

Create and manage wallets, allocations, policies, and keys through the Agents app or Anyway CLI.

```text theme={null}
Base URL: https://api.anyway.sh
```

## Authentication

Every runtime request uses the Agent Wallet Key's P-256 key and sends:

| Header              | Value                                             |
| ------------------- | ------------------------------------------------- |
| `X-Agent-Pubkey`    | Standard Base64-encoded SPKI P-256 public key     |
| `X-Agent-Timestamp` | Current Unix timestamp in seconds                 |
| `X-Agent-Signature` | Standard Base64-encoded ASN.1 DER ECDSA signature |

Sign the SHA-256 digest of this UTF-8 payload:

```text theme={null}
METHOD
/registered/route/path
unix_timestamp
```

Use the registered path without the query string. The timestamp must be within 300 seconds of the server. The CLI handles signing, encoding, and local key selection automatically.

## Route summary

| Method | Path                               | Result                                  |
| ------ | ---------------------------------- | --------------------------------------- |
| `GET`  | `/v1/agent-wallet`                 | Agent and assigned wallet identity      |
| `GET`  | `/v1/agent-wallet/policies`        | Policies attached to the wallet         |
| `GET`  | `/v1/agent-wallet/history`         | Wallet activity                         |
| `GET`  | `/v1/agent-wallet/credit-balance`  | Organization Credit balance             |
| `POST` | `/v1/agent-wallet/sign-typed-data` | Wallet signature for EIP-712 typed data |

An agent runtime receives no merchant management authority.

## Agent identity

```http theme={null}
GET https://api.anyway.sh/v1/agent-wallet
```

The `data` object contains:

| Field                       | Meaning                                                |
| --------------------------- | ------------------------------------------------------ |
| `agentId`, `name`           | Agent identity                                         |
| `publicKey`, `keyQuorumId`  | Current signing identity                               |
| `walletId`, `walletAddress` | Assigned Anyway wallet and EOA address when present    |
| `providerWalletId`, `appId` | Values needed to build wallet authorization signatures |
| `revoked`                   | Whether the agent identity is revoked                  |

Use `anyway wallets agents whoami` for the same runtime check.

## Policies

```http theme={null}
GET https://api.anyway.sh/v1/agent-wallet/policies
```

Each policy includes its public identity, name, and enforcement configuration. Policies are enforced server-side; a client-side confirmation or displayed limit is not the enforcement boundary.

```bash theme={null}
anyway wallets agents policies
```

## History

```http theme={null}
GET https://api.anyway.sh/v1/agent-wallet/history?limit=50
```

`limit` defaults to `50` and accepts `1` through `200`. Entries can include `agentId`, destination address, amount, status, transaction hash, failure message, transfer type, explorer URL, and creation time.

```bash theme={null}
anyway wallets agents history --limit 50 --format json
```

## Organization Credits

```http theme={null}
GET https://api.anyway.sh/v1/agent-wallet/credit-balance
```

```json theme={null}
{
  "success": true,
  "message": "Credit balance retrieved",
  "data": {
    "balance": 12.5,
    "unit": "USDC"
  }
}
```

This is the organization-level Anyway Credit pool, not the agent wallet's on-chain USDC allocation.

## Sign EIP-712 typed data

```http theme={null}
POST https://api.anyway.sh/v1/agent-wallet/sign-typed-data
Content-Type: application/json
```

```json theme={null}
{
  "typed_data": {
    "domain": {},
    "types": {
      "Example": [{ "name": "value", "type": "uint256" }]
    },
    "primary_type": "Example",
    "message": { "value": "1" }
  },
  "signature": "<wallet authorization signature>"
}
```

The successful `data.signature` is a `0x`-prefixed secp256k1 Ethereum signature. The request's `signature` field is a separate wallet authorization signature; it is not one of the three P-256 HTTP authentication headers.

Prefer the CLI for constructing this request:

```bash theme={null}
anyway wallets agents sign --typed-data-file ./typed-data.json
```

## Common errors

| Status | Meaning                                                     |
| ------ | ----------------------------------------------------------- |
| `400`  | Invalid body or no wallet is assigned                       |
| `401`  | Missing, stale, invalid, unknown, or revoked P-256 identity |
| `500`  | Runtime operation failed                                    |

<Warning>
  An Agent Wallet Key is a spending credential. Never send its private material to this API, store it in telemetry, or include it in model prompts. Only the public key and request signature belong in HTTP headers.
</Warning>
