Welcome, Snapforce Developer

This documentation provides a complete overview for developing your own integrations with Snapforce CRM. We explain the many uses other organizations use our API for, and discuss popular workflows. This documentation also explores the available methods at your disposal and real world code examples you can use to get your integration going.

Many customers want to utilize the Snapforce API to keep their data in sync with a proprietary application they are running, or to share data with a third-party service they are using, but whatever the reason – there are many useful ways to programmatically integrate your CRM.


Getting Started 

 

To get started, simply create your API access tokens inside Snapforce under the Developers page in your Administrator Setup area. You can create your initial access token and refresh it as often as needed. Once you complete that, the fun part begins – dive into the Snapforce API Documentation over the following pages and begin building your integrations!

 


Common API Workflows

Introduction

Snapforce CRM provides a RESTful web API, or “Application Programming Interface”, so customers can programmatically control all aspects of their data; inserts, updates, deletes, syncing etc. The only time you will need to use this API is if you are integrating another system, whether it be your company's proprietary systems, your erp, accounting software etc. Less commonly, users may wish to manipulate their CRM's data from an external application, like an Ipad or their users mobile devices. Additionally, the Snapforce API architecture always allows for you to make calls to your CRM, there is no limit on the amount of usage the API can be utilized for. The Snapforce culture believes that our customers should be able to access their data easily and however they wish, we do not believe in charging our users to access their data or make it difficult to do so.

The API in total contains over a half dozen calls that can be made and allows for filtered logic to be passed via the calls as well, which helps you (the programmer) to receive only the data you want and not have to manually parse and write a large amount of additional code to retreive the data you sought out in the first place to obtain. Most users of the API use only a few of the primary functions when implementing their integrations, and when they use these core functions in certain processes it can allow for a very robust workflow.

The remainder of this documentation walks you through the common workflows and gives PHP implementation examples.

If you are looking to quickly get your feet wet and setup a simple but useful integration we detail two of the most widely used API workflows below. In the two examples you will find code samples, syntax specifics, and explanatory information about both of these common workflows. If you are programming a much deeper or complex integration than feel free to skip the below “Primary Worfklows” section and move on to the API Calls documentation.

Primary Workflows - Workflow #1

The first workflow you may wish to implement is the “fetchRecords()” flow, which is simple and useful if you need to pull data out of Snapforce.

With the “fetchRecords()” flow you can (as an example) pull a list of Accounts, or a list of your newest leads, etc. This is one of the most widely used and basic processes of the API. An example of implementation using the PHP programming language can be found below.

 

/*
 * Snapforce Workflow #1 - fetchRecords()
 */
// This page uses cURL to post data to your Snapforce CRM.

// Identify the URL:
$url = 'https://crm2.snapforce.com/sf_receive_request.inc.php';

// Start the process:
$curl = curl_init($url);

$fetchRecords = 'format=xml&api_user=API User&api_key=API Key&module=Leads&status=Active&method=fetchRecords';

// Tell cURL to fail if an error occurs:
curl_setopt($curl, CURLOPT_FAILONERROR, 1); 

// Allow for redirects:
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);

// Assign the returned data to a variable:
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

// Set the timeout:
curl_setopt($curl, CURLOPT_TIMEOUT, 5);

// Use POST:
curl_setopt($curl, CURLOPT_POST, 1);

// Set the POST data:
curl_setopt($curl, CURLOPT_POSTFIELDS, $fetchRecords);

// Execute the transaction:
$r = curl_exec($curl);

// Close the connection:
curl_close($curl);

#####################################
# NOW LETS LOOP THROUGH THE RESULTS #
#####################################
libxml_use_internal_errors(true);    

    $xml = simplexml_load_string($r) or die("Error: Cannot create object");
    #print_r($xml);
    // Output each document
    #echo $xml->leads;
    foreach ($xml as $xml1) {
        echo $xml1->lead_id;
        echo $xml1->type;
        echo $xml1->website;
        echo $xml1->contact_first;
    }
                    

Primary Workflows - Workflow #2

The second workflow you may wish to implement is the “insertRecords()” flow, which is simple and useful if you need to push a lot of data into Snapforce.

With the “insertRecords()” flow you can (as an example) pull of the orders for the day out of your accounting system and insert them into your CRM system. This is one of the most widely used and basic processes of the API. See the correct XML structure for sending an insertRecords() request via the API.

Lead Id Type Owner Prefix Last NameContact Title Company Phone Fax Status Industry Country

Address

City State Postal code Latitude Longitude Email Website Username Lead Source Lead score Facebook page Twitter page Google+ page LinkedIn page Custom Field #1 Custom Field #2 Custom Field #3 Custom Field #4 Custom Field #5 Custom Field #6 Custom Field #7 Custom Field #8 Custom Field #9 Custom Field #10 Custom Field #11 Custom Field #12 Custom Field #13 Custom Field #14 Custom Field #15


Thank you very much for your continued support of Snapforce!