Microsoft Teams
Send and reply to Microsoft Teams alerts via the Alerta v2 API.
Endpoints
| Method | Path | Purpose |
|---|---|---|
POST | /v2/teams/send | Send a new Teams message |
POST | /v2/teams/reply | Reply to an existing Teams message |
Send a Teams Alert
POST /v2/teams/send
Required Fields
channelReftitlemessage
- cURL
- Node
- Python
- Go
- Java
- PHP
- C#
- Rust
- C++
- Elixir
curl --request POST \
--url https://api.alerta.encrisoft.com/v2/teams/send \
--header "content-type: application/json" \
--header "x-api-key: YOUR_API_KEY" \
--header "x-api-secret: YOUR_API_SECRET" \
--data '{
"channelRef": "C_ALT_TEAMS123",
"title": "Database Alert",
"message": "Database replication lag exceeded threshold."
}'
const response = await fetch("https://api.alerta.encrisoft.com/v2/teams/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: "C_ALT_TEAMS123",
title: "Database Alert",
message: "Database replication lag exceeded threshold.",
}),
});
const data = await response.json();
console.log(data);
import os
import requests
response = requests.post(
"https://api.alerta.encrisoft.com/v2/teams/send",
headers={
"content-type": "application/json",
"x-api-key": os.environ["ALERTA_API_KEY"],
"x-api-secret": os.environ["ALERTA_API_SECRET"],
},
json={
"channelRef": "C_ALT_TEAMS123",
"title": "Database Alert",
"message": "Database replication lag exceeded threshold.",
},
timeout=30,
)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
payload := []byte(`{
"channelRef": "C_ALT_TEAMS123",
"title": "Database Alert",
"message": "Database replication lag exceeded threshold."
}`)
req, _ := http.NewRequest(http.MethodPost, "https://api.alerta.encrisoft.com/v2/teams/send", bytes.NewBuffer(payload))
req.Header.Set("content-type", "application/json")
req.Header.Set("x-api-key", os.Getenv("ALERTA_API_KEY"))
req.Header.Set("x-api-secret", os.Getenv("ALERTA_API_SECRET"))
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public final class SendTeamsMessage {
public static void main(String[] args) throws Exception {
String payload = """
{
"channelRef": "C_ALT_TEAMS123",
"title": "Database Alert",
"message": "Database replication lag exceeded threshold."
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.alerta.encrisoft.com/v2/teams/send"))
.header("content-type", "application/json")
.header("x-api-key", System.getenv("ALERTA_API_KEY"))
.header("x-api-secret", System.getenv("ALERTA_API_SECRET"))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$payload = [
"channelRef" => "C_ALT_TEAMS123",
"title" => "Database Alert",
"message" => "Database replication lag exceeded threshold.",
];
$ch = curl_init("https://api.alerta.encrisoft.com/v2/teams/send");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"content-type: application/json",
"x-api-key: " . getenv("ALERTA_API_KEY"),
"x-api-secret: " . getenv("ALERTA_API_SECRET"),
],
CURLOPT_POSTFIELDS => json_encode($payload, JSON_THROW_ON_ERROR),
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch) . PHP_EOL;
curl_close($ch);
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("ALERTA_API_KEY"));
client.DefaultRequestHeaders.Add("x-api-secret", Environment.GetEnvironmentVariable("ALERTA_API_SECRET"));
var json = """
{
"channelRef": "C_ALT_TEAMS123",
"title": "Database Alert",
"message": "Database replication lag exceeded threshold."
}
""";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.alerta.encrisoft.com/v2/teams/send", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
use serde_json::json;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
headers.insert("x-api-key", HeaderValue::from_str(&env::var("ALERTA_API_KEY")?)?);
headers.insert("x-api-secret", HeaderValue::from_str(&env::var("ALERTA_API_SECRET")?)?);
let payload = json!({
"channelRef": "C_ALT_TEAMS123",
"title": "Database Alert",
"message": "Database replication lag exceeded threshold."
});
let response = reqwest::Client::new()
.post("https://api.alerta.encrisoft.com/v2/teams/send")
.headers(headers)
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{response}");
Ok(())
}
#include <curl/curl.h>
int main() {
CURL *curl = curl_easy_init();
if (!curl) return 1;
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, "content-type: application/json");
headers = curl_slist_append(headers, "x-api-key: YOUR_API_KEY");
headers = curl_slist_append(headers, "x-api-secret: YOUR_API_SECRET");
const char *payload =
"{\"channelRef\":\"C_ALT_TEAMS123\",\"title\":\"Database Alert\",\"message\":\"Database replication lag exceeded threshold.\"}";
curl_easy_setopt(curl, CURLOPT_URL, "https://api.alerta.encrisoft.com/v2/teams/send");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}
url = "https://api.alerta.encrisoft.com/v2/teams/send"
headers = [
{"content-type", "application/json"},
{"x-api-key", System.fetch_env!("ALERTA_API_KEY")},
{"x-api-secret", System.fetch_env!("ALERTA_API_SECRET")}
]
body =
Jason.encode!(%{
channelRef: "C_ALT_TEAMS123",
title: "Database Alert",
message: "Database replication lag exceeded threshold."
})
{:ok, response} = Req.post(url, headers: headers, body: body)
IO.puts(response.body)
Sample Response
{
"statusCode": 200,
"message": "Message sent successfully",
"data": {
"messageId": "teams-message-id",
"balance": 90
}
}
Reply To A Teams Message
POST /v2/teams/reply
Required Fields
channelRefrequestReftitlemessage
- cURL
- Node
- Python
- Go
- Java
- PHP
- C#
- Rust
- C++
- Elixir
curl --request POST \
--url https://api.alerta.encrisoft.com/v2/teams/reply \
--header "content-type: application/json" \
--header "x-api-key: YOUR_API_KEY" \
--header "x-api-secret: YOUR_API_SECRET" \
--data '{
"channelRef": "TB_ALT_ZBYD6W5YN0450H4W",
"requestRef": "TBR_ALT_JN26IOOVAKECSKUN",
"title": "Transaction Alert Matthew",
"message": "A suspicious transaction was detected new reply"
}'
const response = await fetch("https://api.alerta.encrisoft.com/v2/teams/reply", {
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: "TB_ALT_ZBYD6W5YN0450H4W",
requestRef: "TBR_ALT_JN26IOOVAKECSKUN",
title: "Transaction Alert Matthew",
message: "A suspicious transaction was detected new reply",
}),
});
const data = await response.json();
console.log(data);
import os
import requests
response = requests.post(
"https://api.alerta.encrisoft.com/v2/teams/reply",
headers={
"content-type": "application/json",
"x-api-key": os.environ["ALERTA_API_KEY"],
"x-api-secret": os.environ["ALERTA_API_SECRET"],
},
json={
"channelRef": "TB_ALT_ZBYD6W5YN0450H4W",
"requestRef": "TBR_ALT_JN26IOOVAKECSKUN",
"title": "Transaction Alert Matthew",
"message": "A suspicious transaction was detected new reply",
},
timeout=30,
)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
payload := []byte(`{
"channelRef": "TB_ALT_ZBYD6W5YN0450H4W",
"requestRef": "TBR_ALT_JN26IOOVAKECSKUN",
"title": "Transaction Alert Matthew",
"message": "A suspicious transaction was detected new reply"
}`)
req, _ := http.NewRequest(http.MethodPost, "https://api.alerta.encrisoft.com/v2/teams/reply", bytes.NewBuffer(payload))
req.Header.Set("content-type", "application/json")
req.Header.Set("x-api-key", os.Getenv("ALERTA_API_KEY"))
req.Header.Set("x-api-secret", os.Getenv("ALERTA_API_SECRET"))
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public final class ReplyTeamsMessage {
public static void main(String[] args) throws Exception {
String payload = """
{
"channelRef": "TB_ALT_ZBYD6W5YN0450H4W",
"requestRef": "TBR_ALT_JN26IOOVAKECSKUN",
"title": "Transaction Alert Matthew",
"message": "A suspicious transaction was detected new reply"
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.alerta.encrisoft.com/v2/teams/reply"))
.header("content-type", "application/json")
.header("x-api-key", System.getenv("ALERTA_API_KEY"))
.header("x-api-secret", System.getenv("ALERTA_API_SECRET"))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$payload = [
"channelRef" => "TB_ALT_ZBYD6W5YN0450H4W",
"requestRef" => "TBR_ALT_JN26IOOVAKECSKUN",
"title" => "Transaction Alert Matthew",
"message" => "A suspicious transaction was detected new reply",
];
$ch = curl_init("https://api.alerta.encrisoft.com/v2/teams/reply");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"content-type: application/json",
"x-api-key: " . getenv("ALERTA_API_KEY"),
"x-api-secret: " . getenv("ALERTA_API_SECRET"),
],
CURLOPT_POSTFIELDS => json_encode($payload, JSON_THROW_ON_ERROR),
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch) . PHP_EOL;
curl_close($ch);
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("ALERTA_API_KEY"));
client.DefaultRequestHeaders.Add("x-api-secret", Environment.GetEnvironmentVariable("ALERTA_API_SECRET"));
var json = """
{
"channelRef": "TB_ALT_ZBYD6W5YN0450H4W",
"requestRef": "TBR_ALT_JN26IOOVAKECSKUN",
"title": "Transaction Alert Matthew",
"message": "A suspicious transaction was detected new reply"
}
""";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.alerta.encrisoft.com/v2/teams/reply", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
use serde_json::json;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
headers.insert("x-api-key", HeaderValue::from_str(&env::var("ALERTA_API_KEY")?)?);
headers.insert("x-api-secret", HeaderValue::from_str(&env::var("ALERTA_API_SECRET")?)?);
let payload = json!({
"channelRef": "TB_ALT_ZBYD6W5YN0450H4W",
"requestRef": "TBR_ALT_JN26IOOVAKECSKUN",
"title": "Transaction Alert Matthew",
"message": "A suspicious transaction was detected new reply"
});
let response = reqwest::Client::new()
.post("https://api.alerta.encrisoft.com/v2/teams/reply")
.headers(headers)
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{response}");
Ok(())
}
#include <curl/curl.h>
int main() {
CURL *curl = curl_easy_init();
if (!curl) return 1;
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, "content-type: application/json");
headers = curl_slist_append(headers, "x-api-key: YOUR_API_KEY");
headers = curl_slist_append(headers, "x-api-secret: YOUR_API_SECRET");
const char *payload =
"{\"channelRef\":\"TB_ALT_ZBYD6W5YN0450H4W\",\"requestRef\":\"TBR_ALT_JN26IOOVAKECSKUN\",\"title\":\"Transaction Alert Matthew\",\"message\":\"A suspicious transaction was detected new reply\"}";
curl_easy_setopt(curl, CURLOPT_URL, "https://api.alerta.encrisoft.com/v2/teams/reply");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}
url = "https://api.alerta.encrisoft.com/v2/teams/reply"
headers = [
{"content-type", "application/json"},
{"x-api-key", System.fetch_env!("ALERTA_API_KEY")},
{"x-api-secret", System.fetch_env!("ALERTA_API_SECRET")}
]
body =
Jason.encode!(%{
channelRef: "TB_ALT_ZBYD6W5YN0450H4W",
requestRef: "TBR_ALT_JN26IOOVAKECSKUN",
title: "Transaction Alert Matthew",
message: "A suspicious transaction was detected new reply"
})
{:ok, response} = Req.post(url, headers: headers, body: body)
IO.puts(response.body)
Sample Response
{
"success": true,
"message": "Teams reply sent successfully.",
"requestRef": "TBR_ALT_JN26IOOVAKECSKUN",
"replyRef": "TBR_ALT_...",
"sentAt": "2026-06-19T10:32:00.000Z"
}
Common Errors
{
"statusCode": 403,
"message": "Missing API key"
}
{
"statusCode": 403,
"message": "Missing API secret"
}
{
"statusCode": 403,
"message": "Invalid API key"
}
{
"statusCode": 403,
"message": "Invalid API secret"
}
{
"statusCode": 403,
"message": "Organization is inactive"
}
{
"statusCode": 400,
"message": "Invalid Channel reference"
}
Teams Notes
- Teams
sendandreplyusechannelRef. - Teams replies require the Alerta
requestRefreturned by the original send request. channelRefis an internal Alerta reference, not the Teams channel name or ID.