Campaigns

Receive notifications when campaigns are triggered or completed.

Overview

Campaign webhooks notify your application when marketing campaigns interact with subscriptions. Use these events to trigger external workflows, sync campaign data with your marketing tools, or track campaign performance.


Use Cases

  • Send personalized emails when a campaign targets a subscription
  • Sync campaign run results with your CRM or analytics platform
  • Trigger external marketing automations based on campaign events
  • Track campaign performance metrics across systems
  • Download export files when campaign runs complete

Events

EventDescription
campaign.triggeredA campaign was triggered for a specific subscription
campaign.run_completedA campaign run finished processing all subscriptions

campaign.triggered

Triggered When

  • A promotional campaign targets a subscription for renewal notification
  • A renewal campaign processes a subscription approaching expiration
  • A cancellation campaign processes a subscription being canceled
  • A creation campaign processes a newly created subscription

Payload

The payload includes both subscription and campaign details, along with a magic link token for passwordless authentication.

{
  "type": "campaign.triggered",
  "id": "evt_a1b2C3d4E5f6g7H8i9J0k1L2",
  "created": 1704067200,
  "data": {
    "campaign": {
      "id": 123,
      "name": "January Renewal Campaign",
      "key": "JAN-2024-RENEW",
      "description": "Renewal reminders for January expirations",
      "site": {
        "id": 1,
        "name": "Main Site"
      },
      "plan": {
        "id": 456,
        "nickname": "Premium Annual",
        "name_internal": "premium_annual",
        "amount": 9999
      },
      "product": {
        "id": 789,
        "name": "Premium Membership",
        "name_internal": "premium_membership"
      },
      "coupon": {
        "id": 101,
        "name": "Loyalty Discount",
        "code": "LOYAL20",
        "percent_off": 20
      }
    },
    "magic_link_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "subscription": {
      "id": 55555,
      "expire_date": "2024-01-31T23:59:59.000000Z",
      "days_to_expire": 15.5,
      "recommended_plan_id": 457,
      "address": {
        "line1": "123 Main Street",
        "line2": "Suite 100",
        "city": "New York",
        "state": "NY",
        "country": "US",
        "postal_code": "10001"
      },
      "plan": {
        "id": 456,
        "nickname": "Premium Annual",
        "name_internal": "premium_annual",
        "interval": "year",
        "interval_count": 1,
        "currency": "usd",
        "amount": 9999
      },
      "product": {
        "id": 789,
        "name": "Premium Membership",
        "name_internal": "premium_membership"
      },
      "user": {
        "id": 67890,
        "title": "Marketing Manager",
        "company": "Acme Inc",
        "first_name": "John",
        "last_name": "Doe",
        "email": "[email protected]"
      }
    }
  }
}

campaign.run_completed

Triggered When

  • A scheduled campaign run finishes processing all targeted subscriptions
  • An on-demand campaign execution completes
  • A campaign export file has been generated

Payload

{
  "type": "campaign.run_completed",
  "id": "evt_b2C3d4E5f6g7H8i9J0k1L2m3",
  "created": 1704153600,
  "data": {
    "campaign": {
      "id": 123,
      "name": "January Renewal Campaign",
      "type": "Renewal",
      "description": "Renewal reminders for January expirations",
      "action": "Both",
      "run": {
        "id": 999,
        "key": "JAN-2024-RENEW-010124",
        "date": 1704153600,
        "download_link": "https://api.pelcro.com/core/campaigns/123/runs/999/report/download"
      }
    }
  }
}

Payload Fields

Campaign Object (campaign.triggered)

FieldTypeDescription
idintegerUnique identifier for the campaign
namestringCampaign display name
keystringCampaign key/code for tracking
descriptionstringCampaign description
siteobjectSite the campaign belongs to (see Site Object)
planobjectPlan offered by the campaign, if any (see Plan Object)
productobjectProduct associated with the campaign plan
couponobjectCoupon offered by the campaign, if any (see Coupon Object)

Campaign Object (campaign.run_completed)

FieldTypeDescription
idintegerUnique identifier for the campaign
namestringCampaign display name
typestringCampaign type: Promotional, Renewal, Cancellation, or Creation
descriptionstringCampaign description
actionstringCampaign action: Notification, Export, Both, Renewal, Cancellation, Cancellation And Export, Creation, or Creation And Export
runobjectDetails about the completed run (see Run Object)

Subscription Object (Nested in campaign.triggered)

FieldTypeDescription
idintegerUnique identifier for the subscription
expire_datestringISO 8601 timestamp when the subscription expires
days_to_expirefloatNumber of days until expiration (can be negative if expired)
recommended_plan_idintegerID of the recommended renewal plan, if configured
addressobjectSubscription shipping address (see Address Object)
planobjectCurrent subscription plan (see Plan Object)
productobjectProduct associated with the subscription plan
userobjectSubscriber details (see User Object)

Run Object (Nested in campaign.run_completed)

FieldTypeDescription
idintegerUnique identifier for the campaign run
keystringRun key/code for tracking
dateintegerUnix timestamp when the run was created
download_linkstringURL to download the export file (null if no export)

Site Object (Nested)

FieldTypeDescription
idintegerSite ID
namestringSite display name

Plan Object (Nested)

FieldTypeDescription
idintegerPlan ID
nicknamestringPlan display name
name_internalstringInternal plan identifier
intervalstringBilling interval: day, week, month, year
interval_countintegerNumber of intervals between billings
currencystringThree-letter ISO currency code (lowercase)
amountintegerPlan amount in cents

Product Object (Nested)

FieldTypeDescription
idintegerProduct ID
namestringProduct display name
name_internalstringInternal product identifier

Coupon Object (Nested)

FieldTypeDescription
idintegerCoupon ID
namestringCoupon display name
codestringCoupon code
percent_offintegerPercentage discount

User Object (Nested)

FieldTypeDescription
idintegerCustomer/user ID
titlestringProfessional title
companystringCompany name
first_namestringFirst name
last_namestringLast name
emailstringEmail address

Address Object (Nested in subscription)

FieldTypeDescription
line1stringStreet address line 1
line2stringStreet address line 2
citystringCity
statestringState or province code
countrystringTwo-letter ISO country code
postal_codestringZIP or postal code

Campaign Types

TypeDescription
PromotionalMarketing campaigns offering special deals or promotions
RenewalAutomated reminders for upcoming subscription renewals
CancellationNotifications when subscriptions are being canceled
CreationNotifications for newly created subscriptions

Campaign Actions

ActionDescription
NotificationSend webhook notifications only
ExportGenerate export file only
BothSend notifications and generate export
RenewalProcess subscription renewals
CancellationProcess subscription cancellations
Cancellation And ExportProcess cancellations and generate export
CreationProcess subscription creations
Creation And ExportProcess creations and generate export

Related