Create a notification rule
POST /v1/notification-rules
| Property | Value |
|---|---|
| Operation | create_notification_rule |
| Group | Notification rules |
| Scope | messages:write |
| Route class | control |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Audited channels.notification_rule.create (mutation) |
| Released in | 1.60.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Creates a rule at revision 1 (1.60.0): the record event types it delivers, a filter, a Connection and one of its notify tools, every argument but the text fixed, and the template over the event envelope. Every issue is a detail of validation_failed (MessagingIssueCode); a revoked Connection is connection_revoked.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the messages:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/notification-rules" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"name": "<name>",
"event_types": [
"<event_types>"
],
"connection_id": "con_...",
"tool": "<tool>",
"template": "<template>"
}'const response = await fetch(`${process.env.VOCAL_API}/v1/notification-rules`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "<name>",
"event_types": [
"<event_types>"
],
"connection_id": "con_...",
"tool": "<tool>",
"template": "<template>"
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/notification-rules",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"name": "<name>",
"event_types": [
"<event_types>",
],
"connection_id": "con_...",
"tool": "<tool>",
"template": "<template>",
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
idempotency-key | header | string | no | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: NotificationRuleCreateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
connection_id | ConnectionId | yes | |
enabled | boolean | no | True when omitted. |
event_types | array of NotificationEventType | yes | |
filter | string | no | |
fixed_arguments | NotificationArgumentsInput | no | |
name | string | yes | |
template | string | yes | |
tool | UpstreamToolName | yes |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
201 | application/json | NotificationRule | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
409 | application/json | ErrorEnvelope | connection_revoked, idempotency_in_progress, idempotency_key_reused |
422 | application/json | ErrorEnvelope | validation_failed |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 201 answer
The shape is NotificationRule.
| Field | Type | Required | Description |
|---|---|---|---|
connection_id | ConnectionId | yes | |
created_at | Timestamp | yes | |
enabled | boolean | yes | |
event_types | array of NotificationEventType | yes | The record event types it delivers (RECORD_EVENT_TYPES). |
filter | string or null | yes | A ZEN expression over the event envelope; null delivers every event. |
fixed_arguments | NotificationArguments | yes | Every argument but the text, fixed at save, such as the destination channel. |
id | NotificationRuleId | yes | |
name | string | yes | |
object | "notification_rule" | yes | |
organization_id | OrganizationId | yes | |
revision | integer | yes | |
template | string | yes | The text in the closed template language of prompt-manager.md section 3, over the event envelope's fields; in PHI mode the envelope carries identifiers only. |
tool | UpstreamToolName | yes | A notify tool of the Connection's Connector. |
updated_at | Timestamp | yes |