## Create a template of a project type (desk:admin)

`POST /api/desk/v1/project-templates`

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

Templates come with the bootstrap (`projectTemplates`).

### Request body

`application/json` (required)

- `key` (string, required): Key of the template, unique in the tenant
- `name` (string, required): Name of the template (max length 200)
- `typeId` (string, required): Project type (id or key on input); fixed
- `archived` (boolean): Archived: the template is kept for existing data but no longer offered in pickers
- `blueprint` (object): What a project made from the template gets
  - `dependencies` (array of object): Finish-to-start between tasks (keys); no cycles
    - `from` (string, required): Key of the task that has to end first
    - `to` (string, required): Key of the task that starts after it
    - `lagDays` (integer): Days between the end of from and the start of to (max 365)
  - `fields` (object): Custom field values of new projects
  - `milestones` (array of object): Milestones of the new project
    - `key` (string, required): Key of the milestone in the template
    - `title` (string, required): Title of the milestone
    - `completion` (string): manual: achieved by hand; items: reached once all its items are done (one of `manual`, `items`)
    - `offsetDays` (integer): Due this many days after the project start (max 3650)
  - `payments` (array of object): The payment plan of new projects (one final payment)
    - `amount` (number, required): Net amount or percentage (amountKind)
    - `role` (string, required): interim payment or the final payment (one of `interim`, `final`)
    - `title` (string, required): Title of the payment
    - `amountKind` (string): fixed: amount is net EUR; percent: amount is a percentage of the project's budgetAmount (one of `fixed`, `percent`)
    - `milestoneKey` (string): A milestone of the template that makes it due
    - `taxRate` (number): VAT rate in percent
  - `tasks` (array of BlueprintTask): Tasks: items of the new project
    - `key` (string, required): Key of the task in the template (referenced by dependencies) (max length 64)
    - `title` (string, required): Title of the item the task creates (max length 200)
    - `description` (string): Description of the item the task creates
    - `durationDays` (integer): Calendar days including the first; 0 and 1 are one day (max 3650)
    - `estimateMinutes` (integer, nullable): Estimate of the created item in minutes
    - `milestoneKey` (string): A milestone of the template the task counts for
    - `offsetDays` (integer): Days after the project start (max 3650)
    - `parentKey` (string): An earlier task; its type is on a higher level than this task's
    - `typeId` (string): Item type (id or key); empty uses the project type's task type
- `description` (string): Description of the template
- `id` (string, read-only): Id of the template
- `version` (integer): Version of the template; send it back on change (409 version_conflict when it is outdated)

Example:

```json
{
  "archived": false,
  "blueprint": {
    "dependencies": [
      {
        "from": "server",
        "lagDays": 0,
        "to": "software"
      },
      {
        "from": "software",
        "lagDays": 4,
        "to": "start"
      }
    ],
    "fields": {},
    "milestones": [
      {
        "completion": "items",
        "key": "basis",
        "offsetDays": 2,
        "title": "Grundinstallation abgeschlossen"
      },
      {
        "completion": "manual",
        "key": "live",
        "offsetDays": 20,
        "title": "Go-live"
      }
    ],
    "payments": [
      {
        "amount": 30,
        "amountKind": "percent",
        "milestoneKey": "basis",
        "role": "interim",
        "title": "Abschlag nach Grundinstallation"
      },
      {
        "amount": 70,
        "amountKind": "percent",
        "milestoneKey": "live",
        "role": "final",
        "title": "Schlussrechnung"
      }
    ],
    "tasks": [
      {
        "durationDays": 3,
        "key": "installation",
        "offsetDays": 0,
        "title": "Grundinstallation",
        "typeId": "5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f06"
      },
      {
        "durationDays": 2,
        "key": "server",
        "milestoneKey": "basis",
        "offsetDays": 0,
        "parentKey": "installation",
        "title": "Server und Datenbank einrichten",
        "typeId": "5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f07"
      },
      {
        "durationDays": 1,
        "key": "software",
        "milestoneKey": "basis",
        "offsetDays": 2,
        "parentKey": "installation",
        "title": "Software installieren und lizenzieren",
        "typeId": "5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f07"
      },
      {
        "durationDays": 1,
        "key": "start",
        "milestoneKey": "live",
        "offsetDays": 18,
        "title": "Produktivstart",
        "typeId": "5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f07"
      }
    ]
  },
  "description": "Vier Wochen: Installation, Konfiguration, Datenübernahme, Schnittstellen, Schulung und Go-live.",
  "id": "9f6a7b8c-0d1e-4f2a-9b4c-6d7e8f9a0b01",
  "key": "erp-einfuehrung",
  "name": "ERP-Einführung",
  "typeId": "6e3f4a5b-7c8d-4e9f-8a1b-3c4d5e6f7a01",
  "version": 2
}
```

### Responses

- **201** Template (`application/json`)

Fields of the 201 answer:

