---
title: "Using mustache templates to enrich notifications"
slug: "using-mustache-templates-to-enrich-notifications"
updated: 2024-09-23T15:39:22Z
published: 2024-09-23T15:39:22Z
canonical: "support.lusid.com/using-mustache-templates-to-enrich-notifications"
---

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

# Using mustache templates to enrich notifications

You can use [the mustache templating system](https://mustache.github.io/mustache.5.html) to create more meaningful notifications.

You can substitute any of the [attributes](/v1/docs/what-system-events-can-i-subscribe-to) of an event into notifications sent out by your subscription to that event. For example, when you call the [ListEventTypes](https://www.lusid.com/docs/api/notification/endpoints/event-types/ListEventTypes/) API to examine the `PortfolioCreated` event, you see it has seven common string attributes in the `headerSchema` and two specific string attributes in the `bodySchema`:

```json
{
  "values": [
    {
      "id": "PortfolioCreated",
      "displayName": "Portfolio Created",
      "description": "An event of this type is fired whenever a PortfolioCreated event is created in LUSID",
      "application": "Lusid",
      "headerSchema": [
        { 
          "name": "eventType",
          "type": "String" 
        },
        { 
          "name": "requestId",
          "type": "String" 
        },
        { 
          "name": "userId",
          "type": "String" 
        },
        { 
          "name": "action",
          "type": "String" 
        },
        { 
          "name": "entityType",
          "type": "String" 
        },
        { 
          "name": "timestamp",
          "type": "String" 
        },
        { 
          "name": "href",
          "type": "String" 
        }
      ],
      "bodySchema": [
        { 
          "name": "portfolioScope",
          "type": "String" 
        },
        { 
          "name": "portfolioCode",
          "type": "String" 
        }
      ]
      "href": "https://<your-domain>.lusid.com/notification/api/eventtypes/PortfolioCreated"
    },
    ...
  ],
}
```

You can use these attributes encapsulated in `{{` `}}` characters as placeholders for values generated by the event. Note you must prefix attributes appropriately with either `Header.` or `Body.` For example, you could create an email notification as follows:

```json
{
   "notificationId": "PortfolioCreatedNotification"
   "displayName": "EmailNotification",
   "notificationType": {
     "type": "Email",
     "subject": "Portfolio created in {{Body.portfolioScope}}",
     "plainTextBody": "A portfolio was created with code {{Body.portfolioCode}} in scope {{Body.portfolioScope}} at {{Header.timestamp}}.",
     "htmlBody": "<p>A portfolio was created with code {{Body.portfolioCode}} in scope {{Body.portfolioScope}} at {{Header.timestamp}}.</p>",
     "emailAddressTo": [
      "portfolio-managers@acme.org"
     ]
  },
  ...
}
```

The person receiving the email might see:

```plaintext
Subject: Portfolio created in Finbourne-Examples
Body: A portfolio was created with code UK-Equities in scope Finbourne-Examples at 2022-07-08 T00:00:00.000000 +00:00.
```
