Data Service

The DataService is used to manipulate most data in Infusionsoft. It permits you to work on any available tables and has a wide range of uses. Here's a list of all available tables, and the fields they contain: InfusionSoft Tables

To manage affiliate information (i.e. Name, Phone, etc.) you will need to use the DataService.


DataService.add

Adds a record to the specified table in Infusionsoft.

Required Parameters

Parameter Name Type Definition
key string Your Infusionsoft API key
table string The Infusionsoft database table name
values struct An associative array of data you would like stored into this new row in the table

Returns

Return: (int) the new records unique ID number

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.add</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>tableName</string></value>
    </param>
    <param>
      <value><struct>
        <member><name>tableColumn1</name>
          <value><string>columnValue1</string></value>
        </member>
        <member><name>tableColumn2</name>
          <value><string>columnValue2</string></value>
        </member>
        <member><name>tableColumn3</name>
          <value><string>columnValue3</string></value>
        </member>
      </struct></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><i4>26</i4></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$conDat = array('FirstName' => 'John',
		'LastName'  => 'Doe',
		'Email'     => 'JDoe@email.com');
$conID = $app->dsAdd("Contact", $conDat);

DataService.load

Loads a struct with data from the given database record

Required Parameters

Parameter Name Type Definition
key string Your Infusionsoft API key
table string Infusionsoft database table name from which you want to load a record
recordId int The unique Id number for the record you would like to load
wantedFields array The fields you would like returned from this row in the database

Returns

Return: (struct) the specified fields for the given contact record

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.load</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>tableName</string></value>
    </param>
    <param>
      <value><int>idNumber</int></value>
    </param>
    <param>
      <value><array>
        <data>
          <value><string>field1</string></value>
          <value><string>field2</string></value>
          <value><string>field3</string></value>
        </data>
      </array></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>field1</name>
            <value>field1Value</value>
          </member>
          <member>
            <name>field2</name>
            <value>field2Value</value>
          </member>
          <member>
            <name>field3</name>
            <value>field3Value</value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$returnFields = array('Email', 'FirstName', 'LastName');
$conDat = $app->dsLoad("Contact", 123, $returnFields);

DataService.update

Updates the specified record (indicated by ID) with the data provided

Required Parameters

Parameter Name Type Definition
key string Your Infusionsoft API key
table string The Infusionsoft database table name
Id int The Id number of the record you would like updated on the given table
values struct An associative array of data you would like updated

Returns

Return: (int) the ID number of the updated record

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.updateCustomField</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><int>customFieldId</int></value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>contextOfField</name>
            <value><string>fieldValue</string></value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value><i4>4</i4></value>
        </member>
        <member>
          <name>faultString</name>
          <value>[DatabaseError]Error creating custom field</value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>

PHP iSDK Sample

$grp = array('GroupName'  => 'Test Group',
'GroupDescription'  => 'This tag was Created with api');
$grpID = 97;
$grpID = $app->dsUpdate("ContactGroup", $grpID, $grp);

DataService.delete

Deletes the specified record in the given table from the database

Required Parameters

Parameter Name Type Definition
key string Your Infusionsoft API key
table string The table you would like to delete the record from
Id int The id number of the record you want to delete

Returns

Return: (boolean) True/False

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.delete</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>tableName</string></value>
    </param>
    <param>
      <value><int>idNumberToDelete</int></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><boolean>1</boolean></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$result = $app->dsDelete('Contact',123);

DataService.findByField

This will locate all records in a given table that match the criteria for a given field

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
table string The Infusionsoft database table name
limit int How many records you would like returned. The maximum possible is 1000
page int The page of results you would like returned. The first page is page 0 (loop through pages to get more than 1000 records)
fieldName string The name of the field you would like to run the search on
fieldValue string The value stored in the field you would like to search by
returnFields array (of strings) The fields you would like returned from the table you are searching on

Returns

Return: (array) array of structs, one per result found. The struct will contain all fields specified in the method call with their corresponding value

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.findByField</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>tableName</string></value>
    </param>
    <param>
      <value><int>limit</int></value>
    </param>
    <param>
      <value><int>page</int></value>
    </param>
    <param>
      <value><string>fieldName</string></value>
    </param>
    <param>
      <value><string>fieldValue</string></value>
    </param>
    <param>
      <value><array>
        <data>
          <value><string>returnField1</string></value>
        </data>
      </array></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><array><data/></array></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$returnFields = array('ContactId','ContactGroup');
