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 (Pro Tip: Open this in a new tab.)
To manage affiliate information (i.e. Name, Phone, etc.) you will need to use the DataService.
Adds a record to the specified table in Infusionsoft.
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 |
Return: (int) the new records unique ID number
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><i4>26</i4></value> </param> </params> </methodResponse>
$conDat = array('FirstName' => 'John', 'LastName' => 'Doe', 'Email' => 'JDoe@email.com'); $conID = $app->dsAdd("Contact", $conDat);
Loads a struct with data from the given database record
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 |
Return: (struct) the specified fields for the given contact record
<?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>
<?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>
$returnFields = array('Email', 'FirstName', 'LastName'); $conDat = $app->dsLoad("Contact", 123, $returnFields);
Updates the specified record (indicated by ID) with the data provided
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 |
Return: (int) the ID number of the updated record
<?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>
<?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>
$grp = array('GroupName' => 'Test Group', 'GroupDescription' => 'This tag was Created with api'); $grpID = 97; $grpID = $app->dsUpdate("ContactGroup", $grpID, $grp);
Deletes the specified record in the given table from the database
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 |
Return: (boolean) True/False
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><boolean>1</boolean></value> </param> </params> </methodResponse>
$result = $app->dsDelete('Contact',123);
This will locate all records in a given table that match the criteria for a given field
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 |
Return: (array) array of structs, one per result found. The struct will contain all fields specified in the method call with their corresponding value
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><array><data/></array></value> </param> </params> </methodResponse>
$returnFields = array('ContactId','ContactGroup'); $contacts = $app->dsFind('ContactGroupAssign',5,0,'GroupId',97,$returnFields);
Performs a query across the given table based on the query data
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 |
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) |
Return: (array) array of structs, one per result found by the query. The struct will contain all fields specified by selectedFields with their correspondingvalues
<?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>
<?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>
$returnFields = array('Id','FirstName'); $query = array('FirstName' => 'justin'); $contacts = $app->dsQuery("Contact",10,0,$query,$returnFields);
Creates a new custom fields within Infusionsoft
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 |
Note: If you are utilizing the API to create the custom field tab and header, before running addCustomField you will
need to utilize the DataService.add method to create the tab and header. You create the tab by adding to the
DataFormTab table. There are two fields on that table you will need to populate, TabName and FormId.
TabName is the display name for that custom tab.
FormId tells the system what record this custom tab appears on. Contacts, Orders, Affiliates, etc. Here are the
values for the FormId field:
1 - Contact record
3 – Affiliate record
4 – Opportunity record
6 – Company record
9 – Order record
10 – Subscription record
After creating the tab, create the Header by adding a line to the table called DataFormGroup.
Return: (int) ID of the custom field added
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value><i4>4</i4></value> </param> </params> </methodResponse>
$newField = $app->addCustomField('Contact','Test Field','Text',1);
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
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 |
Return: (int) user ID of the authenticated user
<?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>
<?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>
$uid = $app->authenticateUser("JDoe","Test123");
This method will return back the data currently configured in a user configured application setting
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 |
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.
Return: (string) Current values in given application setting
<?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>
<?xml version='1.0' encoding='UTF-8'?> <methodResponse> <params> <param> <value>Prospect,Customer,Partner,Personal Contact,Vendor</value> </param> </params> </methodResponse>
$result = $app->dsGetSetting('Contact', 'optiontypes');
Returns an iCalendar entry for the given appointment
Parameter Name | Type | Definition |
---|---|---|
privateKey | string | Your Infusionsoft API key |
appointmentId | int | The id of the appointment you want the calendar for |
Returns an iCalendar entry for the given appointment
<?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>
<?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>
$carray = array( php_xmlrpc_encode($app->key), php_xmlrpc_encode(2)); $app->methodCaller("DataService.getAppointmentICal",$carray);
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.
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 |
Return: (string) a temporary API key valid for one hour
<?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>
$carray = array( php_xmlrpc_encode($app->key), php_xmlrpc_encode("user"), php_xmlrpc_encode(md5("password"))); $app->methodCaller("DataService.getTemporaryKey",$carray);
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)
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 |
Return: (boolean) True/False
<?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>
<?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>
$meta = $app->addCustomField('Contact','API TEST','Text',1); $values = array('Label' => 'API_TEST_UPDATE'); $status = $app->updateCustomField($meta,$values);