# Template commands: extend, promote, upgrade

URL: /code/cli/template/verbs · Id: `page:code/cli/template/verbs`

> The Template Verbs extend, promote, upgrade as CLI commands, with inputs, result, refusals and an example.

Reference for [Template](/business/nouns/template), one group of [Template commands](/code/cli/template).

### Template.extend
Extend adds a Template to a Startup’s bases, pinned to a Version, so the Startup inherits its definition. [Verb page](/business/nouns/template/extend?interface=cli).

```text
npx startup-builder do Template.extend --json '<input>' [--try | --send | --do]
```

Emits [`Template.extended`](/business/events/Template.extended).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `template` | [Template](/business/nouns/template) | Yes | The Template to inherit. |
| `startup` | [Startup](/business/nouns/startup) | Yes | The Startup that extends it. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `startup` | [Startup](/business/nouns/startup) | Yes | The Startup with the Template among its bases. |
| `template` | [Template](/business/nouns/template) | Yes | The Template extended. |

**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. |
| A clash between two bases until the Startup settles it | [`refused`](/code/api/errors/refused) | Clear what the check names, then call it again. | None. |

**Example**

```bash
npx startup-builder do Template.extend --json '{"template":"template_THRQF1h9uX","startup":"startup_l3hr1EnUGY"}'
```

### Template.promote
Promote moves one Startup’s refinement into a Template, so every Startup that extends the Template inherits it. [Verb page](/business/nouns/template/promote?interface=cli).

```text
npx startup-builder do Template.promote --json '<input>' [--try | --send | --do]
```

Emits [`Template.promoted`](/business/events/Template.promoted).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `template` | [Template](/business/nouns/template) | Yes | The Template that receives the refinement. |
| `startup` | [Startup](/business/nouns/startup) | Yes | The Startup that holds the refinement. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `change` | [Change](/business/nouns/change) | Yes | The Change against the Template. |
| `template` | [Template](/business/nouns/template) | Yes | The Template that received the refinement. |

**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
npx startup-builder do Template.promote --json '{"template":"template_THRQF1h9uX","startup":"startup_l3hr1EnUGY"}'
```

### Template.upgrade
Upgrade moves a Startup to a newer Version of a Template it extends, through a Change it can review. [Verb page](/business/nouns/template/upgrade?interface=cli).

```text
npx startup-builder do Template.upgrade --json '<input>' [--try | --send | --do]
```

Emits [`Template.upgraded`](/business/events/Template.upgraded).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `template` | [Template](/business/nouns/template) | Yes | The Template to upgrade. |
| `startup` | [Startup](/business/nouns/startup) | Yes | The Startup that extends it. |
| `version` | [Version](/business/nouns/version) | No | The target Version. Defaults to the latest. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `change` | [Change](/business/nouns/change) | Yes | The Change that moves the pin. |
| `template` | [Template](/business/nouns/template) | Yes | The Template upgraded to. |

**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
npx startup-builder do Template.upgrade --json '{"template":"template_THRQF1h9uX","startup":"startup_l3hr1EnUGY"}'
```