Alerts API
Create an alert
Create a monitoring alert for a project, including Limits alerts.
POST
/
api
/
v1
/
projects
/
{projectRef}
/
monitoring-alerts
Create an alert
curl --request POST \
--url https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts \
--header 'Content-Type: application/json' \
--data '
{
"capabilityKey": "<string>",
"environment": "<string>",
"branch": "<string>",
"params": {
"windowSec": 123
},
"condition": {
"components": [
"<string>"
],
"compositeMode": {},
"signals": [
{}
],
"params": {}
},
"notifiers": [
{}
],
"behavior": {},
"name": "<string>"
}
'import requests
url = "https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts"
payload = {
"capabilityKey": "<string>",
"environment": "<string>",
"branch": "<string>",
"params": { "windowSec": 123 },
"condition": {
"components": ["<string>"],
"compositeMode": {},
"signals": [{}],
"params": {}
},
"notifiers": [{}],
"behavior": {},
"name": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
capabilityKey: '<string>',
environment: '<string>',
branch: '<string>',
params: {windowSec: 123},
condition: {components: ['<string>'], compositeMode: {}, signals: [{}], params: {}},
notifiers: [{}],
behavior: {},
name: '<string>'
})
};
fetch('https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'capabilityKey' => '<string>',
'environment' => '<string>',
'branch' => '<string>',
'params' => [
'windowSec' => 123
],
'condition' => [
'components' => [
'<string>'
],
'compositeMode' => [
],
'signals' => [
[
]
],
'params' => [
]
],
'notifiers' => [
[
]
],
'behavior' => [
],
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts"
payload := strings.NewReader("{\n \"capabilityKey\": \"<string>\",\n \"environment\": \"<string>\",\n \"branch\": \"<string>\",\n \"params\": {\n \"windowSec\": 123\n },\n \"condition\": {\n \"components\": [\n \"<string>\"\n ],\n \"compositeMode\": {},\n \"signals\": [\n {}\n ],\n \"params\": {}\n },\n \"notifiers\": [\n {}\n ],\n \"behavior\": {},\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts")
.header("Content-Type", "application/json")
.body("{\n \"capabilityKey\": \"<string>\",\n \"environment\": \"<string>\",\n \"branch\": \"<string>\",\n \"params\": {\n \"windowSec\": 123\n },\n \"condition\": {\n \"components\": [\n \"<string>\"\n ],\n \"compositeMode\": {},\n \"signals\": [\n {}\n ],\n \"params\": {}\n },\n \"notifiers\": [\n {}\n ],\n \"behavior\": {},\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"capabilityKey\": \"<string>\",\n \"environment\": \"<string>\",\n \"branch\": \"<string>\",\n \"params\": {\n \"windowSec\": 123\n },\n \"condition\": {\n \"components\": [\n \"<string>\"\n ],\n \"compositeMode\": {},\n \"signals\": [\n {}\n ],\n \"params\": {}\n },\n \"notifiers\": [\n {}\n ],\n \"behavior\": {},\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyPrivate beta. This feature is only available to some organizations right now.
Body
string
required
What to alert on. Use
limits.all for a combined Limits alert, or a single limit such as limits.api,
limits.concurrency, limits.queue, limits.webhooks.processing,
limits.webhooks.env_rate, limits.webhooks.endpoint_rate or limits.webhooks.waiters.string
required
One of
dev, staging, prod or preview.string
Preview branch. Only valid when
environment is preview.object
required
For Limits alerts, set
kind to state and stateKey to the same value as capabilityKey.Show properties
Show properties
string[]
limits.all only. The limits to watch. Defaults to all of them. Values are the single limit
capability keys above."any" | "all"
limits.all only. Raise when any selected limit is true, or only when all are.("approaching" | "limited")[]
Which limit signals to watch.
approaching means usage has reached the utilisation share;
limited means the limit is already affecting traffic. limits.queue only supports
approaching.object
Thresholds, for example
utilisationPct (default 80, from 1 to 100).object[]
required
At least one notifier, for example
{ "type": "channel", "channelId": "..." }.object
required
Optional
expiresAt (ISO 8601 date in the future).string
A name for the alert.
components or signals return a 400 with an error message.
Examples
Watch every limit and raise when any is true:curl -X POST "https://api.trigger.dev/api/v1/projects/proj_1234/monitoring-alerts" \
-H "Authorization: Bearer $TRIGGER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"capabilityKey": "limits.all",
"environment": "prod",
"params": { "windowSec": 300 },
"condition": {
"kind": "state",
"stateKey": "limits.all",
"compositeMode": "any",
"signals": ["approaching", "limited"],
"params": { "utilisationPct": 80 }
},
"behavior": {},
"notifiers": [{ "type": "channel", "channelId": "channel_1234" }]
}'
curl -X POST "https://api.trigger.dev/api/v1/projects/proj_1234/monitoring-alerts" \
-H "Authorization: Bearer $TRIGGER_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"capabilityKey": "limits.api",
"environment": "prod",
"params": { "windowSec": 300 },
"condition": {
"kind": "state",
"stateKey": "limits.api",
"signals": ["approaching"],
"params": { "utilisationPct": 90 }
},
"behavior": {},
"notifiers": [{ "type": "channel", "channelId": "channel_1234" }]
}'
Was this page helpful?
⌘I
Create an alert
curl --request POST \
--url https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts \
--header 'Content-Type: application/json' \
--data '
{
"capabilityKey": "<string>",
"environment": "<string>",
"branch": "<string>",
"params": {
"windowSec": 123
},
"condition": {
"components": [
"<string>"
],
"compositeMode": {},
"signals": [
{}
],
"params": {}
},
"notifiers": [
{}
],
"behavior": {},
"name": "<string>"
}
'import requests
url = "https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts"
payload = {
"capabilityKey": "<string>",
"environment": "<string>",
"branch": "<string>",
"params": { "windowSec": 123 },
"condition": {
"components": ["<string>"],
"compositeMode": {},
"signals": [{}],
"params": {}
},
"notifiers": [{}],
"behavior": {},
"name": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
capabilityKey: '<string>',
environment: '<string>',
branch: '<string>',
params: {windowSec: 123},
condition: {components: ['<string>'], compositeMode: {}, signals: [{}], params: {}},
notifiers: [{}],
behavior: {},
name: '<string>'
})
};
fetch('https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'capabilityKey' => '<string>',
'environment' => '<string>',
'branch' => '<string>',
'params' => [
'windowSec' => 123
],
'condition' => [
'components' => [
'<string>'
],
'compositeMode' => [
],
'signals' => [
[
]
],
'params' => [
]
],
'notifiers' => [
[
]
],
'behavior' => [
],
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts"
payload := strings.NewReader("{\n \"capabilityKey\": \"<string>\",\n \"environment\": \"<string>\",\n \"branch\": \"<string>\",\n \"params\": {\n \"windowSec\": 123\n },\n \"condition\": {\n \"components\": [\n \"<string>\"\n ],\n \"compositeMode\": {},\n \"signals\": [\n {}\n ],\n \"params\": {}\n },\n \"notifiers\": [\n {}\n ],\n \"behavior\": {},\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts")
.header("Content-Type", "application/json")
.body("{\n \"capabilityKey\": \"<string>\",\n \"environment\": \"<string>\",\n \"branch\": \"<string>\",\n \"params\": {\n \"windowSec\": 123\n },\n \"condition\": {\n \"components\": [\n \"<string>\"\n ],\n \"compositeMode\": {},\n \"signals\": [\n {}\n ],\n \"params\": {}\n },\n \"notifiers\": [\n {}\n ],\n \"behavior\": {},\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trigger.dev/api/v1/projects/{projectRef}/monitoring-alerts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"capabilityKey\": \"<string>\",\n \"environment\": \"<string>\",\n \"branch\": \"<string>\",\n \"params\": {\n \"windowSec\": 123\n },\n \"condition\": {\n \"components\": [\n \"<string>\"\n ],\n \"compositeMode\": {},\n \"signals\": [\n {}\n ],\n \"params\": {}\n },\n \"notifiers\": [\n {}\n ],\n \"behavior\": {},\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body
