Skip to main content

Use case · Receivables

Pix and boleto charges for your agents

Your agent creates the charge. Your customer pays. CodeSpar confirms the payment so your system can update the invoice or release the order.

Start in a test environment, with no real money moving.

Invoice 1208 · ACME Distribuidora · 2 instalments

"create the two instalments of invoice 1208 for ACME, R$ 1,180.00 each, due Oct 6 and Oct 20, and tell the order system when the first one is paid"

Agreement · 2 instalmentsR$ 2,360.00 · due Oct 6 and Oct 20agreed
Instalment 1/2 · charge createdR$ 1,180.00 · due Oct 6 · payable by Pix or boletoopen
Paid by Pix · 14:03Payment confirmed and linked to the charge+R$ 1,180.00paid
Your system updates the invoiceThe connected system received the confirmation and released order 1208done
Instalment 2/2 · charge createdR$ 1,180.00 · due Oct 20 · QR and code sent by your channelopen until Oct 20
Request repeatedThe same charge is returned; no second charge is createdsame charge
Received · invoice 1208R$ 1,180.00 of R$ 2,360.00
each payment is confirmed and linked to its chargean unpaid instalment closes at its due date

Agent run · demo data

Demo

From charge to payment confirmation.

Create the first instalment, pay it as the customer and see the confirmation reach your system. A repeated request and an expired instalment are there as the other scenarios.

Interactive demo · illustrative data
Activity 0 entries
Simulated result: nothing yet.

Start with the first charge; Reset returns to the beginning.

Invoice 1208 · ACME Distribuidora

Received · of R$ 2,360.00 agreed

R$ 0.00

Open0
Paid0
Expired0
Historynothing received yet

Each step shows what your system sees: the charge, the payment and the state of the invoice.

Collections removes the manual check between the charge, the bank and the order. Your agent creates the charge once, the payment is confirmed to your system, and the next step runs from there.

The flow, side by side

From the charge to the confirmed payment.

Your agent creates and follows up. CodeSpar collects and confirms. Your system takes the next step.

  1. 01Agent

    The charge is created

    Your agent creates one charge per instalment: amount, due date, payer. The customer can pay it by Pix or boleto.

    invoice 1208 · 1/2 · R$ 1,180.00 · due Oct 6
  2. 02Customer

    The customer pays

    By Pix with the QR or the code, or by boleto with the line, in the app they already use.

    Pix or boleto · until Oct 6
  3. 03CodeSpar

    The payment is confirmed

    The payment is confirmed, linked to the charge and recorded in your account's history.

    payment confirmed · R$ 1,180.00
  4. 04Your system

    The next step runs

    Your connected system receives the confirmation and updates the invoice or releases the order.

    order 1208 released · by the connected system

Two ways to pay

In your channel or on a payment page.

Send the QR and the payment code through WhatsApp, e-mail or the app you already use, or share a link to a page where the customer sees the charge and pays. The charge and the confirmation are the same.

In your channel

QR and payment code where you talk to the customer

Your agent reads the QR and the code from the charge; your project's integration sends them in the WhatsApp thread, by e-mail or in your app.

charge created · Pix or boleto · due Oct 6QR + code sent by your channel→ paid · confirmation to your system

Sending through the channel is done by your project's integration.

Collect page

A link the customer opens to pay

Share a link: the customer sees the charge with your name, fills in what is missing and pays by Pix.

payment link createdthe customer opens it and pays→ paid · the same confirmation

The page shows your name as the receiver.

Behind it

Connect your agent to your billing workflow.

Create the charge, follow its state, receive the payment confirmation as an event, and repeat a request without creating a second charge.

Integration · invoice 1208
Createcodespar_charge · pix or boleto · amount, due_date, buyer
Stateaction status · open, paid or expired
Confirmationcommerce.charge.paid · posted to your endpoint
Repeated requestsame idempotency_key · the same charge is returned
Payment recordlinked to the charge · in your account's history
Three situations
PaidInstalment 1/2 is paid by Pix → the confirmation reaches your system → the order is released.
Unpaid at the due dateInstalment 2/2 passes Oct 20 unpaid → it closes as expired. A new charge needs a new key.
With reviewWith an approval rule on codespar_charge, each charge from the agent waits for an operator before it is created.
TypeScript · @codespar/sdk 0.16.11SDK example
const session = await new CodeSpar().create("user_0000", { preset: "brazilian" });const run = await session.send("create instalment 1/2 of invoice 1208 for ACME Distribuidora: R$ 1,180.00, due 2026-10-06, boleto or Pix, key inv-1208-1");const charge = run.tool_calls.find((c) => c.tool_name === "codespar_charge");// paid: commerce.charge.paid reaches your endpoint · unpaid at the due date: commerce.charge.expired

SDK example · not run on this page

What runs it
CollectCreates the charge, by Pix or boleto, and the payment page.Open
TriggersPost the payment confirmation to your endpoint.Open
ApprovalsAn optional rule puts an operator before each charge.Open
WalletPayments received, in the same history as what the agent spends.Open
Your channel and your systemSending the code to the customer and updating the invoice are done by your project's integration.

Cookbook

Two instalments, end to end.

One call creates each instalment with its key; one reads its state. The payment confirmation comes to your endpoint as an event.

  1. A test keyFrom the Dashboard. Test keys are free; nothing moves real money.
  2. An invoice to collectPayer name and document, amount and due date per instalment, and a key that names each one.
  3. An endpoint for the confirmationA trigger on commerce.charge.paid. Your handler matches the invoice and runs the next step.
@codespar/sdk 0.16.11SDK example
// 1 · a test key from the Dashboard; a trigger on commerce.charge.paid points at your endpointimport { CodeSpar } from "@codespar/sdk";const session = await new CodeSpar().create("user_0000", { preset: "brazilian" }); // 2 · one charge per instalment, Pix or boleto with a due date, under a key that names itconst run = await session.send("create instalment 1/2 of invoice 1208 for ACME Distribuidora: R$ 1,180.00, due 2026-10-06, boleto or Pix, key inv-1208-1");const charge = run.tool_calls.find((c) => c.tool_name === "codespar_charge"); // 3 · the customer pays by Pix or boleto; follow the charge until it is paidif (charge) console.log((await session.paymentStatus(charge.id)).payment_status); // "succeeded"

SDK example · not run on this page

Related use cases

Use case

WhatsApp: Pix payment request in chat

A Pix charge inside the conversation, paid in the bank app.

Use case

CFO copilot

Pay approved invoices under your approval policy.

Use case

Business assistant for your customers

A platform offers its business customers an assistant that pays and collects under a mandate they control.

Give your agents a way to pay and get paid.

Build is free: hosted MCP, SDK and sandbox.

Test keys are free.

terminal · test mode
$ claude mcp add --transport http codespar https://connect.codespar.dev/mcp \    --header "Authorization: Bearer <test key>"> "create the two instalments of invoice 1208 for ACME, R$ 1,180.00 each, due Oct 6 and Oct 20"  codespar_charge × 2 · Pix or boleto · one key per instalment  1/2 paid by Pix · confirmation posted to your endpoint · 2/2 open until Oct 20

Illustrative · demo data

Collections agent · CodeSpar