Create user


Create new user with HTTP POST request.

POST

/users/

Data
Type
Description
email
string
Define an email address for user
first_name
string
First name for a user
last_name
string
Last name for a user
company_id
string
Add user as employee to company with given company_id
curl -X POST -H "Authorization: Token <your_64_char_api_key>" -H "Content-Type: application/json" -d '{
  "email": "myemail@example.org",
  "first_name": "John",
  "last_name": "Doe"
}' "https://app.userengage.com/api/public/users/"

Response

{
  "updated_at": "2017-06-13T12:22:38.748397Z",
  "companies": [
    {
      "id": 14,
      "name": "Company name",
      "member_since": "2018-06-14T08:49:56.515083Z"
    }
  ],
  "key": "xSoYQG00fg9z",
  "city": null,
  "linkedin_url": null,
  "tags": [],
  "last_contacted": null,
  "phone_number": null,
  "facebook_url": null,
  "notifications": true,
  "region": null,
  "timezone": null,
  "status": "visitor",
  "gravatar_url": null,
  "twitter_url": null,
  "google_url": null,
  "os_type": null,
  "email": "myemail@example.org",
  "score": 0,
  "unsubscribed": false,
  "first_seen": null,
  "page_views": 0,
  "last_ip": null,
  "chat_id": "Chat ID is deprecated and will be removed in future",
  "browser": null,
  "gender": "unknown",
  "resolution": null,
  "country": null,
  "name": "John Doe",
  "created_at": "2017-06-13T12:22:38.748373Z",
  "last_seen": null,
  "lists": [],
  "attributes": [],
  "browser_language": null,
  "id": 20901703
}
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://app.userengage.com/api/public/users/",
  "method": "POST",
  "headers": {
    "authorization": "Token <your_64_char_api_key>",
    "content-type": "application/json"
  },
  "data": {
    "email": "mynewemail@mydomain.com",
    "first_name": "John",
    "last_name": "Doe"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var data = "email=mynewemail%40mydomain.com&first_name=John&last_name=Doe";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://app.userengage.com/api/public/users/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);
var request = require("request");

var options = { method: 'POST',
  url: 'https://app.userengage.com/api/public/users/',
  headers: {
    'content-type': 'application/json',
    authorization: 'Token <your_64_char_api_key>'
  },
  form: {
    email: 'mynewemail@mydomain.com',
    first_name: 'John',
    last_name: 'Doe'
  }
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://app.userengage.com/api/public/users/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\n  \"email\": \"myemail@mydomain.com\",\n  \"first_name\": \"John\",\n  \"last_name\": \"Doe\"\n}",
  CURLOPT_HTTPHEADER => array(
    "authorization: Token <your_64_char_api_key>",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://app.userengage.com/api/public/users/"

payload = "{\n\"email\": \"myemail@example.org\", \n\"first_name\":\"John\", \n\"last_name\":\"Doe\" \n}"
headers = {
    'authorization': "Token <your_64_char_api_key>",
    'content-type': "application/json"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)