Skip to main content
POST
/
apps
/
{appId}
/
notification-rules
Create Notification Rule
curl --request POST \
  --url https://api.vela.dev/v1/apps/{appId}/notification-rules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "Alert on large payment failure",
  "eventName": "payment.failed",
  "enabled": true,
  "conditions": [
    {
      "id": "cond-1",
      "field": "amountCents",
      "operator": "greater_than",
      "value": 10000
    }
  ],
  "actions": [
    {
      "id": "action-1",
      "destinationId": "dest-uuid",
      "channel": "slack",
      "enabled": true
    }
  ]
}
'
import requests

url = "https://api.vela.dev/v1/apps/{appId}/notification-rules"

payload = {
"name": "Alert on large payment failure",
"eventName": "payment.failed",
"enabled": True,
"conditions": [
{
"id": "cond-1",
"field": "amountCents",
"operator": "greater_than",
"value": 10000
}
],
"actions": [
{
"id": "action-1",
"destinationId": "dest-uuid",
"channel": "slack",
"enabled": True
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Alert on large payment failure',
eventName: 'payment.failed',
enabled: true,
conditions: [{id: 'cond-1', field: 'amountCents', operator: 'greater_than', value: 10000}],
actions: [{id: 'action-1', destinationId: 'dest-uuid', channel: 'slack', enabled: true}]
})
};

fetch('https://api.vela.dev/v1/apps/{appId}/notification-rules', 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.vela.dev/v1/apps/{appId}/notification-rules",
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([
'name' => 'Alert on large payment failure',
'eventName' => 'payment.failed',
'enabled' => true,
'conditions' => [
[
'id' => 'cond-1',
'field' => 'amountCents',
'operator' => 'greater_than',
'value' => 10000
]
],
'actions' => [
[
'id' => 'action-1',
'destinationId' => 'dest-uuid',
'channel' => 'slack',
'enabled' => true
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.vela.dev/v1/apps/{appId}/notification-rules"

payload := strings.NewReader("{\n \"name\": \"Alert on large payment failure\",\n \"eventName\": \"payment.failed\",\n \"enabled\": true,\n \"conditions\": [\n {\n \"id\": \"cond-1\",\n \"field\": \"amountCents\",\n \"operator\": \"greater_than\",\n \"value\": 10000\n }\n ],\n \"actions\": [\n {\n \"id\": \"action-1\",\n \"destinationId\": \"dest-uuid\",\n \"channel\": \"slack\",\n \"enabled\": true\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
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.vela.dev/v1/apps/{appId}/notification-rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Alert on large payment failure\",\n \"eventName\": \"payment.failed\",\n \"enabled\": true,\n \"conditions\": [\n {\n \"id\": \"cond-1\",\n \"field\": \"amountCents\",\n \"operator\": \"greater_than\",\n \"value\": 10000\n }\n ],\n \"actions\": [\n {\n \"id\": \"action-1\",\n \"destinationId\": \"dest-uuid\",\n \"channel\": \"slack\",\n \"enabled\": true\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.vela.dev/v1/apps/{appId}/notification-rules")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Alert on large payment failure\",\n \"eventName\": \"payment.failed\",\n \"enabled\": true,\n \"conditions\": [\n {\n \"id\": \"cond-1\",\n \"field\": \"amountCents\",\n \"operator\": \"greater_than\",\n \"value\": 10000\n }\n ],\n \"actions\": [\n {\n \"id\": \"action-1\",\n \"destinationId\": \"dest-uuid\",\n \"channel\": \"slack\",\n \"enabled\": true\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "rule-uuid",
  "appId": "app-uuid",
  "name": "Alert on large payment failure",
  "eventName": "payment.failed",
  "conditions": [
    {
      "id": "cond-1",
      "field": "amountCents",
      "operator": "greater_than",
      "value": 10000
    }
  ],
  "actions": [
    {
      "id": "action-1",
      "destinationId": "dest-uuid",
      "channel": "slack",
      "target": null,
      "enabled": true
    }
  ],
  "enabled": true,
  "lastTriggeredAt": null,
  "triggerCount": 0,
  "createdAt": "2024-06-01T12:00:00.000Z"
}

Authorizations

Authorization
string
header
required

Client secret for management API access. Format: vela_cs_...

Path Parameters

appId
string
required

App UUID or slug

Body

application/json
name
string
required

Rule display name

eventName
string
required

Event name to watch

conditions
object[]
required

Array of conditions (empty array = trigger on all)

actions
object[]
required

Array of delivery actions

enabled
boolean
default:true

Response

201 - application/json

Rule created

id
string

Rule identifier

appId
string<uuid>
name
string

Rule display name

eventName
string

Event name to watch

conditions
object[]

Conditions to evaluate (empty = trigger on all)

actions
object[]

Delivery actions

enabled
boolean
lastTriggeredAt
string<date-time> | null
triggerCount
integer
createdAt
string<date-time>