All requests to the Texting Blue API require authentication via an API key passed in the x-api-key header.
Base URL:
https://api.texting.blue/v1
API keys follow the format:
tb_{environment}_{32_random_chars}
| Prefix | Environment | Description |
|---|---|---|
tb_live_ |
Production | Sends real iMessages. Use in production apps. |
tb_test_ |
Sandbox | No messages are delivered. Use during development. |
Example key:
tb_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Each API key is scoped to one or more permissions:
| Permission | Description |
|---|---|
messages:send |
Send iMessages |
messages:read |
Read message history |
webhooks:manage |
Create, update, and delete webhooks |
numbers:read |
List phone numbers |
numbers:write |
Add, remove, and update numbers |
* |
All permissions |
- Log in to the Texting Blue dashboard.
- Navigate to Settings > API Keys.
- Click Create API Key.
- Select the permissions you need and give the key a descriptive label.
- Copy the key immediately -- it is shown only once.
- Go to Settings > API Keys in the dashboard.
- Find the key you want to revoke.
- Click Revoke and confirm.
Revoked keys are rejected immediately. Any in-flight requests using the revoked key will fail with a 401 error.
Include your API key in the x-api-key header on every request.
curl -X GET https://api.texting.blue/v1/messages \
-H "x-api-key: tb_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"const response = await fetch("https://api.texting.blue/v1/messages", {
headers: {
"x-api-key": "tb_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
},
});
const data = await response.json();import requests
response = requests.get(
"https://api.texting.blue/v1/messages",
headers={"x-api-key": "tb_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"},
)
data = response.json()$ch = curl_init("https://api.texting.blue/v1/messages");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"x-api-key: tb_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);| HTTP Status | Code | Description |
|---|---|---|
| 401 | unauthorized |
The API key is missing, invalid, or has been revoked. |
| 403 | forbidden |
The API key does not have the required permission for this endpoint. |
{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}{
"error": {
"code": "forbidden",
"message": "Your API key does not have the 'messages:send' permission."
}
}