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

# Manage Templates via API

> Reference for workspace template management over /notifications in Design Studio workflows—routing, Elemental payloads, HTML blocks, publish, and content reads.

Templates can be managed programmatically via Courier’s **[Templates API](/platform/content/templates-api)**. This page focuses on Design Studio assets: **Elemental** bodies, **reusable routing**, and **HTML** inside Elemental.

<Tip>
  See the **[Templates API tutorial](/tutorials/content/how-to-use-templates-api)** for a fast walkthrough: setup, requests, and working code for creating, updating, publishing, and managing templates.
</Tip>

## Notification template endpoints

Templates API requests are authenticated by passing your workspace [API key](/platform/workspaces/environments-api-keys) as a Bearer token in the `Authorization` header: `Authorization: Bearer <token>`. Requests without this header are rejected.

| Endpoint                                                                                                        | Purpose                                   |
| --------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| [`GET /notifications`](/api-reference/notification-templates/list-notification-templates)                       | List templates (paginated).               |
| [`POST /notifications`](/api-reference/notification-templates/create-notification-template)                     | Create a template.                        |
| [`GET /notifications/{id}`](/api-reference/notification-templates/get-notification-template)                    | Get one template (metadata and settings). |
| [`PUT /notifications/{id}`](/api-reference/notification-templates/replace-notification-template)                | Replace a template in full.               |
| [`GET /notifications/{id}/draft/content`](/api-reference/notification-templates/get-notification-content)       | Read draft Elemental content.             |
| [`GET /notifications/{id}/content`](/api-reference/notification-templates/get-notification-content)             | Read published Elemental content.         |
| [`POST /notifications/{id}/publish`](/api-reference/notification-templates/publish-notification-template)       | Publish a draft (or a specific version).  |
| [`GET /notifications/{id}/versions`](/api-reference/notification-templates/list-notification-template-versions) | List template versions.                   |
| [`DELETE /notifications/{id}`](/api-reference/notification-templates/archive-notification-template)             | Archive a template.                       |

## Design Studio alignment: routing and Elemental

Design Studio stores **Elemental** notification content and attaches **reusable routing** (which channels/providers to use). When you create or replace a template over the wire, the **`notification`** object must include **`routing`**: use **`null`** if you are not attaching a strategy yet, or **`{ "strategy_id": "rs_..." }`** with a strategy that already exists in your workspace (for example from [`GET /notifications/{id}`](/api-reference/notification-templates/get-notification-template) or Studio). **`notification.content`** follows Elemental: a **`version`** (for example `2022-01-01`) and an **`elements`** array using [element types](/platform/content/elemental/elements/index) such as `meta`, `text`, `action`, `channel`, etc. See [Elemental overview](/platform/content/elemental/elemental-overview) and [routing configuration](/platform/content/template-designer/routing-configuration).

## Example: create a template (`POST /notifications`)

`POST /notifications` takes **`published`** and **`notification`**. Set **`COURIER_API_KEY`** in your environment. The **[Templates API tutorial](/tutorials/content/how-to-use-templates-api)** walks through create, publish, and send end-to-end with the same REST API.

```bash cURL icon="terminal" wrap theme={null}
curl -sS -X POST "https://api.courier.com/notifications" \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d "$(jq -n '{
      "published": false,
      "notification": {
        "name": "Order shipped",
        "tags": [],
        "brand": null,
        "subscription": null,
        "routing": null,
        "content": {
          "version": "2022-01-01",
          "elements": [
            { "type": "meta", "title": "Your order {{order_id}} shipped" },
            { "type": "text", "content": "Hi {{name}}, tracking: {{tracking_url}}." },
            { "type": "action", "content": "Track", "href": "{{tracking_url}}" }
          ]
        }
      }
    }')"
```

## HTML elements in Elemental content

In addition to Courier's predefined Elemental blocks (`meta`, `text`, `action`, and the rest), you can supply **your own HTML** in Elemental: use **`"type": "html"`** and put the markup in **`content`**. That HTML path is **email-only**; other message formats (for example push or SMS) don't render HTML, so this block isn't available there. See the [HTML element](/platform/content/elemental/elements/html) reference for structure and options like **`locales`**.

```json theme={null}
{
  "version": "2022-01-01",
  "elements": [
    {
      "type": "html",
      "content": "<table role=\"presentation\"><tr><td>{{label}}</td><td>{{value}}</td></tr></table>"
    }
  ]
}
```

## Publish and read content

* **Publish:** [`POST /notifications/{id}/publish`](/api-reference/notification-templates/publish-notification-template) — body can target the latest draft or a specific version, depending on your workflow.
* **Draft body:** [`GET /notifications/{id}/draft/content`](/api-reference/notification-templates/get-notification-content) — current draft Elemental document.
* **Published body:** [`GET /notifications/{id}/content`](/api-reference/notification-templates/get-notification-content) — published Elemental document.

## What's Next

<CardGroup cols={2}>
  <Card title="Templates API" icon="book" href="/platform/content/templates-api">
    Full `/notifications` endpoint guide and API Reference links
  </Card>

  <Card title="Templates API tutorial" icon="code" href="/tutorials/content/how-to-use-templates-api">
    End-to-end curl and send example
  </Card>

  <Card title="Elemental overview" icon="file-code" href="/platform/content/elemental/elemental-overview">
    Structure of Elemental documents
  </Card>

  <Card title="Design Studio overview" icon="palette" href="/platform/content/design-studio/design-studio-overview">
    Editing templates in the UI
  </Card>
</CardGroup>
