# Delivery

URL: /workflows/processes/delivery · Id: `process:delivery`

> Delivery runs the Orders Customers place for Agent and Service outcomes, and bills only on confirmation.

Delivery runs the [Orders](/business/nouns/order) [Customers](/business/nouns/customer) place for [Agent](/business/nouns/agent) and [Service](/business/nouns/service) outcomes, and bills only on confirmation.

## Outcome
| Part | This Process |
| --- | --- |
| Outcome | Each Order is delivered, confirmed by the Customer or remedied, and billed only for confirmed lines. |
| Reads | [Order](/business/nouns/order) |
| Leaves | [Order](/business/nouns/order), [Task](/business/nouns/task), [Invoice](/business/nouns/invoice), [Transaction](/business/nouns/transaction), [Dispute](/business/nouns/dispute) |
| Runs in | Each Startup |

## Accountable
[Operations Lead](/agents/operations/operations-lead), [Operations Team](/agents/operations).

## Workflows
| Workflow | Runs | Team |
| --- | --- | --- |
| [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) | on [`Order.placed`](/business/events/Order.placed) | [Operations Team](/agents/operations) |
| [Bill on confirmation](/workflows/processes/delivery/bill-on-confirm) | on [`Order.confirmed`](/business/events/Order.confirmed) | [Operations Team](/agents/operations) |
| [Start the remedy](/workflows/processes/delivery/start-remedy) | on [`Order.disputed`](/business/events/Order.disputed) | [Operations Team](/agents/operations) |

## Who does each step

| Workflow | Step | Role | Calls | Approval |
| --- | --- | --- | --- | --- |
| [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) | 1. Extract the Order’s fields from what the Customer sent. | [Delivery Manager](/agents/operations/delivery-manager) | [Order.update](/business/nouns/order/update) | None |
| [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) | 2. Ask once, in one Message, for anything missing. | [Delivery Manager](/agents/operations/delivery-manager) | [Message.create](/business/nouns/message/create) | None |
| [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) | 3. Assign the work to an Agent or a Supplier by Credential, state, and load. | [Delivery Manager](/agents/operations/delivery-manager) | [Task.assign](/business/nouns/task/assign) | None |
| [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) | 4. Fulfill the Order, and hold any Reserved Act for Licensed review. | [Delivery Manager](/agents/operations/delivery-manager) | [Order.fulfill](/business/nouns/order/fulfill) | None |
| [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) | 5. Deliver the outcome and request confirmation. | [Delivery Manager](/agents/operations/delivery-manager) | [Order.deliver](/business/nouns/order/deliver) | None |
| [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) | 6. Redo the work once when the Customer rejects it. | [Delivery Manager](/agents/operations/delivery-manager) | [Order.revise](/business/nouns/order/revise) | None |
| [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) | 7. Bill when the Customer confirms. | [Billing Specialist](/agents/finance/billing-specialist) | [Invoice.bill](/business/nouns/invoice/bill) | Asks first; waits 1 business hour |
| [Bill on confirmation](/workflows/processes/delivery/bill-on-confirm) | 1. Capture the authorized payment for the confirmed lines. | [Billing Specialist](/agents/finance/billing-specialist) | [Order.pay](/business/nouns/order/pay) | Asks first; waits 1 business hour |
| [Bill on confirmation](/workflows/processes/delivery/bill-on-confirm) | 2. Bill the confirmed lines on the Order’s Invoice. | [Billing Specialist](/agents/finance/billing-specialist) | [Invoice.bill](/business/nouns/invoice/bill) | Asks first; waits 1 business hour |
| [Bill on confirmation](/workflows/processes/delivery/bill-on-confirm) | 3. Close the Order once every line is confirmed or refunded. | [Billing Specialist](/agents/finance/billing-specialist) | [Order.update](/business/nouns/order/update) | None |
| [Start the remedy](/workflows/processes/delivery/start-remedy) | 1. Hold the fee for the disputed lines. | [Billing Specialist](/agents/finance/billing-specialist) | [Invoice.update](/business/nouns/invoice/update) | None |
| [Start the remedy](/workflows/processes/delivery/start-remedy) | 2. Run the remedy the Outcome Contract names: redo the work, refund, or grant a credit. | [Delivery Manager](/agents/operations/delivery-manager) | [Order.revise](/business/nouns/order/revise) | None |
| [Start the remedy](/workflows/processes/delivery/start-remedy) | 3. Release or return the held fee when the remedy completes. | [Billing Specialist](/agents/finance/billing-specialist) | [Invoice.update](/business/nouns/invoice/update) | None |

