Want more great content like this? Click here to get more Infusionsoft API Tips, Tricks, and Scripts
The Infusionsoft API is the "Secret Sauce" for more powerful, profitable systems
The Infusionsoft API is the secret sauce that allows you to build more powerful systems with Infusionsoft. Most Infusionsoft users learn about the API when they invest in an Addon product like our Tactical Shipping product that connects Infusionsoft to shipping applications from UPS, FedEx, and others. We use the API in that product in a few different ways. For example, we use it to get data about orders that need to be shipped out of Infusionsoft, and to get tracking numbers for the packages back into Infusionsoft, then again to trigger an email with the tracking info to be sent to the customer.
You DON'T Need to be a Developer to use Other People's Scripts. Here's How:
While it's great that you can purchase useful addons for Infusionsoft, you should also know that the API can also be used for very simple, but powerful things, and you DON'T need to be a programmer to be able to benefit from it. You just need to be able to understand how to use existing scripts that were written by other folks. In fact, right in this very article I'm going to give you a script that you can use to set a custom field for a contact to a future date. You can use this script to keep track of renewal dates, expiration dates, etc. And once the date is in a field on the contact's record, it can then be merged into emails, or used to control the timing of steps in a campaign sequence.
So in this video and article, I will show you step-by-step
- How to set up the Infusionsoft iSDK on your server
- How to upload and configure a free script that you can use (and learn from)
- How to use that script in your own Infusionsoft campaigns
- Where to get more handy scripts and tutorials
By the way, the video above shows you the entire process. I've written out the steps below to make sure you don't miss anything. Feel free to print this page and check off the steps as you go. (Hint: Look for the printer icon at the top and bottom of the page to get a nice, clean printout.)
Ready? Let's get going...
How to set up the Infusionsoft iSDK
The easiest way to tap into the Infusionsoft API is through their official iSDK. That stands for Infusionsoft Software Developer Kit. For the techies out there, it's basically a library of useful functions that simplify life for a PHP developer. As I said before, you don't need to be a developer yourself to be able to use scripts created by other developers... but you DO need to have the iSDK on your server because many scripts are programmed to work with it. Here's how you do that:
Step 1 – Gather up the following:
- Your Infusionsoft application name
- This is the first part of the URL when you access Infusionsoft. For example, when I use my Infusionsoft Sandbox account (a special app used for testing things out that's provided to me as an Infusionsoft Certified Partner), the url is https://xxk90758.infusionsoft.com. My application name is "xxk90758" (without the quotes).
- Your API key
- Log into your Infusionsoft App
- From the Admin Menu, Choose Settings, then click Application on the left side of the page. Scroll down to the API area at the bottom of the page.
- Look for the long string of text called Encrypted Key - this is your API Key. Copy and paste it to a text document on your computer.
- If you found the right place, but there is no Encrypted Key yet, you can create one by entering a short passphrase, then click Save. When the page refreshes, you'll see your encrypted key. Copy and paste it to a text document on your computer.
- If you can't get to the Admin Menu, or to the Settings page on the Admin Menu, then your user account does not have the necessary permissions to access that part of Infusionsoft. Ask the owner of the Infusionsoft account to get the API key for you, or ask them to make you a member of the Administrators group.
- The latest Infusionsoft iSDK - download the Zip File from GitHub
- Look for the button on the right side of the page labeled "Download Zip"
- Example scripts for this tutorial - download the TMS Scripts Zip File
- This contains the two scripts used in this tutorial
- FTP Credentials to your hosting account.
- Server Address
- Your hosting account needs to support PHP. The vast majority do, because PHP is the most popular web development language out there. It's what powers WordPress, Drupal, Joomla, and many other popular platforms. If in doubt, ask your hosting provider.
- Many times you can use the main login that you use for accessing the control panel of your hosting account.
- If you've never used FTP and don't want to figure it out now, you can also upload files to your hosting account using a tool inside your control panel. It may be called File Manager or something similar. If in doubt, ask your web master or the tech support folks at your hosting company.
Step 2 - Copy the iSDK files to the tmsscripts folder
- Unzip the file called "tmsscripts.zip" that you downloaded in Step 1.
- You should then see a folder called tmsscripts, with 2 files inside
- Create a subfolder inside of tmsscripts called "isdk".
- Unzip the file called "PHP-iSDK-master.zip" that you downloaded from GitHub.
- You'll see a folder called PHP-iSDK-master with files and subfolders inside. We only need a few of these.
- Copy 4 files from the unzipped PHP-iSDK-master folder into your tmsscripts/isdk folder. Here's the full path to the 4 files:
Step 3 - Edit conn.cfg.php
- Open the conn.cfg.php file with a text editor like Notepad, TextEdit, or similar tool.
- Replace the placeholder text with your Application name (in 2 locations), API Key, and Connection Name
- Note - many people use their Infusionsoft application name for their connection name as well. I prefer to give it a friendly name - I use "sandboxchris" for my sandbox account.
- Write down what you use for the Connection Name because it will be required later when you configure your scripts.
Step 4 - Edit isdk.php to provide new path to xmlrpc.inc
Because we're not uploading the entire XML RPC library, we need to tell the isdk.php file to look for xmlrpc.inc in a different location. It's very easy. Just do the following:
- Open the isdk.php file with a text editor
- Change the line that contains
Step 5 - Edit the TMS Scripts
Note - in the video, I uploaded them then edited the files. You might not be able to easily edit online files with your text editor, so I recommend that you edit them first, then upload them.
- Open the tms-isdk-test.php file with a text editor and verify the path to the isdk.php file (this should not need to be changed if you've followed the directions above) and provide the name of your connection.
- Do the same thing with tms-set-future-date.php
Now what we’re going to do is we’re going to upload this whole folder with the subfolders and the 2 files here up to your server. I’m already connected in ftp. I’m in my site root over here and let’s see here. I’m going to take this tms scripts folder, drag it over to there and now I’m all online.
Now I just need to test my connection and I have this tms ISDK file that I’m giving you to help you with testing. What you’re going to do is you’re going to go to
Step 6 - Upload the "tmsscripts" folder and the "isdk" subfolder to your server
- Use your FTP program or the File Manager in your hosting control panel to upload the "tmsscripts" folder (and everything inside of it) to the root of your web site. For most hosting accounts, the root is "public_html".
Step 7 - Test your configuration / connection with tms-isdk-test.php
- Open up your web browser and enter the full URL to the test script. For example:
- You should see a message saying "Wooohooo! We connected to Infusionsoft!"
- If you get an error message, check the following table to see where you might have gone wrong:
Frequently Seen Error Messages When Setting Up the Infusionsoft iSDK (and what to do about them)
If you see this...
|Warning: require_once(yourfolder/isdk/isdk.php): failed to open stream: No such file or directory in...Fatal error: require_once(): Failed opening required 'yourfolder/isdk/isdk.php' (include_path='.:/usr/share/pear:/usr/share/php') in...||Make sure you have specified the right path to the isdk.php file.|
|Undefined index: connectionName in /home/youraccount/public_html/yourfolder/isdk/isdk.php on line 49Notice: Undefined index: connectionName in /home/youraccount/public_html/yourfolder/isdk/isdk.php on line 50Fatal error: Uncaught exception 'iSDKException' with message 'ERROR: 8 - CURL error: Couldn't resolve host||Make sure you have specified the same connectionName in the script that you used in conn.cfg.php|
|Fatal error: Uncaught exception 'iSDKException' with message 'ERROR: 2 - [InvalidKey]Invalid Key' in...||Make sure you have entered the correct API Key in conn.cfg.php|
|Fatal error: Uncaught exception 'iSDKException' with message 'ERROR: 8 - CURL error: Couldn't resolve host 'yourapp.infusionsoft.com'' in...||Make sure you have entered the correct name of your Infusionsoft app in conn.cfg.php|
|Fatal error: Uncaught exception 'iSDKException' with message 'ERROR: 8 - CURL error: Problem with the SSL CA cert (path? access rights?)' in...||Make sure you have the infusionsoft.pem file in the same folder as isdk.php|
|Warning: include(/home/youraccount/public_html/yourfolder/isdk/conn.cfg.php): failed to open stream: No such file or directory in...||Make sure you have the conn.cfg.php file in the same folder as isdk.php|
After you've verified your settings with the tms-isdk-test.php script (by seeing a message saying "Wooohooo! We connected to Infusionsoft!"), continue on to the next step.
Step 8 - Set up a Campaign and HTTP POST to trigger the tms-set-future-date.php script
Note - API scripts can be triggered in a few different ways. One of the most common ways is with the HTTP POST feature that is built into the Infusionsoft Campaign Builder. In this step, you'll set up a very simple campaign so that you understand how to do it.
- Choose or create a custom date field that you want the script to update. In the video, I used a field called "Renewal Date".
- Get the "Database Name" of the custom field. For my field, the database name is "RenewalDate", and because it is a custom field (as opposed to a built-in field that comes with Infusionsoft), I will refer to it as "_RenewalDate".
- Create a tag called "Set Renewal Date" (or whatever is appropriate for you). I like to put any tag that triggers a campaign into a special category called "Campaign Tags". That's optional, but a good practice to follow. (Go to CRM -> Settings -> Tags to create your tag so that you can put it into a category).
- Create a new campaign in Campaign Builder called "API Test" or something similar.
- Lay out your campaign with a Tag Applied Goal leading into a sequence like so:
- Double-click on the text below the goal and sequence to change the default text to something descriptive (optional but definitely a good practice to follow).
- Configure the goal to use the tag you created earlier.
- Double-click the sequence to edit it.
- Add a step to the sequence that removes the tag that achieved the goal. This will allow you to use the same script multiple times for the same contact if needed.
- Add a step that sends an HTTP POST. The inside of your sequence should like like this:
- Configure the HTTP POST with the URL and name/value pairs like this:
- Finally, publish the campaign, then add the campaign tag to a test contact. Within a minute or so you should see the future date show up in the custom field on their contact record!
Was this helpful? Want more great content like this? Click here to get more Infusionsoft API Tips, Tricks, and Scripts
How did it go?Leave a comment below to let us know if you were successful. Run into issues? Let us know that, too! You can leave a comment by clicking here.