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.

4 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
cancelWithdraw an unpaid cobranca com vencimento; accepted only while it is PENDINGnocharge_idoridempotency_key
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

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.

The same call, four ways
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"
  }
}
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

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, 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.

Notes

Rails and providers, as previously documented

ROUTING
One meta-tool, multiple providers
method:pix
currency:BRL
country:BR
codespar_charge
meta-tool
Asaaspix · br · default
Mercado Pagopix · br · failover
Stark Bankboleto · br
Getnetcard · br
You never name the provider. The three inputs pick the catalog line; the line lists the connected providers, in order.

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.

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 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.

FieldWhat it is
idThe issuer's charge id. Null while the issuance is unconfirmed
statusThe provider's state as far as we know it, normalized. Forced to PROCESSING until the issuance is confirmed
local_statusWhat CodeSpar recorded, which is a different question from the line above
status_conflictTrue when the two disagree terminally, instead of one of them silently winning
method, currency, amount, amount_minor, due_dateThe debt. amount is in units, amount_minor in centavos
payableTrue 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_pasteThe two legs of the one debt. All null before registration
credit_correlation_armedWhether 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_flightTrue when a payment was notified and the receivable is still open. Read this before you write anything off
issuance_unconfirmedTrue 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_charge | CodeSpar