## Apply a template; with dryRun only the plan is returned (desk:admin)

`POST /api/desk/v1/templates/{key}/apply`

Module: Desk · operationId: `applyTemplate` · Tag: Configuration · Auth: access token (`Authorization: Bearer <accessToken>`)

Entries whose key is free are created, identical ones reused, and entries whose key exists with other content are created under the prefix. Value lists and priorities are only added.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `key` | path | string | yes |  |

### Request body

`application/json`

- `bundle` (Bundle): Portable configuration (format desk.config/v1). All references use keys: types name their workflow key, spaces their type keys, labels their space key, categories their path of names, layouts "cf.<field key>".
  - `format` (string, required): Format of the bundle (one of `desk.config/v1`)
  - `categories` (array of object): Categories
  - `description` (string): Description of the bundle
  - `enums` (object): Value lists by kind
  - `fields` (array of object): Custom fields
  - `key` (string): Key of the bundle (templates)
  - `labels` (array of object): Labels
  - `matrix` (object): Priority matrix (impact × urgency)
  - `name` (string): Name of the bundle
  - `prefix` (string): Suggested prefix for conflicting keys
  - `priorities` (array of object): Priorities
  - `projectTemplates` (array of object): Project templates: type is the project type key; blueprint tasks name their typeId by type key, blueprint fields are keyed by field key
  - `projectTypes` (array of object): Project types: workflow, taskSpace and taskType are keys, layout "cf.<field key>", billing as in the project type settings
  - `spaces` (array of object): Spaces
  - `teams` (array of object): Teams
  - `types` (array of object): Item types
  - `workflows` (array of object): Workflows
- `dryRun` (boolean): Only return the plan, change nothing
- `prefix` (string): Up to 8 lower-case letters/digits for conflicting keys; default: the bundle suggestion

Example:

```json
{
  "dryRun": true,
  "prefix": ""
}
```

### Responses

- **200** Result or plan (`application/json`)

Fields of the 200 answer:

- `changes` (array of object): What the import does (or did) per entry
  - `action` (string): created: new; reused: an equal entry exists; renamed: created under another key (as) (one of `created`, `reused`, `renamed`)
  - `as` (string): Key the entry was created under (renamed)
  - `key` (string): Key of the entry in the bundle
  - `kind` (string): Kind of configuration entry (workflow, type, field, space, …)
  - `name` (string): The name or label of the entry, when it has one
- `dryRun` (boolean): Only the plan: nothing was changed

Example 200 answer:

```json
{
  "changes": [
    {
      "action": "reused",
      "key": "service",
      "kind": "workflow",
      "name": "Service"
    },
    {
      "action": "reused",
      "key": "stoerung",
      "kind": "type",
      "name": "Störung"
    },
    {
      "action": "reused",
      "key": "SUP",
      "kind": "space",
      "name": "Support"
    },
    {
      "action": "created",
      "key": "projekt",
      "kind": "workflow",
      "name": "Projekt"
    },
    {
      "action": "created",
      "key": "PRJ",
      "kind": "space",
      "name": "Kundenprojekte"
    },
    {
      "action": "created",
      "key": "kundenprojekt",
      "kind": "projectType",
      "name": "Kundenprojekt"
    },
    {
      "action": "created",
      "key": "erp-einfuehrung",
      "kind": "projectTemplate",
      "name": "ERP-Einführung"
    }
  ],
  "dryRun": true
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/desk/v1/templates/string/apply' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"dryRun":true,"prefix":""}'
```
