# Decision routes

URL: /code/api/decision · Id: `page:code/api/decision`

> Every Decision Verb as an api.sb route, with its inputs, result, refusals and an example.

Reference for [Decision](/business/nouns/decision).

| Noun | System | Run by |
| --- | --- | --- |
| [Decision](/business/nouns/decision) | [Goals](/business/goals) | [Strategist](/agents/founding/strategist) |

### Decision.create
Creates a Decision. [Verb page](/business/nouns/decision/create?interface=api).

```text
POST /{namespace}/decisions
```

Body, as JSON: the inputs. Emits `Decision.created`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `choice` | `text` | Yes | What was chosen. |
| `reason` | `text` | Yes | Why it was chosen. |
| `stakes` | `string` | No | One of `low`, `medium`, or `high`, which sets the delay window. |
| `thing` | [Thing](/business/nouns/thing) | No | A Decision records one choice about a Thing and stays on that Thing’s record forever. |
| `meeting` | [Meeting](/business/nouns/meeting) | No | A Meeting records Decisions, each with its options, choice and reason. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | [Decision](/business/nouns/decision) | Yes | The Decision. |

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

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

```json
{
  "api": "https://api.sb/leaseline.app",
  "decision": {
    "$id": "https://api.sb/leaseline.app/decisions/decision_ipoch3tTJh",
    "$type": "Decision",
    "choice": "Example choice",
    "reason": "Example reason"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Decision.create",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Decision.get
Returns one Decision by id. [Verb page](/business/nouns/decision/get?interface=api).

```text
GET /{namespace}/decisions/{id}
```

Path: `id`. Query: the other inputs. Reads only: it emits no Event.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Decision. |
| `at` | `string` | No | A time or Version name: the record as it stood then. Unset: as it stands now. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | [Decision](/business/nouns/decision) | Yes | The Decision. |

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

```bash
curl https://api.sb/leaseline.app/decisions/decision_ipoch3tTJh \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "$type": "Decision",
  "$id": "https://api.sb/leaseline.app/decisions/decision_ipoch3tTJh",
  "decision": {
    "$id": "https://api.sb/leaseline.app/decisions/decision_ipoch3tTJh",
    "$type": "Decision",
    "choice": "Example choice",
    "reason": "Example reason"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/decisions/decision_ipoch3tTJh",
    "up": "https://api.sb/leaseline.app/decisions"
  },
  "actions": {
    "supersede": "https://api.sb/leaseline.app/decisions/decision_ipoch3tTJh/supersede"
  }
}
```

### Decision.list
Returns Decisions, newest first, one page at a time. [Verb page](/business/nouns/decision/list?interface=api).

```text
GET /{namespace}/decisions
```

Query: the inputs. Reads only: it emits no Event.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `integer` | No | At most this many records, up to 100. The default is 20. |
| `after` | `string` | No | The cursor from the previous page. |
| `where` | `string` | No | A filter over the properties, such as `paidAt = null and total.amount > 500`. |
| `sort` | `string` | No | Properties to sort by, comma-separated; a leading minus sorts descending. |
| `total` | `boolean` | No | True adds the match count as `meta.total`, exact up to 10,000 matches and estimated above. |
| `facets` | `string` | No | Properties to count by value, comma-separated, returned as `meta.facets`. |
| `fields` | `string` | No | Properties to return on each record, comma-separated; `$id` and `$type` always return. |
| `include` | `string` | No | Related records to embed in place of their URLs, comma-separated. |
| `depth` | `integer` | No | How many levels of related records to embed. The default is 1. |
| `q` | `string` | No | Words to match across the text properties, ranked by relevance. |
| `match` | `string` | No | Ranks the search by `words`, or `meaning`; words is the default. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `decisions` | list of [Decision](/business/nouns/decision) | Yes | One page of Decisions. |

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

```bash
curl "https://api.sb/leaseline.app/decisions?limit=20" \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "$type": "Decision",
  "decisions": [
    {
      "$id": "https://api.sb/leaseline.app/decisions/decision_ipoch3tTJh",
      "$type": "Decision",
      "choice": "Example choice",
      "reason": "Example reason"
    }
  ],
  "meta": {
    "limit": 20,
    "after": "decision_ipoch3tTJh"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/decisions?limit=20",
    "next": "https://api.sb/leaseline.app/decisions?after=decision_ipoch3tTJh"
  }
}
```

### Decision.supersede
Supersede replaces a Decision with a newer one, keeping both on record with the reason for the change. [Verb page](/business/nouns/decision/supersede?interface=api).

```text
POST /{namespace}/decisions/{decision}/supersede
```

Path: `decision`. Body, as JSON: the other inputs. Emits [`Decision.superseded`](/business/events/Decision.superseded).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | [Decision](/business/nouns/decision) | Yes | The Decision to replace. |
| `by` | [Decision](/business/nouns/decision) | Yes | The newer Decision. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `decision` | [Decision](/business/nouns/decision) | Yes | The superseded Decision. |

**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/decisions/decision_ipoch3tTJh/supersede \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"by":"decision_ipoch3tTJh"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "decision": {
    "$id": "https://api.sb/leaseline.app/decisions/decision_ipoch3tTJh",
    "$type": "Decision",
    "choice": "Example choice",
    "reason": "Example reason"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Decision.supersede",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```