# refund

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

> Refund returns all or part of a paid Invoice to the Customer’s original payment method and posts the reversing Entries.

Refund returns all or part of a paid [Invoice](/business/nouns/invoice) to the [Customer](/business/nouns/customer)’s original payment method and posts the reversing [Entries](/business/nouns/entry).

## Inputs
| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The paid Invoice. |
| `amount` | `money` | No | The amount. Defaults to the full payment; pro rata takes the unused part of the Period. |
| `reason` | `text` | Yes | Why the money goes back, kept on the Invoice. |

## Outputs
| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The Invoice, with its refunded amount. |

## Effects
- Emits [`Invoice.refunded`](/business/events/Invoice.refunded).
- Performed by the [Billing Specialist](/agents/finance/billing-specialist).
- One-way (money, customer): it waits out its delay window, and runs in the `send` and `do` modes.
- Checks the refund Limit; above it, opens an Approval for the Finance Lead and the Action waits.
- Waits the refund delay window before the money moves.
- Refuses while a Dispute on the Invoice is open.
- Returns money to the original payment only, never to a balance.
- Adds the amount to the Invoice’s refunded total.

## 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. | [Invoice.refund](/business/nouns/invoice/refund) |
| A Dispute on the Invoice is open | [`refused`](/code/api/errors/refused) | Clear what the check names, then call it again. | [Invoice.refund](/business/nouns/invoice/refund) |

## When it waits
| Gate | Default |
| --- | --- |
| Decision class | Medium: one-way, bounded (money, customer) |
| [Delay window](/systems/trust-and-governance/controls/one-way-windows) | 1 business hour, in which a watcher can pause, redirect or cancel it; then it runs. |
| Limit | The spend [Limit](/business/nouns/limit) of the [Permission](/business/nouns/permission) or [Mandate](/business/nouns/mandate) it runs under. |
| Over the Limit | It waits `pending` for an [Approval](/business/nouns/approval) from the [Finance Lead](/agents/finance/finance-lead). 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
Refund the latest invoice.
```

**API**

```bash
curl -X POST https://api.sb/patentpad.com/invoices/invoice_1/refund \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Example reason"}'
```

```json
{
  "api": "https://api.sb/patentpad.com",
  "invoice": {
    "$id": "https://api.sb/patentpad.com/invoices/invoice_1",
    "$type": "Invoice",
    "total": {
      "amount": 499,
      "currency": "USD"
    },
    "due": "2026-10-22"
  },
  "action": {
    "$id": "https://api.sb/patentpad.com/actions/action_1",
    "operation": "Invoice.refund",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/patentpad.com/actions/action_1"
  }
}
```

**SDK**

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

const invoice = await $.Invoice.refund({ invoice: 'invoice_1', reason: 'Example reason' })
```

**CLI**

```bash
npx startup-builder do Invoice.refund --json '{"invoice":"invoice_1","reason":"Example reason"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Invoice.refund({ invoice: 'invoice_1', reason: 'Example reason' })"
  }
}
```