## Events
| Direction | When | What happens |
| --- | --- | --- |
| In | On [`Order.placed`](/business/events/Order.placed) | Starts [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) |
| In | On [`Order.confirmed`](/business/events/Order.confirmed) | Starts [Bill on confirmation](/workflows/processes/delivery/bill-on-confirm) |
| In | On [`Order.disputed`](/business/events/Order.disputed) | Starts [Start the remedy](/workflows/processes/delivery/start-remedy) |
| Out | `Order.updated` | Raised by step 1 of [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) |
| Out | `Message.created` | Raised by step 2 of [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) |
| Out | [`Task.assigned`](/business/events/Task.assigned) | Raised by step 3 of [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) |
| Out | [`Order.fulfilled`](/business/events/Order.fulfilled) | Raised by step 4 of [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) |
| Out | [`Order.delivered`](/business/events/Order.delivered) | Raised by step 5 of [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) |
| Out | [`Order.revised`](/business/events/Order.revised) | Raised by step 6 of [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) |
| Out | [`Invoice.billed`](/business/events/Invoice.billed) | Raised by step 7 of [Deliver an outcome](/workflows/processes/delivery/deliver-outcome) |
| Out | [`Order.paid`](/business/events/Order.paid) | Raised by step 1 of [Bill on confirmation](/workflows/processes/delivery/bill-on-confirm) |
| Out | `Invoice.updated` | Raised by step 1 of [Start the remedy](/workflows/processes/delivery/start-remedy) |

## Plays
No Play names this Process.

## Controls
- [Outcome confirmation](/systems/trust-and-governance/controls/outcome-confirmation)

## Settings
| Setting | Type | Default | Say | Set with |
| --- | --- | --- | --- | --- |
| `delivery.redoLimit` | `integer` | `1` | Redo rejected work once before refunding | [Setting.update](/business/nouns/setting/update) |

## Failure
A failed step retries; when retries run out, the Action goes to the [Operations Lead](/agents/operations/operations-lead).

| Step | On failure |
| --- | --- |
| [Start the remedy](/workflows/processes/delivery/start-remedy) 2. Run the remedy the Outcome Contract names: redo the work, refund, or grant a credit. | Undoes it with [Order.refund](/business/nouns/order/refund). |

## Loop
| Step | Value |
| --- | --- |
| Hypothesis | Confirming each outcome with the Customer before billing raises accepted outcomes per Customer and lowers refunds. |
| Measure | [Accepted outcomes](/agents/operations#accepted-outcomes) over 30d, at least 30 observations |
| Learn | The learn step reads the Readout, records Evidence and a Decision, and drafts the next Variant. |

## Code

**Ask**

```text
Turn on delivery
```

**API**

```bash
curl -X POST https://api.sb/leaseline.app/processes/process_1/enable \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

**SDK**

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

await $.Process.enable({ process: 'process_1' })
```

**CLI**

```bash
npx startup-builder do Process.enable --json '{"process":"process_1"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Process.enable({ process: 'process_1' })"
  }
}
```

## Enable
On by default for [Marketplace](/products/templates/marketplace), [Licensed-human marketplace](/products/templates/licensed-marketplace), [Services-as-Software](/products/templates/services-as-software), [E2E managed service](/products/templates/managed-service). [Process.pause](/business/nouns/process/pause) stops new Actions; Actions in progress finish.

**Ask**

```text
Redo rejected work once before refunding
```

**API**

```bash
curl -X PATCH https://api.sb/leaseline.app/settings/setting_1 \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value":1,"key":"delivery.redoLimit"}'
```

**SDK**

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

await $.Setting.update({ id: 'setting_1', value: 1, key: 'delivery.redoLimit' })
```

**CLI**

```bash
npx startup-builder do Setting.update --json '{"id":"setting_1","value":1,"key":"delivery.redoLimit"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Setting.update({ id: 'setting_1', value: 1, key: 'delivery.redoLimit' })"
  }
}
```

## Example
A café owner orders a reconciled month from a bookkeeping service. An Agent matches 412 [Transactions](/business/nouns/transaction), the owner rejects one category, and the Agent redoes it once. The owner confirms, and the [Invoice](/business/nouns/invoice) follows.