Alerting Notification Channels API

Identifier (id) vs unique identifier (uid)

The identifier (id) of a notification channel is an auto-incrementing numeric value and is only unique per Grafana install.

The unique identifier (uid) of a notification channel can be used for uniquely identify a notification channel between multiple Grafana installs. It’s automatically generated if not provided when creating a notification channel. The uid allows having consistent URL’s for accessing notification channels and when syncing notification channels between multiple Grafana installs, see alert notification channel provisioning for more information.

The uid can have a maximum length of 40 characters.

Get all notification channels

Returns all notification channels that the authenticated user has permission to view.

GET /api/alert-notifications

Example Request:

  1. GET /api/alert-notifications HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "id": 1,
  6. "uid": "team-a-email-notifier",
  7. "name": "Team A",
  8. "type": "email",
  9. "isDefault": false,
  10. "sendReminder": false,
  11. "disableResolveMessage": false,
  12. "settings": {
  13. "addresses": "dev@grafana.com"
  14. },
  15. "created": "2018-04-23T14:44:09+02:00",
  16. "updated": "2018-08-20T15:47:49+02:00"
  17. }
  18. ]

Get notification channel by uid

GET /api/alert-notifications/uid/:uid

Will return the notification channel given the notification channel uid.

Example Request:

  1. GET /api/alert-notifications/uid/team-a-email-notifier HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "id": 1,
  5. "uid": "team-a-email-notifier",
  6. "name": "Team A",
  7. "type": "email",
  8. "isDefault": false,
  9. "sendReminder": false,
  10. "disableResolveMessage": false,
  11. "settings": {
  12. "addresses": "dev@grafana.com"
  13. },
  14. "created": "2018-04-23T14:44:09+02:00",
  15. "updated": "2018-08-20T15:47:49+02:00"
  16. }

Get notification channel by id

GET /api/alert-notifications/:id

Will return the notification channel given the notification channel id.

Example Request:

  1. GET /api/alert-notifications/1 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "id": 1,
  5. "uid": "team-a-email-notifier",
  6. "name": "Team A",
  7. "type": "email",
  8. "isDefault": false,
  9. "sendReminder": false,
  10. "disableResolveMessage": false,
  11. "settings": {
  12. "addresses": "dev@grafana.com"
  13. },
  14. "created": "2018-04-23T14:44:09+02:00",
  15. "updated": "2018-08-20T15:47:49+02:00"
  16. }

Create notification channel

You can find the full list of supported notifiers at the alert notifiers page.

POST /api/alert-notifications

Example Request:

  1. POST /api/alert-notifications HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "uid": "new-alert-notification", // optional
  7. "name": "new alert notification", //Required
  8. "type": "email", //Required
  9. "isDefault": false,
  10. "sendReminder": false,
  11. "settings": {
  12. "addresses": "dev@grafana.com"
  13. }
  14. }

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "id": 1,
  5. "uid": "new-alert-notification",
  6. "name": "new alert notification",
  7. "type": "email",
  8. "isDefault": false,
  9. "sendReminder": false,
  10. "settings": {
  11. "addresses": "dev@grafana.com"
  12. },
  13. "created": "2018-04-23T14:44:09+02:00",
  14. "updated": "2018-08-20T15:47:49+02:00"
  15. }

Update notification channel by uid

PUT /api/alert-notifications/uid/:uid

Updates an existing notification channel identified by uid.

Example Request:

  1. PUT /api/alert-notifications/uid/cIBgcSjkk HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "uid": "new-alert-notification", // optional
  7. "name": "new alert notification", //Required
  8. "type": "email", //Required
  9. "isDefault": false,
  10. "sendReminder": true,
  11. "frequency": "15m",
  12. "settings": {
  13. "addresses": "dev@grafana.com"
  14. }
  15. }

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "id": 1,
  5. "uid": "new-alert-notification",
  6. "name": "new alert notification",
  7. "type": "email",
  8. "isDefault": false,
  9. "sendReminder": true,
  10. "frequency": "15m",
  11. "settings": {
  12. "addresses": "dev@grafana.com"
  13. },
  14. "created": "2017-01-01 12:34",
  15. "updated": "2017-01-01 12:34"
  16. }

Update notification channel by id

PUT /api/alert-notifications/:id

Updates an existing notification channel identified by id.

Example Request:

  1. PUT /api/alert-notifications/1 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "id": 1,
  7. "uid": "new-alert-notification", // optional
  8. "name": "new alert notification", //Required
  9. "type": "email", //Required
  10. "isDefault": false,
  11. "sendReminder": true,
  12. "frequency": "15m",
  13. "settings": {
  14. "addresses": "dev@grafana.com"
  15. }
  16. }

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "id": 1,
  5. "uid": "new-alert-notification",
  6. "name": "new alert notification",
  7. "type": "email",
  8. "isDefault": false,
  9. "sendReminder": true,
  10. "frequency": "15m",
  11. "settings": {
  12. "addresses": "dev@grafana.com"
  13. },
  14. "created": "2017-01-01 12:34",
  15. "updated": "2017-01-01 12:34"
  16. }

Delete alert notification by uid

DELETE /api/alert-notifications/uid/:uid

Deletes an existing notification channel identified by uid.

Example Request:

  1. DELETE /api/alert-notifications/uid/team-a-email-notifier HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "message": "Notification deleted"
  5. }

Delete alert notification by id

DELETE /api/alert-notifications/:id

Deletes an existing notification channel identified by id.

Example Request:

  1. DELETE /api/alert-notifications/1 HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "message": "Notification deleted"
  5. }

Test notification channel

Sends a test notification message for the given notification channel type and settings. You can find the full list of supported notifiers at the alert notifiers page.

POST /api/alert-notifications/test

Example Request:

  1. POST /api/alert-notifications/test HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "type": "email",
  7. "settings": {
  8. "addresses": "dev@grafana.com"
  9. }
  10. }

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "message": "Test notification sent"
  5. }