curl --request POST \
--url https://api.social-api.ai/v1/inbox/conversations/{id}/messages \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"account_id": "acc_abc123",
"attachment_url": "https://cdn.example.com/photo.jpg",
"attachments": [
{
"source": "550e8400-e29b-41d4-a716-446655440000",
"source_type": "media_id",
"type": "image"
}
],
"buttons": [
{
"payload": "VIEW_ORDER",
"title": "View order",
"type": "url",
"url": "https://shop.example.com/orders/1"
}
],
"cards": [
{
"buttons": [
{
"payload": "VIEW_ORDER",
"title": "View order",
"type": "url",
"url": "https://shop.example.com/orders/1"
}
],
"image_url": "https://cdn.example.com/p.jpg",
"subtitle": "Short description",
"title": "Product name"
}
],
"message_tag": "HUMAN_AGENT",
"quick_replies": [
{
"payload": "TRACK_ORDER",
"title": "Track my order"
}
],
"reply_to_message_id": "m_1234567890",
"text": "Thanks for your message!"
}
'import requests
url = "https://api.social-api.ai/v1/inbox/conversations/{id}/messages"
payload = {
"account_id": "acc_abc123",
"attachment_url": "https://cdn.example.com/photo.jpg",
"attachments": [
{
"source": "550e8400-e29b-41d4-a716-446655440000",
"source_type": "media_id",
"type": "image"
}
],
"buttons": [
{
"payload": "VIEW_ORDER",
"title": "View order",
"type": "url",
"url": "https://shop.example.com/orders/1"
}
],
"cards": [
{
"buttons": [
{
"payload": "VIEW_ORDER",
"title": "View order",
"type": "url",
"url": "https://shop.example.com/orders/1"
}
],
"image_url": "https://cdn.example.com/p.jpg",
"subtitle": "Short description",
"title": "Product name"
}
],
"message_tag": "HUMAN_AGENT",
"quick_replies": [
{
"payload": "TRACK_ORDER",
"title": "Track my order"
}
],
"reply_to_message_id": "m_1234567890",
"text": "Thanks for your message!"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
account_id: 'acc_abc123',
attachment_url: 'https://cdn.example.com/photo.jpg',
attachments: [
{
source: '550e8400-e29b-41d4-a716-446655440000',
source_type: 'media_id',
type: 'image'
}
],
buttons: [
{
payload: 'VIEW_ORDER',
title: 'View order',
type: 'url',
url: 'https://shop.example.com/orders/1'
}
],
cards: [
{
buttons: [
{
payload: 'VIEW_ORDER',
title: 'View order',
type: 'url',
url: 'https://shop.example.com/orders/1'
}
],
image_url: 'https://cdn.example.com/p.jpg',
subtitle: 'Short description',
title: 'Product name'
}
],
message_tag: 'HUMAN_AGENT',
quick_replies: [{payload: 'TRACK_ORDER', title: 'Track my order'}],
reply_to_message_id: 'm_1234567890',
text: 'Thanks for your message!'
})
};
fetch('https://api.social-api.ai/v1/inbox/conversations/{id}/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.social-api.ai/v1/inbox/conversations/{id}/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([
'account_id' => 'acc_abc123',
'attachment_url' => 'https://cdn.example.com/photo.jpg',
'attachments' => [
[
'source' => '550e8400-e29b-41d4-a716-446655440000',
'source_type' => 'media_id',
'type' => 'image'
]
],
'buttons' => [
[
'payload' => 'VIEW_ORDER',
'title' => 'View order',
'type' => 'url',
'url' => 'https://shop.example.com/orders/1'
]
],
'cards' => [
[
'buttons' => [
[
'payload' => 'VIEW_ORDER',
'title' => 'View order',
'type' => 'url',
'url' => 'https://shop.example.com/orders/1'
]
],
'image_url' => 'https://cdn.example.com/p.jpg',
'subtitle' => 'Short description',
'title' => 'Product name'
]
],
'message_tag' => 'HUMAN_AGENT',
'quick_replies' => [
[
'payload' => 'TRACK_ORDER',
'title' => 'Track my order'
]
],
'reply_to_message_id' => 'm_1234567890',
'text' => 'Thanks for your message!'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.social-api.ai/v1/inbox/conversations/{id}/messages"
payload := strings.NewReader("{\n \"account_id\": \"acc_abc123\",\n \"attachment_url\": \"https://cdn.example.com/photo.jpg\",\n \"attachments\": [\n {\n \"source\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"source_type\": \"media_id\",\n \"type\": \"image\"\n }\n ],\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"cards\": [\n {\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"image_url\": \"https://cdn.example.com/p.jpg\",\n \"subtitle\": \"Short description\",\n \"title\": \"Product name\"\n }\n ],\n \"message_tag\": \"HUMAN_AGENT\",\n \"quick_replies\": [\n {\n \"payload\": \"TRACK_ORDER\",\n \"title\": \"Track my order\"\n }\n ],\n \"reply_to_message_id\": \"m_1234567890\",\n \"text\": \"Thanks for your message!\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.social-api.ai/v1/inbox/conversations/{id}/messages")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": \"acc_abc123\",\n \"attachment_url\": \"https://cdn.example.com/photo.jpg\",\n \"attachments\": [\n {\n \"source\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"source_type\": \"media_id\",\n \"type\": \"image\"\n }\n ],\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"cards\": [\n {\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"image_url\": \"https://cdn.example.com/p.jpg\",\n \"subtitle\": \"Short description\",\n \"title\": \"Product name\"\n }\n ],\n \"message_tag\": \"HUMAN_AGENT\",\n \"quick_replies\": [\n {\n \"payload\": \"TRACK_ORDER\",\n \"title\": \"Track my order\"\n }\n ],\n \"reply_to_message_id\": \"m_1234567890\",\n \"text\": \"Thanks for your message!\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.social-api.ai/v1/inbox/conversations/{id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"account_id\": \"acc_abc123\",\n \"attachment_url\": \"https://cdn.example.com/photo.jpg\",\n \"attachments\": [\n {\n \"source\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"source_type\": \"media_id\",\n \"type\": \"image\"\n }\n ],\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"cards\": [\n {\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"image_url\": \"https://cdn.example.com/p.jpg\",\n \"subtitle\": \"Short description\",\n \"title\": \"Product name\"\n }\n ],\n \"message_tag\": \"HUMAN_AGENT\",\n \"quick_replies\": [\n {\n \"payload\": \"TRACK_ORDER\",\n \"title\": \"Track my order\"\n }\n ],\n \"reply_to_message_id\": \"m_1234567890\",\n \"text\": \"Thanks for your message!\"\n}"
response = http.request(request)
puts response.read_body{
"message_id": "m_1234567890",
"message_ids": [
"m_1234567890"
],
"success": true
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}Send a message in a conversation
Sends an outgoing DM via the connected platform account and records it in the conversation.
curl --request POST \
--url https://api.social-api.ai/v1/inbox/conversations/{id}/messages \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"account_id": "acc_abc123",
"attachment_url": "https://cdn.example.com/photo.jpg",
"attachments": [
{
"source": "550e8400-e29b-41d4-a716-446655440000",
"source_type": "media_id",
"type": "image"
}
],
"buttons": [
{
"payload": "VIEW_ORDER",
"title": "View order",
"type": "url",
"url": "https://shop.example.com/orders/1"
}
],
"cards": [
{
"buttons": [
{
"payload": "VIEW_ORDER",
"title": "View order",
"type": "url",
"url": "https://shop.example.com/orders/1"
}
],
"image_url": "https://cdn.example.com/p.jpg",
"subtitle": "Short description",
"title": "Product name"
}
],
"message_tag": "HUMAN_AGENT",
"quick_replies": [
{
"payload": "TRACK_ORDER",
"title": "Track my order"
}
],
"reply_to_message_id": "m_1234567890",
"text": "Thanks for your message!"
}
'import requests
url = "https://api.social-api.ai/v1/inbox/conversations/{id}/messages"
payload = {
"account_id": "acc_abc123",
"attachment_url": "https://cdn.example.com/photo.jpg",
"attachments": [
{
"source": "550e8400-e29b-41d4-a716-446655440000",
"source_type": "media_id",
"type": "image"
}
],
"buttons": [
{
"payload": "VIEW_ORDER",
"title": "View order",
"type": "url",
"url": "https://shop.example.com/orders/1"
}
],
"cards": [
{
"buttons": [
{
"payload": "VIEW_ORDER",
"title": "View order",
"type": "url",
"url": "https://shop.example.com/orders/1"
}
],
"image_url": "https://cdn.example.com/p.jpg",
"subtitle": "Short description",
"title": "Product name"
}
],
"message_tag": "HUMAN_AGENT",
"quick_replies": [
{
"payload": "TRACK_ORDER",
"title": "Track my order"
}
],
"reply_to_message_id": "m_1234567890",
"text": "Thanks for your message!"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
account_id: 'acc_abc123',
attachment_url: 'https://cdn.example.com/photo.jpg',
attachments: [
{
source: '550e8400-e29b-41d4-a716-446655440000',
source_type: 'media_id',
type: 'image'
}
],
buttons: [
{
payload: 'VIEW_ORDER',
title: 'View order',
type: 'url',
url: 'https://shop.example.com/orders/1'
}
],
cards: [
{
buttons: [
{
payload: 'VIEW_ORDER',
title: 'View order',
type: 'url',
url: 'https://shop.example.com/orders/1'
}
],
image_url: 'https://cdn.example.com/p.jpg',
subtitle: 'Short description',
title: 'Product name'
}
],
message_tag: 'HUMAN_AGENT',
quick_replies: [{payload: 'TRACK_ORDER', title: 'Track my order'}],
reply_to_message_id: 'm_1234567890',
text: 'Thanks for your message!'
})
};
fetch('https://api.social-api.ai/v1/inbox/conversations/{id}/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.social-api.ai/v1/inbox/conversations/{id}/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([
'account_id' => 'acc_abc123',
'attachment_url' => 'https://cdn.example.com/photo.jpg',
'attachments' => [
[
'source' => '550e8400-e29b-41d4-a716-446655440000',
'source_type' => 'media_id',
'type' => 'image'
]
],
'buttons' => [
[
'payload' => 'VIEW_ORDER',
'title' => 'View order',
'type' => 'url',
'url' => 'https://shop.example.com/orders/1'
]
],
'cards' => [
[
'buttons' => [
[
'payload' => 'VIEW_ORDER',
'title' => 'View order',
'type' => 'url',
'url' => 'https://shop.example.com/orders/1'
]
],
'image_url' => 'https://cdn.example.com/p.jpg',
'subtitle' => 'Short description',
'title' => 'Product name'
]
],
'message_tag' => 'HUMAN_AGENT',
'quick_replies' => [
[
'payload' => 'TRACK_ORDER',
'title' => 'Track my order'
]
],
'reply_to_message_id' => 'm_1234567890',
'text' => 'Thanks for your message!'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.social-api.ai/v1/inbox/conversations/{id}/messages"
payload := strings.NewReader("{\n \"account_id\": \"acc_abc123\",\n \"attachment_url\": \"https://cdn.example.com/photo.jpg\",\n \"attachments\": [\n {\n \"source\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"source_type\": \"media_id\",\n \"type\": \"image\"\n }\n ],\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"cards\": [\n {\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"image_url\": \"https://cdn.example.com/p.jpg\",\n \"subtitle\": \"Short description\",\n \"title\": \"Product name\"\n }\n ],\n \"message_tag\": \"HUMAN_AGENT\",\n \"quick_replies\": [\n {\n \"payload\": \"TRACK_ORDER\",\n \"title\": \"Track my order\"\n }\n ],\n \"reply_to_message_id\": \"m_1234567890\",\n \"text\": \"Thanks for your message!\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.social-api.ai/v1/inbox/conversations/{id}/messages")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": \"acc_abc123\",\n \"attachment_url\": \"https://cdn.example.com/photo.jpg\",\n \"attachments\": [\n {\n \"source\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"source_type\": \"media_id\",\n \"type\": \"image\"\n }\n ],\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"cards\": [\n {\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"image_url\": \"https://cdn.example.com/p.jpg\",\n \"subtitle\": \"Short description\",\n \"title\": \"Product name\"\n }\n ],\n \"message_tag\": \"HUMAN_AGENT\",\n \"quick_replies\": [\n {\n \"payload\": \"TRACK_ORDER\",\n \"title\": \"Track my order\"\n }\n ],\n \"reply_to_message_id\": \"m_1234567890\",\n \"text\": \"Thanks for your message!\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.social-api.ai/v1/inbox/conversations/{id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"account_id\": \"acc_abc123\",\n \"attachment_url\": \"https://cdn.example.com/photo.jpg\",\n \"attachments\": [\n {\n \"source\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"source_type\": \"media_id\",\n \"type\": \"image\"\n }\n ],\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"cards\": [\n {\n \"buttons\": [\n {\n \"payload\": \"VIEW_ORDER\",\n \"title\": \"View order\",\n \"type\": \"url\",\n \"url\": \"https://shop.example.com/orders/1\"\n }\n ],\n \"image_url\": \"https://cdn.example.com/p.jpg\",\n \"subtitle\": \"Short description\",\n \"title\": \"Product name\"\n }\n ],\n \"message_tag\": \"HUMAN_AGENT\",\n \"quick_replies\": [\n {\n \"payload\": \"TRACK_ORDER\",\n \"title\": \"Track my order\"\n }\n ],\n \"reply_to_message_id\": \"m_1234567890\",\n \"text\": \"Thanks for your message!\"\n}"
response = http.request(request)
puts response.read_body{
"message_id": "m_1234567890",
"message_ids": [
"m_1234567890"
],
"success": true
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}Authorizations
Prefix your API key with "Bearer ". Example: Authorization: Bearer sapi_key_...
Path Parameters
Conversation ID
Body
Message payload
"acc_abc123"
AttachmentURL is a single-attachment shorthand. Ignored when attachments is non-empty; its type is inferred from the URL extension.
Deprecated: use Attachments instead, which supersedes it and supports one or many items.
"https://cdn.example.com/photo.jpg"
Attachments sends one or more media items, each as its own message bubble.
Show child attributes
Show child attributes
Buttons renders a button template (1-3 buttons); uses text as the bubble body.
Show child attributes
Show child attributes
Cards renders a generic/carousel template (up to 10 cards).
Show child attributes
Show child attributes
MessageTag attaches a Meta message tag so the DM can be sent outside the standard 24-hour window. Instagram/Facebook only. Instagram accepts only HUMAN_AGENT; Facebook also accepts ACCOUNT_UPDATE, CONFIRMED_EVENT_UPDATE, CUSTOMER_FEEDBACK, POST_PURCHASE_UPDATE. Requires Meta "Human Agent" advanced access for HUMAN_AGENT. Ignored by non-Meta platforms. For beta testers replying on Facebook Messenger, HUMAN_AGENT is applied automatically when this field is omitted.
"HUMAN_AGENT"
QuickReplies renders up to 13 tappable chips above the keyboard; requires text.
Show child attributes
Show child attributes
ReplyToMessageID makes the first sent bubble a reply to a specific prior message (Meta message.reply_to.mid). Instagram/Facebook only.
"m_1234567890"
"Thanks for your message!"
Response
Message sent with ID
MessageID is the first sent message's ID; for a multi-attachment send it is only the first of several IDs.
Deprecated: use MessageIDs instead.
"m_1234567890"
MessageIDs holds every sent message's ID, in send order.
["m_1234567890"]
true