09. Creating a Client

Once your customer has selected a ticket group from an event landing page it is time for the checkout process. 

New Customers

If this is a new customer, you must first create a Client before an Order can be created. Clients can, and in many cases must, also have related properties including, Company, Email Address(es), Phone Number(s), Address(es) and Credit Card(s). You can choose to create these related items, except for Credit Cards, at the same time you create the client or you can create each item individually using the specific endpoints. 

Returning Customers

Although Ticket Evolution does not provide you with the mechanism in which you can verify and authenticate returning customers, we do provide you with the ability to re-use existing Clients and their properties. Doing so will allow you to make subsequent purchases easier and faster as well as access your Client’s purchase history.

Once you have verified and authenticated a returning Client you can utilize the existing client_id for new orders as well as to present existing Email Addresses, Phone Numbers, Addresses and Credit Cards to make the check out process quick. If necessary, you can create additional of each of these items and even update existing ones as necessary.

Creating a Client with Related Properties with a Single Request

In the examples below we will create a Client named Ned Flanders who works for a Company named “The Leftorium” and has home and work Email Addresses and Addresses as well as home, work and cellular Phone Numbers in one single API request.

Creating a Client with related properties using cURL
curl -i \
-X POST \
-H "X-Signature: Vmv9v4xDs/0QRNqLWmhT5sjqeoF08Kcxrjcbs9tvP6M=" \
-H "X-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
  "clients": [
    {
      "office_id": 1937,
      "name": "Ned Flanders",
      "tags": [
        "VIP",
        "Left Handed",
        "Mustache Afficianado"
      ],
      "company": {
        "name": "The Leftorium"
      },
      "notes": "Fan of rock band Kovenant, (ex-girlfriend Rachel Jordan is singer).",
      "email_addresses": [
        {
          "label": "home",
          "address": "nedflanders@example.com",
          "is_primary": false
        },
        {
          "label": "work",
          "address": "theleftorium@example.com",
          "is_primary": true
        }
      ],
      "addresses": [
        {
          "label": "home",
          "name": "Ned Flanders",
          "company": null,
          "street_address": "742 Evergreen Terrace",
          "extended_address": null,
          "locality": "Springfield",
          "region": "OR",
          "postal_code": "97475",
          "country_code": "US",
          "is_primary_shipping": false,
          "is_primary_billing": true
        },
        {
          "label": "work",
          "name": "Ned Flanders",
          "company": "The Leftorium",
          "street_address": "7721 Springfield Mall Drive",
          "extended_address": "Suite 202",
          "locality": "Springfield",
          "region": "OR",
          "postal_code": "97475",
          "country_code": "US",
          "is_primary_shipping": true,
          "is_primary_billing": false
        }
      ],
      "phone_numbers": [
        {
          "label": "home",
          "country_code": "+1",
          "number": "541-555-0123",
          "extension": null,
          "is_primary": false
        },
        {
          "label": "work",
          "country_code": "+1",
          "number": "541-555-0987",
          "extension": 5,
          "is_primary": false
        },
        {
          "label": "cell",
          "country_code": "+1",
          "number": "541-555-0573",
          "extension": null,
          "is_primary": true
        }
      ]
    }
  ]
}' \
--url 'https://api.ticketevolution.com/v9/clients'
Creating a Client with related properties using ticketevolution-php
$company = new stdClass();
$company->name = 'The Leftorium';

$email_address_home = new stdClass();
$email_address_home->label = 'home';
$email_address_home->address = 'nedflanders@example.com';
$email_address_home->is_primary = false;

$email_address_work = new stdClass();
$email_address_work->label = 'work';
$email_address_work->address = 'theleftorium@example.com';
$email_address_work->is_primary = true;

$street_address_home = new stdClass();
$street_address_home->label = 'home';
$street_address_home->name = 'Ned Flanders';
$street_address_home->company = null;
$street_address_home->street_address = '742 Evergreen Terrace';
$street_address_home->extended_address = null;
$street_address_home->locality = 'Springfield';
$street_address_home->region = 'OR';
$street_address_home->postal_code = '97475';
$street_address_home->country_code = 'US';
$street_address_home->is_primary_shipping = false;
$street_address_home->is_primary_billing = true;

$street_address_work = new stdClass();
$street_address_work->label = 'work';
$street_address_work->name = 'Ned Flanders';
$street_address_work->company = 'The Leftorium';
$street_address_work->street_address = '7721 Springfield Mall Drive';
$street_address_work->extended_address = 'Suite 202';
$street_address_work->locality = 'Springfield';
$street_address_work->region = 'OR';
$street_address_work->postal_code = '97475';
$street_address_work->country_code = 'US';
$street_address_work->is_primary_shipping = true;
$street_address_work->is_primary_billing = false;

