> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wellapp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# TaskTemplate

> TaskTemplate is a global, workspace-independent catalogue of onboarding and activation tasks that Well ships as canonical seed data

TaskTemplate is a global, workspace-independent catalogue of onboarding and activation tasks that Well ships as canonical seed data. Each template defines the human-readable content (title, markdown body), the CTA action type that drives the frontend button, a display sort order, and an optional initial status that overrides the default `ice_log` when the seed pipeline materialises a per-workspace Task from the template. Templates have no workspace foreign key; they are append-only canonical rows managed exclusively by the `syncTaskTemplates` seed function and data migrations — users never write to this table. A `Task` row is the per-workspace materialisation of a template; many Tasks may reference the same TaskTemplate via `template_pk`.

| Naming                          | Value                             |
| ------------------------------- | --------------------------------- |
| Object                          | TaskTemplate                      |
| Resource type (JSON:API `type`) | `task_template`                   |
| Collection / records root       | — <sub>(not a records root)</sub> |
| REST base                       | `/v1/task-templates`              |
| Entity class                    | `TaskTemplate`                    |

<Note>
  **Internal object.** Not currently exposed on the public REST API. The operations below describe the intended contract.
</Note>

## API operations

| Operation | Method & path                    | Status     |
| --------- | -------------------------------- | ---------- |
| List      | `GET /v1/task-templates`         | 🟡 Planned |
| Retrieve  | `GET /v1/task-templates/{id}`    | 🟡 Planned |
| Create    | `POST /v1/task-templates`        | 🟡 Planned |
| Update    | `PATCH /v1/task-templates/{id}`  | 🟡 Planned |
| Delete    | `DELETE /v1/task-templates/{id}` | 🟡 Planned |

## Data model

### Attributes

| Field              | Type                                        | Required | Constraints                             | Allowed values                                                                                                                                                                                                                                                                                     | Description                                                                                                                                                                                                                                                              |
| ------------------ | ------------------------------------------- | -------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| task\_template\_id | uuid                                        | ✅ Yes    | unique                                  | —                                                                                                                                                                                                                                                                                                  | Public-facing UUID identifier for the template. Generated by `gen_random_uuid()` at INSERT. Exposed on the API as the resource `id`.                                                                                                                                     |
| slug               | text                                        | ✅ Yes    | unique                                  | —                                                                                                                                                                                                                                                                                                  | Human-readable stable identifier used as the upsert key in the seed pipeline (ON CONFLICT slug). Examples: `connect-bank-account`, `connect-email`. Must be unique across all non-deleted templates.                                                                     |
| title              | text                                        | ✅ Yes    | —                                       | —                                                                                                                                                                                                                                                                                                  | Display title shown to the user for the task. Copied into the child Task row at seed time and kept in sync by migration.                                                                                                                                                 |
| markdown\_content  | text                                        | ✅ Yes    | —                                       | —                                                                                                                                                                                                                                                                                                  | Full instructional body rendered to the user when they open the task. Written in Markdown; may include HTML comment directives for media embedding (e.g. `&lt;!-- media: file.png \| alt: ... --&gt;`).                                                                  |
| action\_type       | 🔒 system — enum (task\_action\_type\_enum) | ⚪ No     | —                                       | connect\_email, connect\_gmail (tombstone — historical only), connect\_bank, connect\_accounting, connect\_provider, chrome\_extension\_fetch, go\_to\_invoices, go\_to\_transactions, go\_to\_workflows, confirm\_subworkspace, connect\_extension, connect\_tools, build\_canvas, manual\_upload | The CTA action triggered by the task card button. Drives frontend routing at click time. NULL means no automated CTA; the task is informational only. Uses a native Postgres enum; stored values are the enum VALUE strings listed below.                                |
| initial\_status    | 🔒 system — enum (task\_status\_enum)       | ⚪ No     | —                                       | ice\_log, open, in\_progress, done, blocked, cancelled, archived                                                                                                                                                                                                                                   | Optional override for the status assigned to the per-workspace Task row when it is materialised by the seed pipeline. When NULL the seed pipeline defaults to `ice_log`. Used to promote high-priority templates (e.g. confirm-subworkspace) directly to `open`.         |
| sort\_order        | integer                                     | ✅ Yes    | default 0; NOT NULL                     | —                                                                                                                                                                                                                                                                                                  | Controls the display order of templates / their materialised tasks (ascending). Default 0; migrations set explicit sequential values (1–N). Has a dedicated index `idx_task_templates_sort`.                                                                             |
| token\_reward      | integer                                     | ✅ Yes    | CHECK (token\_reward >= 0); default 200 | —                                                                                                                                                                                                                                                                                                  | Gamification reward copied into the child Task at seed time. Checked to be non-negative via a DB CHECK constraint (`token_reward &gt;= 0`).                                                                                                                              |
| created\_at        | 🔒 system — timestamptz                     | ✅ Yes    | —                                       | —                                                                                                                                                                                                                                                                                                  | Row creation timestamp. Set by the MikroORM `onCreate` hook; never updated.                                                                                                                                                                                              |
| updated\_at        | 🔒 system — timestamptz                     | ⚪ No     | —                                       | —                                                                                                                                                                                                                                                                                                  | Timestamp of the last mutation. Set by the `onCreate` hook and refreshed by the `onUpdate` hook on every subsequent write.                                                                                                                                               |
| deleted\_at        | 🔒 system — timestamptz                     | ⚪ No     | —                                       | —                                                                                                                                                                                                                                                                                                  | Soft-delete sentinel. NULL when the template is active. Set by the seed pipeline when a template is retired (e.g. `open_setup_flow` templates retired in Migration20260521). Rows with `deleted_at IS NOT NULL` are excluded from all active queries and task backfills. |

### System-computed

* task\_template\_id — generated by gen\_random\_uuid() at INSERT; never written by callers
* sort\_order default 0 — migrations set explicit sequential values; entity TypeScript default = 0
* token\_reward default 200 — entity TypeScript default = 200; DB DEFAULT 200
* created\_at — set by MikroORM onCreate hook (new Date()); never updated
* updated\_at — set by MikroORM onCreate hook and refreshed by onUpdate hook on every write
* deleted\_at — set to a timestamp by the syncTaskTemplates seed function when a template is retired; NULL for active rows
* initial\_status default — when NULL the Task seed pipeline defaults the child task status to ice\_log; the column itself has no DB DEFAULT
* action\_type — seeded and updated exclusively by syncTaskTemplates and data migrations; the TypeScript OptionalProps declaration means MikroORM treats it as server-side defaulted (nullable native enum)

## Example

```json theme={null}
{
  "data": {
    "type": "task_template",
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "attributes": {
      "slug": "connect-bank-account",
      "title": "Connect your bank account",
      "markdown_content": "# Connect your bank account\n\nSee every transaction in one place...",
      "action_type": "connect_bank",
      "initial_status": "open",
      "sort_order": 1,
      "token_reward": 200,
      "created_at": "2026-03-11T10:00:00.000Z",
      "updated_at": "2026-04-13T10:00:00.000Z",
      "deleted_at": null
    }
  }
}
```

<sub>Source: `apps/api/src/database/entities/TaskTemplate.ts` · domain: automation · tier: Activity</sub>
