Microsoft Teams API
Use this page for Microsoft Teams-only public V2 endpoints.
Authentication
All Teams V2 public endpoints require:
x-api-keyx-api-secretContent-Type: application/json
Base path:
/v2
Rate limit:
180 requests / 60 seconds
Teams Routes
| 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 Message
POST /v2/teams/send
Required Fields
channelReftitlemessage
- cURL
- Node
- Python
- Go
- Java
- PHP
- C#
- Rust
- C++
- Elixir
curl --request POST \
--url https://api.usealerta.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.usealerta.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.usealerta.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.usealerta.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.usealerta.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.usealerta.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.usealerta.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.usealerta.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.usealerta.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.usealerta.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
channelRefteamIdchannelIdmessageIdtitlemessage
- cURL
- Node
- Python
- Go
- Java
- PHP
- C#
- Rust
- C++
- Elixir
curl --request POST \
--url https://api.usealerta.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": "C_ALT_TEAMS123",
"teamId": "team-id",
"channelId": "channel-id",
"messageId": "parent-message-id",
"title": "Reply",
"message": "Acknowledged, investigating now."
}'
const response = await fetch("https://api.usealerta.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: "C_ALT_TEAMS123",
teamId: "team-id",
channelId: "channel-id",
messageId: "parent-message-id",
title: "Reply",
message: "Acknowledged, investigating now.",
}),
});
const data = await response.json();
console.log(data);
import os
import requests
response = requests.post(
"https://api.usealerta.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": "C_ALT_TEAMS123",
"teamId": "team-id",
"channelId": "channel-id",
"messageId": "parent-message-id",
"title": "Reply",
"message": "Acknowledged, investigating now.",
},
timeout=30,
)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
payload := []byte(`{
"channelRef": "C_ALT_TEAMS123",
"teamId": "team-id",
"channelId": "channel-id",
"messageId": "parent-message-id",
"title": "Reply",
"message": "Acknowledged, investigating now."
}`)
req, _ := http.NewRequest(http.MethodPost, "https://api.usealerta.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": "C_ALT_TEAMS123",
"teamId": "team-id",
"channelId": "channel-id",
"messageId": "parent-message-id",
"title": "Reply",
"message": "Acknowledged, investigating now."
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.usealerta.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" => "C_ALT_TEAMS123",
"teamId" => "team-id",
"channelId" => "channel-id",
"messageId" => "parent-message-id",
"title" => "Reply",
"message" => "Acknowledged, investigating now.",
];
$ch = curl_init("https://api.usealerta.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": "C_ALT_TEAMS123",
"teamId": "team-id",
"channelId": "channel-id",
"messageId": "parent-message-id",
"title": "Reply",
"message": "Acknowledged, investigating now."
}
""";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.usealerta.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": "C_ALT_TEAMS123",
"teamId": "team-id",
"channelId": "channel-id",
"messageId": "parent-message-id",
"title": "Reply",
"message": "Acknowledged, investigating now."
});
let response = reqwest::Client::new()
.post("https://api.usealerta.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\":\"C_ALT_TEAMS123\",\"teamId\":\"team-id\",\"channelId\":\"channel-id\",\"messageId\":\"parent-message-id\",\"title\":\"Reply\",\"message\":\"Acknowledged, investigating now.\"}";
curl_easy_setopt(curl, CURLOPT_URL, "https://api.usealerta.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.usealerta.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: "C_ALT_TEAMS123",
teamId: "team-id",
channelId: "channel-id",
messageId: "parent-message-id",
title: "Reply",
message: "Acknowledged, investigating now."
})
{:ok, response} = Req.post(url, headers: headers, body: body)
IO.puts(response.body)
Sample Response
{
"statusCode": 200,
"message": "Reply sent successfully",
"data": {
"balance": 80
}
}
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
teamId,channelId, andmessageId. channelRefis an internal Alerta reference, not the Teams channel name or ID.