curl -X POST https://api.magpipe.ai/functions/v1/list-messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"limit": 20,
"phone_number": "+14155551234"
}'
const response = await fetch(
'https://api.magpipe.ai/functions/v1/list-messages',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
limit: 20,
phone_number: '+14155551234'
}),
}
);
const { messages, total } = await response.json();
console.log(`Found ${total} messages`);
import requests
response = requests.post(
'https://api.magpipe.ai/functions/v1/list-messages',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
json={
'limit': 20,
'phone_number': '+14155551234'
}
)
data = response.json()
print(f"Found {data['total']} messages")
{
"messages": [
{
"id": "8e4f9a00-c3d4-6e5f-1a2b-890123cdef01",
"thread_id": "a17b4735-15d2-5274-9460-74f8554172cb",
"from_number": "+16045551234",
"to_number": "+14155551234",
"body": "Your appointment is confirmed for tomorrow at 2pm.",
"direction": "outbound",
"status": "delivered",
"is_ai_generated": false,
"created_at": "2024-01-15T10:30:00Z",
"media": [],
"delivery_error": null
},
{
"id": "7d3e8b00-b2c3-5d4e-0a1b-789012bcde01",
"thread_id": "a17b4735-15d2-5274-9460-74f8554172cb",
"from_number": "+14155551234",
"to_number": "+16045551234",
"body": "Thank you! I'll be there.",
"direction": "inbound",
"status": "delivered",
"is_ai_generated": false,
"created_at": "2024-01-15T10:35:00Z",
"media": [],
"delivery_error": null
},
{
"id": "6c2d7a00-a1b2-4c3d-9f0a-678901abcd01",
"thread_id": "f0e1d2c3-b4a5-5968-8776-554433221100",
"from_number": "+16045551234",
"to_number": "+14155550000",
"body": "Reminder: your invoice is due.",
"direction": "outbound",
"status": "undelivered",
"is_ai_generated": false,
"created_at": "2024-01-15T10:40:00Z",
"media": [],
"delivery_error": {
"code": "30003",
"reason": "Unreachable destination handset",
"at": "2024-01-15T10:40:05Z"
}
}
],
"total": 42,
"has_more": true
}
Messages
List Messages
List SMS messages with filtering and pagination
POST
/
list-messages
curl -X POST https://api.magpipe.ai/functions/v1/list-messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"limit": 20,
"phone_number": "+14155551234"
}'
const response = await fetch(
'https://api.magpipe.ai/functions/v1/list-messages',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
limit: 20,
phone_number: '+14155551234'
}),
}
);
const { messages, total } = await response.json();
console.log(`Found ${total} messages`);
import requests
response = requests.post(
'https://api.magpipe.ai/functions/v1/list-messages',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
json={
'limit': 20,
'phone_number': '+14155551234'
}
)
data = response.json()
print(f"Found {data['total']} messages")
{
"messages": [
{
"id": "8e4f9a00-c3d4-6e5f-1a2b-890123cdef01",
"thread_id": "a17b4735-15d2-5274-9460-74f8554172cb",
"from_number": "+16045551234",
"to_number": "+14155551234",
"body": "Your appointment is confirmed for tomorrow at 2pm.",
"direction": "outbound",
"status": "delivered",
"is_ai_generated": false,
"created_at": "2024-01-15T10:30:00Z",
"media": [],
"delivery_error": null
},
{
"id": "7d3e8b00-b2c3-5d4e-0a1b-789012bcde01",
"thread_id": "a17b4735-15d2-5274-9460-74f8554172cb",
"from_number": "+14155551234",
"to_number": "+16045551234",
"body": "Thank you! I'll be there.",
"direction": "inbound",
"status": "delivered",
"is_ai_generated": false,
"created_at": "2024-01-15T10:35:00Z",
"media": [],
"delivery_error": null
},
{
"id": "6c2d7a00-a1b2-4c3d-9f0a-678901abcd01",
"thread_id": "f0e1d2c3-b4a5-5968-8776-554433221100",
"from_number": "+16045551234",
"to_number": "+14155550000",
"body": "Reminder: your invoice is due.",
"direction": "outbound",
"status": "undelivered",
"is_ai_generated": false,
"created_at": "2024-01-15T10:40:00Z",
"media": [],
"delivery_error": {
"code": "30003",
"reason": "Unreachable destination handset",
"at": "2024-01-15T10:40:05Z"
}
}
],
"total": 42,
"has_more": true
}
Retrieve a paginated list of messages for your account. Supports filtering by direction, phone number, and date range.
Request Body
integer
default:50
Maximum number of messages to return. Max: 100.
integer
default:0
Number of messages to skip for pagination.
string
Filter by message direction:
inbound or outbound.string
Filter by phone number (either from or to).
string
Filter messages after this ISO 8601 date.
string
Filter messages before this ISO 8601 date.
Response
array
Array of message objects. Each carries a
thread_id (stable conversation id — same for every message between a contact and service number), a media array (attachments with 24h-signed url, mime_type, kind, caption; empty when none), and a delivery_error object (code, reason, at) when status is failed or undelivered, otherwise null. See Get Message for the full per-message shape.integer
Total number of messages matching the filters.
boolean
Whether there are more messages to paginate through.
curl -X POST https://api.magpipe.ai/functions/v1/list-messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"limit": 20,
"phone_number": "+14155551234"
}'
const response = await fetch(
'https://api.magpipe.ai/functions/v1/list-messages',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
limit: 20,
phone_number: '+14155551234'
}),
}
);
const { messages, total } = await response.json();
console.log(`Found ${total} messages`);
import requests
response = requests.post(
'https://api.magpipe.ai/functions/v1/list-messages',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
json={
'limit': 20,
'phone_number': '+14155551234'
}
)
data = response.json()
print(f"Found {data['total']} messages")
{
"messages": [
{
"id": "8e4f9a00-c3d4-6e5f-1a2b-890123cdef01",
"thread_id": "a17b4735-15d2-5274-9460-74f8554172cb",
"from_number": "+16045551234",
"to_number": "+14155551234",
"body": "Your appointment is confirmed for tomorrow at 2pm.",
"direction": "outbound",
"status": "delivered",
"is_ai_generated": false,
"created_at": "2024-01-15T10:30:00Z",
"media": [],
"delivery_error": null
},
{
"id": "7d3e8b00-b2c3-5d4e-0a1b-789012bcde01",
"thread_id": "a17b4735-15d2-5274-9460-74f8554172cb",
"from_number": "+14155551234",
"to_number": "+16045551234",
"body": "Thank you! I'll be there.",
"direction": "inbound",
"status": "delivered",
"is_ai_generated": false,
"created_at": "2024-01-15T10:35:00Z",
"media": [],
"delivery_error": null
},
{
"id": "6c2d7a00-a1b2-4c3d-9f0a-678901abcd01",
"thread_id": "f0e1d2c3-b4a5-5968-8776-554433221100",
"from_number": "+16045551234",
"to_number": "+14155550000",
"body": "Reminder: your invoice is due.",
"direction": "outbound",
"status": "undelivered",
"is_ai_generated": false,
"created_at": "2024-01-15T10:40:00Z",
"media": [],
"delivery_error": {
"code": "30003",
"reason": "Unreachable destination handset",
"at": "2024-01-15T10:40:05Z"
}
}
],
"total": 42,
"has_more": true
}
⌘I