Skip to contentSkip to navigationSkip to topbar
On this page

Monitor REST API: Alarms


(information)

Info

This API is currently in private beta. To request access, please contact our support team at support@twilio.com.


Overview

overview page anchor

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.


  • Create alarms to monitor metrics like error rates, usage thresholds, or latency.
  • Retrieve alarm configurations and statuses.
  • Update or delete existing alarms programmatically.

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.


Example authorization header

example-authorization-header page anchor
Authorization: Basic {Base64Encoded(AccountSID:AuthToken)}

Create an Alarm

create-an-alarm page anchor

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 NameDescriptionRequired
Idempotency-TokenA unique key you provide for idempotency.Yes

Request Parameters

ParameterDescriptionTypeRequired
friendlyNameA 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.stringYes
descriptionA description of your alarm's purpose. This field is required and cannot be empty.stringYes
queryTypeThe type of query to perform, such as ERROR_CODE, LOG_LEVEL, or ALL. Must be one of the supported query types.stringYes
queryThe 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.stringYes
triggerValueThe 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.integerYes
timeWindowThe 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.stringYes
emailA list of email addresses to notify. Can include up to 25 valid email addresses, each in proper email format (for example, example@domain.com).arrayNo
webhookA URL for webhook notifications. Allows only one URL in a valid URL format, and must be less than 2000 characters.stringNo
consoleIndicatorWhether to enable Console notifications for your alarm. At least one of email, webhook, or console_indicator must be enabled.booleanNo
enabledWhether your alarm is enabled upon creation.booleanYes

Sample Request

1
curl -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": true
16
}'

Sample Response

1
{
2
"sid": "AKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
3
}

Maximum Alarms limit

  • You can create up to 100 alarms per account.
  • If you attempt to create more than 100 alarms, the API will return a 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

1
curl -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

ParameterTypeDescriptionRequiredValidation
friendlyNamestringA user-friendly name for your alarm.YesMust be between 1 and 64 characters, containing only alphanumeric characters and spaces.
descriptionstringA description of your alarm's purpose.YesRequired.
queryTypestringThe type of query to perform, like ERROR_CODE, LOG_LEVEL, or ALL.YesMust be a valid query type.
querystringThe specific error code value or log level.YesMust be a valid error code or log level.
triggerValueintegerThe value that triggers your alarm.YesMust be at least 1 (minimum value: 1).
timeWindowstringThe time window to evaluate your alarm, like FIVE_MINS, FIFTEEN_MINS, ONE_HOUR, TWELVE_HOURS, or ONE_DAY.YesMust be one of the supported time window values.
emailarrayA list of email addresses to notify.NoEach email must be in valid email format.
webhookstringA URL for webhook notifications.NoOnly one URL is allowed. Must be a valid URL format.
consoleIndicatorbooleanWhether to enable console notifications for your alarm.NoAt least one of email, webhook, or console_indicator must be enabled.
enabledbooleanWhether your alarm is enabled.YesRequired.

Sample Request

1
curl -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": true
15
}'

Sample Response

1
{
2
"sid": "AKv2xxxxxxxxxxxxxxxxxxxxxxx"
3
}

DELETE https://monitor.twilio.com/v2/alarms/{AlarmSid}

Delete an existing alarm.

Sample Request

1
curl -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.

CodeMeaningDescription
200OKRequest succeeded.
201CreatedAlarm was successfully created.
204No ContentAlarm was successfully deleted.
400Bad RequestInvalid input or missing required fields.
401UnauthorizedInvalid credentials.
404Not FoundAlarm or resource doesn't exist.
409ConflictAccount exhausted the limit of number of alarms.
500Internal Server ErrorAn error occurred on the server.

  • Use descriptive names for your alarms to quickly identify them.
  • Test your webhook endpoint to ensure it handles alerts reliably.
  • Regularly review and update your alarm configurations to match your system's needs.
  • Keep track of the number of alarms you create to ensure you don't exceed the limit of 100 alarms.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.