<!-- Generated from the operation definitions by `pnpm docs:reference`. Do not edit by hand. -->

# Get usage by customer: `get_customer_usage`

What each customer sent in one UK month, for billing it on: letters posted, by class, extra sheets, credits charged and credits given back. A letter counts in the month it was posted; credits given back count in the month they came back, so a closed month never changes. Leave out month for this month so far; pass customer for one customer. Free.

| | |
|---|---|
| MCP tool | None: it manages your customers, so it is kept out of the tools an agent reads. Use REST, the CLI or the SDK. |
| REST | `GET /v1/customers/usage` |
| CLI | `atomside get-customer-usage` |
| Key needs | Manage customers (`customers:manage`) |
| Changes anything | No. It only reads. |
| Idempotency key | Not used. |

## Example

A real call and its real answer, made against the API in test mode. A test runs it again and fails if the answer changes. Ids, keys and links are replaced with stand-ins.

### A call that works

REST:

```sh
curl https://api.atomside.com/v1/customers/usage?month=2026-11 \
  -H "Authorization: Bearer $ATOMSIDE_API_KEY"
```

CLI:

```sh
atomside get-customer-usage \
  --month 2026-11
```

The answer (HTTP 200):

```json
{
  "month": "2026-11",
  "closed": false,
  "closed_at": null,
  "totals": {
    "customers": 0,
    "letters": 0,
    "second_class": 0,
    "first_class": 0,
    "extra_sheets": 0,
    "credits": {
      "credits": 0,
      "gbp": "0.00"
    },
    "returned_credits": {
      "credits": 15,
      "gbp": "1.50"
    }
  },
  "customers": [
    {
      "ref": "cust_4471",
      "name": "Acme Lettings",
      "letters": 0,
      "second_class": 0,
      "first_class": 0,
      "extra_sheets": 0,
      "credits": {
        "credits": 0,
        "gbp": "0.00"
      },
      "returned_credits": {
        "credits": 15,
        "gbp": "1.50"
      }
    }
  ],
  "next_cursor": null
}
```

## Input

Over REST, fields in the path go in the path, GET fields in the query string, and POST fields in the JSON body.

```json
{
  "type": "object",
  "properties": {
    "month": {
      "description": "The UK month, as 2026-11. This month so far when left out.",
      "type": "string",
      "maxLength": 20
    },
    "customer": {
      "description": "One customer, by its ref.",
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "limit": {
      "default": 50,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "cursor": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    }
  },
  "additionalProperties": false
}
```

## Output

```json
{
  "type": "object",
  "properties": {
    "month": {
      "type": "string",
      "description": "The UK month, as 2026-11."
    },
    "closed": {
      "type": "boolean",
      "description": "True once the month is closed. A closed month never changes."
    },
    "closed_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
        },
        {
          "type": "null"
        }
      ]
    },
    "totals": {
      "type": "object",
      "properties": {
        "customers": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "letters": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Letters posted in the month."
        },
        "second_class": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "first_class": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "extra_sheets": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Sheets after the first, across the letters."
        },
        "credits": {
          "type": "object",
          "properties": {
            "credits": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "Whole credits. 1 credit is 10p."
            },
            "gbp": {
              "type": "string",
              "pattern": "^-?\\d+\\.\\d{2}$",
              "description": "The same amount in pounds, ex VAT, as a decimal string."
            }
          },
          "required": [
            "credits",
            "gbp"
          ],
          "additionalProperties": false,
          "description": "Credits charged for the letters posted in the month."
        },
        "returned_credits": {
          "type": "object",
          "properties": {
            "credits": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "Whole credits. 1 credit is 10p."
            },
            "gbp": {
              "type": "string",
              "pattern": "^-?\\d+\\.\\d{2}$",
              "description": "The same amount in pounds, ex VAT, as a decimal string."
            }
          },
          "required": [
            "credits",
            "gbp"
          ],
          "additionalProperties": false,
          "description": "Credits given back in the month, for letters declined, lapsed, cancelled or failed, whenever they were sent."
        }
      },
      "required": [
        "customers",
        "letters",
        "second_class",
        "first_class",
        "extra_sheets",
        "credits",
        "returned_credits"
      ],
      "additionalProperties": false
    },
    "customers": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ref": {
            "description": "The customer ref. Null for letters that named none.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "letters": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "Letters posted in the month."
          },
          "second_class": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "first_class": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "extra_sheets": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "Sheets after the first, across the letters."
          },
          "credits": {
            "type": "object",
            "properties": {
              "credits": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991,
                "description": "Whole credits. 1 credit is 10p."
              },
              "gbp": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$",
                "description": "The same amount in pounds, ex VAT, as a decimal string."
              }
            },
            "required": [
              "credits",
              "gbp"
            ],
            "additionalProperties": false,
            "description": "Credits charged for the letters posted in the month."
          },
          "returned_credits": {
            "type": "object",
            "properties": {
              "credits": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991,
                "description": "Whole credits. 1 credit is 10p."
              },
              "gbp": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$",
                "description": "The same amount in pounds, ex VAT, as a decimal string."
              }
            },
            "required": [
              "credits",
              "gbp"
            ],
            "additionalProperties": false,
            "description": "Credits given back in the month, for letters declined, lapsed, cancelled or failed, whenever they were sent."
          }
        },
        "required": [
          "ref",
          "name",
          "letters",
          "second_class",
          "first_class",
          "extra_sheets",
          "credits",
          "returned_credits"
        ],
        "additionalProperties": false
      },
      "description": "Most credits first."
    },
    "next_cursor": {
      "description": "Pass as cursor for the next page. Null at the end.",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "month",
    "closed",
    "closed_at",
    "totals",
    "customers",
    "next_cursor"
  ],
  "additionalProperties": false
}
```

## Refusals

Every refusal has the same shape. Branch on `code`, `answer` and `retry`; repeat `say` to your person.

| Code | Answer | Retry | HTTP | What to do next |
|---|---|---|---|---|
| [`key_missing`](../refusals.md#key_missing) | no | after_fix | 401 | Send the key as "Authorization: Bearer as_test_…". Ask your person if you have none. |
| [`key_not_valid`](../refusals.md#key_not_valid) | no | never | 401 | Ask your person for a new key. There is no link: we cannot say whose it was. |
| [`scope_missing`](../refusals.md#scope_missing) | no | after_person | 403 | Ask your person to give the key that permission. |
| [`invalid_request`](../refusals.md#invalid_request) | no | after_fix | 400 | Fix the field named in details.field. The same idempotency key is fine. |
| [`rate_limited`](../refusals.md#rate_limited) | no | at_time | 429 | Wait. The same idempotency key never sends twice. |
| [`try_again_shortly`](../refusals.md#try_again_shortly) | no | at_time | 503 | Try again after retry_after with the same idempotency key. |
| [`account_expired`](../refusals.md#account_expired) | no | never | 401 | Start again with start_account if your person still wants this. |
| [`connection_ended`](../refusals.md#connection_ended) | no | after_person | 401 | Tell your person. To carry on, they connect Atomside again in your assistant. |
| [`month_not_valid`](../refusals.md#month_not_valid) | no | after_fix | 422 | Give month as YYYY-MM, this UK month or one before it. |
