# apply

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

> Apply spends Credit Grants against a finalizing Invoice, promotional first, then by priority and earliest expiry, and settles them through Stripe credit grants.

Apply spends [Credit Grants](/business/nouns/credit-grant) against a finalizing [Invoice](/business/nouns/invoice), promotional first, then by priority and earliest expiry, and settles them through Stripe credit grants.

## Inputs
| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The Invoice being finalized. |

## Outputs
| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `applied` | `money` | Yes | The total the grants paid toward the Invoice. |
| `creditGrants` | list of [Credit Grant](/business/nouns/credit-grant) | Yes | Each grant drawn, with its new remaining balance. |

## Effects
- Emits [`CreditGrant.applied`](/business/events/CreditGrant.applied).
- Performed by the [Billing Specialist](/agents/finance/billing-specialist).
- Two-way: it runs at once, in the `try`, `send` and `do` modes.
- Pays only metered lines of the Startup’s own Offers; credits are never cash and never transfer.
- At zero balance, the Offer’s `atBound` behavior applies: stop, overage through the Meter, or upgrade.

## 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. | [CreditGrant.apply](/business/nouns/credit-grant/apply) |

## 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
Apply the latest credit grant with an invoice.
```

**API**

```bash
curl -X POST https://api.sb/patentpad.com/credit-grants/apply \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"invoice":"invoice_1"}'
```

```json
{
  "api": "https://api.sb/patentpad.com",
  "applied": {
    "amount": 499,
    "currency": "USD"
  },
  "creditGrants": [
    {
      "$id": "https://api.sb/patentpad.com/credit-grants/credit_grant_1",
      "$type": "CreditGrant",
      "amount": {
        "amount": 499,
        "currency": "USD"
      },
      "category": "paid"
    }
  ],
  "action": {
    "$id": "https://api.sb/patentpad.com/actions/action_1",
    "operation": "CreditGrant.apply",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/patentpad.com/actions/action_1"
  }
}
```

**SDK**

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

const { applied, creditGrants } = await $.CreditGrant.apply({ invoice: 'invoice_1' })
```

**CLI**

```bash
npx startup-builder do CreditGrant.apply --json '{"invoice":"invoice_1"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.CreditGrant.apply({ invoice: 'invoice_1' })"
  }
}
```