# AutomationTemplate

A ready-made flow to start an automation from, from plnnrly's template library. Templates are part of plnnrly itself, so they can be used but never changed. A template asks a few questions, such as whom to notify, and puts the answers in its steps.

## Used by
- GET /api/v2/automation-templates: List automation templates (AutomationTemplateList)
- GET /api/v2/automation-templates/{automation_template}: Read an automation template (AutomationTemplate)

## AutomationTemplate fields
- key (string ≤ 100, required): The template's key; an automation made from it carries it as `template_key`.
- label (string ≤ 255, required): The template's name.
- description (string, required, multiline): What an automation made from it does.
- keywords (array of string, required): Words people may search for besides the name and the description.
- category (string or null ≤ 100, required): The key of the library group it is listed under, such as `reminders`.
- category_label (string or null ≤ 255, required): The name of that group.
- popular (boolean, required): Whether the library lists it among the popular templates.
- personal_only (boolean, required): Whether an automation made from it only ever concerns its maker, such as a reminder to themselves. It is then offered only for the whole organisation, to someone making it for themselves.
- one_record_only (boolean, required): Whether, for projects or customers, it only makes sense for one at a time, such as a weekly e-mail about one customer. It is then not offered for every project or customer.
- scopes (array of string, required): Where the template makes sense: `organization`, `project` and `customer`.
- usage_count (integer, required): How many of the organisation's automations were made from it, deleted ones left out.
- availability (array of object, required, detail only): Whether you may start an automation from it at each level you may make automations at, checked the way saving its flow would check it. A template is listed when it is available or forbidden somewhere.
  - level (string ≤ 40, required): `organization` for the whole organisation, `project:all` or `customer:all` for every project or customer, `project:one` or `customer:one` for one of them.
  - status (string ≤ 20, required): `available`; `forbidden` when you, or the owner the automation would get, may not do or read everything it does; `hidden` when it does not fit that level or uses something the organisation does not have.
  - reason (string or null, optional): Why it is forbidden or hidden, when there is one reason to give.
- questions (array of object, required, detail only): What the template asks, in the order it asks it.
  - name (string ≤ 40, required): The question's name, which its answer is given under.
  - type (string ≤ 20, required): What kind of answer it takes: `text`, `texts` (a list of texts), `number`, `url`, `time` (`HH:MM`), `secret`, `record` or `audience` (people or teams).
  - label (string ≤ 255, required): The question as people are asked it.
  - required (boolean, required): Whether the steps it fills stay unfinished without an answer.
  - has_default (boolean, required): Whether it has a default, used when it is not answered.
  - helper_text (string or null, optional): More about what to answer.
  - record_type (string or null ≤ 255, optional): For a `record` question, the record type it takes, such as `project`.
  - multiple (boolean or null, optional): For a `record` or `audience` question, whether it takes several.
  - minimum (integer or null, optional): For a `number` question, the lowest answer.
  - maximum (integer or null, optional): For a `number` question, the highest answer.
  - audience_types (array of string or null, optional): For an `audience` question, the kinds of audience it takes, such as `users` and `teams`, answered with ids from `/users` and `/teams`.
- steps (array of object, required, detail only): The steps of an automation made from it, in the order people read the flow.
  - name (string ≤ 100, required): The template's own name for the step.
  - type (string ≤ 100, required): The step type.
  - label (string ≤ 255, required): The step type's name.
  - kind (string or null, optional): What kind of step it is.
  - summary (string or null, optional): What the step does, as its card says it.
  - open (string or null, optional): What is still to be chosen in the step while its questions are unanswered.
- links (AutomationTemplateLinks, required)
  - self (url, required): The canonical URI of this record.

Only on `?view=detail`: availability, questions, steps

## Variants

### AutomationTemplateList

What a collection returns, and what `?view=summary` returns on a single record.

12 fields.
Omits: availability, questions, steps

### AutomationTemplateLinks

The `links` object on this resource.

Keys: self

## Example
```json
{
  "key": "…",
  "label": "…",
  "description": "…",
  "keywords": [
    "…"
  ],
  "category": "…",
  "category_label": "…",
  "popular": false,
  "personal_only": false,
  "one_record_only": false,
  "scopes": [
    "…"
  ],
  "usage_count": 1,
  "availability": [
    {
      "level": "…",
      "status": "…",
      "…": "1 optional field left out"
    }
  ],
  "questions": [
    {
      "name": "…",
      "type": "…",
      "label": "…",
      "required": false,
      "has_default": false,
      "…": "6 optional fields left out"
    }
  ],
  "steps": [
    {
      "name": "…",
      "type": "…",
      "label": "…",
      "…": "3 optional fields left out"
    }
  ],
  "links": {
    "self": "https://<your-url>/api/v2/work-items/1"
  }
}
```
