Live Chat
Send a Chat Message
POST /2/broadcasts/:id/chat posts a plain-text chat message to a live broadcast, attributed to the authenticated user.
POST
/
2
/
broadcasts
/
{id}
/
chat
Send a Chat Message to a Live Broadcast
curl --request POST \
--url https://api.x.com/2/broadcasts/{id}/chat \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"relay_source": "<string>",
"reply_to": "<string>"
}
'import requests
url = "https://api.x.com/2/broadcasts/{id}/chat"
payload = {
"text": "<string>",
"relay_source": "<string>",
"reply_to": "<string>"
}
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({text: '<string>', relay_source: '<string>', reply_to: '<string>'})
};
fetch('https://api.x.com/2/broadcasts/{id}/chat', 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.x.com/2/broadcasts/{id}/chat",
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([
'text' => '<string>',
'relay_source' => '<string>',
'reply_to' => '<string>'
]),
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.x.com/2/broadcasts/{id}/chat"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"relay_source\": \"<string>\",\n \"reply_to\": \"<string>\"\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.x.com/2/broadcasts/{id}/chat")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"relay_source\": \"<string>\",\n \"reply_to\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.x.com/2/broadcasts/{id}/chat")
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 \"text\": \"<string>\",\n \"relay_source\": \"<string>\",\n \"reply_to\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"success": true,
"timestamp": "<string>"
},
"errors": [
{
"detail": "<string>",
"resource_type": "<string>",
"title": "<string>",
"type": "https://api.x.com/2/problems/resource-not-found",
"parameter": "<string>",
"resource_id": "<string>",
"status": 123,
"value": "<string>"
}
]
}{
"code": 123,
"message": "<string>"
}Posts a plain-text chat message to a live broadcast. The message is attributed to the authenticated user.
:id is the alphanumeric broadcast_id, and text must be from 1 through 140 characters.
The broadcast must be currently live. Its chat settings and the authenticated user’s eligibility determine whether the user may send a message. For example, chat may be disabled or limited to verified users, subscribers, or users followed by the host.
The response’s timestamp is the server timestamp of the message in nanoseconds, returned as a decimal string. It also serves as the message id — for example, as the reply_to value of a follow-up message or the message_id when deleting the message.
Errors
- A request returns
400 Bad Requestif the broadcast cannot be found, is not currently live, or the message is invalid. - It returns
403 Forbiddenif the authenticated user is not permitted to chat in the broadcast.
This endpoint sends messages only. To receive chat messages in real time, subscribe to the
broadcast.chat event on the X Activity API as described in Accessing Live Chat.Authorizations
OAuth2UserTokenUserToken
Scopes
Body
application/json
The chat message text.
Required string length:
1 - 140Response
The request has succeeded.
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
- Option 10
- Option 11
- Option 12
- Option 13
- Option 14
- Option 15
- Option 16
- Option 17
- Option 18
- Option 19
- Option 20
- Option 21
- Option 22
- Option 23
- Option 24
- Option 25
- Option 26
- Option 27
- Option 28
- Option 29
- Option 30
- Option 31
- Option 32
- Option 33
- Option 34
- Option 35
- Option 36
- Option 37
- Option 38
- Option 39
- Option 40
- Option 41
- Option 42
- Option 43
- Option 44
- Option 45
- Option 46
- Option 47
- Option 48
- Option 49
- Option 50
- Option 51
- Option 52
- Option 53
- Option 54
- Option 55
- Option 56
- Option 57
- Option 58
- Option 59
- Option 60
- Option 61
Show child attributes
Show child attributes
⌘I
Send a Chat Message to a Live Broadcast
curl --request POST \
--url https://api.x.com/2/broadcasts/{id}/chat \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"relay_source": "<string>",
"reply_to": "<string>"
}
'import requests
url = "https://api.x.com/2/broadcasts/{id}/chat"
payload = {
"text": "<string>",
"relay_source": "<string>",
"reply_to": "<string>"
}
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({text: '<string>', relay_source: '<string>', reply_to: '<string>'})
};
fetch('https://api.x.com/2/broadcasts/{id}/chat', 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.x.com/2/broadcasts/{id}/chat",
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([
'text' => '<string>',
'relay_source' => '<string>',
'reply_to' => '<string>'
]),
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.x.com/2/broadcasts/{id}/chat"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"relay_source\": \"<string>\",\n \"reply_to\": \"<string>\"\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.x.com/2/broadcasts/{id}/chat")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"relay_source\": \"<string>\",\n \"reply_to\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.x.com/2/broadcasts/{id}/chat")
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 \"text\": \"<string>\",\n \"relay_source\": \"<string>\",\n \"reply_to\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"success": true,
"timestamp": "<string>"
},
"errors": [
{
"detail": "<string>",
"resource_type": "<string>",
"title": "<string>",
"type": "https://api.x.com/2/problems/resource-not-found",
"parameter": "<string>",
"resource_id": "<string>",
"status": 123,
"value": "<string>"
}
]
}{
"code": 123,
"message": "<string>"
}