Overview
You can use this request to create a new customer.
The Method
| Type | Request | Method |
|---|---|---|
| REST | POST | https://[Your URL]/api/2.0/customers |
| XML-RPC | Call | CreateCustomer |
Your URL is the address of your 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.
| Property | Type | Description | Required |
|---|---|---|---|
| $properties | structarray | The properties of the customer to be created. Required properties are: name and email (See Properties table below for more details). | yes |
Properties
You can set the following properties using this request.
| Property | Type | Description | Default | Required | Read Only |
|---|---|---|---|---|---|
| name | string | Name | empty | yes | no |
| status | string | Status Possible values: on / off / suspended / deleted | empty | no | no |
| string | empty | yes | no | ||
| email_package_id | integer | Package identifier | empty | no | no |
| email_quota | integer | Prepaid email quota | empty | no | no |
| sms_quota | integer | Prepaid SMS quota | empty | no | no |
| transactions_package_id | integer | Package Identifier | empty | no | no |
| transactions_quota | integer | Transactions prepaid quota. | empty | no | no |
| deleted | string | Customer deleted Possible values: yes / no | empty | no | no |
| address | string | Address | empty | no | no |
| state_provinces | string | State or Province | empty | no | no |
| postal_code | string | Postal or Zip code. | empty | no | no |
| telephone | string | Telephone number. | empty | no | no |
| website_url | string | Website URL. | empty | no | no |
| country | string | Two-character country code. | empty | no | no |
| industry | string | Customer 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. | empty | no | no |
| unique_id | string | Unique customer identifier. | empty | no | no |
Responses
| Type | Description |
|---|---|
| object | The properties of the created customer. |
Code Samples
The following is a code sample for the create customer request:
<?php
$user = 'Administrator';
$apiKey = '(Your API Key)';
$host = '(Your URL)';
$path = '/api/2.0/customers';
$method = 'POST';
$json = '
{
"name":"customer name",
"email":"[email protected]"
}
';
$cSession = curl_init();
$auth = base64_encode($user . ':' . $apiKey);
$headers = array();
$headers[] = 'Authorization: Basic ' . $auth;
$headers[] = 'Content-Type: application/json';
curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers);
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);
$result = curl_exec($cSession);
curl_close($cSession);
echo $result;
?>