Merchant API Building Blocks
ShareASale’s API is an often untapped way to save time by automating common or repetitive tasks. Its technical nature, however, can be a barrier to truly tapping into the full potential of our API. In this tutorial, we are going to explore the step-by-step building blocks needed for a successful merchant API request.
Step #1: What do you want to do?
Decide what task you’d like to control using the API. Would you like to automate reconciliation by having transaction voids and edits reflected in ShareASale automatically? Try the VOID or EDIT API requests. The newest version of our Merchant API (3.0) will even allow you to void or edit child transactions related to an original, source transaction too. For example, a two-tier or leapfrog transaction could also be voided with the original order that triggered it, if applicable and necessary.
If you would like to have all ShareASale transactions on-hand locally for your own records, you could request the Transaction Detail Report using the API. All of your affiliates’ referred transactions would be returned and you can store them internally. Then, you’ll always know which transactions were referred by any affiliate without ever having to login!
For a final example, you might decide to automate your seasonal banner updates. The deal, banner, or text link edit API requests are perfect for that task and once setup might save you a bundle of time.
Start with: https://api.shareasale.com/w.cfm?
- ?merchantID=YourMerchantID (your merchant ID number)
- &token=abcDE1 (your unique token – tools tab > API)
- &version=3.0 (current API version – Tools > API)
- &action=void (your desired API action/request)
Step #2: Create the URL Request
All API requests are basically a URL – you might be familiar with something similar when navigating the web. When you type in the URL ‘www.facebook.com’ you’re requesting information from Facebook. For the ShareASale API your URL is ‘https://api.shareasale.com/w.cfm’.
Instead of the browser receiving a web page for a human, an API request is a script receiving data for a computer.
Let’s first create the URL:
Start with: https://api.shareasale.com/w.cfm
All requests must contain:
- ?merchantID= your merchant ID number
- &token= unique alphanumeric token received when account is set up for API use. Check your settings for yours.
- &action= one of the supported actions (edit, void, etc. from step 1 above)
- &version= currently 3.0
Step #3: Adding Additional Parameters
Working through a VOID transaction API request, we have the following so far:
Different API requests require extra parameters. A VOID API request also needs the minimum:
- &date= format mm/dd/yyyy of the original order’s date
- &ordernumber= your order number to be voided
- &reason= URL encoded text description of void reason
If we had an order number 123 originally placed on June 1st 2022 that was returned by a customer as the wrong size our request is now:
Step #4: The Final Touch
As a safety measure, ShareASale’s API requires you prove you really are our merchant. This prevents anyone other than yourself to void transactions, request reports, or edit banners!
That is why every request requires authentication. You can set only certain IP addresses to gain access, and/or send a special encoded authentication string with your request depending on the API version.
This is a bit technical, so read more on our Merchant API settings page (Tools >> Merchant API) including sample code to get you started. Once the authentication is setup, no more work is necessary.