> ## 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`, the default import of the v7 Node SDK. 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.
> 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.

export const Doc = ({href, children, name, bare}) => {
  const label = children || name || href;
  if (bare) {
    return <a href={href}>{label}</a>;
  }
  return <a className="cx-endpoint" data-kind="doc" href={href}>
      <span className="cx-endpoint-label">{label}</span>
      <span className="cx-endpoint-method">DOC</span>
    </a>;
};

The HTML element embeds raw HTML in your notification. Use it when the other Elemental elements cannot produce the structure or styling you need. 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

<Warning>
  HTML elements only work on email. They do not render on push, SMS, or any other channel. Use standard Elemental elements for cross-channel content.
</Warning>

**Basic example**

<CodeGroup>
  ```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.
  ```
</CodeGroup>

**Fields**

<ParamField path="content" type="string" required>
  The raw HTML. Any valid HTML markup, including CSS styles.
</ParamField>

<ParamField path="locales" type="object">
  Region-specific content for localization. See the <Doc href="/docs/design/elemental/locales">Locales documentation</Doc>.
</ParamField>

<ParamField path="channels" type="string[]">
  An array of channel names. The HTML element renders only for the listed channels. See <Doc href="/docs/design/elemental/control-flow#channels">Control flow</Doc>.
</ParamField>

**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
* **Email only**: HTML elements only work in email channels
* **Test thoroughly**: HTML rendering varies across email clients. Test in several
* **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
