For a while now, Apptivo has allowed customers to integrate their website, or other outside applications using our API. We’re happy to announce a new REST API, which is not only more powerful, but also simpler to implement. While the existing SOAP API allowed for many useful functions, such as placing a form on your website that could generate a lead in your CRM, it had limitations. Customers have been requesting more advanced capabilities, such as being able to not only write data into the system, but pull data out from the system to do things such as customized user portals, special reporting tools, or integrations with other applications.

Using the REST API

While the new API is still under active development, it’s online and available for use. Today we ran our first presentation on using the REST API, and demonstrated how to create a simple web form, that generates a support request inside of Apptivo. Using the REST API the form is able to search for a customer within the CRM, determine if exists and create one if needed, then generate a support ticket linked up with that customer. If you weren’t able to attend the webinar, we’ve recorded everything here for you:

Cases API Workshop – Webinar Recording

Please note, this video is only recommended for programmers or those with moderate technical skills.

Code Example

Here is the example code that was produced during the demonstration in the video above.


/* START Config Settings */
$api_key = 'cb83cbc3-7efc-4457-9beb-a72871187cea';
$access_key = 'grxPZSZKvEtB-eIArCNDnLNXl-0910a13e-651b-4e63-8175-86cb8f243b2a';
$user_email_address = '';
$api_environment = '';
/* END Config Settings */

        //Support case info collected from the web form
                $case_subject = $_POST['case_subject'];
                $case_description = $_POST['case_description'];
                $customer_email_address = $_POST['customer_email'];
                $contact_email_address = $_POST['customer_email'];
        //Initialize cUrl
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,   0);
                curl_setopt($ch, CURLOPT_SSLVERSION, 3);
                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,   0);
        // Check if a customer already exists
        $api_get_customer_url = $api_environment.'customer?a=getAllcustomersByEmailId&apiKey='.$api_key.'&accessKey='.$access_key.'&assigneeId=30389&assignedType=employee&emailId='.$customer_email_address.'&userName='.$user_email_address;
        curl_setopt($ch, CURLOPT_URL, $api_get_customer_url);

        $dat_result = curl_exec($ch);
        $api_response = json_decode($dat_result);
        if(!$api_response->numResults > 0)
                //No customer exists, return an error
                $api_create_customer_url = $api_environment.'customer?a=createNewCustomer&objectId=3&customerData={"customerName":"'.$customer_email_address.'","customerEmail":"'.$customer_email_address.'","customerNumber":"Auto+generated+number","phoneNumber":"","customerCategoryId":"","mobileNumber":"","":"","employeeId":"23463","assigneeType":"employee","faxNumber":"","skypeName":"","description":""}&addressData1:["-1","70","7B/71,23,Tamizhan+Street","New+Ramnad+Road","Madurai","Madurai","Tamil+Nadu","625009","70"]&addressData2:["-1","70","7B/71,24,Meenakshi+Street","New+Ramnad+Road","Madurai","Madurai","Tamil+Nadu","625009","70"]&apiKey='.$api_key.'&accessKey='.$access_key;
                curl_setopt($ch, CURLOPT_URL, $api_create_customer_url);

                $dat_result = curl_exec($ch);
                $api_response = json_decode($dat_result);
        //A customer was found, create the case and attach to customer
        $case_subject = urlencode($case_subject);
        $case_description = urlencode($case_description);

        $api_request_url = $api_environment.'cases?a=createCase&caseDetails={"caseNumber":"Auto+generated+number","subject":"'.$case_subject.'","description":"'.$case_description.'","customerEmailId":"'.$customer_email_address.'","resType":"mobile"}&apiKey='.$api_key.'&accessKey='.$access_key.'&userName='.$user_email_address;

        curl_setopt($ch, CURLOPT_URL, $api_request_url);
        $api_response = json_decode(curl_exec($ch));

        if($api_response && $api_response->responseCode == '0')
                $form_message = 'Your case was successfully submitted.';
                $form_message = 'Sorry, there was an error submitting your information.  Please contact us directly.';
        $form_message = 'Please enter your case details below';

/* START Web Form */
                        <form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">
                                <label>Subject: </label>
                                <input type="text" name="case_subject" />
                                <label>Company Email: </label>
                                <input type="text" name="customer_email" />
                                <label>Description: </label>
                                <textarea name="case_description"></textarea>
                                <input type="submit" value="Submit" />

/* END Web Form */


Leave a Reply

Latest Blogs

How CRM Improve Business Performance

Business can be of any type, but one prime factor that all businesses focus on while boosting the business performance metrics is customer relationship management. Customer Relationship Management is the backbone for efficient business performance management

Read more 

5 Smart Ways To Manage Your Real Estate Leads - Real Estate CRM

The Real Estate industry is a developing arena forming a significant part of the construction sector. The Real Estate business has existed since the beginning

Read more 

Apptivo Mobile Release Updates as of December 28, 2021 – Android All-In-One Mobile App: v6.3.10

We are back with the latest updates from Apptivo’s Android application. As this year comes to an end, we have rolled out version 6

Read more