Create User

You can use this request to create a new user.


The Method

API Method
RESTPOSThttp://[Your URL]/api/2.0/users
XML-RPCCallCreateUser
Your URL is the address of your Everlytic install.

Your method must be structured as follows:

CreateUser(\struct | array $properties) : obj

Parameters

Required Parameters

You must specify the name, email, username, customer_id of the user you want to create.

PropertyTypeDescriptionDefaultRequired
$properties\structarrayThe 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

You can use the following properties to create a user with this request:

PropertyTypeDescriptionDefaultRequiredRead Only
namestringNameemptyyesno
emailstringEmail addressemptyyes no
usernamestringUser identifieremptyyesno
customer_idintegerCustomer ID that the user belongs to.emptyyesno

Responses

TypeDescription
objectThe properties of the created user.

Code Samples

Tutorial

The rest of this document describes the example above, step-by-step.

In our Getting Started section we covered the four important components of an API request; URL, method, headers, and body.

RequestStructure

Let's analyse the code sample above to determine where each line fits into this outline.

1. State your user credentials for the API server

$user = 'Administrator';

$apiKey = '(Your API Key)';

2. Load the Everlytic API

The following line of code tells the server which API URL to access for the request:

$host = 'http://(Your URL)';

$path = '/api/2.0/users';

Your URL is the URL of your Everlytic installation.

3. Method

In this line of code, you tell the API which REST function to use:

$method = 'POST';

4. Set up the fields to use in the Request

$json = '

{

"name":"Dimitriou Androas",

"email":"dimitriou@everlytic.com",

"customer_id" : "3",

"username" : "dimitrioua"

}

';

5. cURL

cURL is a tool for sending and receiving files from a web server. This line of code initialises the cURL session.

$cSession = curl_init();

6. Initiate the Headers

This section of the code opens the headers section and passes the authentication (including your API key).

$auth = base64_encode($user . ':' . $apiKey);

$headers = array();

$headers[] = 'Authorization: Basic ' . $auth;

$headers[] = 'Content-Type: application/json';

7. Set various cURL options for the session

These lines of code tell the server that we're using cURL to transfer data.

curl_setopt($cSession, CURLOPT_URL, $host . $path);

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);

8. Output the API response

$result = curl_exec($cSession);

9. Close the cURL session

curl_close($cSession);
Translate »