Create an alert policy
POST /api/alert/policies
POST /api/alert/policiesInteractive request editor loads with JavaScript.
In: header
Request Body
application/json
Response Body
application/json
application/json
curl -X POST "$API_BASE_URL/api/alert/policies" \ -H "Content-Type: application/json" \ -d '{ "name": "500 status alert", "trigger_logical_operator": "All", "trigger_conditions": [ { "event": "number_of_status_code", "scope": {}, "event_config": { "duration": 60, "unit": "second", "http_status_code": "500" }, "operator": "larger_than", "value": 5 } ] }'Alert policy created successfully.
{
"value": {
"id": "509fd356-df70-480b-8622-c38e27cfdd99",
"created_at": 1742288232,
"updated_at": 1742288235,
"name": "500 status alert",
"desc": "Object description.",
"labels": {
"version": "v2",
"env": "prod"
},
"enable": true,
"check_interval": 1,
"severity": "high",
"trigger_logical_operator": "All",
"trigger_conditions": [
{
"event": "number_of_status_code",
"scope": {
"gateway_group_ids": [
"bd58fce2-b6cc-4d2d-a53c-6ce11b19c101"
],
"gateway_group_labels": {
"version": "v2",
"env": "prod"
},
"service_id": "bd58fce2-b6cc-4d2d-a53c-6ce11b19c101",
"route_id": "bd58fce2-b6cc-4d2d-a53c-6ce11b19c101"
},
"event_config": {
"duration": 60,
"unit": "second",
"http_status_code": "500"
},
"operator": "larger_than",
"value": 5
}
],
"notifications": [
{
"type": "email",
"contact_point_ids": [
"bd58fce2-b6cc-4d2d-a53c-6ce11b19c101"
],
"subject": "API7 Notification",
"content": "The xxx gateway group has received more than 5 responses with 500 status code in the last 60 seconds."
}
],
"debug_sessions": [
{
"max_samples": 100,
"duration_secs": 300,
"sampling_rule": [
[
"status",
">=",
500
]
]
}
]
}
}Bad Request — The request was malformed or contained invalid parameters. Check the error_msg field for details.
{
"value": {},
"error_msg": "error message"
}Complete operation details and schema variants
POST /api/alert/policies
Create an alert policy
Create a new alert policy that defines trigger conditions, evaluation behavior, and notification routing. After creation, the policy can begin generating alert history entries when conditions are met.
Required IAM Permission: Action gateway:CreateAlertPolicy, Resource arn:api7:gateway:alert/*
Parameters
Request body
Content type: application/json
name(string, required): The alert policy name.desc(string, optional): The alert policy description.labels(object, optional): Key-value pairs of labels.enable(boolean, optional): If true, enable the alert policy.check_interval(integer, optional): The check interval for the alert policy. The unit is second.severity(string, optional): The alert severity level.trigger_logical_operator(string, required): The logical relationship between multiple triggers.trigger_conditions(array, required): The alert trigger conditions.- oneOf variant 1: Status Code
trigger_conditions[].event(string, required): The event of the trigger.trigger_conditions[].scope(object, required): The scope of the trigger.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.trigger_conditions[].scope.service_id(string, optional): Published service ID to scope the alert to.trigger_conditions[].scope.route_id(string, optional): Route ID to scope the alert to.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
trigger_conditions[].event_config(object, required): Alert event configurations.trigger_conditions[].event_config.duration(integer, required): The duration time.trigger_conditions[].event_config.unit(string, required): The duration unit.trigger_conditions[].event_config.http_status_code(string, required): The HTTP status code.trigger_conditions[].operator(string, required): The operator for the trigger condition.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.- oneOf variant 2: Certificate Expiry
trigger_conditions[].event(string, required): The event of the trigger.trigger_conditions[].scope(object, required): The scope of the trigger.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
trigger_conditions[].operator(string, required): The operator for the trigger condition.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.trigger_conditions[].value_unit(string, required): The duration unit.- oneOf variant 3: License Expiry
trigger_conditions[].event(string, required): The event of the trigger.trigger_conditions[].operator(string, required): The operator for the trigger condition.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.trigger_conditions[].value_unit(string, required): The duration unit.- oneOf variant 4: Gateway Instance Offline
trigger_conditions[].event(string, required): The event of trigger.trigger_conditions[].scope(object, required): The scope of the trigger.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
trigger_conditions[].operator(string, required): The operator for the trigger condition.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.trigger_conditions[].value_unit(string, required): The duration unit.- oneOf variant 5: Data Plane Cores Exceeded
trigger_conditions[].event(string, optional): The event of trigger.- oneOf variant 6: Numbers of Healthy Gateway Instances
trigger_conditions[].event(string, required): The event of trigger.trigger_conditions[].scope(object, required): The scope of the trigger.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
trigger_conditions[].operator(string, required): The operator for the trigger condition.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.- oneOf variant 7: Shared Dict Free Space Percentage
trigger_conditions[].event(string, required): The event of trigger for shared memory (shared dictionary) free space monitoring in percentage. Applies to all shared dictionaries; the alert reports which one is affected.trigger_conditions[].scope(object, required): The scope of the trigger.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
trigger_conditions[].operator(string, required): The operator for the trigger condition.trigger_conditions[].value(integer, required): The free space percentage threshold to trigger the alert.notifications(array, optional): The alert notifications.- oneOf variant 1: Email
notifications[].type(string, required): The notification type.notifications[].contact_point_ids(array, optional): An array of contact point IDs.notifications[].subject(string, required): The email subject.notifications[].content(string, required): The email content.- oneOf variant 2: Webhook
notifications[].type(string, required): The notification type.notifications[].contact_point_ids(array, optional): An array of contact point IDs.notifications[].alert_message(string, required): The alert message.debug_sessions(array, optional): Debug session configurations to create automatically when the alert is triggered.debug_sessions[].max_samples(integer, required): The maximum number of trace samples to collect.debug_sessions[].duration_secs(integer, required): The duration in seconds for the debug session.debug_sessions[].sampling_rule(array,null, optional): Sampling rules in lua-resty-expr format.
Responses
200: Alert policy created successfully.- allOf variant 1
value(object, optional): The specific resource.- allOf variant 2
value(object, optional): The definition of an alert policy.value.id(string, optional): The alert policy ID.value.created_at(integer, optional): The create timestamp of an alert policy.value.updated_at(integer, optional): The update timestamp of an alert policy.- allOf variant 1
value.name(string, required): The alert policy name.value.desc(string, optional): The alert policy description.value.labels(object, optional): Key-value pairs of labels.value.enable(boolean, optional): If true, enable the alert policy.value.check_interval(integer, optional): The check interval for the alert policy. The unit is second.value.severity(string, optional): The alert severity level.value.trigger_logical_operator(string, required): The logical relationship between multiple triggers.value.trigger_conditions(array, required): The alert trigger conditions.- oneOf variant 1: Status Code
value.trigger_conditions[].event(string, required): The event of the trigger.value.trigger_conditions[].scope(object, required): The scope of the trigger.value.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.value.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.value.trigger_conditions[].scope.service_id(string, optional): Published service ID to scope the alert to.value.trigger_conditions[].scope.route_id(string, optional): Route ID to scope the alert to.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
value.trigger_conditions[].event_config(object, required): Alert event configurations.value.trigger_conditions[].event_config.duration(integer, required): The duration time.value.trigger_conditions[].event_config.unit(string, required): The duration unit.value.trigger_conditions[].event_config.http_status_code(string, required): The HTTP status code.value.trigger_conditions[].operator(string, required): The operator for the trigger condition.value.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.- oneOf variant 2: Certificate Expiry
value.trigger_conditions[].event(string, required): The event of the trigger.value.trigger_conditions[].scope(object, required): The scope of the trigger.value.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.value.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
value.trigger_conditions[].operator(string, required): The operator for the trigger condition.value.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.value.trigger_conditions[].value_unit(string, required): The duration unit.- oneOf variant 3: License Expiry
value.trigger_conditions[].event(string, required): The event of the trigger.value.trigger_conditions[].operator(string, required): The operator for the trigger condition.value.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.value.trigger_conditions[].value_unit(string, required): The duration unit.- oneOf variant 4: Gateway Instance Offline
value.trigger_conditions[].event(string, required): The event of trigger.value.trigger_conditions[].scope(object, required): The scope of the trigger.value.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.value.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
value.trigger_conditions[].operator(string, required): The operator for the trigger condition.value.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.value.trigger_conditions[].value_unit(string, required): The duration unit.- oneOf variant 5: Data Plane Cores Exceeded
value.trigger_conditions[].event(string, optional): The event of trigger.- oneOf variant 6: Numbers of Healthy Gateway Instances
value.trigger_conditions[].event(string, required): The event of trigger.value.trigger_conditions[].scope(object, required): The scope of the trigger.value.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.value.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
value.trigger_conditions[].operator(string, required): The operator for the trigger condition.value.trigger_conditions[].value(integer, required): The numeric threshold to trigger to alert.- oneOf variant 7: Shared Dict Free Space Percentage
value.trigger_conditions[].event(string, required): The event of trigger for shared memory (shared dictionary) free space monitoring in percentage. Applies to all shared dictionaries; the alert reports which one is affected.value.trigger_conditions[].scope(object, required): The scope of the trigger.value.trigger_conditions[].scope.gateway_group_ids(array, optional): An array of gateway group IDs.value.trigger_conditions[].scope.gateway_group_labels(object, optional): Key-value pairs of gateway group labels.- oneOf variant 1: Gateway Group IDs
- oneOf variant 2: Gateway Group Labels
value.trigger_conditions[].operator(string, required): The operator for the trigger condition.value.trigger_conditions[].value(integer, required): The free space percentage threshold to trigger the alert.value.notifications(array, optional): The alert notifications.- oneOf variant 1: Email
value.notifications[].type(string, required): The notification type.value.notifications[].contact_point_ids(array, optional): An array of contact point IDs.value.notifications[].subject(string, required): The email subject.value.notifications[].content(string, required): The email content.- oneOf variant 2: Webhook
value.notifications[].type(string, required): The notification type.value.notifications[].contact_point_ids(array, optional): An array of contact point IDs.value.notifications[].alert_message(string, required): The alert message.value.debug_sessions(array, optional): Debug session configurations to create automatically when the alert is triggered.value.debug_sessions[].max_samples(integer, required): The maximum number of trace samples to collect.value.debug_sessions[].duration_secs(integer, required): The duration in seconds for the debug session.value.debug_sessions[].sampling_rule(array,null, optional): Sampling rules in lua-resty-expr format.400: Bad Request — The request was malformed or contained invalid parameters. Check the error_msg field for details.value(object, optional): The specific resource.error_msg(string, optional): The error message.
cURL
curl -X POST '$API_BASE_URL/api/alert/policies'