> For the complete documentation index, see [llms.txt](https://docs.useshadowpay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.useshadowpay.com/api-reference/agents-and-spend-policies.md).

# Agents & Spend Policies

Create agent accounts and manage their spend policies programmatically. See [Spend Policies](/agents-and-automation/spend-policies.md) for the conceptual overview.

***

## Create an agent account

```
POST /v1/accounts/me/agents
```

### Request body

```json
{
  "name": "research-bot",
  "spend_policy": {
    "daily_limit_usdc": 500.00,
    "per_transaction_limit_usdc": 50.00,
    "allowed_recipients": ["api.market", "*.anthropic.com"],
    "assets": ["USDC"],
    "active_hours": "00:00-23:59",
    "hitl_threshold_usdc": 25.00
  }
}
```

### Response

```json
{
  "account_id": "acct_9d3a2f",
  "handle": "@yourname/research-bot",
  "public_key": "9d3a2fXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "status": "active",
  "spend_policy_id": "policy_4471"
}
```

***

## Update a spend policy

```
PATCH /v1/agents/{account_id}/spend-policy
```

Accepts a partial update. Only the fields included are changed; everything else is left as is.

```json
{
  "per_transaction_limit_usdc": 75.00,
  "hitl_threshold_usdc": 40.00
}
```

Changes apply immediately to any transaction the agent attempts to sign after the update. They don't affect anything already settled.

***

## Get a spend policy

```
GET /v1/agents/{account_id}/spend-policy
```

### Response

```json
{
  "policy_id": "policy_4471",
  "daily_limit_usdc": 500.00,
  "per_transaction_limit_usdc": 75.00,
  "allowed_recipients": ["api.market", "*.anthropic.com"],
  "assets": ["USDC"],
  "active_hours": "00:00-23:59",
  "hitl_threshold_usdc": 40.00,
  "updated_at": "2026-07-02T10:11:00Z"
}
```

***

## Approve or reject a pending agent transaction

Transactions above the `hitl_threshold_usdc` are held for approval rather than signed automatically.

```
POST /v1/agents/transactions/{transaction_id}/approve
POST /v1/agents/transactions/{transaction_id}/reject
```

Both endpoints return the updated transaction state. An approved transaction is signed and submitted immediately. A rejected transaction is discarded and no funds move.

***

## List pending approvals

```
GET /v1/agents/transactions/pending
```

### Response

```json
{
  "pending": [
    {
      "transaction_id": "tx_5c1e2a",
      "agent": "@yourname/research-bot",
      "to": "compute-provider.io",
      "requested_at": "2026-07-02T14:00:00Z",
      "expires_at": "2026-07-03T14:00:00Z"
    }
  ]
}
```

Amounts are omitted from this list for the same reason they're omitted elsewhere in the API: they're encrypted, and only client-side decryption using your key can reveal them. The dashboard UI decrypts and displays them locally when you review a pending approval.

***

## Error responses

| Status | Code                    | Description                                                         |
| ------ | ----------------------- | ------------------------------------------------------------------- |
| `400`  | `invalid_policy`        | Spend policy fields fail validation (for example, a negative limit) |
| `403`  | `not_agent_owner`       | The authenticated account doesn't own the specified agent           |
| `404`  | `transaction_not_found` | No pending transaction found for the given ID                       |
| `409`  | `transaction_expired`   | The approval window for this transaction has passed                 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.useshadowpay.com/api-reference/agents-and-spend-policies.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
