Skip to content

Notification Service – Samples

Sending E-mails with Simple Content

Use the following endpoint to send a simple e-mail:

1
POST /api/notification/v3/publisher/messages

Sample Request payload:

1
2
3
4
5
6
7
8
9
{
    "body":
        {
            "message":"message"
        },
    "recipientsTo":"mail@provider.com;mail@provider-B.com",
    "from":"name",
    "subject":"subject"
}

The recipientTo field accepts multiple recipients separated by semicolons.

Sending E-mail Notifications using a Template

For sending e-mail notifications using templates, the recipients, the e-mail content and a communication category have to be created first.

Creating a Recipient

A recipient is registered using the following endpoint:

1
POST /api/notification/v3/recipient/

For providing valid input for the addresstypeid, refer to the /recipient/addresstype of the Notification Service API Specification.

Sample Request:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "recipientname" : "name",
  "recipientdetail" : [ {
    "address" : "mail@provider.com",
    "addresstypeid" : 2
  },
  {
    "address" : "mail@provider-B.com",
    "addresstypeid" : 1
  } ]
}

Sample Response:

1
806

The response contains the recipientID of the created recipient. Store this information as reference for the following API calls.

Creating a Template for E-Mail Content

The template for e-mail content is created using the following endpoint:

1
POST /api/notification/v3/template/

Refer to the API for this endpoint for detailed information on the request structure and creating placeholders. For providing valid input for the commChannelId, refer to the /communicationchannel/ of the Notification Service API Specification.

Sample template:

1
2
3
<html xmlns:th="http://www.thymeleaf.org" th:inline="text" th:remove="tag">
  Hello [[${name}]]. Please click the URL for more details : <a th:href="${actualurl}">[[${url}]]</a>
</html>

In this template, the name of the recipient and the included URL are the defined placeholders.

Sample response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "templatesetId": 111,
    "templatesetName": "TestTemplateForEmail",
    "templateList": [
        {
            "templateId": 412,
            "commChannelId": 1,
            "commChannelName": "Email"
        }
    ]
}

Store the values of templatesetId and templateId as reference for the following API calls.

Creating a Communication Category

A communication category is created using the following endpoint:

1
POST /api/notification/v3/communicationcategories/

In the following sample request, the recipientID, templatesetId and templateId created in the previous steps are reused.

Sample Request:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
    "msgCategoryName": "category name",
    "subject": "subject",
    "priority":1,
    "from":"name",
    "recipients":[
        {
            "recipientId":807,
            "position":"TO"
        }
    ],
    "templates":[
        {
            "templateId":412,
            "templatesetId":111,
            "commChannelName":"Email"
        }
    ]
}

Sample Response:

1
    642

The response contains the categoryID of the generated communication category. Store this information as reference for the following API call.

Triggering the Notification

For triggering the prepared notification, use the following endpoint:

1
POST /api/notification/v3/publisher/messages

The request must provide the categoryId and define values for the placeholders of the template for the e-mail content. Default recipients for a communication category are defined during its creation, but the recipientTo field accepts additional recipients separated by semicolons.

Sample Request:

1
2
3
4
5
6
7
8
{
  "body" : {
    "placeholderkey1" : "value1",
    "placeholderkey2" : "value2",
        },
    "recipientsTo" : "mail@provider.com",
    "messageCategoryId" :642
}

Sending Push Notifications using a Template

The Notification Service provides the functionality to send push notifications to mobile devices. For sending push notifications using templates, the recipients, the e-mail content and a communication category have to be created first.

Creating a recipient with push notification details

A recipient is registered using the following endpoint:

1
POST /api/notification/v3/recipient/

For providing valid input for the addresstypeid, refer to the /recipient/addresstype of the Notification Service API Specification. The following information must be provided in the address field of the request:

  • appId: Unique device and application specific ID issued by the GCM connection servers, which allows the client app to receive messages.
  • serverApiKey: Unique application specific key of an application, which is stored on the app server and provides authorized access to Google services
  • applicationName: Name of the application, that sends the notifications

Sample Request:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "recipientname" : "PushNotificationTest",
  "recipientdetail" : [{
    "address" : {
            "appId":"id",
            "serverApiKey":"apiKey",
            "applicationName":"app name"
    },
    "addresstypeid" : 7
  } ]
}

Sample Response:

1
807

The response contains the recipientID of the created recipient. Store this information as reference for the following API calls.

Creating a Template for Push Notification Content

The template for e-mail content is created using the following endpoint:

1
POST /api/notification/v3/template/

Refer to the API for this endpoint for detailed information on the request structure and creating placeholders. For providing valid input for the commChannelId, refer to the /communicationchannel/ of the Notification Service API Specification.

Sample template:

1
2
3
<html xmlns:th="http://www.thymeleaf.org" th:inline="text" th:remove="tag">
  Hello [[${name}]]. Please click the URL for more details : <a th:href="${actualurl}">[[${url}]]</a>
</html>

In this template, the name of the recipient and the included URL are the defined placeholders.

Sample response:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "templatesetId": 436,
    "templatesetName": "TestTemplateForPushNotification12",
    "templateList": [
        {
            "templateId": 468,
            "commChannelId": 3,
            "commChannelName": "Push Notification"
        }
    ]
}

Store the values of templatesetId and templateId as reference for the following API calls.

Creating a Communication Category

A communication category is created using the following endpoint:

1
POST /api/notification/v3/communicationcategories/

In the following sample request, the recipientID, templatesetId and templateId created in the previous steps are reused. A subject for the push notification must be provided in the respective field of the request.

Sample Request:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
    "msgCategoryName": "category name",
    "subject": "subject",
    "priority":1,
    "from":"name",
    "recipients":[
        {
            "recipientId":806,
            "position":"TO"
        }
    ] ,
    "templates":[
        {
            "templateId":468,
            "templatesetId":436,
            "commChannelName":"Push Notification"
        }
    ]
}

Sample Response:

1
    642

The response contains the categoryID of the generated communication category. Store this information as reference for the following API call.

Triggering the Notification

For triggering the prepared notification, use the following endpoint:

1
POST /api/notification/v3/publisher/messages

The request must provide the categoryId and define values for the placeholders of the template for the e-mail content. Default recipients for a communication category are defined during its creation, but the recipientTo field accepts additional recipients separated by semicolons.

Sample Request:

1
2
3
4
5
6
7
8
{
    "body" :
    {
        "placeholderkey1" : "value1",
        "placeholderkey2" : "value2",
    },
    "messageCategoryId":642
}

For further details refer to the Notification Service API Specification.

Removing Blocked E-Mail Addresses from the Blacklist

Use the following endpoint:

1
DELETE /api/notification/v3/communicationcategories/bouncedEmailIds

Sample Request:

1
2
3
4
5
6
{
    "body" :
    {
        "emailList" : ["mail@provider.com"]
    }
}

Hint

Use the following endpoint to list all blacklisted e-mail addresses:

1
GET /api/notification/v3/communicationcategories/bouncedEmailIds

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.