$phone_number_home = new stdClass();
$phone_number_home->label = 'home';
$phone_number_home->country_code = '+1';
$phone_number_home->number = '541-555-0123';
$phone_number_home->extension = null;
$phone_number_home->is_primary = false;

$phone_number_work = new stdClass();
$phone_number_work->label = 'work';
$phone_number_work->country_code = '+1';
$phone_number_work->number = '541-555-0987';
$phone_number_work->extension = '5';
$phone_number_work->is_primary = false;

$phone_number_cellular = new stdClass();
$phone_number_cellular->label = 'work';
$phone_number_cellular->country_code = '+1';
$phone_number_cellular->number = '541-555-0573';
$phone_number_cellular->extension = null;
$phone_number_cellular->is_primary = true;


$client = new stdClass();
$client->name = 'Ned Flanders';
$client->tags = [
    'VIP',
    'Left Handed',
    'Mustache Afficianado',
];
$client->company = $company;
$client->notes = 'Fan of rock band Kovenant, (ex-girlfriend Rachel Jordan is singer).';
$client->email_addresses = [
    $email_address_home,
    $email_address_work
];
$client->addresses = [
    $street_address_home,
    $street_address_work
];
$client->phone_numbers = [
    $phone_number_home,
    $phone_number_work,
    $phone_number_cellular
];


$response = $apiClient->createClients(['clients' => [$client]]);

Creating a Client with Related Properties with Multiple Requests

In the examples below we will create the same Client and properties as above using separate requests to each endpoint.

Create the company

Creating a Company using cURL
curl -i \
-X POST \
-H "X-Signature: zothvUyg1ShpFgiNwwYdZZU7+mMM2310FeIPDWEegrs=" \
-H "X-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"companies":[{"name":"The Leftorium"}]}' \
--url 'https://api.sandbox.ticketevolution.com/v9/companies?'

Create the Client using company_id 11228 which was in the response of the Companies / Create POST.

Creating a Client with a related, existing Company using cURL
curl -i \
-X POST \
-H "X-Signature: xukJ+gsqsQ2/S+6qcvl8Ckwec+mn3gMWI+eJRG86rQY=" \
-H "X-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
  "clients": [
    {
      "office_id": 1937,
      "name": "Ned Flanders",
      "tags": [
        "VIP",
        "Left Handed",
        "Mustache Afficianado"
      ],
      "company_id": 11228,
      "notes": "Fan of rock band Kovenant, (ex-girlfriend Rachel Jordan is singer)."
    }
  ]
}' \
--url 'https://api.sandbox.ticketevolution.com/v9/clients?'

Create the Email Addresses using client_id 168188 which was in the response of the Clients / Create POST.

Creating Email Addresses for an existing Client using cURL
curl -i \
-X POST \
-H "X-Signature: BgxMsvTC3tpTyUgwQuyEVvUHpD+iTDzq13F+fIGBlBE=" \
-H "X-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
  "email_addresses": [
    {
      "label": "home",
      "address": "nedflanders@example.com",
      "is_primary": false
    },
    {
      "label": "work",
      "address": "theleftorium@example.com",
      "is_primary": true
    }
  ]
}' \
--url 'https://api.sandbox.ticketevolution.com/v9/clients/168188/email_addresses?'

Create the Addresses using client_id 168188 which was in the response of the Clients / Create POST.

Creating Addresses for an existing Client using cURL
curl -i \
-X POST \
-H "X-Signature: x6jcsqlkbzN50HKd4llXO3SINFESQsmk3YrLWMN4KDw=" \
-H "X-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
  "addresses": [
    {
      "label": "home",
      "name": "Ned Flanders",
      "company": null,
      "street_address": "742 Evergreen Terrace",
      "extended_address": null,
      "locality": "Springfield",
      "region": "OR",
      "postal_code": "97475",
      "country_code": "US",
      "is_primary_shipping": false,
      "is_primary_billing": true
    },
    {
      "label": "work",
      "name": "Ned Flanders",
      "company": "The Leftorium",
      "street_address": "7721 Springfield Mall Drive",
      "extended_address": "Suite 202",
      "locality": "Springfield",
      "region": "OR",
      "postal_code": "97475",
      "country_code": "US",
      "is_primary_shipping": true,
      "is_primary_billing": false
    }
  ]
}' \
--url 'https://api.sandbox.ticketevolution.com/v9/clients/168188/addresses?'

Create the Phone Numbers using client_id 168188 which was in the response of the Clients / Create POST.

