Manage Your Reseller Accounts with our API

ActiveCampaign resellers have a powerful tool at their disposal: our reseller API allows you to create your own interface for managing your reseller accounts. Combined with our standard API, this allows you to extend your own products and services to take advantage of reseller-specific functionality.

This article will provide a brief tutorial on how to use our API to establish a simple interface for managing your reseller accounts, which you can add to your own website or application.

We are going to demonstrate a step-by-step form that allows you to add new accounts, add a template for each account, and provide a link that logs-in the user automatically.

Requirements

Custom Domain

This tutorial assumes you have your own custom domain that you use for each account. For example, let’s say your custom domain is:

yourdomain.com

For each account created, it will be assumed to map to a sub-domain of the above. For example:

  • yourclient1.yourdomain.com
  • yourclient2.yourdomain.com

Getting Started

We are providing the entire script that you can use on your own site. Feel free to download it and compare with it as we walk through things below.

Start by defining your custom domain, ActiveCampaign reseller URL, and API Key towards the top of the script:

<?php

$your_domain = "yourdomain.com";
$reseller_api_url = "https://www.activecampaign.com";
$reseller_api_key = "";

?>

Resellers can find their API URL and key in the reseller administration interface:

Screenshot of reseller panel

Our HTML form (for the first step) will look like this:

Screenshot of the HTML form

When submitted, we first check if the account name exists, and if not, add the account:

$account_name = $_POST["account_name"];

// check if account name already exists
$name_exists = $ac->api("account/name_check?account={$account_name}");

if (!(int)$name_exists->success) {
  $alert = $name_exists->error;
}
else {

  // name is available. proceed with adding account.

  // add account
  $account = get_object_vars(json_decode('{
    "account": "' . $account_name . '",
    "cname": "' . $account_name . '.' . $your_domain . '",
    "name": "' . $client_name . '",
    "email": "' . $client_email . '",
    "notification": "' . $client_email . '",
    "plan": "' . $plan . '"
  }'));

  $account = $ac->api("account/add", $account);

}

If adding the account is successful, it will inherit your default branding settings that you have set up. For example:

Screenshot of Reseller admin panel

Next, we’ll need to pause the script for a minute or two (sometimes it can take a few minutes to fully create an account in the system).

sleep(120);

Then we can obtain that account’s API Key (so we can add data to the account on their behalf).

// obtain this account's API URL and key
$ac2 = new ActiveCampaign(ACTIVECAMPAIGN_URL, null, "admin",  $account->password);
$user_me = $ac2->api("user/me");

$_SESSION["account_api_url"] = $user_me->apiurl;
$_SESSION["account_api_key"] = $user_me->apikey;

Next we’ll add an email template to the system (so it is ready for your client to use immediately):

Screenshot of the HTML form

Here is the code to add the template:

// add template
$template = array(
  "name" => $name,
  "html" => htmlspecialchars($html),
  "template_scope" => "all",
);

$template = $ac->api("message/template_add", $template);

What we’ll also do is generate a log-in link that you can send to the user, which will log-in them in automatically. You can also share the username and password with them.

// get SSO link
$username = $_SESSION["username"];
$ip = $_SERVER["REMOTE_ADDR"];
$sso = $ac->api("auth/singlesignon?sso_user={$username}&sso_addr={$ip}&sso_duration=20");

$sso_url = $_SESSION["account_name"] . ".{$your_domain}/admin/main.php?_ssot={$sso->token}";

Screenshot of the HTML page

The user can log-in here with their username and password:

http://yourclient1.yourdomain.com/admin/

Or, using the automatic log-in link above will look something like this:

http://yourclient1.yourdomain.com/admin/main.php?_ssot=e09d6dc6df3bf91fe2b2f663cc8d0b2a

We also provide a sample email message that you could send to your user, informing them that their account was created, and containing useful links:

Again, grab our custom script and let us know if we can improve it, clarify anything, or help get this set up for you!

A trial is worth a thousand words.
Get started today, no credit card required.

 
 
  • Seriously awesome, thank you guys!!

  • gustavo

    Good to know, Active Campaign team are making continuos improvements.

    In regards of this spectacular deal, we had develop a module to help you create/ bill/ suspend/ unsuspend/ cancel your own clientes. is 100% based on new reseller API.

    Any interested in manage users using WHMCS, can contact me. gustavovillega at gmail dot com.

    Best regards and congratulations to AC developement team.

    gustavo.

    • jvandeboom

      If you have some more details on this please shoot over an email to info@activecampaign.com. We would like to check it out.

  • Any chance you guys could turn this into a WordPress plugin?

    • jvandeboom

      It isn’t something we would likely due in the near future (as typical usage has been people implementing this in all sorts of custom ways) but you could suggest it at feedback.activecampaign.com (to see if others have the same interest)

  • The custom script link at the bottom of this post is broken, please could you update it? Thanks!

  • The link to the script is broken https://gist.github.com/3743457

  • juanvillegas

    Hey Guys thanks for this. Have two questions that couldn’t find an answer for:
    -Does the API support testing keys? I mean, is there a way to test the apis without using real accounts?
    -Are webhooks enabled for the reseller API, or only for “traditional” API? For example, is there a way to be notified when a contact is added on an account created through the reseller API?

    Any clues are appreciated!

    • Hi – we don’t have an API “sandbox” mode or anything like that, but you can easily create free trial accounts and test the API that way. Yes, webhooks work on all accounts (even reseller-created accounts).

      • juanvillegas

        thanks!

    • Jon

      Hi Juan, Unfortunately, there are no test APIs on the reseller account. That is a good idea though and I would add that as an internal feedback for you. You can also add your suggestion at http://feedback.activecampaign.com.

      Webhooks are only for accounts and not for the reseller panel.

  • S├ębastien DE Carvalho

    This is serious business guys, i know, i’m always late to the party…