users.attributes.update
Update custom user attributes in DX.
Facts
| Method | POST https://api.getdx.com/users.attributes.update |
| Required scope | users:write |
Arguments
| Name | Type | Description |
|---|---|---|
token |
Token |
Auth token passed as an HTTP header. |
email |
Text |
The email of the user you want to update. |
attributes |
Array<JSON> |
Array of attribute objects. |
Usage info
This API method allows you to create and update your users’ custom attributes within DX. If an attribute is set that is not part of an existing attribute group in DX, that attribute group will be created.
Attributes updated using this method will apply to the user in DX associated with the email you provide in the request payload.
Please note: Custom user attributes are different than user properties.
Behaviors
This API method has the following behaviors:
- DX will only update or create values for attributes for a user based on what is passed into the request payload. This means if an attribute is set for a user, but you want to remove that attribute, you will need to specify the attribute and pass in a value of
nullfor it. - If the name of an attribute doesn’t exist in DX, an attribute group will be created for the attribute and the value of that attribute will be assigned to the user.
- If the name of an attribute does exist in DX, the value for that attribute will be assigned to the user. All attributes that are not included in the payload will not be modified for the user.
Example request
This is a typical request:
curl -X POST 'https://api.getdx.com/users.attributes.update' \
-H 'Authorization: Bearer xxxx-xxxxxxxxx-xxxx' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "john.doe@example.com",
"attributes": [
{
"name": "Department",
"value": "Engineering"
},
{
"name": "Location",
"value": "Remote"
},
{
"name": "Region",
"value": null
}
]
}'
Example response
This is a typical success response:
{
"ok": true,
"user": {
"id": "user_123",
"email": "john.doe@example.com",
"failures": [],
"attributes": [
{
"name": "Department",
"value": "Engineering",
"updated": true
},
{
"name": "Location",
"value": "Remote",
"updated": true
}
]
}
}
Please note: Attributes set to null will not be returned in the response payload.
Errors
This table lists the expected errors that this method could return. However, other errors can be returned in the case where the service is down or other unexpected factors affect processing. Callers should always check the value of the ok param in the response.
| Error | Description |
|---|---|
not_authed |
No authentication token provided. |
invalid_auth |
Some aspect of authentication cannot be validated. |