---
title: Consumer funding
description: The 4 operations under funding, as typed calls on the generated REST client.
---

Available from `@codespar/sdk` 0.12.0; the version on npm is 0.16.18. When these docs build, the examples on this page are compiled against `@codespar/sdk` 0.16.18, 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](/docs/api/sdk/rest-client) explains `request`, `response`, the option bag and the errors. The values are placeholders shaped by the document.

```ts twoslash
import { CodeSpar } from "@codespar/sdk";

const cs = new CodeSpar({ apiKey: process.env.CODESPAR_API_KEY });
```

### POST `/v1/consumers/{consumerId}/fund/pix-in`

<Endpoint method="POST" path="/v1/consumers/{consumerId}/fund/pix-in" deprecated />

Mint a sandbox Pix charge to fund a consumer (deprecated path)

```ts twoslash
import { CodeSpar } from "@codespar/sdk";
const cs = new CodeSpar({ apiKey: "csk_test_0000" });
// ---cut---
const r = await cs.api.response("post", "/v1/consumers/{consumerId}/fund/pix-in", {
  path: {
    consumerId: "csm_0000000000000000"
  },
  body: {
    consumer_id: "csm_0000000000000000",
    amount_minor: 1000,
    description: "string"
  }
});
// r.status is one of the documented statuses (200, 403, 422),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
  console.log(r.data);
}
```

Parameters, body and every documented response: [POST /v1/consumers/\{consumerId\}/fund/pix-in in the HTTP reference](/docs/api/reference/funding#post-v1consumersconsumeridfundpix-in).

### POST `/v1/consumers/{consumerId}/fund/pix-in/settle`

<Endpoint method="POST" path="/v1/consumers/{consumerId}/fund/pix-in/settle" deprecated money="Settles the charge the mint produced and credits the consumer." />

Settle a sandbox Pix charge and credit the consumer (deprecated path)

```ts twoslash
import { CodeSpar } from "@codespar/sdk";
const cs = new CodeSpar({ apiKey: "csk_test_0000" });
// ---cut---
const r = await cs.api.response("post", "/v1/consumers/{consumerId}/fund/pix-in/settle", {
  path: {
    consumerId: "csm_0000000000000000"
  },
  body: {
    consumer_id: "csm_0000000000000000",
    amount_minor: 1000,
    transaction_id: "transaction_0000000000000000"
  }
});
// r.status is one of the documented statuses (200, 403, 422),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
  console.log(r.data);
}
```

The gates that refuse this call, the meaning of each refusal, parameters and every documented response: [POST /v1/consumers/\{consumerId\}/fund/pix-in/settle in the HTTP reference](/docs/api/reference/funding#post-v1consumersconsumeridfundpix-insettle).

### POST `/v1/consumers/{consumerId}/fund/sandbox`

<Endpoint method="POST" path="/v1/consumers/{consumerId}/fund/sandbox" deprecated money="Credits the consumer's sandbox account directly, without going through a Pix." />

Credit a consumer in the sandbox (deprecated path)

```ts twoslash
import { CodeSpar } from "@codespar/sdk";
const cs = new CodeSpar({ apiKey: "csk_test_0000" });
// ---cut---
const r = await cs.api.response("post", "/v1/consumers/{consumerId}/fund/sandbox", {
  path: {
    consumerId: "csm_0000000000000000"
  },
  body: {
    consumer_id: "csm_0000000000000000",
    amount_minor: 1000,
    account: "string",
    idempotency_key: "string"
  }
});
// r.status is one of the documented statuses (200, 403, 422),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
  console.log(r.data);
}
```

The gates that refuse this call, the meaning of each refusal, parameters and every documented response: [POST /v1/consumers/\{consumerId\}/fund/sandbox in the HTTP reference](/docs/api/reference/funding#post-v1consumersconsumeridfundsandbox).

### GET `/v1/consumers/{consumerId}/fund/{txId}`

Poll an onramp, and credit the wallet when it settles

```ts twoslash
import { CodeSpar } from "@codespar/sdk";
const cs = new CodeSpar({ apiKey: "csk_test_0000" });
// ---cut---
const result = await cs.api.get("/v1/consumers/{consumerId}/fund/{txId}", {
  path: {
    consumerId: "csm_0000000000000000",
    txId: "tx_0000000000000000"
  }
});
```

Parameters, body and every documented response: [GET /v1/consumers/\{consumerId\}/fund/\{txId\} in the HTTP reference](/docs/api/reference/funding#get-v1consumersconsumeridfundtxid).

