---
title: "codespar charges"
description: "Charges: issue one, read it, list them, withdraw one"
---

Charges: issue one, read it, list them, withdraw one

5 commands in `@codespar/cli 0.16.0`.

Each one prints what its operation answered. [What a command prints](/docs/cli/reference#what-a-command-prints) has the rule, and [Configuration](/docs/cli/config#what-a-script-gets-when-a-command-fails) has the exit codes and the shape of a failure.

### `codespar charges list`

List charges

```bash
codespar charges list
```

| option | what it does |
|---|---|
| `-q, --query <key=value>` | Query parameter (repeatable) (default: []) |
| `--timeout <ms>` | Per-request timeout in milliseconds |

`GET /v1/charges` · [parameters, responses and refusals](/docs/api/reference/charges#get-v1charges)

### `codespar charges create`

Issue a charge

```bash
codespar charges create --input-file body.json
```

```json title="body.json"
{
  "amount": 1000,
  "currency": "BRL",
  "method": "string",
  "consumer_id": "csm_0000000000000000",
  "description": "string",
  "buyer": {},
  "due_date": "string",
  "idempotency_key": "string",
  "country": "string",
  "metadata": {}
}
```

| option | what it does |
|---|---|
| `-q, --query <key=value>` | Query parameter (repeatable) (default: []) |
| `--timeout <ms>` | Per-request timeout in milliseconds |
| `-i, --input <json>` | Request body as a JSON string |
| `-f, --input-file <path>` | Request body from a JSON file |

`POST /v1/charges` · [parameters, responses and refusals](/docs/api/reference/charges#post-v1charges)

### `codespar charges get`

Read a charge

```bash
codespar charges get charge_0000000000000000
```

| argument | what it is |
|---|---|
| `<chargeId>` | String. |

| option | what it does |
|---|---|
| `-q, --query <key=value>` | Query parameter (repeatable) (default: []) |
| `--timeout <ms>` | Per-request timeout in milliseconds |

`GET /v1/charges/{chargeId}` · [parameters, responses and refusals](/docs/api/reference/charges#get-v1chargeschargeid)

### `codespar charges cancel`

Withdraw a charge

```bash
codespar charges cancel charge_0000000000000000
```

| argument | what it is |
|---|---|
| `<chargeId>` | String. |

| option | what it does |
|---|---|
| `-q, --query <key=value>` | Query parameter (repeatable) (default: []) |
| `--timeout <ms>` | Per-request timeout in milliseconds |

`POST /v1/charges/{chargeId}/cancel` · [parameters, responses and refusals](/docs/api/reference/charges#post-v1chargeschargeidcancel)

### `codespar charges sandbox-pay`

Pay a charge in the sandbox (alias path)

> **Deprecated route.** The served document marks this operation as dead. The command still answers today and will go; the HTTP reference below names what took its place.

```bash
codespar charges sandbox-pay charge_0000000000000000 --input '{"amount_minor":1000}'
```

| argument | what it is |
|---|---|
| `<chargeId>` | String. |

| option | what it does |
|---|---|
| `-q, --query <key=value>` | Query parameter (repeatable) (default: []) |
| `--timeout <ms>` | Per-request timeout in milliseconds |
| `-i, --input <json>` | Request body as a JSON string |
| `-f, --input-file <path>` | Request body from a JSON file |

`POST /v1/charges/{chargeId}/sandbox/pay` · [parameters, responses and refusals](/docs/api/reference/charges#post-v1chargeschargeidsandboxpay)
