# Credit Grant programs: apply, issue, void

URL: /code/mcp/credit-grant/verbs · Id: `page:code/mcp/credit-grant/verbs`

> The Credit Grant Verbs apply, issue, void as MCP do programs, with inputs, result, refusals and an example.

Reference for [Credit Grant](/business/nouns/credit-grant), one group of [Credit Grant programs](/code/mcp/credit-grant).

### CreditGrant.apply
Apply spends Credit Grants against a finalizing Invoice, promotional first, then by priority and earliest expiry, and settles them through Stripe credit grants. [Verb page](/business/nouns/credit-grant/apply?interface=mcp).

```text
do: return await $.CreditGrant.apply(input)
```

Emits [`CreditGrant.applied`](/business/events/CreditGrant.applied).

**Inputs**

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

**Returns**

| 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. |

**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. | None. |

**Example**

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

### CreditGrant.issue
Issue gives a Customer a paid or promotional Credit Grant that its metered calls draw down before anything is invoiced. [Verb page](/business/nouns/credit-grant/issue?interface=mcp).

```text
do: return await $.CreditGrant.issue(input)
```

Emits [`CreditGrant.issued`](/business/events/CreditGrant.issued).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `customer` | [Customer](/business/nouns/customer) | Yes | The Customer who receives it. |
| `amount` | `money` | Yes | The balance granted. |
| `category` | `string` | Yes | `paid` for a balance the Customer bought; `promotional` for one given, which is never cash. |
| `appliesTo` | [Offer](/business/nouns/offer) | No | The metered Offer it pays for; every metered Offer of the Startup when absent. |
| `expiresAt` | `datetime` | No | When any remaining balance lapses; never, when absent. |
| `priority` | `integer` | No | Order of use among grants; a lower number spends first. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `creditGrant` | [Credit Grant](/business/nouns/credit-grant) | Yes | The new Credit Grant, its remaining balance equal to its amount. |

**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. | None. |

**Example**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.CreditGrant.issue({ customer: 'cus_K1BROJhqzZ', amount: { amount: 29, currency: 'USD' }, category: 'paid' })"
  }
}
```

### CreditGrant.void
Void ends a promotional Credit Grant early and forfeits its remaining balance, keeping the record. [Verb page](/business/nouns/credit-grant/void?interface=mcp).

```text
do: return await $.CreditGrant.void(input)
```

Emits [`CreditGrant.voided`](/business/events/CreditGrant.voided).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `creditGrant` | [Credit Grant](/business/nouns/credit-grant) | Yes | The grant to end. |
| `reason` | `text` | Yes | Why it ends, shown to the Customer. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `creditGrant` | [Credit Grant](/business/nouns/credit-grant) | Yes | The voided grant, its remaining balance zero. |

**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. | None. |

**Example**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.CreditGrant.void({ creditGrant: 'credgr_PduV9IB1HF', reason: 'Example reason' })"
  }
}
```