Creating Phone Numbers for an existing Client using cURL
curl -i \
-X POST \
-H "X-Signature: My34yt1WWrDw2N3oz8ogf02U3NZI2eAK4OfOKEYrT0I=" \
-H "X-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
  "phone_numbers": [
    {
      "label": "home",
      "country_code": "+1",
      "number": "541-555-0123",
      "extension": null,
      "is_primary": false
    },
    {
      "label": "work",
      "country_code": "+1",
      "number": "541-555-0987",
      "extension": 5,
      "is_primary": false
    },
    {
      "label": "cell",
      "country_code": "+1",
      "number": "541-555-0573",
      "extension": null,
      "is_primary": true
    }
  ]
}' \
--url 'https://api.sandbox.ticketevolution.com/v9/clients/168188/phone_numbers?'
Creating a Client with related properties using ticketevolution-php
// Create the Company
$company = new stdClass();
$company->name = 'The Leftorium';
$response = $apiClient->createCompanies(['companies' => [$company]]);
// Capture the company_id for use later
$company_id = $response['companies'][0]['id'];


// Create the Client
$client = new stdClass();
$client->name = 'Ned Flanders';
$client->tags = [
    'VIP',
    'Left Handed',
    'Mustache Afficianado',
];
$client->company = $company;
$client->notes = 'Fan of rock band Kovenant, (ex-girlfriend Rachel Jordan is singer).';
$response = $apiClient->createClients(['clients' => [$client]]);
// Capture the client_id for use later
$client_id = $response['clients'][0]['id'];


// Create the Email Addresses
$email_address_home = new stdClass();
$email_address_home->label = 'home';
$email_address_home->address = 'nedflanders@example.com';
$email_address_home->is_primary = false;

$email_address_work = new stdClass();
$email_address_work->label = 'work';
$email_address_work->address = 'theleftorium@example.com';
$email_address_work->is_primary = true;

$response = $client->createClientEmailAddresses([
    'client_id'       => $client_id,
    'email_addresses' => [
        $email_address_home,
        $email_address_work
    ]
]);


// Create the Addresses
$street_address_home = new stdClass();
$street_address_home->label = 'home';
$street_address_home->name = 'Ned Flanders';
$street_address_home->company = null;
$street_address_home->street_address = '742 Evergreen Terrace';
$street_address_home->extended_address = null;
$street_address_home->locality = 'Springfield';
$street_address_home->region = 'OR';
$street_address_home->postal_code = '97475';
$street_address_home->country_code = 'US';
$street_address_home->is_primary_shipping = false;
$street_address_home->is_primary_billing = true;

$street_address_work = new stdClass();
$street_address_work->label = 'work';
$street_address_work->name = 'Ned Flanders';
$street_address_work->company = 'The Leftorium';
$street_address_work->street_address = '7721 Springfield Mall Drive';
$street_address_work->extended_address = 'Suite 202';
$street_address_work->locality = 'Springfield';
$street_address_work->region = 'OR';
$street_address_work->postal_code = '97475';
$street_address_work->country_code = 'US';
$street_address_work->is_primary_shipping = true;
$street_address_work->is_primary_billing = false;

$response = $client->createClientAddresses([
    'client_id' => $client_id,
    'addresses' => [
        $street_address_home,
        $street_address_work
    ]
]);


// Create the Addresses
$phone_number_home = new stdClass();
$phone_number_home->label = 'home';
$phone_number_home->country_code = '+1';
$phone_number_home->number = '541-555-0123';
$phone_number_home->extension = null;
$phone_number_home->is_primary = false;

$phone_number_work = new stdClass();
$phone_number_work->label = 'work';
$phone_number_work->country_code = '+1';
$phone_number_work->number = '541-555-0987';
$phone_number_work->extension = '5';
$phone_number_work->is_primary = false;

$phone_number_cellular = new stdClass();
$phone_number_cellular->label = 'work';
$phone_number_cellular->country_code = '+1';
$phone_number_cellular->number = '541-555-0573';
$phone_number_cellular->extension = null;
$phone_number_cellular->is_primary = true;

$response = $client->createClientPhoneNumbers([
    'client_id'     => $client_id,
    'phone_numbers' => [
        $phone_number_home,
        $phone_number_work,
        $phone_number_cellular
    ]
]);

Managing Client Properties

If you are going to offer a way for your Clients to have an account you should be sure to offer the ability for that Client to manage all of their related properties and add/delete/update items like Phone Numbers, Addresses, and Email Addresses. The Ticket Evolution API offers all of the endpoints necessary to offer this type of management. You can find the technical details under the documentation for each endpoint.  

A good example of how such properties can be managed at checkout—and also within a client profile section—is Amazon.com as shown below.