Skip to main content

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.

7 min read
View MarkdownEdit on GitHub
Sell-sideYour agent is the merchant: it collects from, invoices, ships to, or verifies a counterparty.

Inbound charges — the buyer pays you.

tool codespar_charge3 actionsmoves no money

The inbound counterpart to codespar_pay. Use it for ecommerce checkout, marketplace order capture, and any flow where money comes IN.

Actions

actionWhat it doesMoneyNeeds
create
example below
Issue an inbound charge (the default): an immediate Pix, or with method boleto plus due_date a cobranca com vencimentonoamountcurrencymethoddescriptionbuyer
statusRead a cobranca com vencimento you issued, by charge_id or idempotency_key; returns the barcode and Pix once they existnocharge_idoridempotency_key
cancelWithdraw an unpaid cobranca com vencimento; accepted only while it is PENDINGnocharge_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.

Call · tools/call
arguments
{
  "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"
  }
}
Result

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 passyou getgood for
method: "pix"an immediate Pix charge: a copia-e-cola returned right away, expiring in about an hoursomeone paying now, in front of you
method: "boleto" + due_datea cobrança com vencimento: ONE receivable the payer settles either as a boleto (barcode + linha digitável) or by Pixan 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_date and its own idempotency_key. There is no single "parcelado" charge: each parcela stands on its own, can be paid or cancelled on its own, and fires its own commerce.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 create answers status: "PROCESSING" with no document and payable: 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 to commerce.charge.created, or poll action: "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 answers issuance_unconfirmed: true with id: null and issues nothing, and commerce.charge.created (or action: "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.
  • status and cancel serve 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

FieldTypeRequiredDescription
actionstringNocreate (the default when omitted) | status | cancel
amountnumberFor createMajor currency unit (R$ 125.00 → 125)
currencystringFor createBRL, USD, EUR
methodstringFor createpix, boleto, card, wallet. In Brazil the instrument follows method plus due_date (table above)
descriptionstringFor createShown to the buyer
buyerobjectFor 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_datestringNoYYYY-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
countrystringNoISO 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_idstringFor status, cancelThe id create returned. Resolved against the charges this project issued, so an id from elsewhere is simply not found
idempotency_keystringFor create of a cobrança com vencimentoStable 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
metadataobjectNoProvider-specific overrides

Errors and what to do

ErrorCauseWhat to do
invalid_argsA 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_providersThe 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 chargeThe 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 resultThe 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 createNot 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. 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.

Notes

Rails and providers, as previously documented

RailCurrencyCountryProviders
PixBRLBRAsaas (default), Mercado Pago, EBANX, iugu, Stone
BoletoBRLBRStark Bank
CardBRLBRGetnet, PagSeguro, Rede, Rinne
CardUSDUSStripe ACP
Card · hosted checkoutUSDUSStripe ACP
CardUSDINTLCircle
CardMXNMXClip, Kushki
CardPENPEIzipay, Niubiz, Kushki
CardCOPCOBold, ePayco, Kushki
PSECOPCOBold
CardCLPCLKushki
CardARSARPayway
CardUSDECKushki
WalletBRLBRPicPay
WalletCOPCONequi

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 (SDK), as previously documented. { id, tool_call_id, pix_copy_paste?, qr_code_url?, checkout_url?, status: "pending", expires_at? }. This revision did not re-verify that list against the runtime; the states the tool document itself names are PROCESSING and payable: false on a cobrança com vencimento, and PENDING as the only state a cancel is accepted in.

codespar_charge | CodeSpar