# Order methods: cancel, confirm, deliver, dispute

URL: /code/sdk/order/verbs · Id: `page:code/sdk/order/verbs`

> The Order Verbs cancel, confirm, deliver, dispute as typed SDK methods, with inputs, result, refusals and an example.

Reference for [Order](/business/nouns/order), one group of [Order methods](/code/sdk/order).

### Order.cancel
Cancel ends an Order before fulfillment and returns any payment in full. [Verb page](/business/nouns/order/cancel?interface=sdk).

```ts
interface OrderVerbs {
  cancel(input: OrderCancelInput, options?: SB.CallOptions): SB.Call<Order>
}
```

Emits [`Order.canceled`](/business/events/Order.canceled).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `order` | [Order](/business/nouns/order) | Yes | The unfulfilled Order. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `order` | [Order](/business/nouns/order) | Yes | The canceled Order. |

**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. |
| The record changed since it was read, so the write would overwrite a newer version. | [`conflict`](/code/api/errors/conflict) | Read the record again, then retry the write against its current state. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

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

const order = await $.Order.cancel({ order: 'order_dswDnxf2vt' })
```

### Order.confirm
Confirm records the Customer’s sign-off on delivered work, which closes the Order and earns the Startup its fee. [Verb page](/business/nouns/order/confirm?interface=sdk).

```ts
interface OrderVerbs {
  confirm(input: OrderConfirmInput, options?: SB.CallOptions): SB.Call<Order>
}
```

Emits [`Order.confirmed`](/business/events/Order.confirmed).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `order` | [Order](/business/nouns/order) | Yes | The delivered Order. |
| `lines` | `json` | No | The lines confirmed; every delivered line when absent. Each confirmed line bills on its own. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `order` | [Order](/business/nouns/order) | Yes | The closed Order. |

**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. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

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

const order = await $.Order.confirm({ order: 'order_dswDnxf2vt' })
```

### Order.deliver
Deliver hands the finished work of a Service Order to its Customer and opens the acceptance window. [Verb page](/business/nouns/order/deliver?interface=sdk).

```ts
interface OrderVerbs {
  deliver(input: OrderDeliverInput, options?: SB.CallOptions): SB.Call<Order>
}
```

Emits [`Order.delivered`](/business/events/Order.delivered).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `order` | [Order](/business/nouns/order) | Yes | The Order whose work is done. |
| `work` | `json` | Yes | The deliverable and its evidence. |
| `lines` | `json` | No | The lines delivered; every open line when absent. Each delivered line opens its own acceptance window. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `order` | [Order](/business/nouns/order) | Yes | The delivered Order. |

**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. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

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

const order = await $.Order.deliver({ order: 'order_dswDnxf2vt', work: {} })
```

### Order.dispute
Dispute contests a delivered Order under its Outcome Contract and starts the remedy the contract names. [Verb page](/business/nouns/order/dispute?interface=sdk).

```ts
interface OrderVerbs {
  dispute(input: OrderDisputeInput, options?: SB.CallOptions): SB.Call<Order>
}
```

Emits [`Order.disputed`](/business/events/Order.disputed).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `order` | [Order](/business/nouns/order) | Yes | The delivered Order. |
| `reason` | `text` | Yes | What falls short of the promise. |
| `lines` | `json` | No | The lines disputed; every delivered line when absent. Undisputed lines stay open to confirm. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `order` | [Order](/business/nouns/order) | Yes | The disputed Order. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The input does not match the schema of the operation. | [`invalid-input`](/code/api/errors/invalid-input) | Read the schema of the operation, then send every required field with the right type. | None. |
| 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. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

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

const order = await $.Order.dispute({ order: 'order_dswDnxf2vt', reason: 'Example reason' })
```