# AgentLine Prepaid (No Signup)

Use this when the agent has no account but can pay from a wallet. A recharge
adds prepaid credit and returns an `agent_token`. Use it as a Bearer token for
the `/v1/x402/*` endpoints, `GET /v1/billing/balance`, and the MCP server.

Paying moves real money. Get the human's explicit approval for the amount before
every recharge.

## Recharge

`GET` or `POST https://api.agentline.cloud/v1/billing/topup/x402/pay?amount=5`

- `amount`: USD, $1 to $1000, default $1.
- The first request returns `402 Payment Required` with a `payment-required`
  challenge. Retry with exactly one credential:
  - **x402** (Base USDC, `eip155:8453`) in the `PAYMENT-SIGNATURE` header.
  - **MPP** (Tempo, `eip155:4217`) in the `Payment-Authorization` header.
- Payment details: `https://api.agentline.cloud/.well-known/agent-payments.json`.

A settled recharge returns:

```json
{
  "status": "settled",
  "amount_usd": 5.0,
  "new_balance": 5.0,
  "access_mode": "wallet_agent",
  "agent_token": "agent_...",
  "owner_wallet": "0x...",
  "payment_protocol": "x402",
  "network": "eip155:8453"
}
```

Save `agent_token` immediately. It expires after 30 days. Recharge at least
$2.50 to buy a number and start a call.

If a signup account's API key is sent as the Bearer token on recharge, the
credit goes to that account instead.

## Use the Token

```bash
export AGENTLINE_AGENT_TOKEN="agent_..."
```

Buy a number ($2.00 for a 30-day lease). The agent is created with it:

```bash
curl -s -X POST https://api.agentline.cloud/v1/x402/numbers/buy \
  -H "Authorization: Bearer $AGENTLINE_AGENT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"agent_name":"My Agent","area_code":"415","voice_id":"female-1"}'
```

Body fields (all optional): `agent_name`, `system_prompt`, `initial_greeting`,
`voice_id`, `voicemail_message`, `owner_phone`, `country` (`US`),
`number_type` (`local` or `tollfree`), `area_code`.

| Action | Endpoint |
|---|---|
| List wallet numbers | `GET /v1/x402/numbers` |
| Renew lease 30 days ($2.00) | `POST /v1/x402/numbers/renew {"phone_number":"+1..."}` |
| Get agent | `GET /v1/x402/agents` |
| Update agent | `PATCH /v1/x402/agents` (same fields as buy, minus number fields) |
| Place call | `POST /v1/x402/calls {"from_number":"+1...","to_number":"+1..."}` |
| Transcript | `GET /v1/x402/calls/{call_id}/transcript` |
| Set webhook | `POST /v1/x402/webhooks {"phone_number":"+1...","url":"https://..."}` |
| Test webhook | `POST /v1/x402/webhooks/test {"phone_number":"+1...","url":"https://..."}` |
| Poll events | `GET /v1/x402/events?phone_number=+1...&event_type=...&limit=...` |
| Balance | `GET /v1/billing/balance` |

Live events over WebSocket:

```text
wss://api.agentline.cloud/v1/events/ws?agent_id=<agent_id>&lease_token=<token>
```

Call behavior, events, relay context, and webhook signatures work the same as
the signup flow. See https://agentline.md/calls.md,
https://agentline.md/relay.md, and
https://agentline.md/webhooks.md

## Notes

- Send `agent_token` as `Authorization: Bearer`, not in a URL. The WebSocket
  `lease_token` query parameter is the one exception; never log that URL.
- Only the recharge endpoint accepts payment. Every other endpoint debits the
  prepaid balance.
- Unanswered and failed calls are free.

AgentLine: https://agentline.cloud | API: https://api.agentline.cloud | All guides: https://agentline.md
