curl --request POST \
--url https://api.messages.dev/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "+15551234567",
"to": "+15559876543",
"text": "Hello from Messages.dev!",
"attachments": [
"file_abc123"
],
"reply_to": "msg_abc123"
}
'import requests
url = "https://api.messages.dev/v1/messages"
payload = {
"from": "+15551234567",
"to": "+15559876543",
"text": "Hello from Messages.dev!",
"attachments": ["file_abc123"],
"reply_to": "msg_abc123"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '+15551234567',
to: '+15559876543',
text: 'Hello from Messages.dev!',
attachments: ['file_abc123'],
reply_to: 'msg_abc123'
})
};
fetch('https://api.messages.dev/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.messages.dev/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => '+15551234567',
'to' => '+15559876543',
'text' => 'Hello from Messages.dev!',
'attachments' => [
'file_abc123'
],
'reply_to' => 'msg_abc123'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.messages.dev/v1/messages"
payload := strings.NewReader("{\n \"from\": \"+15551234567\",\n \"to\": \"+15559876543\",\n \"text\": \"Hello from Messages.dev!\",\n \"attachments\": [\n \"file_abc123\"\n ],\n \"reply_to\": \"msg_abc123\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.messages.dev/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"+15551234567\",\n \"to\": \"+15559876543\",\n \"text\": \"Hello from Messages.dev!\",\n \"attachments\": [\n \"file_abc123\"\n ],\n \"reply_to\": \"msg_abc123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.messages.dev/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": \"+15551234567\",\n \"to\": \"+15559876543\",\n \"text\": \"Hello from Messages.dev!\",\n \"attachments\": [\n \"file_abc123\"\n ],\n \"reply_to\": \"msg_abc123\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"status": "pending",
"request_id": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "missing_required_parameter",
"message": "The 'from' query parameter is required.",
"param": "from"
},
"request_id": "req_abc123"
}{
"error": {
"type": "authentication_error",
"code": "missing_api_key",
"message": "Missing Authorization header. Use 'Authorization: Bearer sk_live_...'"
},
"request_id": "req_abc123"
}{
"error": {
"type": "invalid_request_error",
"code": "contact_has_not_messaged",
"message": "Cannot send to a contact who has not messaged this line first.",
"param": "to"
},
"request_id": "req_abc123"
}{
"error": {
"type": "not_found_error",
"code": "line_not_found",
"message": "Line not found.",
"param": "from"
},
"request_id": "req_abc123"
}Send a message
Sends an iMessage or SMS. Returns a delivery ID with status: "pending".
Use GET /outbox or webhooks to track delivery.
Contact-first restriction: outside the sandbox, the recipient must
have messaged your line first. If they haven’t, the request returns
403 contact_has_not_messaged.
Group chats: pass a chat ID (cht_...) returned from GET /v1/chats
as to. Group chats also follow the contact-first rule: at least one
inbound message must have been received in the chat.
Replies: pass reply_to (a msg_... ID or raw iMessage GUID) to
thread a reply to a specific message.
Attachments: upload a file via POST /v1/files and pass its
file_... ID in the attachments array. At least one of text or
attachments is required. To send an audio message that renders as a
native voice-memo balloon, use POST /v1/audio-messages instead. To
send a vCard contact card, upload the .vcf file and pass its file
ID in attachments (no text needed).
curl --request POST \
--url https://api.messages.dev/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "+15551234567",
"to": "+15559876543",
"text": "Hello from Messages.dev!",
"attachments": [
"file_abc123"
],
"reply_to": "msg_abc123"
}
'import requests
url = "https://api.messages.dev/v1/messages"
payload = {
"from": "+15551234567",
"to": "+15559876543",
"text": "Hello from Messages.dev!",
"attachments": ["file_abc123"],
"reply_to": "msg_abc123"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '+15551234567',
to: '+15559876543',
text: 'Hello from Messages.dev!',
attachments: ['file_abc123'],
reply_to: 'msg_abc123'
})
};
fetch('https://api.messages.dev/v1/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.messages.dev/v1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => '+15551234567',
'to' => '+15559876543',
'text' => 'Hello from Messages.dev!',
'attachments' => [
'file_abc123'
],
'reply_to' => 'msg_abc123'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.messages.dev/v1/messages"
payload := strings.NewReader("{\n \"from\": \"+15551234567\",\n \"to\": \"+15559876543\",\n \"text\": \"Hello from Messages.dev!\",\n \"attachments\": [\n \"file_abc123\"\n ],\n \"reply_to\": \"msg_abc123\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.messages.dev/v1/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"+15551234567\",\n \"to\": \"+15559876543\",\n \"text\": \"Hello from Messages.dev!\",\n \"attachments\": [\n \"file_abc123\"\n ],\n \"reply_to\": \"msg_abc123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.messages.dev/v1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": \"+15551234567\",\n \"to\": \"+15559876543\",\n \"text\": \"Hello from Messages.dev!\",\n \"attachments\": [\n \"file_abc123\"\n ],\n \"reply_to\": \"msg_abc123\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"status": "pending",
"request_id": "<string>"
}{
"error": {
"type": "invalid_request_error",
"code": "missing_required_parameter",
"message": "The 'from' query parameter is required.",
"param": "from"
},
"request_id": "req_abc123"
}{
"error": {
"type": "authentication_error",
"code": "missing_api_key",
"message": "Missing Authorization header. Use 'Authorization: Bearer sk_live_...'"
},
"request_id": "req_abc123"
}{
"error": {
"type": "invalid_request_error",
"code": "contact_has_not_messaged",
"message": "Cannot send to a contact who has not messaged this line first.",
"param": "to"
},
"request_id": "req_abc123"
}{
"error": {
"type": "not_found_error",
"code": "line_not_found",
"message": "Line not found.",
"param": "from"
},
"request_id": "req_abc123"
}Authorizations
Use an API key as a bearer token: Authorization: Bearer sk_live_...
Each key has a set of scopes that gate which endpoints it can call:
messages:read, messages:write, chats:read, lines:read,
reactions:read, reactions:write, typing:read, typing:write,
receipts:read, receipts:write, webhooks:read, webhooks:write,
outbox:read, files:read, files:write. Keys can also be restricted
to a subset of lines.
Body
Sender line handle (phone number or Apple ID)
"+15551234567"
Recipient phone number, Apple ID, or chat ID (cht_... for group chats)
"+15559876543"
Message text (at least one of text or attachments required)
"Hello from Messages.dev!"
Array of file IDs (max 1). Upload files via POST /v1/files first.
1["file_abc123"]
Message ID (msg_...) or iMessage GUID to reply to
"msg_abc123"