You can use LUSID's filtering syntax to subscribe to an event conditionally; that is, to only trigger notifications when those conditions are met.
You can filter on any of the attributes of an event. For example, when you call the 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
:
{
"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 apply your filter in the filter
field when you create a subscription to that event. Note you must prefix attributes appropriately with either Header.
or Body.
For example, you could subscribe to the PortfolioCreated
event only when a portfolio is created in a particular scope, and by a particular user:
"matchingPattern": {
"eventType": "PortfolioCreated",
"filter": "Header.userId eq '00uji4twb4jDcHGjN2p8' and Body.portfolioScope eq 'Finbourne-Examples'"
}