Unable to create Alert using Grafana (v 8.5.4) HTTP API

Hi,

I am trying to create alert using Grafana Dashboard HTTP API but its not working. I can create alert for the same dashboard using UI and when I compare the JSON of alert/panel that was created from UI to the one sent by API, there are no differences. Any idea what are the possible reasons for this?

Here is the dashboard JSON having two panels. One of them has alert created through UI and the other panel has non working alert.

{
	"annotations": {
		"list": [{
			"builtIn": 1,
			"datasource": {
				"type": "grafana",
				"uid": "-- Grafana --"
			},
			"enable": true,
			"hide": true,
			"iconColor": "rgba(0, 211, 255, 1)",
			"name": "Annotations  Alerts",
			"target": {
				"limit": 100,
				"matchAny": false,
				"tags": [],
				"type": "dashboard"
			},
			"type": "dashboard"
		}]
	},
	"editable": true,
	"fiscalYearStartMonth": 0,
	"graphTooltip": 0,
	"id": 143,
	"links": [],
	"liveNow": false,
	"panels": [{
			"alert": {
				"alertRuleTags": {},
				"conditions": [{
					"evaluator": {
						"params": [
							2
						],
						"type": "lt"
					},
					"operator": {
						"type": "and"
					},
					"query": {
						"params": [
							"A",
							"5m",
							"now"
						]
					},
					"reducer": {
						"params": [],
						"type": "count"
					},
					"type": "query"
				}],
				"executionErrorState": "alerting",
				"for": "5m",
				"frequency": "1m",
				"handler": 1,
				"name": "Alert graph for campaign: 24",
				"noDataState": "no_data",
				"notifications": []
			},
			"aliasColors": {},
			"bars": false,
			"dashLength": 10,
			"dashes": false,
			"datasource": {
				"type": "prometheus",
				"uid": "WIwfLiz4k"
			},
			"fieldConfig": {
				"defaults": {
					"links": []
				},
				"overrides": []
			},
			"fill": 1,
			"fillGradient": 0,
			"gridPos": {
				"h": 9,
				"w": 12,
				"x": 0,
				"y": 0
			},
			"hiddenSeries": false,
			"id": 106,
			"legend": {
				"avg": false,
				"current": false,
				"max": false,
				"min": false,
				"show": true,
				"total": false,
				"values": false
			},
			"lines": true,
			"linewidth": 1,
			"nullPointMode": "null",
			"options": {
				"alertThreshold": true
			},
			"percentage": false,
			"pluginVersion": "8.5.4",
			"pointradius": 2,
			"points": false,
			"renderer": "flot",
			"seriesOverrides": [],
			"spaceLength": 10,
			"stack": false,
			"steppedLine": false,
			"targets": [{
				"expr": "sum(rate(request_total{campaign_id=\"24\"}[5m]))",
				"refId": "A",
				"scenarioId": "random_walk"
			}],
			"thresholds": [{
				"colorMode": "critical",
				"fill": true,
				"line": true,
				"op": "gt",
				"value": 50
			}],
			"timeRegions": [],
			"title": "Campaign Requests Graph Alert (Campaign ID = 24)",
			"tooltip": {
				"shared": true,
				"sort": 0,
				"value_type": "individual"
			},
			"type": "graph",
			"xaxis": {
				"mode": "time",
				"show": true,
				"values": []
			},
			"yaxes": [{
					"format": "short",
					"logBase": 1,
					"show": true
				},
				{
					"format": "short",
					"logBase": 1,
					"show": true
				}
			],
			"yaxis": {
				"align": false
			}
		},
		{
			"alert": {
				"alertRuleTags": {},
				"conditions": [{
					"evaluator": {
						"params": [
							2
						],
						"type": "lt"
					},
					"operator": {
						"type": "and"
					},
					"query": {
						"params": [
							"A",
							"5m",
							"now"
						]
					},
					"reducer": {
						"params": [],
						"type": "count"
					},
					"type": "query"
				}],
				"executionErrorState": "alerting",
				"for": "5m",
				"frequency": "1m",
				"handler": 1,
				"name": "Alert graph for campaign: 19",
				"noDataState": "no_data",
				"notifications": []
			},
			"aliasColors": {},
			"bars": false,
			"dashLength": 10,
			"dashes": false,
			"datasource": "Adtech-V2-Dev-Prometheus",
			"fieldConfig": {
				"defaults": {
					"links": []
				},
				"overrides": []
			},
			"fill": 1,
			"fillGradient": 0,
			"gridPos": {
				"h": 9,
				"w": 12,
				"x": 0,
				"y": 9
			},
			"hiddenSeries": false,
			"id": 101,
			"legend": {
				"avg": false,
				"current": false,
				"max": false,
				"min": false,
				"show": true,
				"total": false,
				"values": false
			},
			"lines": true,
			"linewidth": 1,
			"nullPointMode": "null",
			"options": {
				"alertThreshold": true
			},
			"percentage": false,
			"pluginVersion": "8.5.4",
			"pointradius": 2,
			"points": false,
			"renderer": "flot",
			"seriesOverrides": [],
			"spaceLength": 10,
			"stack": false,
			"steppedLine": false,
			"targets": [{
				"expr": "sum(rate(request_total{campaign_id=\"19\"}[5m]))",
				"refId": "A",
				"scenarioId": "random_walk"
			}],
			"thresholds": [{
				"colorMode": "critical",
				"fill": true,
				"line": true,
				"op": "gt",
				"value": 50
			}],
			"timeRegions": [],
			"title": "Requests Graph Alert (Campaign ID = 19)",
			"tooltip": {
				"shared": true,
				"sort": 0,
				"value_type": "individual"
			},
			"type": "graph",
			"xaxis": {
				"mode": "time",
				"show": true,
				"values": []
			},
			"yaxes": [{
					"format": "short",
					"logBase": 1,
					"show": true
				},
				{
					"format": "short",
					"logBase": 1,
					"show": true
				}
			],
			"yaxis": {
				"align": false
			}
		},
		{
			"alert": {
				"alertRuleTags": {},
				"conditions": [{
					"evaluator": {
						"params": [
							2
						],
						"type": "lt"
					},
					"operator": {
						"type": "and"
					},
					"query": {
						"params": [
							"A",
							"5m",
							"now"
						]
					},
					"reducer": {
						"params": [],
						"type": "count"
					},
					"type": "query"
				}],
				"executionErrorState": "alerting",
				"for": "5m",
				"frequency": "1m",
				"handler": 1,
				"name": "Alert graph for campaign: 2",
				"noDataState": "no_data",
				"notifications": []
			},
			"aliasColors": {},
			"bars": false,
			"dashLength": 10,
			"dashes": false,
			"datasource": "Dev-Prometheus",
			"fieldConfig": {
				"defaults": {
					"links": []
				},
				"overrides": []
			},
			"fill": 1,
			"fillGradient": 0,
			"gridPos": {
				"h": 9,
				"w": 12,
				"x": 0,
				"y": 18
			},
			"hiddenSeries": false,
			"id": 88,
			"legend": {
				"avg": false,
				"current": false,
				"max": false,
				"min": false,
				"show": true,
				"total": false,
				"values": false
			},
			"lines": true,
			"linewidth": 1,
			"nullPointMode": "null",
			"options": {
				"alertThreshold": true
			},
			"percentage": false,
			"pluginVersion": "8.5.4",
			"pointradius": 2,
			"points": false,
			"renderer": "flot",
			"seriesOverrides": [],
			"spaceLength": 10,
			"stack": false,
			"steppedLine": false,
			"targets": [{
				"expr": "sum(rate(request_total{campaign_id=\"2\"}[5m]))",
				"refId": "A",
				"scenarioId": "random_walk"
			}],
			"thresholds": [{
				"colorMode": "critical",
				"fill": true,
				"line": true,
				"op": "gt",
				"value": 50
			}],
			"timeRegions": [],
			"title": "Requests Graph Alert working (Campaign ID = 2)",
			"tooltip": {
				"shared": true,
				"sort": 0,
				"value_type": "individual"
			},
			"type": "graph",
			"xaxis": {
				"mode": "time",
				"show": true,
				"values": []
			},
			"yaxes": [{
					"format": "short",
					"logBase": 1,
					"show": true
				},
				{
					"format": "short",
					"logBase": 1,
					"show": true
				}
			],
			"yaxis": {
				"align": false
			}
		}
	],
	"schemaVersion": 36,
	"style": "dark",
	"tags": [],
	"templating": {
		"list": []
	},
	"time": {
		"from": "now-6h",
		"to": "now"
	},
	"timepicker": {},
	"timezone": "",
	"title": "campaigns-alerts",
	"uid": "Y5In-WGVk",
	"version": 28,
	"weekStart": ""
}

development on alerting is moving at light speed. I’d upgrade to 9+ and use the newest provisioning docs

Here are the newest stable API endpoints for provisioning Grafana alerts: