If you’re a LiveChat Partner with an appetite for growth, you’re in luck: the team behind the Partner Program have released a new API that is A) opening vast new possibilities, and B) open itself. Let’s take a look at what it offers and what you can do with it.
As LiveChat Affiliate or a Solution Partner, you can now craft yourself the tools that will help you track and improve your performance.
What can you make it do?
There are many things you can do with Partners API. In fact, the whole dashboard is built on top of it. In this post, we’ll show you some examples of how things are working under the hood. You’ll also learn how to use the API to:
collect information about your earnings,
create a new campaign,
create a subscription for your clients.
In order to use Partners API in your own project, you have to be our Partner in the first place. Then, you want to generate API token so you can append it in every request you’re going to make.
Collect information about your earnings
It’s easy to make money being a LiveChat Partner so getting your earning info may be very important. When you go to Affiliate Partner section in the dashboard, among other details, you can see your total earned commission and a current balance.
How you’d get this information in your own tool or application?
Just make a GET
request to https://api.livechatinc.com/v2/partners/earnings
cURL example:
curl "https://api.livechatinc.com/v2/partners/earnings" \
-H "Authorization: Bearer <YOUR_API_TOKEN>"
In the response you’ll get a json containing the following properties:
{
"balance":641.50,
"commission":9894,
"blocked":0,
"withdrawals": 9252.50,
"pending":0,
"discount":21569.8
}
You can find there a value of balance, commission, and also additional data, e.g. withdrawals
which indicates how much money you have already withdrawn.
Create a new campaign
By default, you have your own affiliate link that looks like this:
https://www.livechat.com/?a=<YOUR_PARTNER_ID>
When you share it and someone would click on it and sign up for LiveChat, they would get a 30-day trial - and you’d get 20% lifetime commission once they convert to a paid user - that’s a standard. But you can do better.
Campaigns allow you to extend trial duration (up to 60 days) and add a discount for end-user. You can also point user to /signup
or to other subpages instead of LiveChat homepage. These three additional options can lay in your affiliate link.
You can create a new campaign in Campaigns tab in the dashboard.
You probably knew that already but...
Do you know you can create a campaign from your own project?
Make a POST
request to https://api.livechatinc.com/v2/partners/affiliates/campaigns
with the following payload:
name
- required - campaign name (min. 5, max. 100 characters)
trial_duration
- required - days of trial period (min. 30, max. 60)
coupon_id
- optional - ID of the coupon assigned to partner (will apply a discount)
link
- optional - slug of LiveChat page. If you want the campaign to point end-user to https://www.livechat.com/signup/, set
link
param tosignup/
(we will add https://www.livechat.com/ automatically)
- optional - slug of LiveChat page. If you want the campaign to point end-user to https://www.livechat.com/signup/, set
How can you get coupon_id?
Make a GET
request to https://api.livechatinc.com/v2/partners/coupons
- in the response you’ll receive an array with available coupons, e.g.:
{
"result": [
{
"id": 1,
"label": "30% off first payment"
},
{
"id": 2,
"label": "$25 discount"
}
]
}
Getting back to campaign creation, here’s a cURL example:
curl "https://api.livechatinc.com/v2/partners/affiliates/campaigns" \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
-X POST \
-d "name=Summer campaign&trial_duration=45&coupon_id=1"
If everything went smooth, you’d get 201
status code and response with a newly created campaign:
{
"name": "Summer campaign",
"slug": "pp_summer-campaign",
"trial_duration": 45,
"discount": "30% off first payment",
"url": "https://www.livechat.com/?a=<YOUR_PARTNER_ID>&utm_campaign=pp_summer-campaign",
"short_url": "https://lc.chat/<SHORT_LINK>",
"creation_timestamp": "2018-05-16 17:30:40"
}
url
and short_url
props contain new links you can share and end-users will get both extended trial period and special discount on the first payment.
Create subscriptions for your clients
For security reasons, we don’t store any credit card data on our side at LiveChat. When you have many clients as a Solution Partner, using a dashboard, it could be inconvenient to enter the same CC details every time you want to create a subscription for a client. Here’s how using our API with your tool and database can make this process as automatic as possible.
Let’s say you have a database (or even a JSON file) with your credit card details and your own app where you can see a list of your clients. You can have a small form with three fields (Plan, Seats, and Billing cycle) and Create subscription button next to every single trial license with a click event which does the following operations:
1. Get data from the click (basically, you pass it through the button click event)
You need license ID and parameters of new subscription:
plan
- one of
starter
,team
orbusiness
(compare plans),
- one of
seats
- number of agents who can log to LiveChat at the same time (min. 1),
billing_cycle
monthly
orannual
(annual gets 15% off).
2. Get token from Recurly - necessary for creating a subscription
Make simple GET
request to https://api.recurly.com/js/v1/token
with the following parameters:
key=ewr1-QCXZap10wOSm13fxI4u5Jt
(public key),first_name
- first name,
last_name
- last name,
number
- credit card number,
month
- credit card expiration month (format: MM),
year
- credit card expiration year (format: YYYY),
verification_value
- CVV code,
address1
- address,
city
- city,
state
- state,
zip
- ZIP/Postal code,
country
- country code, one of these.
Instead of manually entering the values above, you just get it from your source (database, json file, etc).
When the request is valid, you’ll receive a response with an id property which is our token we’re going to use in step #3.
3. Create an actual subscription
Having a license ID and subscription details (from step #1) and token (from step #2) you can make the last POST
request to https://api.livechatinc.com/v2/partners/resellers/licenses/<LICENSE_ID>/subscription
with the following payload:
plan
- from step #1,
billing_cycle
- from step #1,
seats
- from step #1,
token
- from step #2.
Example cURL request:
curl "https://api.livechatinc.com/v2/partners/resellers/licenses/<LICENSE_ID>/subscription" \
-H "Authorization: Bearer <YOUR_API_TOKEN>" \
-X POST \
-d "plan=business&seats=50&billing_cycle=annual&token=<TOKEN>"
Having 201
status code means everything went fine and subscription has been created successfully
Wrapping up
Remember that you can write to partners@livechatinc.com anytime, and with any questions about the API and it’s deployment. We strongly advise checking API documentation where you can find all available endpoints and described required parameters. We’re always happy to help, and you can contact us in the comments section below, or by chatting with us.