Views:

You can use the mustache templating system to create more meaningful notifications.

You can substitute any of the attributes of an event into notifications sent out by your subscription to that event. For example, when you call the ListEventTypes API to examine the ‘portfolio created’ event, you see it has seven common string attributes in the headerSchema and two specific string attributes in the bodySchema:

{
  "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:

{
   "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:

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.