Overview

You can use this request to create a new user.

The Method

API-Method
RESTPOSThttps://[Your URL]/api/2.0/users

Parameters

PropertyTypeDescriptionDefaultRequired
$propertiesJSON ObjectThe properties of the user to be created.

Required properties are:
name
email
username
customer_id
(See the Properties table below for more details.)
noneYes

Properties

PropertyTypeDescriptionDefaultRequired
namestringUser’s nameemptyYes
emailstringUser’s Email AddressemptyYes
usernamestringThe Identifier that the user will use to login. Our standard is to use their email address to ensure it’s unique, but you can set anything that’s unique here.emptyYes
customer_idintegerThe Customer ID that the user will be added to.emptyYes

Example Request

<?php
$username = 'administrator';
$apiKey = '7IjRKva9OzwCsy9xaCwsihA6HxUTwE7a_999';
$localUrl = 'https://localhost';
$customerId = 2;
$packageIdentifier = 24;
$url = $localUrl . '/api/2.0/users/';
$method = 'POST';
$auth = base64_encode($username . ':' . $apiKey);

$cSession = curl_init();

curl_setopt($cSession, CURLOPT_URL, $url);
curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cSession, CURLOPT_HEADER, false);
curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt($cSession, CURLOPT_POSTFIELDS, json_encode([
    'name' => 'Test User',
    'email' => '[email protected]',
    'username' => '[email protected]',
    'customer_id' => 1,
]));
curl_setopt($cSession, CURLOPT_HTTPHEADER, [
    'Authorization: Basic ' . $auth,
    'Content-Type: application/json'
]);

$response = curl_exec($cSession);
var_dump($response);

curl_close($cSession);

Example Response

{
   "links":[
      {
         "title":"Self",
         "rel":"self",
         "href":"http:\/\/localhost\/api\/2.0\/users\/"
      },
      {
         "title":"Home",
         "rel":"home",
         "href":"http:\/\/localhost\/api\/2.0\/"
      }
   ],
   "item":{
      "id":2,
      "hash":"nPGPHpbX8DoJgE0G",
      "enterprise_id":1,
      "customer_id":1,
      "language":"default",
      "name":"Test User",
      "email":"[email protected]",
      "username":"[email protected]",
      "can_customer_admin":"yes"
   }
}