Modules@robinpath/activecampaign
activecampaign

@robinpath/activecampaign

0.1.2Node.jsPublic

ActiveCampaign -- contacts, automations, campaigns, deals, lists, and tags via the ActiveCampaign REST API v3.

ActiveCampaign

ActiveCampaign -- contacts, automations, campaigns, deals, lists, and tags via the ActiveCampaign REST API v3.

The activecampaign module wraps the ActiveCampaign REST API (v3), providing full access to contact management, email campaign orchestration, marketing automations, deal pipelines, lists, and tag systems. It enables you to build marketing workflows, manage subscriber segments, and track sales deals directly from RobinPath scripts.

Package: @robinpath/activecampaign | Category: Email Marketing | Type: Integration

Authentication

ActiveCampaign requires an account name (your subdomain) and an API token. You can find both in your ActiveCampaign account under Settings > Developer.

  • Account name: The subdomain in your ActiveCampaign URL (e.g., mycompany from https://mycompany.activehosted.com)
  • API token: Found on the same Developer settings page
activecampaign.setCredentials "mycompany" "your-api-token-here"

Call setCredentials once at the start of your script before using any other function. Credentials persist for the duration of the script execution.

Use Cases

Use the activecampaign module when you need to:

  • Manage contacts -- create, update, delete, and list contacts in your ActiveCampaign account
  • Automate email marketing -- add contacts to automations and trigger campaign workflows
  • Track sales deals -- create and update deals in your CRM pipeline
  • Organize subscribers -- manage lists, tags, and contact segmentation
  • Build lead nurturing flows -- combine contacts, tags, lists, and automations into multi-step workflows
  • Sync CRM data -- pull contacts, deals, and campaign data into other systems

Quick Reference

FunctionDescriptionReturns
setCredentialsConfigure API credentials (account name + token)string
listContactsList all contacts, optionally filtered{ contacts, meta }
getContactGet a single contact by ID{ contact }
createContactCreate a new contact{ contact }
updateContactUpdate an existing contact by ID{ contact }
deleteContactDelete a contact by ID{}
listListsList all mailing lists{ lists, meta }
getListGet a mailing list by ID{ list }
createListCreate a new mailing list{ list }
addContactToListSubscribe a contact to a list{ contactList }
removeContactFromListUnsubscribe a contact from a list{}
listTagsList all tags{ tags, meta }
createTagCreate a new tag{ tag }
addTagToContactApply a tag to a contact{ contactTag }
removeTagFromContactRemove a tag from a contact{}
listAutomationsList all automations{ automations, meta }
addContactToAutomationEnroll a contact into an automation{ contactAutomation }
listDealsList all deals in the CRM{ deals, meta }
createDealCreate a new deal{ deal }
updateDealUpdate an existing deal by ID{ deal }
listCampaignsList all email campaigns{ campaigns, meta }

Functions

setCredentials

Configure ActiveCampaign API credentials. Must be called before any other function.

Module: activecampaign | Returns: string -- "Activecampaign credentials configured."

activecampaign.setCredentials "mycompany" "your-api-token"
ParameterTypeRequiredDescription
accountNamestringYesYour ActiveCampaign account subdomain (e.g., "mycompany")
apiTokenstringYesYour ActiveCampaign API token from Settings > Developer

Errors:

  • "activecampaign.setCredentials requires accountName, apiToken." -- one or both arguments missing

listContacts

Retrieve a paginated list of all contacts in your account.

Module: activecampaign | Returns: object

set $result as activecampaign.listContacts
set $contacts as $result.contacts
ParameterTypeRequiredDescription
(none)NoCall with no arguments to list all contacts

Return shape:

{
  "contacts": [
    { "id": "1", "email": "jane@example.com", "firstName": "Jane", "lastName": "Doe", "phone": "+1234567890", "cdate": "2024-01-15T10:30:00-05:00" }
  ],
  "meta": { "total": "150" }
}

getContact

Retrieve a single contact by their ID.

Module: activecampaign | Returns: object

set $result as activecampaign.getContact "42"
set $email as $result.contact.email
set $name as $result.contact.firstName
ParameterTypeRequiredDescription
idstringYesThe contact ID to retrieve

Return shape:

{
  "contact": {
    "id": "42",
    "email": "jane@example.com",
    "firstName": "Jane",
    "lastName": "Doe",
    "phone": "+1234567890",
    "cdate": "2024-01-15T10:30:00-05:00",
    "udate": "2024-06-20T14:00:00-05:00"
  }
}

createContact

Create a new contact in ActiveCampaign.

Module: activecampaign | Returns: object

set $result as activecampaign.createContact {"email": "jane@example.com", "firstName": "Jane", "lastName": "Doe", "phone": "+1234567890"}
set $newId as $result.contact.id
ParameterTypeRequiredDescription
dataobjectYesContact fields: email (required), firstName, lastName, phone

Accepted fields in data object:

FieldTypeDescription
emailstringContact email address (required)
firstNamestringFirst name
lastNamestringLast name
phonestringPhone number

Return shape:

{
  "contact": {
    "id": "55",
    "email": "jane@example.com",
    "firstName": "Jane",
    "lastName": "Doe",
    "phone": "+1234567890",
    "cdate": "2024-06-20T14:00:00-05:00"
  }
}

updateContact

Update an existing contact's fields by their ID.

Module: activecampaign | Returns: object

set $result as activecampaign.updateContact "42" {"firstName": "Janet", "phone": "+9876543210"}
ParameterTypeRequiredDescription
idstringYesThe contact ID to update
dataobjectYesFields to update (same fields as createContact)

Return shape:

{
  "contact": {
    "id": "42",
    "email": "jane@example.com",
    "firstName": "Janet",
    "lastName": "Doe",
    "phone": "+9876543210"
  }
}

Errors:

  • "activecampaign.updateContact requires an ID." -- called without an ID argument

deleteContact

Permanently delete a contact by ID.

Module: activecampaign | Returns: object

activecampaign.deleteContact "42"
ParameterTypeRequiredDescription
idstringYesThe contact ID to delete

Return shape: empty object {} on success.

Errors:

  • "activecampaign.deleteContact requires an ID." -- called without an ID argument

listLists

Retrieve all mailing lists in the account.

Module: activecampaign | Returns: object

set $result as activecampaign.listLists
set $lists as $result.lists
ParameterTypeRequiredDescription
(none)NoCall with no arguments to list all mailing lists

Return shape:

{
  "lists": [
    { "id": "1", "name": "Newsletter Subscribers", "stringid": "newsletter", "cdate": "2024-01-10T08:00:00-05:00", "subscriber_count": 1200 }
  ],
  "meta": { "total": "5" }
}

getList

Get a specific mailing list by ID.

Module: activecampaign | Returns: object

set $result as activecampaign.getList "1"
set $name as $result.list.name
set $count as $result.list.subscriber_count
ParameterTypeRequiredDescription
idstringYesThe list ID to retrieve

Return shape:

{
  "list": {
    "id": "1",
    "name": "Newsletter Subscribers",
    "stringid": "newsletter",
    "cdate": "2024-01-10T08:00:00-05:00",
    "subscriber_count": 1200
  }
}

createList

Create a new mailing list.

Module: activecampaign | Returns: object

set $result as activecampaign.createList {"name": "VIP Customers", "stringid": "vip-customers"}
set $listId as $result.list.id
ParameterTypeRequiredDescription
dataobjectYesList fields: name (required), stringid (required)

Accepted fields in data object:

FieldTypeDescription
namestringDisplay name of the list (required)
stringidstringURL-safe identifier (required)

Return shape:

{
  "list": {
    "id": "6",
    "name": "VIP Customers",
    "stringid": "vip-customers"
  }
}

addContactToList

Subscribe a contact to a mailing list.

Module: activecampaign | Returns: object

activecampaign.addContactToList {"list": "1", "contact": "42", "status": "1"}
ParameterTypeRequiredDescription
dataobjectYesAssociation object with list, contact, and status

Accepted fields in data object:

FieldTypeDescription
liststringList ID to subscribe to (required)
contactstringContact ID to subscribe (required)
statusstring"1" = subscribed, "2" = unsubscribed (required)

Return shape:

{
  "contactList": {
    "contact": "42",
    "list": "1",
    "status": "1"
  }
}

removeContactFromList

Unsubscribe a contact from a mailing list by the contact-list association ID.

Module: activecampaign | Returns: object

activecampaign.removeContactFromList "789"
ParameterTypeRequiredDescription
idstringYesThe contact-list association ID

Return shape: empty object {} on success.

Errors:

  • "activecampaign.removeContactFromList requires an ID." -- called without an ID argument

listTags

List all tags in the account.

Module: activecampaign | Returns: object

set $result as activecampaign.listTags
set $tags as $result.tags
ParameterTypeRequiredDescription
(none)NoCall with no arguments to list all tags

Return shape:

{
  "tags": [
    { "id": "1", "tag": "VIP", "tagType": "contact", "cdate": "2024-03-01T09:00:00-05:00" }
  ],
  "meta": { "total": "12" }
}

createTag

Create a new tag.

Module: activecampaign | Returns: object

set $result as activecampaign.createTag {"tag": "VIP", "tagType": "contact"}
set $tagId as $result.tag.id
ParameterTypeRequiredDescription
dataobjectYesTag fields: tag (required), tagType (required)

Accepted fields in data object:

FieldTypeDescription
tagstringTag name (required)
tagTypestring"contact" or "deal" (required)

Return shape:

{
  "tag": {
    "id": "13",
    "tag": "VIP",
    "tagType": "contact"
  }
}

addTagToContact

Apply a tag to a contact.

Module: activecampaign | Returns: object

activecampaign.addTagToContact {"contact": "42", "tag": "5"}
ParameterTypeRequiredDescription
dataobjectYesAssociation object with contact and tag IDs

Accepted fields in data object:

FieldTypeDescription
contactstringContact ID (required)
tagstringTag ID (required)

Return shape:

{
  "contactTag": {
    "contact": "42",
    "tag": "5",
    "id": "201"
  }
}

The returned contactTag.id is the association ID -- use it with removeTagFromContact to undo this operation.


removeTagFromContact

Remove a tag from a contact by the contact-tag association ID.

Module: activecampaign | Returns: object

activecampaign.removeTagFromContact "201"
ParameterTypeRequiredDescription
idstringYesThe contact-tag association ID (returned by addTagToContact)

Return shape: empty object {} on success.

Errors:

  • "activecampaign.removeTagFromContact requires an ID." -- called without an ID argument

listAutomations

List all automations in the account.

Module: activecampaign | Returns: object

set $result as activecampaign.listAutomations
set $automations as $result.automations
ParameterTypeRequiredDescription
(none)NoCall with no arguments to list all automations

Return shape:

{
  "automations": [
    { "id": "1", "name": "Welcome Series", "status": "1", "cdate": "2024-02-01T12:00:00-05:00", "entered": 500, "exited": 350 }
  ],
  "meta": { "total": "8" }
}

addContactToAutomation

Enroll a contact into an automation workflow.

Module: activecampaign | Returns: object

activecampaign.addContactToAutomation {"contact": "42", "automation": "1"}
ParameterTypeRequiredDescription
dataobjectYesAssociation object with contact and automation IDs

Accepted fields in data object:

FieldTypeDescription
contactstringContact ID (required)
automationstringAutomation ID (required)

Return shape:

{
  "contactAutomation": {
    "contact": "42",
    "automation": "1",
    "id": "305"
  }
}

listDeals

List all deals in the CRM pipeline.

Module: activecampaign | Returns: object

set $result as activecampaign.listDeals
set $deals as $result.deals
ParameterTypeRequiredDescription
(none)NoCall with no arguments to list all deals

Return shape:

{
  "deals": [
    { "id": "10", "title": "Enterprise Contract", "value": "50000", "currency": "usd", "stage": "2", "owner": "1", "cdate": "2024-04-15T10:00:00-05:00" }
  ],
  "meta": { "total": "25" }
}

createDeal

Create a new deal in the CRM pipeline.

Module: activecampaign | Returns: object

set $result as activecampaign.createDeal {"title": "Enterprise Contract", "value": 50000, "currency": "usd"}
set $dealId as $result.deal.id
ParameterTypeRequiredDescription
dataobjectYesDeal fields: title (required), plus optional value, currency, stage, owner, etc.

Accepted fields in data object:

FieldTypeDescription
titlestringDeal name (required)
valuenumberMonetary value in minor unit
currencystringCurrency code, e.g., "usd", "eur"
stagestringPipeline stage ID
ownerstringOwner user ID
contactstringAssociated contact ID
groupstringPipeline/group ID

Return shape:

{
  "deal": {
    "id": "26",
    "title": "Enterprise Contract",
    "value": "50000",
    "currency": "usd",
    "stage": "1",
    "owner": "1"
  }
}

updateDeal

Update an existing deal's fields by ID.

Module: activecampaign | Returns: object

set $result as activecampaign.updateDeal "10" {"value": 75000, "stage": "3"}
ParameterTypeRequiredDescription
idstringYesThe deal ID to update
dataobjectYesFields to update (same fields as createDeal)

Return shape:

{
  "deal": {
    "id": "10",
    "title": "Enterprise Contract",
    "value": "75000",
    "currency": "usd",
    "stage": "3"
  }
}

Errors:

  • "activecampaign.updateDeal requires an ID." -- called without an ID argument

listCampaigns

List all email campaigns.

Module: activecampaign | Returns: object

set $result as activecampaign.listCampaigns
set $campaigns as $result.campaigns
ParameterTypeRequiredDescription
(none)NoCall with no arguments to list all campaigns

Return shape:

{
  "campaigns": [
    { "id": "1", "name": "June Newsletter", "type": "single", "status": "5", "sdate": "2024-06-01T09:00:00-05:00", "send_amt": 1200 }
  ],
  "meta": { "total": "10" }
}

Error Handling

All API functions throw on failure. Wrap calls in a try/catch or use if guards.

Common errors:

ErrorCauseFix
Activecampaign: "accountName" not configuredCalled a function before setCredentialsCall setCredentials first
Activecampaign: "apiToken" not configuredCalled a function before setCredentialsCall setCredentials first
Activecampaign API error (401)Invalid API tokenCheck your token in Settings > Developer
Activecampaign API error (404)Resource not found (bad ID)Verify the ID exists
Activecampaign API error (422)Validation error (missing required fields)Check required fields in the data object
@desc "Setup authentication"
do
  activecampaign.setCredentials $account $token
enddo

@desc "Get contact and validate result"
do
  set $result as activecampaign.getContact "99999"
  if $result.contact == null
    print "Contact not found"
  end
enddo

Recipes

1. Enroll a new subscriber into an automation

Create a contact and immediately add them to a marketing automation workflow.

@desc "Setup authentication"
do
  activecampaign.setCredentials "myaccount" "tok_abc123"
enddo

@desc "Create contact and add contact to automation"
do
  set $result as activecampaign.createContact {"email": "newuser@example.com", "firstName": "Alex"}
  set $contactId as $result.contact.id
  activecampaign.addContactToAutomation {"contact": $contactId, "automation": "1"}
  print "Enrolled contact " + $contactId + " into Welcome Series"
enddo

2. Tag and segment contacts into a list

Add a VIP tag to a contact and subscribe them to a premium mailing list.

@desc "Setup authentication"
do
  activecampaign.setCredentials $account $token
enddo

@desc "Add tag to contact and add contact to list"
do
  set $tagResult as activecampaign.addTagToContact {"contact": "123", "tag": "5"}
  activecampaign.addContactToList {"list": "2", "contact": "123", "status": "1"}
  print "Contact 123 tagged as VIP and added to premium list"
enddo

3. Bulk-create contacts from a data source

Loop through a list of leads and create contacts for each one.

@desc "Setup authentication"
do
  activecampaign.setCredentials $account $token
enddo

@desc "Create contact and iterate results"
do
  set $leads as [{"email": "a@test.com", "firstName": "Alice"}, {"email": "b@test.com", "firstName": "Bob"}, {"email": "c@test.com", "firstName": "Carol"}]
  each $lead in $leads
    set $result as activecampaign.createContact $lead
    print "Created: " + $result.contact.email + " (ID: " + $result.contact.id + ")"
  end
enddo

4. Create a deal linked to a contact

Create a contact and then open a sales deal tied to them.

@desc "Setup authentication"
do
  activecampaign.setCredentials $account $token
enddo

@desc "Create contact and create deal"
do
  set $contact as activecampaign.createContact {"email": "buyer@corp.com", "firstName": "Dana", "lastName": "Smith"}
  set $deal as activecampaign.createDeal {"title": "Dana Smith - Annual Plan", "value": 12000, "currency": "usd", "contact": $contact.contact.id}
  print "Deal created: " + $deal.deal.title + " ($" + $deal.deal.value + ")"
enddo

5. Move a deal through pipeline stages

Update a deal's stage and value as it progresses.

@desc "Setup authentication"
do
  activecampaign.setCredentials $account $token
enddo

@desc "List deals and update deal"
do
  set $deals as activecampaign.listDeals
  each $deal in $deals.deals
    if $deal.stage == "1"
      activecampaign.updateDeal $deal.id {"stage": "2", "value": 25000}
      print "Advanced deal: " + $deal.title
    end
  end
enddo

6. Build a contact report with tags

List all contacts and display their information.

@desc "Setup authentication"
do
  activecampaign.setCredentials $account $token
enddo

@desc "List contacts and iterate results"
do
  set $result as activecampaign.listContacts
  each $contact in $result.contacts
    print $contact.firstName + " " + $contact.lastName + " <" + $contact.email + "> (ID: " + $contact.id + ")"
  end
enddo

@desc "Output result"
do
  print "Total contacts: " + $result.meta.total
enddo

7. Create a tag, then apply it to multiple contacts

Create a new campaign tag and assign it to a list of contact IDs.

@desc "Setup authentication"
do
  activecampaign.setCredentials $account $token
enddo

@desc "Create tag and add tag to contact"
do
  set $tag as activecampaign.createTag {"tag": "Summer-Sale-2024", "tagType": "contact"}
  set $tagId as $tag.tag.id
  set $contactIds as ["10", "22", "35", "48"]
  each $id in $contactIds
    activecampaign.addTagToContact {"contact": $id, "tag": $tagId}
    print "Tagged contact " + $id
  end
enddo

8. Full lead onboarding workflow

Complete workflow: create contact, add to list, apply tag, enroll in automation, and open a deal.

@desc "Setup authentication"
do
  activecampaign.setCredentials $account $token
enddo

@desc "Step 1: Create the contact"
do
  set $contact as activecampaign.createContact {"email": $leadEmail, "firstName": $leadName, "phone": $leadPhone}
  set $cid as $contact.contact.id
  print "Created contact: " + $cid
enddo

@desc "Step 2: Subscribe to mailing list"
do
  activecampaign.addContactToList {"list": "1", "contact": $cid, "status": "1"}
enddo

@desc "Step 3: Apply lead source tag"
do
  activecampaign.addTagToContact {"contact": $cid, "tag": "3"}
enddo

@desc "Step 4: Enroll in welcome automation"
do
  activecampaign.addContactToAutomation {"contact": $cid, "automation": "1"}
enddo

@desc "Step 5: Open a deal"
do
  activecampaign.createDeal {"title": $leadName + " - New Lead", "value": 5000, "currency": "usd", "contact": $cid}
enddo

@desc "Output result"
do
  print "Lead onboarding complete for " + $leadEmail
enddo

Related Modules

  • hubspot -- Full CRM with marketing, sales, and service hubs; alternative CRM integration
  • brevo -- Alternative email marketing and transactional email platform
  • mailchimp -- Email marketing with audience management and campaign analytics
  • slack -- Send notifications to Slack channels when contacts are created or deals close
  • google-sheets -- Export contact lists or deal pipelines to spreadsheets for reporting
  • json -- Parse and construct the data objects required by ActiveCampaign functions

Versions (1)

VersionTagPublished
0.1.2latest1 months ago
Install
$ robinpath add @robinpath/activecampaign

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.2
LicenseMIT
Unpacked Size8.4 KB
Versions1
Weekly Downloads30
Total Downloads30
Stars0
Last Publish1 months ago
Created1 months ago

Category

marketing