$contacts = $app->dsFind('ContactGroupAssign',5,0,'GroupId',97,$returnFields);

DataService.query

Performs a query across the given table based on the query data

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
table string The table to look in
limit int The number of records to pull (max 1000)
page int What page of data to pull (in case there are more than 1000 records). The paging starts with 0
queryData struct A struct containing query data. The key is the field to search on, and the value is the data to look for. % is the wild card operator and all searches are case insensitive. If you would like to query for an empty(null) field, use ~null~ in your query parameter, such as ‘FirstName' => ‘~null~'
selectedFields array What fields to return from the query

Optional Parameters

Parameter Name Type Definition
orderBy string The field which the results should be sorted by
ascending bool Changes the order of results to ascending instead of descending (default)

Returns

Return: (array) array of structs, one per result found by the query. The struct will contain all fields specified by selectedFields with their correspondingvalues

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.query</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>tableName</string></value>
    </param>
    <param>
      <value><int>limit</int></value>
    </param>
    <param>
      <value><int>page</int></value>
    </param>
    <param>
      <value><struct>
        <member><name>queryField</name>
          <value><string>query</string></value>
        </member>
      </struct></value>
    </param>
    <param>
      <value><array>
        <data>
          <value><string>returnField1</string></value>
          <value><string>returnField2</string></value>
        </data>
      </array></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value>
        <array>
          <data>
            <value>
              <struct>
                <member>
                  <name>FirstName</name>
                  <value>Chuck</value>
                </member>
                <member>
                  <name>Id</name>
                  <value><i4>22</i4></value>
                </member>
              </struct>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$returnFields = array('Id','FirstName');
$query = array('FirstName' => 'justin');
$contacts = $app->dsQuery("Contact",10,0,$query,$returnFields);

DataService.count

Performs a query across the given table based on the query data and returns the count of records

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
table string The table to look in
queryData struct A struct containing query data. The key is the field to search on, and the value is the data to look for. % is the wild card operator and all searches are case insensitive. If you would like to query for an empty(null) field, use ~null~ in your query parameter, such as ‘FirstName' => ‘~null~'

Returns

Return: (int) Count of records that match the specified query

Sample Request

<?xml version="1.0"?>
<methodCall>
    <methodName>DataService.count</methodName>
    <params>
        <param>
            <value>
                <string>APIKEY</string>
            </value>
        </param>
        <param>
            <value>
                <string>Contact</string>
            </value>
        </param>
        <param>
            <value>
                <struct>
                    <member>
                        <name>Email</name>
                        <value>
                            <string>test@example.com</string>
                        </value>
                    </member>
                </struct>
            </value>
        </param>
    </params>
</methodCall>

Sample Response

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
    <params>
        <param>
            <value>
                <i4>7</i4>
            </value>
        </param>
    </params>
</methodResponse>

PHP iSDK Sample

$query = array('FirstName' => 'justin');
$contacts = $app->dsCount("Contact",$query);

DataService.addCustomField

Creates a new custom fields within Infusionsoft

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
customFieldType string Where the custom field will be used inside Infusionsoft. Options include Contact, Company, Affiliate, Task/Appt/Note, Order, Subscription, or Opportunity
displayName string The label/name of this new custom field
dataType string What type of data this field will support. Text, Dropdown, TextArea, etc.
headerId int Which custom field header you want this field to appear under. Customer headers are located on custom tabs

Returns

Return: (int) ID of the custom field added

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.addCustomField</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>contextOfField</string></value>
    </param>
    <param>
      <value><string>displayName</string></value>
    </param>
    <param>
      <value><string>dataType</string></value>
    </param>
    <param>
      <value><int>headerID</int></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value><i4>4</i4></value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$newField = $app->addCustomField('Contact','Test Field','Text',1);

DataService.authenticateUser

This method is used to authenticate an Infusionsoft username and password(md5 hash). If the credentials match it will return back a User ID, if the credentials do not match it will send back an error message

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
username string The Infusionsoft username
passwordHash string An MD5 hash of the Infusionsoft users' password

Returns

Return: (int) user ID of the authenticated user

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.authenticateUser</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>userName</string></value>
    </param>
    <param>
      <value><string>password</string></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value><i4>13</i4></value>
        </member>
        <member>
          <name>faultString</name>
          <value>[FailedLoginAttempt]Invalid username and/or password.</value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>

PHP iSDK Sample

$uid = $app->authenticateUser("JDoe","Test123");

DataService.getAppSetting

This method will return back the data currently configured in a user configured application setting

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
module string The application module this setting is a part of
setting string The database name of the setting you would like the values returned for

