Charges
The 5 operations under charges, as typed calls on the generated REST client.
Available from @codespar/sdk 0.12.0; the version on npm is 0.16.23. When these docs build, the examples on this page are compiled against @codespar/sdk 0.16.23, the version this site installs: a call that does not type-check against it fails the build.
Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.
import { } from "@codespar/sdk";
const = new ({ : .. });GET /v1/charges
List charges
const = await ..("/v1/charges");Parameters, body and every documented response: GET /v1/charges in the HTTP reference.
POST /v1/charges
/v1/chargesIssues an inbound charge: the buyer pays the merchant.
Issue a charge
const = await ..("/v1/charges", {
: {
: 1000,
: "BRL",
: "string",
: "csm_0000000000000000",
: "string",
: {},
: "2026-01-15",
: "string",
: "string",
: {}
}
});The gates that refuse this call, the meaning of each refusal, parameters and every documented response: POST /v1/charges in the HTTP reference.
GET /v1/charges/{chargeId}
Read a charge
const = await ..("/v1/charges/{chargeId}", {
: {
: "charge_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/charges/{chargeId} in the HTTP reference.
POST /v1/charges/{chargeId}/cancel
Withdraw a charge
const = await ..("/v1/charges/{chargeId}/cancel", {
: {
: "charge_0000000000000000"
}
});Parameters, body and every documented response: POST /v1/charges/{chargeId}/cancel in the HTTP reference.
POST /v1/charges/{chargeId}/sandbox/pay
/v1/charges/{chargeId}/sandbox/payledger `fund()` with the `pending -> settled` claim
Pay a charge in the sandbox (alias path)
const = await ..("post", "/v1/charges/{chargeId}/sandbox/pay", {
: {
: "charge_0000000000000000"
},
: {
: 1000
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (.) {
.(.);
}The gates that refuse this call, the meaning of each refusal, parameters and every documented response: POST /v1/charges/{chargeId}/sandbox/pay in the HTTP reference.