> ## 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.

> ## Agent Instructions
> Install the Courier skill before writing code: `npx skills add trycourier/courier-skills`. It carries the verified SDK shapes and the rules you cannot get wrong.
> Authenticate every request with `Authorization: Bearer <API_KEY>`. A workspace has several environments and each has its own keys, which are plain `pk_` strings with no environment prefix. Start with Test.
> Send with `client.send.message` from the Node SDK (`@trycourier/courier` v7 and later, where the client is the default import). Reference a template by its `nt_` id or its alias.
> A send accepts a bare Elemental element list, but storing content on a template requires the top-level elements wrapped in a channel element.
> To translate a template, write one locale at a time with `PUT /notifications/{id}/locales/{localeId}`, which merges into the existing translations. `PUT /notifications/{id}/content` and `PUT /notifications/{id}/elements/{elementId}` overwrite translations along with the content, so send each element's `id` and `locales` back, and first remove every `checksum` and any `locales` key that starts with an underscore.
> Templates and journeys can be built in the Courier app or created through the API. Either way they live in the workspace and are referenced by ID when you send.
> The hosted MCP server is https://mcp.courier.com. For a briefing on what Courier is and when to use it, read https://www.courier.com/llms.txt.
> Prefer the Guides tab for how-do-I questions and the Docs tab for how-does-it-behave questions. The API reference lives under /api-reference.

# Elemental HTML element

> Embed raw HTML when no other element produces the structure you need. It renders on email only and supports Handlebars variables and translations.

The HTML element embeds raw HTML in your notification. Use it when the other Elemental elements can't produce the structure or styling you need. It renders on email only. The type value is `"html"`.

**When to use:**

* Custom HTML structures (tables, complex layouts)
* HTML that requires specific formatting not available in Elemental elements
* Legacy HTML content that needs to be preserved
* Custom styling that requires direct HTML/CSS

**Basic example**

```json Elemental theme={null}
{
  "type": "html",
  "content": "<h1>Hello, <strong>World!</strong></h1>"
}
```

```javascript Node.js highlight={9-12} theme={null}
const { requestId } = await client.send.message({
  message: {
    to: {
      email: "sarah@acme-corp.com",
    },
    content: {
      version: "2022-01-01",
      elements: [
        {
          type: "html",
          content: "<h1>Hello, <strong>World!</strong></h1>",
        },
      ],
    },
  },
});
```

```python Python highlight={9-12} theme={null}
response = client.send.message(
    message={
      "to": {
        "email": "sarah@acme-corp.com",
      },
      "content": {
        "version": "2022-01-01",
        "elements": [
          {
            "type": "html",
            "content": "<h1>Hello, <strong>World!</strong></h1>",
          },
        ],
      },
    },
)
```

```bash cURL highlight={12-15} theme={null}
curl -X POST https://api.courier.com/send \
  -H "Authorization: Bearer $COURIER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "message": {
        "to": {
          "email": "sarah@acme-corp.com"
        },
        "content": {
          "version": "2022-01-01",
          "elements": [
            {
              "type": "html",
              "content": "<h1>Hello, <strong>World!</strong></h1>"
            }
          ]
        }
      }
    }'
```

```ruby Ruby highlight={9-12} theme={null}
response = courier.send_.message(
  message: {
    to: {
      email: "sarah@acme-corp.com"
    },
    content: {
      version: "2022-01-01",
      elements: [
        {
          type: "html",
          content: "<h1>Hello, <strong>World!</strong></h1>"
        }
      ]
    }
  }
)
```

```go Go highlight={5-8} theme={null}
// Elemental nodes carry no typed content fields, so pass the document as raw JSON.
content := param.Override[shared.ElementalContentParam](json.RawMessage(`{
  "version": "2022-01-01",
  "elements": [
    {
      "type": "html",
      "content": "<h1>Hello, <strong>World!</strong></h1>"
    }
  ]
}`))

response, err := client.Send.Message(context.TODO(), courier.SendMessageParams{
	Message: courier.SendMessageParamsMessage{
		To: courier.SendMessageParamsMessageToUnion{
			OfUserRecipient: &shared.UserRecipientParam{
				Email: courier.String("sarah@acme-corp.com"),
			},
		},
		Content: courier.SendMessageParamsMessageContentUnion{OfElementalContent: &content},
	},
})
```

