Telegram
Send and reply to Telegram alerts via the Alerta v2 API.
Endpoints
| Method | Endpoint | Purpose |
|---|---|---|
POST | /v2/telegram/send | Send a Telegram alert |
POST | /v2/telegram/reply | Reply to a Telegram alert |
POST /v2/telegram/send
Send an alert to a connected Telegram channel.
Required Fields
channelRef— your Alerta channel reference (e.g.TG_ALT_xxxxx)message— the alert body
Optional Fields
title— short summary shown above the messageseverity— e.g.Critical,High,Medium,Low,Infocategory— label for the alert type (e.g.payments,infra)metadata— key/value object for extra context
Request Example
- cURL
- Node
- Python
curl -X POST https://api.alerta.encrisoft.com/v2/telegram/send \
-H "Content-Type: application/json" \
-H "x-api-key: $ALERTA_API_KEY" \
-H "x-api-secret: $ALERTA_API_SECRET" \
-d '{
"channelRef": "TG_ALT_xxxxx",
"title": "Payment Alert",
"message": "Suspicious transaction spike detected.",
"severity": "Critical",
"category": "payments",
"metadata": {
"incidentId": "INC-1192"
}
}'
const response = await fetch("https://api.alerta.encrisoft.com/v2/telegram/send", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.ALERTA_API_KEY,
"x-api-secret": process.env.ALERTA_API_SECRET,
},
body: JSON.stringify({
channelRef: "TG_ALT_xxxxx",
title: "Payment Alert",
message: "Suspicious transaction spike detected.",
severity: "Critical",
category: "payments",
metadata: { incidentId: "INC-1192" },
}),
});
const data = await response.json();
console.log(data);
import os
import requests
response = requests.post(
"https://api.alerta.encrisoft.com/v2/telegram/send",
headers={
"Content-Type": "application/json",
"x-api-key": os.environ["ALERTA_API_KEY"],
"x-api-secret": os.environ["ALERTA_API_SECRET"],
},
json={
"channelRef": "TG_ALT_xxxxx",
"title": "Payment Alert",
"message": "Suspicious transaction spike detected.",
"severity": "Critical",
"category": "payments",
"metadata": {"incidentId": "INC-1192"},
},
timeout=30,
)
print(response.json())
Sample Response
{
"statusCode": 200,
"message": "Message sent successfully",
"data": {
"requestRef": "TGR_ALT_xxxxx",
"requestId": 123
}
}
Save requestRef or requestId from the response if you need to reply to this alert later.
Idempotent Send
Add x-idempotency-key to prevent duplicate deliveries on retry:
curl -X POST https://api.alerta.encrisoft.com/v2/telegram/send \
-H "Content-Type: application/json" \
-H "x-api-key: $ALERTA_API_KEY" \
-H "x-api-secret: $ALERTA_API_SECRET" \
-H "x-idempotency-key: incident-1192-alert-1" \
-d '{
"channelRef": "TG_ALT_xxxxx",
"message": "Suspicious transaction spike detected."
}'
POST /v2/telegram/reply
Reply to a previously sent Telegram alert.
Using requestRef
requestRef— therequestRefvalue returned when the original alert was sentmessage— the reply body
Using requestId
Alternatively, use the numeric requestId from the original send response:
requestId— the numeric ID returned when the original alert was sentmessage— the reply body
Optional Fields
title— short summaryseverity— e.g.Info,Medium,Highcategory— alert category label
Request Example
- Using requestRef
- Using requestId
curl -X POST https://api.alerta.encrisoft.com/v2/telegram/reply \
-H "Content-Type: application/json" \
-H "x-api-key: $ALERTA_API_KEY" \
-H "x-api-secret: $ALERTA_API_SECRET" \
-d '{
"requestRef": "TGR_ALT_xxxxx",
"title": "Update",
"message": "Engineering is investigating.",
"severity": "Info",
"category": "payments"
}'
curl -X POST https://api.alerta.encrisoft.com/v2/telegram/reply \
-H "Content-Type: application/json" \
-H "x-api-key: $ALERTA_API_KEY" \
-H "x-api-secret: $ALERTA_API_SECRET" \
-d '{
"requestId": 123,
"message": "Engineering is investigating."
}'
Sample Response
{
"statusCode": 200,
"message": "Reply sent successfully"
}