Below your floor, a Pix to fund the wallet.
The agent reads the wallet's BRL balance with codespar_wallet. When it is below the floor your code sets, it mints a dynamic Pix copia-e-cola for the amount you choose. Whoever holds the funding source pays it, and the statement shows the credit. CodeSpar does not watch the balance or refill it on its own: the floor and the decision are your agent's.
Below the floor, a Pix to fund the wallet.
An example with demo data: the agent reads BRL 180.00, below the R$ 500.00 floor your code sets, and mints a dynamic Pix of R$ 1,000.00. The funding source pays it and the statement shows the credit.
- The floor is your code's, not a platform setting
- The dynamic Pix funds the wallet only once someone pays it
- The statement shows the credit after the payment
The conversation is the easy part.
Payout floats run dry at the worst time. Someone tops them up by hand, and until they do, every payout waits.
Watch the balance by hand
The agent reads the balance with codespar_wallet
Generate a Pix charge in the bank portal
action=receive mints a dynamic Pix for the amount
Copy the code and send it to whoever pays
The copia-e-cola comes back in the answer, ready to send
Check later whether the money arrived
action=statement lists the wallet's entries
A top-up your code decides, a Pix someone pays.
codespar_wallet reads the balance (action=balance), mints a dynamic Pix copia-e-cola to fund the wallet (action=receive, dynamic=true) and lists the entries (action=statement). Your agent holds the floor and decides when to mint; the funding source pays the Pix. CodeSpar does not watch the balance or top it up on its own.
codespar_walletBRL balance
WalletBelow your floor?
codespar_walletA dynamic Pix
PixThe funding source pays
codespar_walletThe statement shows the credit
Walletcodespar_wallet with action=balance returns the wallet's balance per currency. With action=receive and dynamic=true it mints a dynamic Pix charge on the Celcoin account behind the wallet and returns its copia-e-cola. Once the funding source pays, the credit shows in action=statement. The floor and the decision to top up are your agent's code.
The code, and what it assumes.
// Prerequisites: CODESPAR_API_KEY set to a test key (csk_test_…) and a consumer // (user_0000) with a wallet. The floor is your code: CodeSpar does not watch the // balance, and the Pix funds the wallet only once someone pays it. import { CodeSpar } from "@codespar/sdk"; const session = await new CodeSpar().create("user_0000", { preset: "brazilian" }); const FLOOR_MINOR = 50_000; // R$ 500.00, your floor const TOP_UP_MINOR = 100_000; // R$ 1,000.00 const read = await session.execute("codespar_wallet", { action: "balance", consumer_id: "user_0000" }); const { balances } = read.data as { balances: { currency: string; balance_minor: number | string }[] }; const brl = Number(balances.find((b) => b.currency === "BRL")?.balance_minor ?? 0); if (brl < FLOOR_MINOR) { const pix = await session.execute("codespar_wallet", { action: "receive", consumer_id: "user_0000", amount: TOP_UP_MINOR, dynamic: true, description: "Wallet top-up", }); console.log(pix.data); // the copia-e-cola for the funding source to pay }
Example with the published SDK (@codespar/sdk 0.16.11). Its prerequisites are in the comments. Compiling does not prove the integration: run it in test mode first.
codespar_walletReads the balance and the statement, and mints a dynamic Pix to fund the wallet.
Start with a test key.
Test keys are free. Open the sandbox, connect the providers your project uses and see which tools it can call before you build.