# createContentTemplate

Create a reusable template. type is EMAIL | SMS | NOTE | TASK | TASK_SET. The nested input carries name, bodyContent (merge fields and [a|b] spintax allowed) and subjectContent (email only). Its merge fields are the vocabulary of WHATEVER NODE renders it, since a template has no domain of its own: from a CONTACT node or applyTaskTemplate, the CONTACT vocabulary listed under updateWorkflowGraph ({{firstName}}, {{contactPropertyAddress}}, {{userFirstName}}, …); from an APPOINTMENT text node, that PLUS the appointment fields ({{appointmentStartTime}}, …). Quote merge fields to the person as [First name], not raw keys, unless they check spelling. Keys match EXACTLY and case-sensitively, with no dotted or snake_case form: {{merge_fields}} and {{contact.firstName}} send the literal braces. TASK (the checklist/SOP step under Automations → Templates) takes input.taskConfig; bodyContent holds the task description and the due date is RELATIVE, resolved when applied. TASK_SET is a whole SOP: bodyContent "", no taskConfig, and input.taskSetSteps of 1-25 steps (their rules are on the input shape), applied in one call with applyTaskSet.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "createContentTemplate", "variables": {...} }`
- Scope: `WRITE`
- Type: mutation
- Idempotency: honors `Idempotency-Key` (24 h)
- Rate-limited: no

## Variables

- `input`: `CreateContentTemplateInput!` (required)
  - `name`: `String!` (required)
  - `input`: `ContentTemplateMutationInput!` (required)
    - `name`: `String!` (required)
    - `bodyContent`: `String!` (required)
    - `bodyFormat`: `String`
    - `subjectContent`: `String`
    - `attachments`: `[ContentTemplateAttachmentInput!]`
      - `uploadedFileId`: `ID!` (required)
      - `fileName`: `String!` (required)
      - `contentType`: `String!` (required)
      - `fileSize`: `Int!` (required)
      - `page`: `ContentTemplateAttachmentPageInput`
        - `itemId`: `ID!` (required)
        - `versionNumber`: `Int!` (required)
        - `sendsLatestAs`: `ID`
    - `taskConfig`: `TaskTemplateConfigInput`. Structured config for a TASK content template. The template's `bodyContent` holds the task description and `name` is the template label; everything else task-shaped lives here. Assignee is intentionally absent: an applied task template is always assigned to the acting user at apply time.
      - `title`: `String!` (required). Task title. Rendered with merge fields + spintax against the contact at apply time.
      - `taskType`: `String`. Free-text subtype label (maps to `Task.taskType`).
      - `dueOffset`: `TaskTemplateRelativeDateOffsetInput!` (required). Due date as a relative offset from apply time.
        - `amount`: `Int!` (required)
        - `unit`: `TaskTemplateRelativeTimeUnit!` (required, one of `DAYS`, `WEEKS`, `MONTHS`)
      - `preferredTimeOfDay`: `TaskTemplateTimeOfDayInput!` (required). Time-of-day the resolved due date snaps to.
        - `hour`: `Int!` (required)
        - `minute`: `Int!` (required)
        - `timezone`: `Timezone!` (required, one of `IDLW`, `SST`, `HST`, `AKST`, `PST`, `MST`, `AZ`, `CST`, `EST`, `AST`, `BRT`, `FNT`, `AZOT`, `UTC`, `CET`, `EET`, `MSK`, `GST`, `PKT`, `BST`, `ICT`, `JST`, `AEST`, `NCT`, `NZST`). AZ: Arizona: MST all year, no DST.
      - `autoCompleteOnNoteAdded`: `Boolean`
      - `autoCompleteOnReassignment`: `Boolean`
    - `taskSetSteps`: `[TaskSetStepInput!]`. One step of a TASK_SET template. `taskTemplateId` must name a TASK template in the caller's organization: a TASK_SET is rejected (a set cannot contain a set). The same template may appear more than once. The timing here WINS over the referenced template's own `taskConfig` timing.
      - `taskTemplateId`: `ID!` (required)
      - `dueOffset`: `TaskTemplateRelativeDateOffsetInput!` (required)
        - `amount`: `Int!` (required)
        - `unit`: `TaskTemplateRelativeTimeUnit!` (required, one of `DAYS`, `WEEKS`, `MONTHS`)
      - `preferredTimeOfDay`: `TaskTemplateTimeOfDayInput!` (required)
        - `hour`: `Int!` (required)
        - `minute`: `Int!` (required)
        - `timezone`: `Timezone!` (required, one of `IDLW`, `SST`, `HST`, `AKST`, `PST`, `MST`, `AZ`, `CST`, `EST`, `AST`, `BRT`, `FNT`, `AZOT`, `UTC`, `CET`, `EET`, `MSK`, `GST`, `PKT`, `BST`, `ICT`, `JST`, `AEST`, `NCT`, `NZST`). AZ: Arizona: MST all year, no DST.
  - `type`: `ContentTemplateType!` (required, one of `EMAIL`, `SMS`, `NOTE`, `TASK`, `TASK_SET`). TASK_SET: A named collection of TASK templates, each with its own due offset and time-of-day, applied to a contact in one gesture. Carries no body and no taskConfig of its own: see `ContentTemplate.taskSetSteps`.
  - `folderId`: `ID`

## Response (data, an example)

```json
{
  "workflowAutomationsMutation": {
    "createContentTemplate": {
      "id": "<ID>",
      "name": "…",
      "type": "EMAIL",
      "folderId": "<ID>",
      "taskSetSteps": [
        {
          "id": "<ID>",
          "taskTemplate": {
            "id": "<ID>",
            "name": "…"
          },
          "dueOffset": {
            "amount": 0,
            "unit": "DAYS"
          },
          "preferredTimeOfDay": {
            "hour": 0,
            "minute": 0,
            "timezone": "IDLW"
          }
        }
      ]
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operationId": "createContentTemplate",
    "variables": {
      "input": {
        "name": "<String>",
        "input": {
          "name": "<String>",
          "bodyContent": "<String>"
        },
        "type": "EMAIL"
      }
    }
  }'
```
