PUT/ users/ mass_update_standard_attributes/
Mass update standard attributes
HTTP PUT request enabling you to update chosen standard attribute for users in bulk.
Allowed attributes: assigned_to, city, company_id, country, email, facebook_url, first_name, gender, google_url, gravatar_url, last_name, linkedin_url, notifications, phone_number, region, score, status, timezone, twitter_url, unsubscribed, custom_id.
Attributes
Optional unless marked required
- ids
- List of users' ids (unique identifiers for the user which are given by User automatically).
- attribute
- A name of your attribute. It must a be a standard and allowed for update attribute.
- value
- A value for the attribute
Request
- cURL
- JavaScript
- PHP
- Python
curl -X PUT "https://<your_app_subdomain>.user.com/api/public/users/mass_update_standard_attributes/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"ids": [
1924,
1925,
1926
],
"attribute": "country",
"value": "Poland"
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/users/mass_update_standard_attributes/",
{
method: "PUT",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
ids: [
1924,
1925,
1926,
],
attribute: "country",
value: "Poland",
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/users/mass_update_standard_attributes/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"ids" => [
1924,
1925,
1926,
],
"attribute" => "country",
"value" => "Poland",
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.put(
"https://<your_app_subdomain>.user.com/api/public/users/mass_update_standard_attributes/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"ids": [
1924,
1925,
1926,
],
"attribute": "country",
"value": "Poland",
},
)
print(response.json())
Response examples
- 200 OK
- 400 Bad Request
{
"status": "ok"
}
{"ids": ["This field is required."],"attribute": ["This field is required."],"value": ["This field is required."]}A 400 names the fields that were rejected. The messages you're most likely to see:
| Message | When |
|---|---|
This field is required. | ids, attribute or value is missing (each missing field is listed). |
<name> is not a valid user attribute. | No contact attribute has that name. |
Enter a valid email address. (in non_field_errors) | value doesn't fit the attribute, here email. |
IDs in ids that aren't contacts are skipped: the other contacts are updated and the response is 200 as usual.
Response fields
Fields returned in the 200 OK response body.
- status
okwhen the update was accepted.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.