# Spend categories and export

> Code agent spend to your general ledger and export every payment for month-end close

- Human URL: https://conto.finance/docs/guides/accounting-export
- Raw Markdown: https://conto.finance/docs/guides/accounting-export.md
- Terminal view: https://conto.finance/ai/docs/guides/accounting-export

Documentation group: Operate

Conto exports every payment your agents make in one file: wallet payments, x402 and MPP calls,
agent-to-agent payments, transfers between your wallets, card purchases, and checkouts your agents
reported. Each row carries the agent, its owner, its team and cost center, a spend category, and the
category's general ledger (GL) account.

## Spend categories

Go to **Settings** > **Accounting** to add categories. Each category has a name, an optional GL
account, and optional rules. Owners and Admins can change categories. An agent's key cannot.

A payment lands in a category in this order:

1. **The category the agent sent.** When an agent sends a `category` with a payment and it matches a
   category's label or name, the payment uses that category.
2. **Rules.** Otherwise Conto checks each category's rules: card merchant category codes (MCC)
   first, then merchant domains, then rails. A domain also matches its subdomains, so `openai.com`
   matches `api.openai.com`. When two categories match at the same step, the first by name wins.
3. **Uncategorized.** A payment that matches nothing exports with an empty category.

Categories are applied when you export, not when the payment is made. A new category or rule
applies to earlier payments too, and a payment is never stopped because of its category.

```bash
curl -X POST https://conto.finance/api/spend-categories \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Travel",
    "glAccountCode": "6400",
    "matchRules": { "mccs": ["4511", "3000"] }
  }'
```

Rules take `mccs` (four digit codes), `merchantDomains`, and `rails`. Rails are `wallet`, `x402`,
`mpp`, `agent`, `transfer`, `card`, and `checkout`.

## Export

In **Settings** > **Accounting**, pick a date range and download the CSV. Dates are UTC, and the
range includes both days you pick.

From the API, `GET /api/spending/export` returns CSV by default, up to 20,000 rows. For a larger
range, page through it as JSON:

```bash
curl "https://conto.finance/api/spending/export?format=json&from=2026-10-01T00:00:00Z&to=2026-11-01T00:00:00Z&limit=500" \
  -H "Authorization: Bearer $CONTO_ORG_API_KEY"
```

Pass the response's `nextCursor` as `cursor` to read the next page. `nextCursor` is `null` on the
last page. `from` is inclusive and `to` is exclusive.

Use an organization API key or a signed-in session. An agent's key cannot export the organization's
spend.

### Columns

| Column                                           | What it holds                                                                                                     |
| ------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| `date`                                           | When the payment started, in UTC                                                                                  |
| `rail`                                           | `wallet`, `x402`, `mpp`, `agent`, `transfer`, `card`, or `checkout`                                               |
| `direction`                                      | `out` for money your organization paid, `in` for money it received, `internal` for a transfer between its wallets |
| `ownerEmail`                                     | The agent's owner                                                                                                 |
| `team`, `costCenter`                             | The agent's team and the team's cost center code                                                                  |
| `merchant`                                       | Merchant name, service domain, or recipient address                                                               |
| `amount`, `currency`                             | The payment amount in its own currency                                                                            |
| `status`, `statusLabel`                          | Where the payment stands, and the rail's own word for it                                                          |
| `category`, `categoryMatchedBy`, `glAccountCode` | The category, how it was chosen (`supplied`, `mcc`, `merchant_domain`, or `rail`), and its GL account             |
| `department`                                     | The department recorded with the payment. For an agent in a team, the team's label                                |
| `purpose`                                        | The purpose the agent gave                                                                                        |
| `policyResult`                                   | How policy decided the payment                                                                                    |
| `reference`                                      | Transaction hash, card last four, or the order reference the agent reported                                       |

Owner, team and cost center are the agent's current ones. Department is what the payment recorded
when it was made. Card and checkout amounts are the card network's or the agent's reported amount.
Conto does not see the charge for a checkout an agent completed itself.

## SDK and CLI

The export needs SDK `0.9.0` or later and CLI `0.6.0` or later. With a `ContoAdmin` client
configured with an organization key:

```typescript
const bounds = { from: '2026-10-01T00:00:00Z', to: '2026-11-01T00:00:00Z' };
const csvBytes = await admin.spending.exportSpend(bounds);
const page = await admin.spending.listSpend({ ...bounds, limit: 500 });
```

For each next JSON page, pass `page.nextCursor` as `cursor` with the same date bounds.

```bash
conto spending export --from 2026-10-01T00:00:00Z --to 2026-11-01T00:00:00Z --output october.csv
conto spending export --format json --limit 500
```

The CLI uses the configured organization key. `--output` creates a private file and refuses to
overwrite an existing one. Without `--output`, it writes the export to standard output.
JSON returns one page and its `nextCursor`. Use `--cursor` to continue.

### Receipt references

The additional `receiptPath` column links to the authenticated Conto transaction receipt API,
relative to your API base URL. It is null for card and reported-checkout rows and incoming-only
transactions that the receipt endpoint does not expose to your organization. A Conto transaction
receipt records the payment and its controls. It is not a merchant invoice. No private receipt
files or expiring signed download links are embedded in the export.
