This API is currently in private beta. To request access, please contact our support team at support@twilio.com.
The Alarms API enables you to monitor and manage Twilio resources by setting up, retrieving, updating, and deleting alarms for specific metrics. With this API, you can stay informed about critical issues and automate responses to ensure your applications run smoothly.
After reading this document, you will be able to use the Alarms API to create, retrieve, update, and delete alarms for monitoring your Twilio resources.
https://monitor.twilio.com/v2/alarms
The Alarms API uses the same HTTP Basic Authentication as other Twilio APIs. Use your Twilio Account SID as your username and your Auth Token as your password.
POST https://monitor.twilio.com/v2/alarms
Create a new alarm configuration with specified parameters. This operation is idempotent, ensuring that repeated requests with the same Idempotency-Token will not create duplicate alarms.
Headers
Header Name | Description | Required |
---|---|---|
Idempotency-Token | A unique key you provide for idempotency. | Yes |
Request Parameters
Parameter | Description | Type | Required |
---|---|---|---|
friendlyName | A user-friendly name for your alarm. It must be between 1 and 64 characters long, containing only alphanumeric characters and spaces, and cannot be empty. | string | Yes |
description | A description of your alarm's purpose. This field is required and cannot be empty. | string | Yes |
queryType | The type of query to perform, such as ERROR_CODE , LOG_LEVEL , or ALL . Must be one of the supported query types. | string | Yes |
query | The specific query value. For ERROR_CODE , must be a numeric error code. For LOG_LEVEL , it must be either WARNING , ERROR , or INFO . For ALL , typically empty or not required. | string | Yes |
triggerValue | The value that triggers your alarm. Must be an integer of at least 1. If you provide a value below 1, the API will return a 400 Bad Request error. | integer | Yes |
timeWindow | The time window to evaluate your alarm, such as FIVE_MINS , FIFTEEN_MINS , ONE_HOUR , TWELVE_HOURS , or ONE_DAY . Must be one of the supported time window values. | string | Yes |
email | A list of email addresses to notify. Can include up to 25 valid email addresses, each in proper email format (for example, example@domain.com ). | array | No |
webhook | A URL for webhook notifications. Allows only one URL in a valid URL format, and must be less than 2000 characters. | string | No |
consoleIndicator | Whether to enable Console notifications for your alarm. At least one of email , webhook , or console_indicator must be enabled. | boolean | No |
enabled | Whether your alarm is enabled upon creation. | boolean | Yes |
Sample Request
1curl -X POST https://monitor.twilio.com/v2/alarms \2-u "AccountSID:AuthToken" \3-H "Idempotency-Token: 123e4567-e89b-12d3-a456-426614174000" \4-H "Content-Type: application/json" \5-d '{6"friendlyName": "High CPU Usage",7"description": "An alarm for CPU usage exceeding 90%.",8"queryType": "ERROR_CODE",9"query": "404",10"triggerValue": 90,11"timeWindow": "FIVE_MINS",12"email": ["admin@example.com"],13"webhook": "https://example.com/alerts",14"consoleIndicator": true,15"enabled": true16}'
Sample Response
1{2"sid": "AKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"3}
Maximum Alarms limit
409 Conflict
error with a message indicating the limit has been reached.GET https://monitor.twilio.com/v2/alarms/{AlarmSid}
Retrieve details of a specific alarm.
Sample Request
1curl -X GET https://monitor.twilio.com/v2/alarms/AKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \2-u "AccountSID:AuthToken"
Sample Response
1{2"sid": "AKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",3"friendlyName": "High CPU Usage",4"description": "An alarm for CPU usage exceeding 90%.",5"queryType": "ERROR_CODE",6"query": "404",7"triggerValue": 90,8"timeWindow": "FIFTEEN_MINS",9"email": ["admin@example.com"],10"webhook": "https://example.com/alerts",11"consoleIndicator": true,12"enabled": true,13"product": "Multiple"14}
PUT https://monitor.twilio.com/v2/alarms/{AlarmSid}
Update an existing alarm configuration.
Request Parameters
Parameter | Type | Description | Required | Validation |
---|---|---|---|---|
friendlyName | string | A user-friendly name for your alarm. | Yes | Must be between 1 and 64 characters, containing only alphanumeric characters and spaces. |
description | string | A description of your alarm's purpose. | Yes | Required. |
queryType | string | The type of query to perform, like ERROR_CODE , LOG_LEVEL , or ALL . | Yes | Must be a valid query type. |
query | string | The specific error code value or log level. | Yes | Must be a valid error code or log level. |
triggerValue | integer | The value that triggers your alarm. | Yes | Must be at least 1 (minimum value: 1). |
timeWindow | string | The time window to evaluate your alarm, like FIVE_MINS , FIFTEEN_MINS , ONE_HOUR , TWELVE_HOURS , or ONE_DAY . | Yes | Must be one of the supported time window values. |
email | array | A list of email addresses to notify. | No | Each email must be in valid email format. |
webhook | string | A URL for webhook notifications. | No | Only one URL is allowed. Must be a valid URL format. |
consoleIndicator | boolean | Whether to enable console notifications for your alarm. | No | At least one of email , webhook , or console_indicator must be enabled. |
enabled | boolean | Whether your alarm is enabled. | Yes | Required. |
Sample Request
1curl -X PUT https://monitor.twilio.com/v2/alarms/AKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \2-u "AccountSID:AuthToken" \3-H "Content-Type: application/json" \4-d '{5"friendlyName": "High CPU Usage",6"description": "An alarm for CPU usage exceeding 90%.",7"queryType": "ERROR_CODE",8"query": "404",9"triggerValue": 90,10"timeWindow": "FIFTEEN_MINS",11"email": ["admin@example.com"],12"webhook": "https://example.com/alerts",13"consoleIndicator": true,14"enabled": true15}'
Sample Response
1{2"sid": "AKv2xxxxxxxxxxxxxxxxxxxxxxx"3}
DELETE https://monitor.twilio.com/v2/alarms/{AlarmSid}
Delete an existing alarm.
Sample Request
1curl -X DELETE https://monitor.twilio.com/v2/alarms/AKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \2-u "AccountSID:AuthToken"
Sample Response
HTTP Status Code: 204 No Content
The API returns standard HTTP response codes to indicate success or failure.
Code | Meaning | Description |
---|---|---|
200 | OK | Request succeeded. |
201 | Created | Alarm was successfully created. |
204 | No Content | Alarm was successfully deleted. |
400 | Bad Request | Invalid input or missing required fields. |
401 | Unauthorized | Invalid credentials. |
404 | Not Found | Alarm or resource doesn't exist. |
409 | Conflict | Account exhausted the limit of number of alarms. |
500 | Internal Server Error | An error occurred on the server. |