---
title: Pay to Agent
description: Pay another agent by Agent ID instead of a raw address. The recipient must be a registered, non-revoked identity — never an anonymous wallet. Payouts, splits, and tips over USDC on Base mainnet.
---

import { Callout } from "fumadocs-ui/components/callout";

# Pay to Agent

<Callout title="KYA required" type="warn">
Pay-to-Agent never settles to an anonymous address. The recipient must be a
**registered, active agent identity** in your account. An unknown or revoked
agent is refused before any money moves.
</Callout>

A consumer spend can name another **agent** as the payee instead of a raw
`0x` address. CodeSpar resolves the Agent ID to that agent's on-chain wallet,
checks it is a known, non-revoked identity ([Know-Your-Agent](/docs/concepts/agent-trust)),
and settles the USDC through the same proven direct-transfer leg — with a
hash-chained receipt. This is the primitive under agent-to-agent payouts,
revenue splits, and tips.

## Paying an agent

Set the mandate's payee (and the spend's `payee`) to `agent:<agent_id>`:

```bash
# 1. mint a mandate that allowlists the agent payee
codespar mandate create \
  --consumer payer \
  --agent orchestrator \
  --payee "agent:helper-42" \
  --cap 100 --per-tx-cap 100 --rail usdc-onchain --currency USDC

# 2. spend against it
curl -X POST https://api.codespar.dev/v1/consumers/mandates/<cm_...>/spend \
  -H "authorization: Bearer $CODESPAR_API_KEY" \
  -H "content-type: application/json" \
  -d '{ "agent_id": "orchestrator", "amount_minor": 10, "payee": "agent:helper-42" }'
```

The `agent:` payee routes to the USDC slot, resolves to `helper-42`'s wallet,
and settles wallet-to-wallet on Base. The recipient agent needs no setup beyond
being registered — the payer constructs the payment from the Agent ID alone.

## The KYA gate

Resolution enforces that the recipient is a real, current identity:

| Condition | Result |
|---|---|
| Agent is registered and `active` | Resolves; the payment settles |
| Agent id is unknown in your account | `403 agent_not_registered` |
| Agent identity is suspended / retired / unregistered | `403 agent_revoked` |

The refusal happens before settlement, so a rejected payment never moves money.
Register agents through the [Agent identity](/docs/concepts/agent-trust) surface.

## What is and isn't included

The rail-level primitive — resolve by Agent ID, KYA gate, settle with a receipt —
is live. **Splits** (one payment fanned across several helper agents) and **tips**
as packaged flows build on this same primitive and are rolling out with design
partners.

## Related

- [Monetize Gateway](/docs/concepts/monetize-gateway) — the other direction: charge agents for your service.
- [Agent trust](/docs/concepts/agent-trust) — Know-Your-Agent identity and reputation.
- [Directed-pay](/docs/concepts/directed-pay) — the signed-mandate spend model this rides on.
