Update account settings
Updates the account settings of the authenticated user. Only the settings present in the request are changed. allow_media_tagging and allow_dms_from accept only their listed values, matched exactly; quiet_hours hours are 0–23 in the user’s time zone; time_zone.name and language are checked by the account store.
curl --request PUT \
--url https://api.x.com/2/users/me/settings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"always_allow_dms_from_subscribers": true,
"discoverable_by_email": true,
"discoverable_by_phone": true,
"display_sensitive_media": true,
"language": "<string>",
"location_tagging_enabled": true,
"protected": true,
"quiet_hours": {
"enabled": true,
"end_hour": 11,
"start_hour": 11
},
"use_cookie_personalization": true
}
'import requests
url = "https://api.x.com/2/users/me/settings"
payload = {
"always_allow_dms_from_subscribers": True,
"discoverable_by_email": True,
"discoverable_by_phone": True,
"display_sensitive_media": True,
"language": "<string>",
"location_tagging_enabled": True,
"protected": True,
"quiet_hours": {
"enabled": True,
"end_hour": 11,
"start_hour": 11
},
"use_cookie_personalization": True
}
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({
always_allow_dms_from_subscribers: true,
discoverable_by_email: true,
discoverable_by_phone: true,
display_sensitive_media: true,
language: '<string>',
location_tagging_enabled: true,
protected: true,
quiet_hours: {enabled: true, end_hour: 11, start_hour: 11},
use_cookie_personalization: true
})
};
fetch('https://api.x.com/2/users/me/settings', 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/users/me/settings",
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([
'always_allow_dms_from_subscribers' => true,
'discoverable_by_email' => true,
'discoverable_by_phone' => true,
'display_sensitive_media' => true,
'language' => '<string>',
'location_tagging_enabled' => true,
'protected' => true,
'quiet_hours' => [
'enabled' => true,
'end_hour' => 11,
'start_hour' => 11
],
'use_cookie_personalization' => true
]),
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/users/me/settings"
payload := strings.NewReader("{\n \"always_allow_dms_from_subscribers\": true,\n \"discoverable_by_email\": true,\n \"discoverable_by_phone\": true,\n \"display_sensitive_media\": true,\n \"language\": \"<string>\",\n \"location_tagging_enabled\": true,\n \"protected\": true,\n \"quiet_hours\": {\n \"enabled\": true,\n \"end_hour\": 11,\n \"start_hour\": 11\n },\n \"use_cookie_personalization\": true\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/users/me/settings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"always_allow_dms_from_subscribers\": true,\n \"discoverable_by_email\": true,\n \"discoverable_by_phone\": true,\n \"display_sensitive_media\": true,\n \"language\": \"<string>\",\n \"location_tagging_enabled\": true,\n \"protected\": true,\n \"quiet_hours\": {\n \"enabled\": true,\n \"end_hour\": 11,\n \"start_hour\": 11\n },\n \"use_cookie_personalization\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.x.com/2/users/me/settings")
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 \"always_allow_dms_from_subscribers\": true,\n \"discoverable_by_email\": true,\n \"discoverable_by_phone\": true,\n \"display_sensitive_media\": true,\n \"language\": \"<string>\",\n \"location_tagging_enabled\": true,\n \"protected\": true,\n \"quiet_hours\": {\n \"enabled\": true,\n \"end_hour\": 11,\n \"start_hour\": 11\n },\n \"use_cookie_personalization\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"updated": true
},
"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>"
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Body
Who can send the user direct messages: all (anyone), verified (verified accounts only), or following (accounts the user follows).
all, following, verified Who may tag the user in media: all (anyone), following (accounts the user follows), or none.
all, following, none Whether the user's subscribers can always message them regardless of allow_dms_from.
Whether people who have the user's email address can find them on X.
Whether people who have the user's phone number can find them on X.
Whether media that may contain sensitive content is displayed to the user.
The language of the account, as a BCP 47 tag (for example en, pt-BR).
2 - 35Whether a precise location may be attached to the user's posts.
Whether the user's posts are protected (visible only to approved followers).
The daily window during which the user does not receive push and SMS notifications.
Show child attributes
Show child attributes
The time zone of the account.
Show child attributes
Show child attributes
Whether X may use the user's off-X web activity to personalize their experience.
Response
The request has succeeded.
Show child attributes
Show child attributes
- 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
Show child attributes
Show child attributes
curl --request PUT \
--url https://api.x.com/2/users/me/settings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"always_allow_dms_from_subscribers": true,
"discoverable_by_email": true,
"discoverable_by_phone": true,
"display_sensitive_media": true,
"language": "<string>",
"location_tagging_enabled": true,
"protected": true,
"quiet_hours": {
"enabled": true,
"end_hour": 11,
"start_hour": 11
},
"use_cookie_personalization": true
}
'import requests
url = "https://api.x.com/2/users/me/settings"
payload = {
"always_allow_dms_from_subscribers": True,
"discoverable_by_email": True,
"discoverable_by_phone": True,
"display_sensitive_media": True,
"language": "<string>",
"location_tagging_enabled": True,
"protected": True,
"quiet_hours": {
"enabled": True,
"end_hour": 11,
"start_hour": 11
},
"use_cookie_personalization": True
}
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({
always_allow_dms_from_subscribers: true,
discoverable_by_email: true,
discoverable_by_phone: true,
display_sensitive_media: true,
language: '<string>',
location_tagging_enabled: true,
protected: true,
quiet_hours: {enabled: true, end_hour: 11, start_hour: 11},
use_cookie_personalization: true
})
};
fetch('https://api.x.com/2/users/me/settings', 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/users/me/settings",
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([
'always_allow_dms_from_subscribers' => true,
'discoverable_by_email' => true,
'discoverable_by_phone' => true,
'display_sensitive_media' => true,
'language' => '<string>',
'location_tagging_enabled' => true,
'protected' => true,
'quiet_hours' => [
'enabled' => true,
'end_hour' => 11,
'start_hour' => 11
],
'use_cookie_personalization' => true
]),
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/users/me/settings"
payload := strings.NewReader("{\n \"always_allow_dms_from_subscribers\": true,\n \"discoverable_by_email\": true,\n \"discoverable_by_phone\": true,\n \"display_sensitive_media\": true,\n \"language\": \"<string>\",\n \"location_tagging_enabled\": true,\n \"protected\": true,\n \"quiet_hours\": {\n \"enabled\": true,\n \"end_hour\": 11,\n \"start_hour\": 11\n },\n \"use_cookie_personalization\": true\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/users/me/settings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"always_allow_dms_from_subscribers\": true,\n \"discoverable_by_email\": true,\n \"discoverable_by_phone\": true,\n \"display_sensitive_media\": true,\n \"language\": \"<string>\",\n \"location_tagging_enabled\": true,\n \"protected\": true,\n \"quiet_hours\": {\n \"enabled\": true,\n \"end_hour\": 11,\n \"start_hour\": 11\n },\n \"use_cookie_personalization\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.x.com/2/users/me/settings")
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 \"always_allow_dms_from_subscribers\": true,\n \"discoverable_by_email\": true,\n \"discoverable_by_phone\": true,\n \"display_sensitive_media\": true,\n \"language\": \"<string>\",\n \"location_tagging_enabled\": true,\n \"protected\": true,\n \"quiet_hours\": {\n \"enabled\": true,\n \"end_hour\": 11,\n \"start_hour\": 11\n },\n \"use_cookie_personalization\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"updated": true
},
"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>"
}