How do I notify people via SMS when an event occurs?

Prev Next

Providing you are a LUSID user with sufficient access control permissions, you can create an SMS notification to send to people when an event you have subscribed to occurs. For example, you could notify all the portfolio managers by SMS when the LUSID PortfolioCreated event occurs.

  1. Sign in to the LUSID web app as a user with suitable permissions.

  2. From the top left menu, select Notifications Management > Subscriptions.

  3. Locate the you wish to create a notification for, and click the Create Notification icon.

  4. Select SMS as the notification type.

  5. Specify:

    • A Display name to uniquely identify the notification.

    • The SMS body.

      Note: You can use the Add template field dropdown to insert runtime values from the event subscription as mustache templates, making the text more meaningful.

    • The phone numbers of the intended notification recipients. You can specify up to 10 recipients.

  6. Click Create to save the notification.

Note

You must ensure the notification’s subscription is enabled in order to receive notifications for the event.

Currently, you can create one notification per API call. Note you must have already subscribed to the event you want to attach the SMS notification to.

  1. Obtain an API access token.

  2. Call the CreateNotification API, passing in your API access token and:

    • The scope and code of the subscription to attach it to.

    • A body. You can use attributes of the subscribed event in mustache templates to make the text more meaningful.

    • A comma-separated list of phone numbers. You can specify up to 10 recipients.

    For example, to attach an SMS notification to a subscription with the scope PortfolioEvents and code PortfolioCreated:

    curl -X POST "https://<your-domain>.lusid.com/notification/api/subscriptions/PortfolioEvents/PortfolioCreatedEvent/notifications" 
        -H "Authorization: Bearer <your-API-access-token>" 
        -H "Content-Type: application/json" 
        -d '{
          "notificationId": "PortfolioCreatedSmsNotification",
          "displayName": "SmsNotification",
          "notificationType": {
            "Type": "Sms",
            "Body": "A portfolio was created with code {{Body.portfolioCode}} in {{Body.portfolioScope}} at {{Header.timestamp}}.",
            "Recipients": [
              "+447000000000"
            ],
          }
        }'
    JSON

    The response is as follows. Note you can use the id of the notification to reference it again in subsequent API calls:

    {
        "notificationId": "PortfolioCreatedSmsNotification",
        "displayName": "SmsNotification",
        "notificationType": {
          "type": "Sms",
          "body": "A portfolio was created with code {{Body.portfolioCode}} in {{Body.portfolioScope}} at {{Header.timestamp}}.",
          "recipients": [
            "+447000000000"
          ]
        },
        "createdAt": "2023-07-14T10:20:29.1903787+00:00",
        "userIdCreated": "00uji4twb7X42sdse2p7",
        "modifiedAt": "2023-07-14T10:20:29.1903787+00:00",
        "userIdModified": "00uji4twb7X42sdse2p7",
        "href": "https://<your-domain>.lusid.com/notification/api/subscriptions/PortfolioEvents/PortfolioCreatedEvent/notifications/PortfolioCreatedSmsNotification"
    }
    JSON