Additional Notes

Note: to find the module and option names, view the HTML field name within the Infusionsoft settings. You will see something such as name="Contact_WebModule0optiontypes". The portion before the underscore is the module name. "Contact" in this example. The portion after the 0 is the setting name, "optiontypes" in this example.

Returns

Return: (string) Current values in given application setting

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.getAppSetting</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><string>moduleName</string></value>
    </param>
    <param>
      <value><string>settingName</string></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <params>
    <param>
      <value>Prospect,Customer,Partner,Personal Contact,Vendor</value>
    </param>
  </params>
</methodResponse>

PHP iSDK Sample

$result = $app->dsGetSetting('Contact', 'optiontypes');

DataService.getAppointmentICal

Returns an iCalendar entry for the given appointment

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
appointmentId int The id of the appointment you want the calendar for

Returns

Returns an iCalendar entry for the given appointment

Sample Request

<?xml version="1.0"?>
<methodCall>
   <methodName>DataService.getAppointmentICal</methodName>
      <params>
         <param>
            <value><string>privateKey</string></value>
         </param>
         <param>
            <value><int>appointmentId</int></value>
         </param>
       </params>
</methodCall>

Sample Response

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
    <params>
        <param>
            <value>BEGIN:VCALENDAR PRODID:-//Infusionsoft//iCal4j 1.0//EN VERSION:2.0 CALSCALE:GREGORIAN BEGIN:VEVENT DTSTAMP:20120430T235728Z DTSTART:20120430T181500Z DTEND:20120430T184500Z SUMMARY:blah UID:20120430T235728Z-vuurr24@fe80:0:0:0:d6be:d9ff:feaa:f495%3 DESCRIPTION: ORGANIZER;ROLE=REQ-PARTICIPANT;CN=Chris Conrey:mailto:chris@vuurr.com END:VEVENT END:VCALENDAR</value>
        </param>
    </params>
</methodResponse>

PHP iSDK Sample

$carray = array(
php_xmlrpc_encode($app->key),
php_xmlrpc_encode(2));

$app->methodCaller("DataService.getAppointmentICal",$carray);

DataService.getTemporaryKey

Returns a temporary API key which is valid for one hour if given a valid Vendor key and user credentials. For security, never store a users password in plaintext. You only need to pass the MD5 hash with this method, so only the MD5 hash needs to be stored.

Required Parameters

Parameter Name Type Definition
vendorKey string Your Infusionsoft Vendor key
username string An Infusionsoft username
passwordHash string An MD5 hash of the users' password. This is the password used to login to the Infusionsoft UI

Returns

Return: (string) a temporary API key valid for one hour

Sample Request

<?xml version="1.0"?>
<methodCall>
   <methodName>DataService.getTemporaryKey</methodName>
      <params>
         <param>
            <value><string>vendorKey</string></value>
         </param>
         <param>
            <value><string>username</string></value>
         </param>
         <param>
            <value><string>passwordHash</string></value>
         </param>
      </params>
</methodCall>

Sample Response


PHP iSDK Sample

$carray = array(
php_xmlrpc_encode($app->key),
php_xmlrpc_encode("user"),
php_xmlrpc_encode(md5("password")));

$app->methodCaller("DataService.getTemporaryKey",$carray);

DataService.updateCustomField

Updates a custom field. Every field can have it's display name and group id changed, but only certain data types will allow you to change values(dropdown, listbox, radio, etc)

Required Parameters

Parameter Name Type Definition
privateKey string Your Infusionsoft API key
customFieldId int The Id number of the custom field you would like to update
values struct The preset values for the given custom field

Returns

Return: (boolean) True/False

Sample Request

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.updateCustomField</methodName>
  <params>
    <param>
      <value><string>privateKey</string></value>
    </param>
    <param>
      <value><int>customFieldId</int></value>
    </param>
    <param>
      <value><struct>
        <member><name>contextOfField</name>
          <value><string>fieldValue</string></value>
        </member>
      </struct></value>
    </param>
  </params>
</methodCall>

Sample Response

<?xml version='1.0' encoding='UTF-8'?>
<methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value><i4>4</i4></value>
        </member>
        <member>
          <name>faultString</name>
          <value>[DatabaseError]Error creating custom field</value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>

PHP iSDK Sample

$meta = $app->addCustomField('Contact','API TEST','Text',1);
$values = array('Label' => 'API_TEST_UPDATE');
$status = $app->updateCustomField($meta,$values);