skip to content

API - Add New Client

URL: NewClient.php

JSON Option (recommended):

to use as JSON, append ?apiformat=json to the URL, then send through all variables as a JSON encoded string.

Required Fields:

username
password
client_invoice_name (255 characters max)
client_email (255 characters max)

Optional Fields:

client_branch_name (255 characters max)
client_account_number (255 characters max)
client_vat_nr (255 characters max)
client_phone_nr (20 characters max)
client_phone_nr2 (20 characters max)
client_fax_nr (20 characters max)
client_mobile_nr (20 characters max)
client_website (255 characters max)
contact_name (255 characters max)
contact_surname (255 characters max)
client_postal_address1 (255 characters max)
client_postal_address2 (255 characters max)
client_postal_address3 (255 characters max)
client_postal_address4 (255 characters max)
client_physical_address1 (255 characters max)
client_physical_address2 (255 characters max)
client_physical_address3 (255 characters max)
client_physical_address4 (255 characters max)
custom_field_1 (100 characters max)
custom_field_2 (100 characters max)
custom_field_3 (100 characters max)
custom_field_4 (100 characters max)
custom_field_5 (100 characters max)
custom_field_6 (100 characters max)
custom_field_7 (100 characters max)
custom_field_8 (100 characters max)
custom_field_9 (100 characters max)
custom_field_10 (100 characters max)
payment_terms - (string) valid options are: cod, 7 days, 14 days, 30 days, 60 days, 90 days. Use '' (empty string) for unspecified.

Returns:

Integer; //only an integer will be returned, which is either the new client_id or an existing client_id if the client already exists.

If anything else is returned, an error occurred and the error is returned as a string.

Example PHP code with JSON

$param['username'] = '';
$param['password'] = '';
$param['client_invoice_name'] = '';
$param['client_branch_name'] = '';
$param['client_phone_nr'] = '';
$param['client_phone_nr2'] = '';
$param['client_mobile_nr'] = '';
$param['client_website'] = '';
$param['client_email'] = '';
$param['client_vat_nr'] = '';
$param['client_fax_nr'] = '';
$param['contact_name'] = '';
$param['contact_surname'] = '';
$param['client_postal_address1'] = '';
$param['client_postal_address2'] = '';
$param['client_postal_address3'] = '';
$param['client_postal_address4'] = '';
$param['client_physical_address1'] = '';
$param['client_physical_address2'] = '';
$param['client_physical_address3'] = '';
$param['client_physical_address4'] = '';

$url = 'https://www.jobcardsonline.co.za/api/NewClient.php?apiformat=json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //set the url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return as a variable
curl_setopt($ch, CURLOPT_POST, 1); //set POST method
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($param)); //set the POST variables
$response = curl_exec($ch); //run the whole process and return the response

 

Updated: Mon, 29 March 2021