PUT
/users-by-id/:custom_id/Update user
You can update a specific user. You can also set up any custom attribute of your choice. Custom attributes have to be created in the User.com app before sending them within requests.
| Attributes | Type | Required | Description |
|---|---|---|---|
| custom_id | string | yes | The unique identifier for the user which is provided by the client. |
| company_id | integer | no | A unique identifier for the company which is given by User.com automatically. |
| custom_attr | string | no | An example value of your custom attribute. |
| string | no | A user email address. | |
| first_name | string | no | A first name for a user (the maximum number of characters is 40). |
| last_name | string | no | A last name for a user (the maximum number of characters is 40). |
| tags | list(strings) | no | A list of tag names. |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X PUT -H "Authorization: Token <your_64_char_api_key>"
-H "Accept: */*; version=2" -H "Content-Type: application/json" -d '{
"email": "john@example.org",
"gravatar_url": "https://randomuser.me/api/portraits/men/51.jpg",
"tags": ["updated", "verified"]
}' "https://<your_app_subdomain>.user.com/api/public/users-by-id/:custom_id/"
var data = JSON.stringify({
"first_name": "John",
"last_name": "Doe",
"gender": 2,
"status": 2,
"phone_number": "+48123456789",
"first_seen": null,
"last_seen": null,
"page_views": 8,
"last_ip": "84.23.84.23",
"timezone": null,
"city": "Warsaw",
"country": "Poland",
"unsubscribed": false,
"browser_language": null,
"browser": "Chrome",
"os_type": null,
"resolution": null,
"created_at": "2016-08-08T09:22:25.795373Z",
"updated_at": "2016-08-08T09:22:32.823346Z",
"attributes": [],
"gravatar_url": null,
"lists": [],
"tags": [
{
"id": 372,
"name": "john123"
}
],
"notifications": true
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("PUT", "https://<your_app_subdomain>.user.com/api/public/users-by-id/:custom_id/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("accept", "*/*; version=2");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
<?php
$request = new HttpRequest();
$request->setUrl('https://<your_app_subdomain>.user.com/api/public/users-by-id/:custom_id/');
$request->setMethod(HTTP_METH_PUT);
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => 'Token <your_64_char_api_key>'
));
$request->setBody('{
"first_name": "John",
"last_name": "Doe",
"gender": 2,
"status": 2,
"phone_number": "+48123456789",
"first_seen": null,
"last_seen": null,
"page_views": 8,
"last_ip": "84.23.84.23",
"timezone": null,
"city": "Warsaw",
"country": "Poland",
"unsubscribed": false,
"browser_language": null,
"browser": "Chrome",
"os_type": null,
"resolution": null,
"created_at": "2016-08-08T09:22:25.795373Z",
"updated_at": "2016-08-08T09:22:32.823346Z",
"attributes": [],
"gravatar_url": null,
"lists": [],
"tags": [
{
"id": 372,
"name": "john123"
}
],
"notifications": true
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
import requests
url = "https://<your_app_subdomain>.user.com/api/public/users-by-id/:custom_id/"
payload = "{\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"gender\": 2,\n \"status\": 2,\n \"phone_number\": \"+48123456789\",\n \"first_seen\": null,\n \"last_seen\": null,\n \"page_views\": 8,\n \"last_ip\": \"84.23.84.23\",\n \"timezone\": null,\n \"city\": \"Warsaw\",\n \"country\": \"Poland\",\n \"unsubscribed\": false,\n \"browser_language\": null,\n \"browser\": \"Chrome\",\n \"os_type\": null,\n \"resolution\": null,\n \"created_at\": \"2016-08-08T09:22:25.795373Z\",\n \"updated_at\": \"2016-08-08T09:22:32.823346Z\",\n \"attributes\": [],\n \"gravatar_url\": null,\n \"lists\": [],\n \"tags\": [\n {\n \"id\": 372,\n \"name\": \"john123\"\n }\n ],\n \"notifications\": true\n}"
headers = {
'authorization': "Token <your_64_char_api_key>",
'Accept': "*/*; version=2",
'content-type': "application/json"
}
response = requests.request("PUT", url, data=payload, headers=headers)
print(response.text)
Response
{
"chat_id": "Chat ID is deprecated and will be removed in future",
"twitter_url": null,
"last_contacted": null,
"timezone": null,
"updated_at": "2017-06-14T07:29:06.976662Z",
"companies": [
{
"id": 14,
"name": "Company name",
"member_since": "2018-06-14T08:49:56.515083Z"
}
],
"google_url": null,
"lists": [],
"status": "visitor",
"resolution": null,
"phone_number": null,
"gravatar_url": "https://randomuser.me/api/portraits/men/51.jpg",
"os_type": null,
"facebook_url": null,
"name": "Jane Doe",
"page_views": 0,
"tags": [
{
"name": "tag",
"id": 1441
}
],
"linkedin_url": null,
"browser": null,
"last_seen": "2017-06-14T11:06:08.182761Z",
"id": 19678376,
"first_seen": null,
"last_ip": null,
"score": 0,
"unsubscribed": false,
"region": null,
"attributes": [
{
"value": true,
"name": "Example attr",
"name_std": "example_attr",
"id": 1109
},
{
"value": "attribute value",
"name": "My string attr",
"name_std": "my_string_attr",
"id": 2429
}
],
"created_at": "2017-06-07T09:41:13.466897Z",
"gender": "unknown",
"key": "g3FaYocCy0U6",
"notifications": true,
"country": null,
"email": "updated@email.com",
"browser_language": null,
"city": null
}