- `key` (string, required): Key of the template, unique in the tenant
- `name` (string, required): Name of the template (max length 200)
- `typeId` (string, required): Project type (id or key on input); fixed
- `archived` (boolean): Archived: the template is kept for existing data but no longer offered in pickers
- `blueprint` (object): What a project made from the template gets
  - `dependencies` (array of object): Finish-to-start between tasks (keys); no cycles
    - `from` (string, required): Key of the task that has to end first
    - `to` (string, required): Key of the task that starts after it
    - `lagDays` (integer): Days between the end of from and the start of to (max 365)
  - `fields` (object): Custom field values of new projects
  - `milestones` (array of object): Milestones of the new project
    - `key` (string, required): Key of the milestone in the template
    - `title` (string, required): Title of the milestone
    - `completion` (string): manual: achieved by hand; items: reached once all its items are done (one of `manual`, `items`)
    - `offsetDays` (integer): Due this many days after the project start (max 3650)
  - `payments` (array of object): The payment plan of new projects (one final payment)
    - `amount` (number, required): Net amount or percentage (amountKind)
    - `role` (string, required): interim payment or the final payment (one of `interim`, `final`)
    - `title` (string, required): Title of the payment
    - `amountKind` (string): fixed: amount is net EUR; percent: amount is a percentage of the project's budgetAmount (one of `fixed`, `percent`)
    - `milestoneKey` (string): A milestone of the template that makes it due
    - `taxRate` (number): VAT rate in percent
  - `tasks` (array of BlueprintTask): Tasks: items of the new project
    - `key` (string, required): Key of the task in the template (referenced by dependencies) (max length 64)
    - `title` (string, required): Title of the item the task creates (max length 200)
    - `description` (string): Description of the item the task creates
    - `durationDays` (integer): Calendar days including the first; 0 and 1 are one day (max 3650)
    - `estimateMinutes` (integer, nullable): Estimate of the created item in minutes
    - `milestoneKey` (string): A milestone of the template the task counts for
    - `offsetDays` (integer): Days after the project start (max 3650)
    - `parentKey` (string): An earlier task; its type is on a higher level than this task's
    - `typeId` (string): Item type (id or key); empty uses the project type's task type
- `description` (string): Description of the template
- `id` (string, read-only): Id of the template
- `version` (integer): Version of the template; send it back on change (409 version_conflict when it is outdated)

Example 201 answer:

```json
{
  "archived": false,
  "blueprint": {
    "dependencies": [
      {
        "from": "server",
        "lagDays": 0,
        "to": "software"
      },
      {
        "from": "software",
        "lagDays": 4,
        "to": "start"
      }
    ],
    "fields": {},
    "milestones": [
      {
        "completion": "items",
        "key": "basis",
        "offsetDays": 2,
        "title": "Grundinstallation abgeschlossen"
      },
      {
        "completion": "manual",
        "key": "live",
        "offsetDays": 20,
        "title": "Go-live"
      }
    ],
    "payments": [
      {
        "amount": 30,
        "amountKind": "percent",
        "milestoneKey": "basis",
        "role": "interim",
        "title": "Abschlag nach Grundinstallation"
      },
      {
        "amount": 70,
        "amountKind": "percent",
        "milestoneKey": "live",
        "role": "final",
        "title": "Schlussrechnung"
      }
    ],
    "tasks": [
      {
        "durationDays": 3,
        "key": "installation",
        "offsetDays": 0,
        "title": "Grundinstallation",
        "typeId": "5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f06"
      },
      {
        "durationDays": 2,
        "key": "server",
        "milestoneKey": "basis",
        "offsetDays": 0,
        "parentKey": "installation",
        "title": "Server und Datenbank einrichten",
        "typeId": "5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f07"
      },
      {
        "durationDays": 1,
        "key": "software",
        "milestoneKey": "basis",
        "offsetDays": 2,
        "parentKey": "installation",
        "title": "Software installieren und lizenzieren",
        "typeId": "5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f07"
      },
      {
        "durationDays": 1,
        "key": "start",
        "milestoneKey": "live",
        "offsetDays": 18,
        "title": "Produktivstart",
        "typeId": "5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f07"
      }
    ]
  },
  "description": "Vier Wochen: Installation, Konfiguration, Datenübernahme, Schnittstellen, Schulung und Go-live.",
  "id": "9f6a7b8c-0d1e-4f2a-9b4c-6d7e8f9a0b01",
  "key": "erp-einfuehrung",
  "name": "ERP-Einführung",
  "typeId": "6e3f4a5b-7c8d-4e9f-8a1b-3c4d5e6f7a01",
  "version": 2
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/desk/v1/project-templates' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"archived":false,"blueprint":{"dependencies":[{"from":"server","lagDays":0,"to":"software"},{"from":"software","lagDays":4,"to":"start"}],"fields":{},"milestones":[{"completion":"items","key":"basis","offsetDays":2,"title":"Grundinstallation abgeschlossen"},{"completion":"manual","key":"live","offsetDays":20,"title":"Go-live"}],"payments":[{"amount":30,"amountKind":"percent","milestoneKey":"basis","role":"interim","title":"Abschlag nach Grundinstallation"},{"amount":70,"amountKind":"percent","milestoneKey":"live","role":"final","title":"Schlussrechnung"}],"tasks":[{"durationDays":3,"key":"installation","offsetDays":0,"title":"Grundinstallation","typeId":"5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f06"},{"durationDays":2,"key":"server","milestoneKey":"basis","offsetDays":0,"parentKey":"installation","title":"Server und Datenbank einrichten","typeId":"5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f07"},{"durationDays":1,"key":"software","milestoneKey":"basis","offsetDays":2,"parentKey":"installation","title":"Software installieren und lizenzieren","typeId":"5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f07"},{"durationDays":1,"key":"start","milestoneKey":"live","offsetDays":18,"title":"Produktivstart","typeId":"5d2e3f4a-6b7c-4d8e-9f0a-2b3c4d5e6f07"}]},"description":"Vier Wochen: Installation, Konfiguration, Datenübernahme, Schnittstellen, Schulung und Go-live.","id":"9f6a7b8c-0d1e-4f2a-9b4c-6d7e8f9a0b01","key":"erp-einfuehrung","name":"ERP-Einführung","typeId":"6e3f4a5b-7c8d-4e9f-8a1b-3c4d5e6f7a01","version":2}'
```
