In this tutorial we'll see how to use the Notification REST API to create a LUSID webhook notification.
Let's imagine we want to automatically seed all new portfolios we create with some cash. To do this, we need to subscribe to the portfolio created event that LUSID emits every time a transaction portfolio is created and attach a webhook notification to post to the LUSID UpsertTransactions API.
Note: To complete this tutorial, you must have suitable access control permissions. This can most easily be achieved by assigning your LUSID user the built-in
lusid-administratorrole, which should already be the case if you are the domain owner. If you are informed you do not have a license to perform a certain operation, contact support.
Step 1: Subscribing to the portfolio created event
Before we can create a notification, we need to subscribe to the portfolio created event using the CreateSubscription API, passing in:
An API access token as a Bearer token in the Authorization HTTP header. See how to obtain a token.
PortfolioEventas ourscopeandAnyPortfolioCreatedas ourcodefor the subscription.A
displayNameanddescriptionfor the subscription.The
eventTypeto subscribe to. In our case, we want to subscribe to thePortfolioCreatedevent type every time it occurs, so we leave thefilterparameter empty.
curl -X POST "https://<your-domain>.lusid.com/notification/api/subscriptions"
-H "Authorization: Bearer <your-API-access-token>"
-H "Content-Type: application/json"
-d '{
"id": {
"scope": "PortfolioEvent",
"code": "AnyPortfolioCreated"
},
"displayName": "Any Portfolio Created",
"description": "Subscribes to all PortfolioCreated events",
"status": "Active",
"matchingPattern": {
"eventType": "PortfolioCreated",
"filter": ""
}
}'The response is as follows:
{
"id": {
"scope": "PortfolioEvent",
"code": "AnyPortfolioCreated"
},
"displayName": "Any Portfolio Created",
"description": "Subscribes to all PortfolioCreated events",
"status": "Active",
"matchingPattern": {
"eventType": "PortfolioCreated",
"filter": ""
},
"createdAt": "2023-02-15T10:13:36.8915431+00:00",
"userIdCreated": "00uji4twb7X42sdse2p7",
"modifiedAt": "2023-02-15T10:13:36.8915431+00:00",
"userIdModified": "00uji4twb7X42sdse2p7"
"useAsAuth":"00uji4twb7X42sdse2p7"
"href": "https://<your-domain>.lusid.com/notification/api/subscriptions/PortfolioEvent/AnyPortfolioCreated"
}You can sign in to the LUSID web app to view the new subscription on the Subscriptions dashboard, available from the top left menu under Notifications Management:.png?sv=2022-11-02&spr=https&st=2025-10-20T21%3A44%3A12Z&se=2025-10-20T21%3A57%3A12Z&sr=c&sp=r&sig=8ZKwR3MsuxNg%2FNKvTmTRmJj%2FZbbh1FeEaxPZ4IRPo%2BI%3D)
Step 2: Attaching a webhook notification to the subscription
Now that we have subscribed to the portfolio created event, we can create a webhook notification for the subscription to post to the UpsertTransactions API each time the event occurs.
In this tutorial, we want to seed all newly-created portfolios with 10,000,000 USD and 7,500,000 GBP cash. To do so, we call the CreateNotification API, passing in our API access token and:
The
scopeandcodeof the subscription to attach the notification to. In our case,PortfolioEventandAnyPortfolioCreated.A
displayNameand uniquenotificationIdto refer to the notification once created.A
notificationTypecontaining:A
TypeofWebhook.The
HttpMethodfor the type of request we want to make to the LUSID REST API. In our case, we want to make aPOSTrequest.The
Urlwe want to make a POST request to.A
ContentTypeofJson.A
Contentobject which contains the expected payload for the UpsertTransactions API.
curl -X POST "https://<your-domain>.lusid.com/notification/api/subscriptions/PortfolioEvent/AnyPortfolioCreated/notifications"
-H "Authorization: Bearer <your-API-access-token>"
-H "Content-Type: application/json"
-d '{
"notificationId": "PortfolioCreatedWebhook",
"displayName": "Seed Portfolio With Cash",
"description": "Any portfolio created seed with cash",
"notificationType": {
"Type": "Webhook",
"HttpMethod": "Post",
"Url": "/api/api/transactionportfolios/{{Body.portfolioScope}}/{{Body.portfolioCode}}/transactions",
"AuthenticationType": "Lusid",
"ContentType": "Json",
"Content": [ {
"transactionId": "SeedFundsTransactionUSD",
"type": "FundsIn",
"instrumentIdentifiers": {"Instrument/default/Currency": "USD"},
"transactionDate": "{{Header.timestamp}}",
"settlementDate": "{{Header.timestamp}}",
"units": 10000000,
"transactionPrice": {
"price": 1,
"type": "Price"
},
"totalConsideration": {
"amount": 10000000,
"currency": "USD"
},
"transactionCurrency": "USD",
},
{
"transactionId": "SeedFundsTransactionGBP",
"type": "FundsIn",
"instrumentIdentifiers": {"Instrument/default/Currency": "GBP"},
"transactionDate": "{{Header.timestamp}}",
"settlementDate": "{{Header.timestamp}}",
"units": 7500000,
"transactionPrice": {
"price": 1,
"type": "Price"
},
"totalConsideration": {
"amount": 7500000,
"currency": "GBP"
},
"transactionCurrency": "GBP",
}
]
}'Step 3: Checking that a new portfolio is automatically seeded with cash
Now that we have created a webhook notification, we can create a new transaction portfolio to check that new portfolios are now automatically seeded with cash. Let's create a new portfolio via the Portfolios dashboard in the LUSID web app with scope FBNUniversity and code NewTradingPortfolio​​​​​:.png?sv=2022-11-02&spr=https&st=2025-10-20T21%3A44%3A12Z&se=2025-10-20T21%3A57%3A12Z&sr=c&sp=r&sig=8ZKwR3MsuxNg%2FNKvTmTRmJj%2FZbbh1FeEaxPZ4IRPo%2BI%3D)
Once the new portfolio has been created, navigate from the top left menu in the web app to Dashboard > Transactions and select the new portfolio. We can see that the webhook notification has successfully seeded our new portfolio with the USD and GBP cash amounts specified earlier:.png?sv=2022-11-02&spr=https&st=2025-10-20T21%3A44%3A12Z&se=2025-10-20T21%3A57%3A12Z&sr=c&sp=r&sig=8ZKwR3MsuxNg%2FNKvTmTRmJj%2FZbbh1FeEaxPZ4IRPo%2BI%3D)