codespar_pay
Outbound transfers — money leaving the merchant to a recipient. 26 provider rails across BR (incl. 9 banks direct via mTLS), MX, PE, CL, CO, and international card/wire.
codespar_pay
Meta-tool
codespar_pay is the outbound counterpart to codespar_charge. Use it whenever money leaves the merchant — vendor payouts, marketplace seller settlement, refunds, mass payouts. The agent specifies the recipient and the amount; CodeSpar picks the rail.
Pay is async. The call returns immediately with a tool_call_id and idempotency_key; settlement is correlated by the async settlement chain. Poll paymentStatus(toolCallId) or stream paymentStatusStream(toolCallId) until terminal.
Rails
| Rail | Currency | Country | Providers |
|---|---|---|---|
| Pix | BRL | BR | Asaas (default), Mercado Pago, Celcoin — plus 9 banks direct via mTLS: Banco do Brasil, Itaú, Bradesco, Santander, Caixa, Sicoob, Sicredi, C6, Original |
| Card | BRL | BR | Cielo (+ 3DS), Pagar.me |
| Boleto | BRL | BR | Stark Bank |
| Card | MXN | MX | Conekta |
| Card | PEN | PE | Culqi |
| Card | CLP | CL | Transbank |
| Card | COP | CO | Wompi |
| Bank transfer | COP | CO | Cobre |
| Wire | CLP | CL | Khipu |
| Card · hosted checkout | USD / EUR | US / INTL | Stripe ACP, Adyen, Airwallex, dLocal, Rapyd |
26 provider rails across six countries. The router fails over within a rail when the primary provider degrades — e.g. Pix BRL walks Asaas → Mercado Pago → a direct bank. See /dashboard/router for live failover telemetry. The 9 Brazilian banks connect over mTLS (client certificate) for direct-from-account Pix; see cert auth.
Direct execute
There is no typed wrapper for codespar_pay yet — call via session.execute().
const result = await session.execute("codespar_pay", {
amount: 25000,
currency: "BRL",
method: "pix",
recipient: {
document: "12345678900",
pix_key: "vendor@example.com",
},
idempotency_key: crypto.randomUUID(),
});
console.log(result.tool_call_id, result.status); // "pending"import uuid
result = session.execute("codespar_pay", {
"amount": 25000,
"currency": "BRL",
"method": "pix",
"recipient": {
"document": "12345678900",
"pix_key": "vendor@example.com",
},
"idempotency_key": str(uuid.uuid4()),
})
print(result["tool_call_id"], result["status"])Args shape
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Amount in smallest currency unit (centavos for BRL) |
currency | string | Yes | ISO 4217 — BRL, MXN, CLP, COP |
method | string | Yes | pix, spei, khipu, transbank |
recipient | object | Yes | Object with document, one of pix_key / bank_account / wallet_address, optional name |
idempotency_key | string | Yes | Caller-supplied UUID. Backend writes it through to provider's external-reference field |
metadata | object | No | Arbitrary key-value pairs persisted on the tool_calls row |
Result shape
type PayResult = {
tool_call_id: string;
idempotency_key: string;
status: "pending"; // always "pending" — terminal state lands via paymentStatus
rail: string; // resolved rail, e.g. "asaas-pix"
};Operator setup
Each rail needs operator-stamped credentials in /dashboard/auth-configs:
- Asaas — API key (
api_keyauth_type). Sandbox key for test, production key for live. - Mercado Pago — Access token (
api_keyauth_type). Tied to a single seller account. - Wompi / Conekta / Khipu / Transbank — Per-provider API key + sandbox toggle.
The dashboard wizard renders the right inputs based on each server's auth_type declared in the catalog.
Async settlement
After codespar_pay returns, settlement happens via the provider webhook. The flow:
session.execute("codespar_pay", ...) → { tool_call_id, idempotency_key, status: "pending" }
↓
provider settles asynchronously (seconds for Pix, hours-to-days for SPEI/wallet)
↓
provider POSTs webhook → backend correlates external_reference ↔ idempotency_key
↓
session.paymentStatus(tool_call_id) → { status: "succeeded", final_amount_minor, settled_at }See async settlement for the full correlation chain and per-provider idempotency-key shapes (Asaas externalReference, Mercado Pago X-Idempotency-Key header, etc.). Streaming variant: SSE streaming.
See also
- codespar_charge — inbound counterpart
- Async settlement — correlation chain + webhook flow
- SDK reference —
paymentStatus/paymentStatusStream - Tools & meta-tools — full meta-tool list
- Pix Payment Agent cookbook — simplest end-to-end example
- Marketplace Payout cookbook — split fee + seller payout
Tool Router
Route tool calls and raw HTTP requests through a managed session — auth is injected server-side, so your agent never touches provider credentials.
codespar_charge
Inbound charges — buyer pays merchant. 19 provider rails — Pix/boleto/card/wallet across BR, MX, PE, CO, CL, AR + USD. Async settlement, uniform payload.