codespar_charge
Inbound charges, the buyer pays the merchant. An immediate Pix, a cobrança com vencimento (boleto or Pix, with a due date), hosted card checkout or a wallet redirect; then read or cancel what you issued.
Inbound charges — the buyer pays you.
codespar_charge3 actionsmoves no moneyThe inbound counterpart to codespar_pay. Use it for ecommerce checkout, marketplace order capture, and any flow where money comes IN.
Actions
action | What it does | Money | Needs |
|---|---|---|---|
cancel | Withdraw an unpaid cobranca com vencimento; accepted only while it is PENDING | no | charge_idoridempotency_key |
createexample below | Issue an inbound charge (the default): an immediate Pix, or with method boleto plus due_date a cobranca com vencimento | no | amountcurrencymethoddescriptionbuyer |
status | Read a cobranca com vencimento you issued, by charge_id or idempotency_key; returns the barcode and Pix once they exist | no | charge_idoridempotency_key |
Unknown action: refused; nothing is issued. Measured 2026-09-09.
Names come from the published tool document (/v1/meta-tools.json, the same list the MCP server answers to tools/list); the one-line summaries and the money class are kept in the docs repository and checked against it on every build.
Example
action: "create" (the default, so action may be omitted) of an immediate Pix charge.
{
"name": "codespar_charge",
"arguments": {
"action": "create",
"amount": 25,
"currency": "BRL",
"method": "pix",
"description": "Example order",
"buyer": {
"name": "Example Buyer",
"document": "00000000000",
"email": "buyer@example.com"
},
"idempotency_key": "charge_0000"
}
}const result = await session.execute("codespar_charge", {
action: "create",
amount: 25,
currency: "BRL",
method: "pix",
description: "Example order",
buyer: {
name: "Example Buyer",
document: "00000000000",
email: "buyer@example.com"
},
idempotency_key: "charge_0000"
});result = session.execute("codespar_charge", {
"action": "create",
"amount": 25,
"currency": "BRL",
"method": "pix",
"description": "Example order",
"buyer": {
"name": "Example Buyer",
"document": "00000000000",
"email": "buyer@example.com"
},
"idempotency_key": "charge_0000"
})codespar tool codespar_charge \
-i '{
"action": "create",
"amount": 25,
"currency": "BRL",
"method": "pix",
"description": "Example order",
"buyer": {
"name": "Example Buyer",
"document": "00000000000",
"email": "buyer@example.com"
},
"idempotency_key": "charge_0000"
}'Result shape: see runtime. The tool document says an immediate Pix charge returns its copia-e-cola right away (it expires in the next hour or so), and that a cobrança com vencimento answers status: "PROCESSING" with payable: false and no document yet; it names no other field. The published document is /v1/meta-tools.json.
amount here is in the major unit (R$ 125.00 → 125), unlike codespar_pay, which takes minor units.
When to use
The two Brazilian instruments are not two flavours of the same thing, and picking the wrong one is the most common way this tool disappoints:
| you pass | you get | good for |
|---|---|---|
method: "pix" | an immediate Pix charge: a copia-e-cola returned right away, expiring in about an hour | someone paying now, in front of you |
method: "boleto" + due_date | a cobrança com vencimento: ONE receivable the payer settles either as a boleto (barcode + linha digitável) or by Pix | an instalment, a debt agreement, any invoice with a date |
- An agreement in N instalments is N cobranças com vencimento, one per parcela, each with its own
due_dateand its ownidempotency_key. There is no single "parcelado" charge: each parcela stands on its own, can be paid or cancelled on its own, and fires its owncommerce.charge.paid. - A cobrança com vencimento is not payable the instant you create it. It is registered with the banking clearing house first, so
createanswersstatus: "PROCESSING"with no document andpayable: false. The barcode and the Pix code arrive about 30 seconds later, occasionally up to an hour. Do not read the empty barcode as a failure: subscribe a trigger tocommerce.charge.created, or pollaction: "status". - The key is the debt. A cobrança com vencimento requires
idempotency_key, and the key is reserved before the issuer is called: two calls under one key issue once, and a retry gets the same charge back. When the issuer's answer is lost (a timeout, a dropped connection) the key is kept, not freed: the result names it, a retry with the same key answersissuance_unconfirmed: truewithid: nulland issues nothing, andcommerce.charge.created(oraction: "status"with the key) resolves it once the clearing house registers the charge. To issue a second receivable on purpose, use a new key. The instrument is issued by one issuer and never falls over to another: a refusal is reported, not routed around. statusandcancelserve the cobrança com vencimento only. An immediate Pix charge hands you its copia-e-cola at create time and expires on its own; there is nothing to read back or withdraw.- Card and wallet:
method: "card"returns a hosted checkout URL the agent surfaces to the buyer;method: "wallet"is a digital-wallet redirect (PicPay in Brazil).
Arguments
| Field | Type | Required | Description |
|---|---|---|---|
action | string | No | create (the default when omitted) | status | cancel |
amount | number | For create | Major currency unit (R$ 125.00 → 125) |
currency | string | For create | BRL, USD, EUR |
method | string | For create | pix, boleto, card, wallet. In Brazil the instrument follows method plus due_date (table above) |
description | string | For create | Shown to the buyer |
buyer | object | For create | { name, email, document, phone }. For a BR due-dated charge document is required and must be a real CPF/CNPJ: the clearing house validates its check digit, and the charge names who owes it |
due_date | string | No | YYYY-MM-DD (a full ISO-8601 instant is narrowed to the date). With method: "boleto" issues the cobrança com vencimento; the immediate Pix charge has no due date and refuses one |
country | string | No | ISO 3166-1 alpha-2 for the eligibility rail (BR, US, MX, AR, CL, CO, INTL). Defaults to BR; US for cross-border USD card via Stripe ACP, INTL for hosted-checkout flows |
charge_id | string | For status, cancel | The id create returned. Resolved against the charges this project issued, so an id from elsewhere is simply not found |
idempotency_key | string | For create of a cobrança com vencimento | Stable caller key that identifies the debt. Required with method: "boleto" + due_date: a repeat with the same key returns the charge already issued (or its still-open reservation, see issuance_unconfirmed) instead of a second one, and a call without it is refused before anything is sent. On status and cancel it can stand in for charge_id |
metadata | object | No | Provider-specific overrides |
Errors and what to do
| Error | Cause | What to do |
|---|---|---|
invalid_args | A create without amount, currency, method, description or buyer; a cobrança com vencimento without idempotency_key; a due_date on an immediate Pix; an unknown action; a cancel on a key whose issuance is still unconfirmed. Nothing is issued. | Fix the call against the Arguments table. For the unconfirmed key, wait for commerce.charge.created or poll status, then cancel by id. |
no_eligible_providers | The method × currency × country intent has no catalog line, or none of its providers is connected. Nothing is issued. | See the rails in Notes; connect the provider via codespar_manage_connections. |
A refused cancel on a PROCESSING charge | The clearing house accepts a cancellation only while the charge is PENDING; a still-registering charge is refused, and a paid charge cannot be withdrawn. | Retry once it registers (poll status). |
issuance_unconfirmed: true in the result | The issuer's answer to a create under this key was lost; the key is held so a retry cannot issue a second receivable for the same debt. id is null and payable is false. | Wait for commerce.charge.created, or poll status with the same idempotency_key. Use a new key only if you mean a second charge. |
An empty barcode right after create | Not an error: the cobrança com vencimento is registering. | Wait for commerce.charge.created or poll status. |
Money and mandate
No money moves on this tool. create issues a receivable (a copia-e-cola, a boleto, a checkout URL) that the buyer settles later; commerce.charge.paid fires when they do, by either leg, and it is the event that means the funds are in the account.
Do not act on anything earlier than that. A boleto payment can be preceded by commerce.charge.payment_notified, the clearing house's operational baixa, which the issuer says explicitly is not proof of payment. Every convênio has a daily cut-off, so a boleto paid after it is notified on one day and credited on the next business day; the notification carries liquidation_date if you want to tell the payer when. There is no consumer mandate on the sell side: the operator's connected rail authorizes issuance. The idempotency rule is what protects the buyer from paying twice: a retry of a cobrança com vencimento with the same key returns the same charge, and only a cobrança com vencimento is replayed; retrying an immediate Pix, card or wallet create issues a new charge.
Related
codespar_pay: the outbound counterpart, and the tool that settles an existing boletocodespar_checkout: a cart summed into a charge with a hosted payment pagecodespar_invoice: the fiscal document after settlement- Triggers:
commerce.charge.created,commerce.charge.paid, and whycommerce.charge.payment_notifiedis not the same thing - Async settlement: correlation and webhook flow
- E-Commerce Checkout cookbook: charge → invoice → ship → notify
Notes
Rails and providers, as previously documented
You do not choose a provider, and there is no field to choose one with. method × currency × country selects a catalog line, and the line carries the providers that this project has connected, in order. The table below is that catalog.
Two consequences worth reading before the table. Failover is within a rail, not across rails: a Pix BRL charge that Asaas refuses is retried on Mercado Pago, and never silently becomes a boleto. And a combination with no catalog line, or whose providers are all unconnected, answers no_eligible_providers and issues nothing — it is not a partial charge to reconcile later.
| Rail | Currency | Country | Providers |
|---|---|---|---|
| Pix | BRL | BR | Asaas (default), Mercado Pago, EBANX, iugu, Stone |
| Boleto | BRL | BR | Stark Bank |
| Card | BRL | BR | Getnet, PagSeguro, Rede, Rinne |
| Card | USD | US | Stripe ACP |
| Card · hosted checkout | USD | US | Stripe ACP |
| Card | USD | INTL | Circle |
| Card | MXN | MX | Clip, Kushki |
| Card | PEN | PE | Izipay, Niubiz, Kushki |
| Card | COP | CO | Bold, ePayco, Kushki |
| PSE | COP | CO | Bold |
| Card | CLP | CL | Kushki |
| Card | ARS | AR | Payway |
| Card | USD | EC | Kushki |
| Wallet | BRL | BR | PicPay |
| Wallet | COP | CO | Nequi |
27 catalog lines over 21 providers, across seven countries (BR, MX, PE, CO, CL, AR, EC) plus US and the international USD corridor. The router fails over within a rail (Pix BRL: Asaas → Mercado Pago). The cobrança com vencimento runs on the licensed BaaS partner.
Operator setup. Asaas / Mercado Pago / iugu / Stone: API key (api_key auth_type), sandbox vs production toggle in the modal. Stripe: restricted key with payment_intents:write; the same key handles regular charges and ACP create_checkout_session.
From the SDK. session.charge(args) is the typed wrapper (SDK reference); session.execute("codespar_charge", arguments) takes the same arguments as the MCP call. Settlement is asynchronous: poll session.paymentStatus(tool_call_id) until it leaves pending, or use paymentStatusStream for sub-second latency to terminal.
Result shape of a cobrança com vencimento, read from the code that builds it (bolepixOutputFromRow, measured 11/09/2026). Every create, status and idempotent replay of a method: "boleto" + due_date charge answers this object.
| Field | What it is |
|---|---|
id | The issuer's charge id. Null while the issuance is unconfirmed |
status | The provider's state as far as we know it, normalized. Forced to PROCESSING until the issuance is confirmed |
local_status | What CodeSpar recorded, which is a different question from the line above |
status_conflict | True when the two disagree terminally, instead of one of them silently winning |
method, currency, amount, amount_minor, due_date | The debt. amount is in units, amount_minor in centavos |
payable | True only when all four hold: the issuance is confirmed, our row is still open, the provider says PENDING, and at least one document exists. This is the field to branch on, not status |
boleto_bar_code, boleto_bank_line, pix_copy_paste | The two legs of the one debt. All null before registration |
credit_correlation_armed | Whether an inbound Pix on this charge's Pix leg can resolve a wallet on its own. False until registration hands us the leg's identifier |
payment_in_flight | True when a payment was notified and the receivable is still open. Read this before you write anything off |
issuance_unconfirmed | True while the row is a reservation with no charge id: the issuer's answer to the create was lost, or a create is in flight elsewhere under the same key. Nothing is payable and nothing was duplicated |
Four fields appear only when they apply. payment_notified_at, liquidation_date and payment_release_date arrive together once the clearing house notifies a payment, and the last two are what you tell the payer when the credit lands. issuance and next_action appear only while issuance_unconfirmed is true, and next_action names the two ways out in words. idempotent_replay and status_is_last_known mark an answer served from the row with no provider call, so a stale PROCESSING does not read as a fresh one. raw carries the provider's own body on a live read.
payment_in_flight exists because refusing to close a paid receivable is only half the job. The issuer can answer EXPIRED for a boleto it already told us was paid: the baixa happened before the due date and the credit lands on the next business day. CodeSpar refuses to write that row off, but without this field a caller sees a clean EXPIRED with no disagreement flagged and writes it off itself, which is the same loss one layer up.
The other methods' result shape has not been verified. { id, tool_call_id, pix_copy_paste?, qr_code_url?, checkout_url?, status: "pending", expires_at? } is what earlier revisions documented for an immediate Pix, card or wallet charge, and this revision did not re-read the runtime for those paths. Treat the table above as measured and that list as inherited.
codespar_checkout
Sell-side merchant checkout. Assemble a cart and create a charge for a shopper to pay you, returned with a hosted payment page and, on Pix, the copia-e-cola. Pix in Brazil is the live rail today.
codespar_invoice
Fiscal documents. Issue, read, or amend an NF-e or NFS-e in Brazil, or a consumer invoice in Mexico, Argentina and Colombia; the fiscal partner and Bling in Brazil, Facturapi, AFIP and Siigo elsewhere.