Send Message on Conversation
curl --request POST \
--url https://api.bland.ai/v1/sms/conversations/{conversation_id}/messages \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"message": "<string>",
"sender": "<string>"
}
'import requests
url = "https://api.bland.ai/v1/sms/conversations/{conversation_id}/messages"
payload = {
"message": "<string>",
"sender": "<string>"
}
headers = {
"authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({message: '<string>', sender: '<string>'})
};
fetch('https://api.bland.ai/v1/sms/conversations/{conversation_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.bland.ai/v1/sms/conversations/{conversation_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([
'message' => '<string>',
'sender' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$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.bland.ai/v1/sms/conversations/{conversation_id}/messages"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"sender\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
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.bland.ai/v1/sms/conversations/{conversation_id}/messages")
.header("authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"sender\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bland.ai/v1/sms/conversations/{conversation_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"sender\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"status": "processing",
"message": "Message accepted for delivery",
"conversation_id": "8f1c2a4e-1b7d-4f2a-9c1e-2d3f4a5b6c7d",
"sender": "HUMAN",
"message_id": "b7e2c1d0-3f4a-4b5c-8d9e-0f1a2b3c4d5e",
"human_handoff_active": true
},
"errors": null
}
Messaging
Send Message on Conversation
Send a message on an existing conversation from the agent number, as a human rep or as the agent.
POST
/
v1
/
sms
/
conversations
/
{conversation_id}
/
messages
Send Message on Conversation
curl --request POST \
--url https://api.bland.ai/v1/sms/conversations/{conversation_id}/messages \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"message": "<string>",
"sender": "<string>"
}
'import requests
url = "https://api.bland.ai/v1/sms/conversations/{conversation_id}/messages"
payload = {
"message": "<string>",
"sender": "<string>"
}
headers = {
"authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({message: '<string>', sender: '<string>'})
};
fetch('https://api.bland.ai/v1/sms/conversations/{conversation_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.bland.ai/v1/sms/conversations/{conversation_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([
'message' => '<string>',
'sender' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$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.bland.ai/v1/sms/conversations/{conversation_id}/messages"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"sender\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
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.bland.ai/v1/sms/conversations/{conversation_id}/messages")
.header("authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"sender\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bland.ai/v1/sms/conversations/{conversation_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"sender\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"status": "processing",
"message": "Message accepted for delivery",
"conversation_id": "8f1c2a4e-1b7d-4f2a-9c1e-2d3f4a5b6c7d",
"sender": "HUMAN",
"message_id": "b7e2c1d0-3f4a-4b5c-8d9e-0f1a2b3c4d5e",
"human_handoff_active": true
},
"errors": null
}
Enterprise Feature - SMS is only available on Enterprise plans.
sender set to "HUMAN" (default) or "AGENT".
Unlike Send SMS, this is keyed on the conversation ID rather than the number pair, so it always lands on this thread, including while the conversation is handed off to a human.
Headers
string
required
Your API key for authentication.
string
Safe retries: repeated requests with the same key do not send a second message.
Path Parameters
string
required
The conversation to send on.
Body Parameters
string
required
The text to send. Up to 1600 characters.
string
"HUMAN" (default) attributes the message to a human rep in the transcript and webhooks. "AGENT" attributes it to the agent, the same as agent_message on Send SMS.Response
string
Use with delivery status webhooks.
boolean
Whether the conversation is currently handed off.
{
"data": {
"status": "processing",
"message": "Message accepted for delivery",
"conversation_id": "8f1c2a4e-1b7d-4f2a-9c1e-2d3f4a5b6c7d",
"sender": "HUMAN",
"message_id": "b7e2c1d0-3f4a-4b5c-8d9e-0f1a2b3c4d5e",
"human_handoff_active": true
},
"errors": null
}
Was this page helpful?