Notifications API
To retrieve a list of all supported notification configuration types, send a GET request to the resource.
Sample Request
Sample Response
{
"allowed_config_type_list" : [
"slack",
"chime",
"webhook",
"email",
"sns",
"ses_account",
"smtp_account",
"email_group"
],
"plugin_features" : {
"tooltip_support" : "true"
}
}
List all notification configurations
To retrieve a list of all notification configurations, send a GET request to the configs
resource.
Sample Request
GET _plugins/_notifications/configs
Sample Response
{
"start_index" : 0,
"total_hits" : 2,
"total_hit_relation" : "eq",
"config_list" : [
{
"config_id" : "sample-id",
"last_updated_time_ms" : 1652760532774,
"created_time_ms" : 1652760532774,
"config" : {
"name" : "Sample Slack Channel",
"description" : "This is a Slack channel",
"config_type" : "slack",
"is_enabled" : true,
"slack" : {
"url" : "https://sample-slack-webhook"
}
}
},
{
"config_id" : "sample-id2",
"last_updated_time_ms" : 1652760735380,
"created_time_ms" : 1652760735380,
"config" : {
"name" : "Test chime channel",
"description" : "A test chime channel",
"config_type" : "chime",
"is_enabled" : true,
"chime" : {
"url" : "https://sample-chime-webhook"
}
}
]
}
To filter the notification configuration types this request returns, you can refine your query with the following optional path parameters.
Sample Request
POST /_plugins/_notifications/configs/
{
"config_id": "sample-id",
"name": "sample-name",
"config": {
"name": "Sample Slack Channel",
"description": "This is a Slack channel",
"config_type": "slack",
"is_enabled": true,
"slack": {
"url": "https://sample-slack-webhook"
}
}
The create channel API operation accepts the following fields in its request body:
Field | Data Type | Description | Required |
---|---|---|---|
config_id | String | The configuration’s custom ID. | No |
config | Object | Contains all relevant information, such as channel name, configuration type, and plugin source. | Yes |
name | String | Name of the channel. | Yes |
description | String | The channel’s description. | No |
config_type | String | The destination of your notification. Valid options are sns , slack , chime , webhook , smtp_account , ses_account , email_group , and email . | Yes |
is_enabled | Boolean | Indicates whether the channel is enabled for sending and receiving notifications. Default is true. | No |
The create channel operation accepts multiple config_types
as possible notification destinations, so follow the format for your preferred config_type
.
"sns": {
"topic_arn": "<arn>",
"role_arn": "<arn>" //optional
}
"slack": {
"url": "https://sample-chime-webhoook"
}
"chime": {
"url": "https://sample-amazon-chime-webhoook"
}
"webhook": {
"url": "https://custom-webhook-test-url.com:8888/test-path?params1=value1¶ms2=value2"
}
"smtp_account": {
"host": "test-host.com",
"port": 123,
"method": "start_tls",
"from_address": "test@email.com"
}
"ses_account": {
"region": "us-east-1",
"role_arn": "arn:aws:iam::012345678912:role/NotificationsSESRole",
"from_address": "test@email.com"
}
"email_group": { //Email recipient group
"recipient_list": [
{
"recipient": "test-email1@test.com"
},
{
"recipient": "test-email2@test.com"
}
]
}
"email": { //The channel that sends emails
"email_account_id": "<smtp or ses account config id>",
"recipient_list": [
{
"recipient": "custom.email@test.com"
}
],
"email_group_id_list": []
}
The following example demonstrates how to create a channel using email as a config_type
:
Sample Response
{
"config_id" : "<config_id>"
}
Get channel configuration
Sample Request
GET _plugins/_notifications/configs/<config_id>
Sample Response
{
"start_index" : 0,
"total_hits" : 1,
"total_hit_relation" : "eq",
"config_list" : [
{
"config_id" : "sample-id",
"last_updated_time_ms" : 1652760532774,
"config" : {
"name" : "Sample Slack Channel",
"description" : "This is a Slack channel",
"is_enabled" : true,
"slack" : {
"url" : "https://sample-slack-webhook"
}
}
}
]
}
To update a channel configuration, send a POST request to the configs
resource and specify the channel’s config_id
as a path parameter. Specify the new configuration details in the request body.
Sample Request
PUT _plugins/_notifications/configs/<config_id>
{
"config": {
"name": "Slack Channel",
"description": "This is an updated channel configuration",
"config_type": "slack",
"is_enabled": true,
"slack": {
"url": "https://hooks.slack.com/sample-url"
}
}
}
Sample Response
{
"config_id" : "<config_id>"
}
Delete channel configuration
To delete a channel configuration, send a DELETE request to the configs
resource and specify the config_id
as a path parameter.
Sample Request
Sample Response
{
"delete_response_list" : {
"<config_id>" : "OK"
}
}
You can also submit a comma-separated list of channel IDs you want to delete, and OpenSearch deletes all of the specified notification channels.
Sample Request
DELETE /_plugins/_notifications/configs/?config_id_list=<config_id1>,<config_id2>,<config_id3>...
Sample Response
{
"delete_response_list" : {
"<config_id1>" : "OK",
"<config_id2>" : "OK",
"<config_id3>" : "OK"
}
}
Sample Request
GET _plugins/_notifications/feature/test/<config_id>
Sample Response
{
"event_source" : {
"title" : "Test Message Title-0Jnlh4ABa4TCWn5C5H2G",
"reference_id" : "0Jnlh4ABa4TCWn5C5H2G",
"severity" : "info",
"tags" : [ ]
},
"status_list" : [
{
"config_id" : "0Jnlh4ABa4TCWn5C5H2G",
"config_type" : "slack",
"config_name" : "sample-id",
"email_recipient_status" : [ ],
"delivery_status" : {
"status_code" : "200",
"status_text" : """<!doctype html>
<html>
<head>
</head>
<body>
<div>
<h1>Example Domain</h1>
<p>Sample paragraph.</p>
<p><a href="sample.example.com">TO BE OR NOT TO BE, THAT IS THE QUESTION</a></p>
</div>
</body>
</html>
"""
}
}