PUT/ users/ mass_update_custom_attributes/
Mass update custom attributes
You can update a value for your custom attributes for many users at the same time.
Attributes
Optional unless marked required
- ids
- List of users' ids (unique identifiers for the user which are given by User automatically).
- attribute
- The name of your attribute. Has to be at least 1 character, and cannot be longer than 255 characters.
- value
- A possible attribute types: boolean, fixed, string, date, datetime, integer, float and json.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X PUT "https://<your_app_subdomain>.user.com/api/public/users/mass_update_custom_attributes/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"ids": [
1924,
1925,
1926
],
"attribute": "20261110_1519_seats",
"value": 7
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/users/mass_update_custom_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: "20261110_1519_seats",
value: 7,
}),
},
);
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_custom_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" => "20261110_1519_seats",
"value" => 7,
]),
]);
$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_custom_attributes/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"ids": [
1924,
1925,
1926,
],
"attribute": "20261110_1519_seats",
"value": 7,
},
)
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. |
“abc” value must be an integer. (in non_field_errors) | value doesn't fit the attribute's type. |
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.