# Order routes: cancel, confirm, deliver, dispute

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

> The Order Verbs cancel, confirm, deliver, dispute as api.sb routes, with inputs, result, refusals and an example.

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

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

```text
POST /{namespace}/orders/{order}/cancel
```

Path: `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**

```bash
curl -X POST https://api.sb/leaseline.app/orders/order_dswDnxf2vt/cancel \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "order": {
    "$id": "https://api.sb/leaseline.app/orders/order_dswDnxf2vt",
    "$type": "Order",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "status": "canceled"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Order.cancel",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### 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=api).

```text
POST /{namespace}/orders/{order}/confirm
```

Path: `order`. Body, as JSON: the other inputs. 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**

```bash
curl -X POST https://api.sb/leaseline.app/orders/order_dswDnxf2vt/confirm \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "order": {
    "$id": "https://api.sb/leaseline.app/orders/order_dswDnxf2vt",
    "$type": "Order",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "status": "placed"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Order.confirm",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### 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=api).

```text
POST /{namespace}/orders/{order}/deliver
```

Path: `order`. Body, as JSON: the other inputs. 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**

```bash
curl -X POST https://api.sb/leaseline.app/orders/order_dswDnxf2vt/deliver \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"work":{}}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "order": {
    "$id": "https://api.sb/leaseline.app/orders/order_dswDnxf2vt",
    "$type": "Order",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "status": "placed"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Order.deliver",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### 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=api).

```text
POST /{namespace}/orders/{order}/dispute
```

Path: `order`. Body, as JSON: the other inputs. 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**

```bash
curl -X POST https://api.sb/leaseline.app/orders/order_dswDnxf2vt/dispute \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Example reason"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "order": {
    "$id": "https://api.sb/leaseline.app/orders/order_dswDnxf2vt",
    "$type": "Order",
    "total": {
      "amount": 29,
      "currency": "USD"
    },
    "status": "placed"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Order.dispute",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```