Creating new Slack notification channels with a secure URL

I’m using the HTTP API to create notification channels. I hit /api/alert-notifications with a body that looks something like this:

{
  "disableResolveMessage": false,
  "id": 0,
  "isDefault": false,
  "name": "Slack5",
  "secureFields": {
    "url": true
  },
  "sendReminder": false,
  "settings": {
    "autoResolve": false,
    "recipient": "@joseph.larson",
    "uploadImage": false,
    "url": "https://hooks.slack.com/services/TheRestOfMyURL"
  },
  "type": "slack",
  "uid": "d194A_wGk5"
}

It took a while to figure this out, as I couldn’t find examples. Everything is now working, except the URL field is not being held secure. Within Grafana, listing the channels, I can see the URL. But if I create it via the web GUI, it’s hidden and just shows “Configured”. If I hit save while viewing it, it does an update and becomes secure.

I’m not sure what I’m missing.

I think you should move url to the secureSettings object, like so:

{
  "disableResolveMessage": false,
  "id": 0,
  "isDefault": false,
  "name": "Slack5",
  "secureFields": {},
  "secureSettings: {
    "url": "https://hooks.slack.com/services/TheRestOfMyURL"
  },
  "sendReminder": false,
  "settings": {
    "autoResolve": false,
    "recipient": "@joseph.larson",
    "uploadImage": false
  },
  "type": "slack",
  "uid": "d194A_wGk5"
}

This is how the Web client creates a Slack notification channel.