Create Customer

You can use this request to create a new customer.


The Method

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

Your method must be structured as follows:

CreateCustomer(\struct | array $properties) : int

Parameters

Required Parameters

You must specify the name and email of the customer you want to create.

PropertyTypeDescriptionRequired
$properties\structarrayThe properties of the customer to be created. Required properties are:
name
email
(See Properties table below for more details)
yes

Properties

You can set the following properties using this request.

PropertyTypeDescriptionDefaultRequiredRead Only
namestringNameemptyyesno
statusstringStatus
Possible values:
on
off
suspended
deleted
emptynono
emailstringEmail addressemptyyesno
email_package_idintegerPackage identifierempty nono
email_quotaintegerPrepaid email quotaemptynono
sms_quotaintegerPrepaid SMS quotaemptynono
transactions_package_idintegerPackage identifieremptynono
transactions_quotaintegerTransactions prepaid quotaemptynono
deletedstringCustomer deleted
Possible values:
yes
no
emptynono
addressstringAddressemptynono
state_provincesstringState or Provinceemptynono
postal_codestringPostal or Zip codeemptynono
telephonestringTelephone numberemptynono
website_urlstringWebsite URLemptynono
countrystringTwo-character country codeemptynono
industrystringCustomer industry. Possible values:
Personal Use,
Agriculture & Environmental,
Automotive,
Business & Consulting Services,
E-commerce,
Education & Training,
Financial Institutions,
Governmental Organisations,
Hospitality, Travel & Tourism,
Industry, Trade & Manufacture,
Lifestyle, Arts & Entertainment,
Logistic Services,
Publishing & Media,
Agencies & Marketing,
Medical & Healthcare,
Non Governmental Organisations,
Property & Real Estate,
Retail & Wholesale,
Technology & Science.
emptynono
unique_idstringUnique customer identifier.emptynono

Responses

TypeDescription
objectThe properties of the created customer.

Code Sample

The following is a code sample for the create customer request:

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. Open the request and pass in your credentials

<?php

$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 = '(Your URL)';

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

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 pass to the server

$json = '

{

"name":"customer name",

"email":"customer@email.com"

}

';

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

5. 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';

curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers);

6. Set the cURL options for the request

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

7. Execute the request and close the session

$result = curl_exec($cSession);

curl_close($cSession);

8. Print the result as a JSON string

echo $result;
Translate »