Broadcasts
End Broadcast
PUT /2/broadcasts/:id/state with state END ends one of the authenticated user’s live broadcasts.
PUT
/
2
/
broadcasts
/
{id}
/
state
End a Broadcast
curl --request PUT \
--url https://api.x.com/2/broadcasts/{id}/state \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"state": "<string>",
"chat_option": 123,
"locale": "<string>",
"should_not_tweet": true,
"title": "<string>"
}
'import requests
url = "https://api.x.com/2/broadcasts/{id}/state"
payload = {
"state": "<string>",
"chat_option": 123,
"locale": "<string>",
"should_not_tweet": True,
"title": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
state: '<string>',
chat_option: 123,
locale: '<string>',
should_not_tweet: true,
title: '<string>'
})
};
fetch('https://api.x.com/2/broadcasts/{id}/state', 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}/state",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'state' => '<string>',
'chat_option' => 123,
'locale' => '<string>',
'should_not_tweet' => true,
'title' => '<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}/state"
payload := strings.NewReader("{\n \"state\": \"<string>\",\n \"chat_option\": 123,\n \"locale\": \"<string>\",\n \"should_not_tweet\": true,\n \"title\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.x.com/2/broadcasts/{id}/state")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"state\": \"<string>\",\n \"chat_option\": 123,\n \"locale\": \"<string>\",\n \"should_not_tweet\": true,\n \"title\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.x.com/2/broadcasts/{id}/state")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"state\": \"<string>\",\n \"chat_option\": 123,\n \"locale\": \"<string>\",\n \"should_not_tweet\": true,\n \"title\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"state": "<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>"
}Ends one of the authenticated user’s broadcasts.
Send exactly
:id is the alphanumeric broadcast ID. The broadcast moves to ENDED; this is irreversible, and a broadcast can’t be restarted. This route replaces END on the deprecated Publish or End a Broadcast route; see the migration guide.
Only
END is supported. PUBLISH is rejected with 400: to go live, use Go Live (POST /2/broadcasts), which creates and publishes a broadcast in one call.{"state": "END"}. Don’t include title, locale, chat_option or should_not_tweet: if any of them is set, the request is rejected with 400 (for example, "title must not be set").
On success, the response is 200 with the broadcast ID and its new state, ENDED. After ending, stop your encoder. Read the final broadcast, including end_ms, with GET /2/broadcasts/:id.
Errors
Errors use the standard X API problem format.| Status | Problem type | When | What to do |
|---|---|---|---|
400 | https://api.x.com/2/problems/invalid-request | The body asks for PUBLISH, has an invalid state, or sets another field. The message is in the problem’s errors array. | Send exactly {"state":"END"}. Use Go Live to go live. |
400 | https://api.x.com/2/problems/invalid-request | The broadcast can’t be ended in its current state. | Check it with GET /2/broadcasts/:id. |
401 | about:blank | The request isn’t authenticated. | Send a valid user-context access token. |
403 | about:blank | The broadcast belongs to another user, the account can’t manage it, or the broadcast was moderated. | Don’t retry. |
403 | https://api.x.com/2/problems/missing-scopes | The OAuth 2.0 token lacks broadcast.write. | Re-authorize the user with the broadcast.read and broadcast.write scopes. |
404 | https://api.x.com/2/problems/resource-not-found | The broadcast doesn’t exist. | Check the broadcast ID. |
503 | about:blank | Temporary failure. A 503 doesn’t confirm the broadcast ended. | Retry with backoff. |
Authorizations
OAuth2UserTokenUserToken
Scopes
Body
application/json
Response
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
End a Broadcast
curl --request PUT \
--url https://api.x.com/2/broadcasts/{id}/state \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"state": "<string>",
"chat_option": 123,
"locale": "<string>",
"should_not_tweet": true,
"title": "<string>"
}
'import requests
url = "https://api.x.com/2/broadcasts/{id}/state"
payload = {
"state": "<string>",
"chat_option": 123,
"locale": "<string>",
"should_not_tweet": True,
"title": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
state: '<string>',
chat_option: 123,
locale: '<string>',
should_not_tweet: true,
title: '<string>'
})
};
fetch('https://api.x.com/2/broadcasts/{id}/state', 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}/state",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'state' => '<string>',
'chat_option' => 123,
'locale' => '<string>',
'should_not_tweet' => true,
'title' => '<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}/state"
payload := strings.NewReader("{\n \"state\": \"<string>\",\n \"chat_option\": 123,\n \"locale\": \"<string>\",\n \"should_not_tweet\": true,\n \"title\": \"<string>\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.x.com/2/broadcasts/{id}/state")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"state\": \"<string>\",\n \"chat_option\": 123,\n \"locale\": \"<string>\",\n \"should_not_tweet\": true,\n \"title\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.x.com/2/broadcasts/{id}/state")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"state\": \"<string>\",\n \"chat_option\": 123,\n \"locale\": \"<string>\",\n \"should_not_tweet\": true,\n \"title\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"state": "<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>"
}