```java Java highlight={7-9} theme={null}
SendMessageParams params = SendMessageParams.builder()
    .message(SendMessageParams.Message.builder()
        .to(JsonValue.from(java.util.Map.of("email", "sarah@acme-corp.com")))
        .content(JsonValue.from(java.util.Map.of(
                "version", "2022-01-01",
                "elements", java.util.List.of(
                  java.util.Map.of(
                    "type", "html",
                    "content", "<h1>Hello, <strong>World!</strong></h1>")))))
        .build())
    .build();
SendMessageResponse response = client.send().message(params);
```

```php PHP highlight={9-12} theme={null}
$response = $client->send->message(
  message: [
    'to' => [
      'email' => 'sarah@acme-corp.com',
    ],
    'content' => [
      'version' => '2022-01-01',
      'elements' => [
        [
          'type' => 'html',
          'content' => '<h1>Hello, <strong>World!</strong></h1>',
        ],
      ],
    ],
  ],
);
```

```csharp C# highlight={12-15} theme={null}
// Elemental nodes expose no typed content fields, so build the document from raw JSON.
SendMessageParams parameters = new()
{
    Message = new()
    {
        To = new UserRecipient { Email = "sarah@acme-corp.com" },
        Content = ElementalContent.FromRawUnchecked(
            JsonSerializer.Deserialize<Dictionary<string, JsonElement>>("""
            {
              "version": "2022-01-01",
              "elements": [
                {
                  "type": "html",
                  "content": "<h1>Hello, <strong>World!</strong></h1>"
                }
              ]
            }
            """)),
    },
};

var response = await client.Send.Message(parameters);
```

```bash CLI highlight={4} theme={null}
courier send message \
  --api-key "$COURIER_API_KEY" \
  --message.to '{"email": "sarah@acme-corp.com"}' \
  --message.content '{"version": "2022-01-01", "elements": [{"type": "html", "content": "<h1>Hello, <strong>World!</strong></h1>"}]}'
```

```text MCP theme={null}
With Courier MCP, send an email to sarah@acme-corp.com with a raw HTML block.
```

**Fields**

**content** `string` *required*

The raw HTML. Any valid HTML markup, including CSS styles.

**locales** `object`

Translations of `content`, keyed by locale code. See [Template translations](https://www.courier.com/docs/design/elemental/locales.md).

**channels** `string[]`

An array of channel names. The HTML element renders only for the listed channels. See [Control flow](https://www.courier.com/docs/design/elemental/control-flow.md#channels).

**Examples and variants**

**Simple HTML**

Basic HTML content:

```json theme={null}
{
  "type": "html",
  "content": "<h1>Hello, <strong>World!</strong></h1>"
}
```

**HTML table**

Create custom HTML tables:

```json theme={null}
{
  "type": "html",
  "content": "<table style='width: 100%; border-collapse: collapse;'><tr><th style='border: 1px solid #ddd; padding: 8px;'>Item</th><th style='border: 1px solid #ddd; padding: 8px;'>Price</th></tr><tr><td style='border: 1px solid #ddd; padding: 8px;'>Product A</td><td style='border: 1px solid #ddd; padding: 8px;'>$99.99</td></tr></table>"
}
```

**HTML with Handlebars**

Use Handlebars variables in HTML:

```json theme={null}
{
  "type": "html",
  "content": "<div><h2>Order #{{order_id}}</h2><p>Total: ${{order_total}}</p></div>"
}
```

**HTML with localization**

Localize HTML content:

```json theme={null}
{
  "type": "html",
  "content": "<h1>Welcome!</h1>",
  "locales": {
    "es": {
      "content": "<h1>¡Bienvenido!</h1>"
    },
    "fr": {
      "content": "<h1>Bienvenue!</h1>"
    }
  }
}
```

**Channel-specific HTML**

Only render HTML for email:

```json theme={null}
{
  "type": "html",
  "channels": ["email"],
  "content": "<div style='background: #f5f5f5; padding: 20px;'>Email-only HTML content</div>"
}
```

### Best practices

* **Use sparingly**: prefer standard Elemental elements for cross-channel compatibility
* **Test thoroughly**: HTML rendering varies across email clients.
* **Use inline styles**: email clients often strip `<style>` tags, so use inline CSS
* **Keep it simple**: complex HTML may not render correctly in all email clients

**Channel support**

* **Email**: ✅ Full support
* **Push**: ❌ Not supported
* **SMS**: ❌ Not supported
* **Inbox**: ❌ Not supported
