# categorize

URL: /business/nouns/transaction/categorize · Id: `verb:Transaction.categorize` · Call: `await $.Transaction.categorize({ … })` (SDK) or the `do` tool at `https://api.sb/mcp`. Inputs says what to pass, Outputs what returns, When it waits who approves.

> Categorize codes a Transaction to an account in the chart by the Startup’s Policy and flags a low-confidence code for review.

Categorize codes a [Transaction](/business/nouns/transaction) to an account in the chart by the [Startup](/business/nouns/startup)’s [Policy](/business/nouns/policy) and flags a low-confidence code for review.

## Inputs
| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `transaction` | [Transaction](/business/nouns/transaction) | Yes | The Transaction to code. |
| `account` | `string` | No | The account code to use in place of the Policy’s choice. |

## Outputs
| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `transaction` | [Transaction](/business/nouns/transaction) | Yes | The coded Transaction. |
| `account` | `string` | Yes | The account code it was coded to. |
| `confidence` | `number` | Yes | How sure the code is, from 0 to 1. |

## Effects
- Emits [`Transaction.categorized`](/business/events/Transaction.categorized).
- Performed by the [Finance Lead](/agents/finance/finance-lead).
- Two-way: it runs at once, in the `try`, `send` and `do` modes.
- Below the Policy’s confidence threshold, opens a review Task for the Finance Lead.
- A new code posts a reversing pair and a new pair; the first pair stays.

## Refuses when
| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | [Transaction.categorize](/business/nouns/transaction/categorize) |

## When it waits
| Gate | Default |
| --- | --- |
| Decision class | Low: two-way, nothing at stake |
| [Delay window](/systems/trust-and-governance/controls/one-way-windows) | None: it runs once review passes. |
| Limit | The call [Limit](/business/nouns/limit) of the [Permission](/business/nouns/permission) it runs under. |
| Over the Limit | It waits `pending` for an [Approval](/business/nouns/approval) from the [Founder](/agents/founding/founder). Approved, it runs; refused, it ends `refused` with [`limit-exceeded`](/code/api/errors/limit-exceeded); unanswered by its deadline, it ends `canceled`. |

## Example

**Ask**

```text
Categorize the latest transaction.
```

**API**

```bash
curl -X POST https://api.sb/ledgerlark.com/transactions/transaction_1/categorize \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/ledgerlark.com",
  "transaction": {
    "$id": "https://api.sb/ledgerlark.com/transactions/transaction_1",
    "$type": "Transaction",
    "kind": "charge",
    "amount": {
      "amount": 400,
      "currency": "USD"
    }
  },
  "account": "Example account",
  "confidence": 1,
  "action": {
    "$id": "https://api.sb/ledgerlark.com/actions/action_1",
    "operation": "Transaction.categorize",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/ledgerlark.com/actions/action_1"
  }
}
```

**SDK**

```ts
import { $ } from 'startup-builder'

const { transaction, account, confidence } = await $.Transaction.categorize({ transaction: 'transaction_1' })
```

**CLI**

```bash
npx startup-builder do Transaction.categorize --json '{"transaction":"transaction_1"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Transaction.categorize({ transaction: 'transaction_1' })"
  }
}
```