Skip to main content
All CollectionsAPI
Creating a New Account
Creating a New Account
Liam avatar
Written by Liam
Updated over a year ago

Creating a new Account using the API

The API is an open method that allows data to be programmatically inserted, updated or extracted.

API URL

New Accounts can be created from an external program by submitting xml via a POST http request:

<full path to FIVE CRM installation>/api.php?mode=import&hash=<hash>

Finding the full path to FIVE CRM

The normal path to your system is: http://[company_name].fivecrm.com

Open that URL, then right click and select View page source

Look for the line with the text: <frame name="mainFrame"

The full path is after src= between the quotes ("): <frame name="mainFrame" src="https://europe4.fivecrm.com/123456/index.php">

Take the path and replace index.php with api.php, for this example: https://europe4.fivecrm.com/123456/api.php

Parameters

mode

Use the appropriate mode option:

Function Mode

Creating a new account import

Adding contact history import

Updating existing accounts import

Updating existing contact name details import

Exporting account details import

Running reports import

<hash> is found by going to the Menu option, Setup > Users > User Profiles. Click on a Username, the hash is displayed at the top of the screen. Note that if the password is changed then the original hash will no longer work.

The XML is submitted in a post variable called โ€œxmlโ€

There is only a return value if an error occurred.

Example XML

<?xml version="1.0"?>

<importdata>

<area>001</area>

<data>

<notify>admin@company.com</notify>

<account>

<field table="TELRCM" field="COMPANY">Test Industries</field>

<field table="TELRCM" field="POSTCODE">AA01 0AA</field>

<field table="TELRCM" field="TELEPHONE">01234 567890</field>

<field table="TELRCM" field="CUSTOMERSTATUS">Not called</field>

<field table="TELRCM" field="OWNER">New data</field>

<field table="RCMANL" field="ANAL01">25</field>

</account>

<contact>

<field table="CONT" field="CONTACT">Test 1</field>

<field table="CONT" field="EMAIL">test@a.com</field>

</contact>

<contact>

<field table="CONT" field="CONTACT">Test 2</field>

<field table="CONT" field="EMAIL">test@aa.com</field>

</contact>

<contact>

<field table="CONT" field="CONTACT">Test 3</field>

<field table="CONT" field="EMAIL">test@aaa.com</field>

</contact>

</data>

<data>

<notify>admin@company.com</notify>

<account>

<field table="TELRCM" field="COMPANY">Test2 Industries</field>

<field table="TELRCM" field="POSTCODE">AA01 0AA</field>

<field table="TELRCM" field="TELEPHONE">01234 567890</field>

<field table="TELRCM" field="CUSTOMERSTATUS">Not called</field>

<field table="TELRCM" field="OWNER">New data</field>

<field table="RCMANL" field="ANAL01">25</field>

</account>

<contact>

<field table="CONT" field="CONTACT">Test 11</field>

<field table="CONT" field="EMAIL">test@a.com</field>

</contact>

<contact>

<field table="CONT" field="CONTACT">Test 22</field>

<field table="CONT" field="EMAIL">test@aa.com</field>

</contact>

<contact>

<field table="CONT" field="CONTACT">Test 33</field>

<field table="CONT" field="EMAIL">test@aaa.com</field>

</contact>

</data>

</importdata>

Notify

The Notify tag used in the example can be used to send an email or a system message to users. Multiple tags are supported (add each system User or email address on a newline), so you can email and message several people at once. If the notify value contains an @ sign, it is presumed to be a valid email address, otherwise it will look for a system user with that Username.

Note: If you wish to insert new Accounts and predefine an Account Number you will need to ensure you have the following code below the notify line in the XML.

<?xml version="1.0"?>

<importdata>

<area>001</area>

<data>

<notify>admin@company.com</notify>

<accountno>1001</accountno>

This is not something we advise to do as it means you will have to manage your Account Numbers ensuring they never overlap. If Account Numbers do overlap the matching Account will be updated with the new information instead of a new Account being created.

Example PHP Script

Note: This is only an example of how the API can be used from a PHP script. The actual script will depend on user implementation requirements.

<?php

/****************************************************************

Creating new accounts via the FIVE CRM API example

****************************************************************/

//example data

$notify = "FIVECRMuser1";

//$notify = "user1@fivecrm.com";

$company = "Silver Industries2";

$postcode = "AA01 0AA";

$telephone = "01234 567890";

$name = "John Smith";

$customerstatus = "Not called";

$owner = "New data";

$employees = "25";

//To update an record ensure that the account number is provided

//$account = "12345";

//to insert data into the system we need a unique "hash" code

$hash = "1debf279286ed5361157ccd7b843f04a";

//define what area to insert to

$area = "001";

//creating the xml document

$doc = new DOMDocument('1.0');

$doc->formatOutput = true;

//everything is contained in the import data tag

$importdata = $doc->createElement("importdata");

$doc->appendChild($importdata);

//Element for target area

$area = $doc->createElement("area",$area);

$importdata->appendChild($area);

//Create data tag

$data = $doc->createElement("data");

//Create Notify element

$notify = $doc->createElement("notify",$notify);

$data->appendChild($notify);

$importdata->appendChild($data);

//Create account tag

$account = $doc->createElement("account");

//Create account elements

$j = $doc->createElement("field",$company);

$j->setAttribute("table", "TELRCM");

$j->setAttribute("field", "COMPANY");

$account->appendChild($j);

$j = $doc->createElement("field",$postcode);

$j->setAttribute("table", "TELRCM");

$j->setAttribute("field", "POSTCODE");

$account->appendChild($j);

$j = $doc->createElement("field",$telephone);

$j->setAttribute("table", "TELRCM");

$j->setAttribute("field", "TELEPHONE");

$account->appendChild($j);

$j = $doc->createElement("field",$customerstatus);

$j->setAttribute("table", "TELRCM");

$j->setAttribute("field", "CUSTOMERSTATUS");

$account->appendChild($j);

$j = $doc->createElement("field",$owner);

$j->setAttribute("table", "TELRCM");

$j->setAttribute("field", "OWNER");

$account->appendChild($j);

$j = $doc->createElement("field",$employees);

$j->setAttribute("table", "RCMANL");

$j->setAttribute("field", "ANAL30");

$account->appendChild($j);

//Create contact elements.

//Can have more than one contact

$contact = $doc->createElement("contact");

$k = $doc->createElement("field",$name);

$k->setAttribute("table", "CONT");

$k->setAttribute("field", "CONTACT");

$contact->appendChild($k);

$k = $doc->createElement("field",$email);

$k->setAttribute("table", "CONT");

$k->setAttribute("field", "EMAIL");

$contact->appendChild($k);

//To update contact details provide an Contact_ID

// $k = $doc->createElement("field",$cid);

// $k->setAttribute("table", "CONT");

// $k->setAttribute("field", "CID");

// $contact->appendChild($k);

$data->appendChild($contact);

$xml = $doc->saveXML();

$data = http_build_query(array('xml' => $xml));

$params = array('http' => array('method' => 'POST','content' => $data ));

$ctx = stream_context_create($params);

$fp = fopen($url, 'rb', false, $ctx);

if (!$fp) {

die("<br>could not open url");

}

$response = @stream_get_contents($fp);

if ($response === false) {

die("<br>could not read from url");

}

?>

Did this answer your question?