LostChurn Docs
API Reference

Campaigns API

Create, update, activate, and manage dunning campaigns programmatically via the LostChurn REST API.

The Campaigns API lets you manage dunning campaigns programmatically. You can list existing campaigns, create new ones, update configuration, and activate or pause campaigns.

Endpoints

MethodPathDescription
GET/v1/campaignsList campaigns
GET/v1/campaigns/:idGet a campaign
POST/v1/campaignsCreate a campaign
PUT/v1/campaigns/:idUpdate a campaign
POST/v1/campaigns/:id/activateActivate a campaign
POST/v1/campaigns/:id/pausePause a campaign
POST/v1/campaigns/:id/archiveArchive a campaign

List Campaigns

Retrieve all campaigns in your workspace.

GET /v1/campaigns

Query Parameters

ParameterTypeDefaultDescription
statusstringallFilter: active, paused, draft, archived
triggerstring--Filter by trigger type (e.g., payment_failed, card_expired)
sortstringcreated_atSort field: created_at, name, status
orderstringdescSort order
pageinteger1Page number
per_pageinteger20Results per page (max: 100)

Example Request

curl "https://api.lostchurn.com/v1/campaigns?status=active" \
  -H "Authorization: Bearer lc_live_your_api_key"

Example Response

{
  "data": [
    {
      "id": "cmp_abc123",
      "name": "Soft Decline Recovery",
      "status": "active",
      "trigger": "payment_failed",
      "channels": ["email", "sms"],
      "steps_count": 3,
      "enrolled_count": 142,
      "recovered_count": 89,
      "recovery_rate": 0.63,
      "created_at": "2025-01-10T09:00:00Z",
      "updated_at": "2025-03-01T12:00:00Z"
    },
    {
      "id": "cmp_def456",
      "name": "Expired Card Outreach",
      "status": "active",
      "trigger": "card_expired",
      "channels": ["email"],
      "steps_count": 4,
      "enrolled_count": 56,
      "recovered_count": 23,
      "recovery_rate": 0.41,
      "created_at": "2025-02-05T14:00:00Z",
      "updated_at": "2025-03-07T08:00:00Z"
    }
  ],
  "pagination": {
    "total": 2,
    "page": 1,
    "per_page": 20,
    "total_pages": 1
  }
}

Get a Campaign

Retrieve full details for a campaign, including all steps and stop conditions.

GET /v1/campaigns/:id

Example Request

curl https://api.lostchurn.com/v1/campaigns/cmp_abc123 \
  -H "Authorization: Bearer lc_live_your_api_key"

Example Response

{
  "data": {
    "id": "cmp_abc123",
    "name": "Soft Decline Recovery",
    "description": "Multi-step email and SMS campaign for soft decline failures.",
    "status": "active",
    "trigger": "payment_failed",
    "trigger_conditions": {
      "decline_categories": ["soft_retry"],
      "min_amount": null,
      "max_amount": null
    },
    "steps": [
      {
        "index": 0,
        "channel": "email",
        "template_id": "tpl_email_001",
        "subject": "Action needed: update your payment method",
        "delay_hours": 0,
        "delay_from": "enrollment"
      },
      {
        "index": 1,
        "channel": "email",
        "template_id": "tpl_email_002",
        "subject": "Your subscription is at risk",
        "delay_hours": 72,
        "delay_from": "previous_step"
      },
      {
        "index": 2,
        "channel": "sms",
        "template_id": "tpl_sms_001",
        "delay_hours": 48,
        "delay_from": "previous_step"
      }
    ],
    "stop_conditions": {
      "max_attempts": 3,
      "stop_on_recovery": true,
      "stop_on_terminal": true,
      "stop_on_card_update": true
    },
    "quiet_hours": {
      "enabled": true,
      "start_hour": 21,
      "end_hour": 8,
      "timezone": "America/New_York"
    },
    "stats": {
      "enrolled_count": 142,
      "recovered_count": 89,
      "terminal_count": 12,
      "active_count": 41,
      "recovery_rate": 0.63,
      "total_recovered_amount": 704242,
      "currency": "usd"
    },
    "created_at": "2025-01-10T09:00:00Z",
    "activated_at": "2025-01-10T09:30:00Z",
    "updated_at": "2025-03-01T12:00:00Z"
  }
}

Create a Campaign

Create a new campaign in draft status. You must activate it separately.

POST /v1/campaigns

Request Body

FieldTypeRequiredDescription
namestringYesCampaign display name
descriptionstringNoInternal description
triggerstringYesTrigger type (see table below)
trigger_conditionsobjectNoAdditional conditions for enrollment
stepsarrayYesOrdered list of campaign steps
stop_conditionsobjectNoWhen to end the campaign for a customer
quiet_hoursobjectNoTime window to suppress messages

Trigger Types

TriggerDescription
payment_failedAny failed payment
card_expiringCard expiration approaching
card_expiredCard already expired
soft_declineSoft decline after retries exhausted
repeated_failureMultiple consecutive failures
high_value_churnFailed payment above threshold
pre_dunningPreventive outreach
manualManual enrollment only
any_declineAny decline type

Example Request

curl -X POST https://api.lostchurn.com/v1/campaigns \
  -H "Authorization: Bearer lc_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Expired Card Recovery",
    "trigger": "card_expired",
    "steps": [
      {
        "channel": "email",
        "template_id": "tpl_email_expired_01",
        "subject": "Your card on file has expired",
        "delay_hours": 0
      },
      {
        "channel": "email",
        "template_id": "tpl_email_expired_02",
        "subject": "Reminder: please update your payment method",
        "delay_hours": 72
      }
    ],
    "stop_conditions": {
      "max_attempts": 2,
      "stop_on_recovery": true,
      "stop_on_card_update": true
    }
  }'

Example Response

{
  "data": {
    "id": "cmp_new789",
    "name": "Expired Card Recovery",
    "status": "draft",
    "trigger": "card_expired",
    "steps_count": 2,
    "created_at": "2025-03-08T15:00:00Z"
  }
}

Update a Campaign

Update a campaign's configuration. Campaigns in active status can be updated, but changes only apply to newly enrolled customers. Customers already in the campaign continue with the original configuration.

PUT /v1/campaigns/:id

The request body accepts the same fields as campaign creation. Only include fields you want to change.

Example Request

curl -X PUT https://api.lostchurn.com/v1/campaigns/cmp_new789 \
  -H "Authorization: Bearer lc_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Expired Card Recovery v2",
    "quiet_hours": {
      "enabled": true,
      "start_hour": 22,
      "end_hour": 7,
      "timezone": "America/Los_Angeles"
    }
  }'

Example Response

{
  "data": {
    "id": "cmp_new789",
    "name": "Expired Card Recovery v2",
    "status": "draft",
    "updated_at": "2025-03-08T15:30:00Z"
  }
}

Activate a Campaign

Move a campaign from draft or paused to active. Active campaigns begin enrolling customers that match the trigger conditions.

POST /v1/campaigns/:id/activate

Example Request

curl -X POST https://api.lostchurn.com/v1/campaigns/cmp_new789/activate \
  -H "Authorization: Bearer lc_live_your_api_key"

Example Response

{
  "data": {
    "id": "cmp_new789",
    "status": "active",
    "activated_at": "2025-03-08T16:00:00Z"
  }
}

Creating and activating campaigns counts toward your plan's campaign limit. Check Usage Limits for your current plan's allowance.

Pause a Campaign

Pause an active campaign. No new customers are enrolled and pending messages for currently enrolled customers are held until the campaign is reactivated.

POST /v1/campaigns/:id/pause

Archive a Campaign

Archive a campaign. Archived campaigns cannot be reactivated. All currently enrolled customers are removed from the campaign. Historical performance data is retained.

POST /v1/campaigns/:id/archive

Campaign Object

FieldTypeDescription
idstringCampaign ID
namestringDisplay name
descriptionstringInternal description
statusstringdraft, active, paused, archived
triggerstringTrigger type
trigger_conditionsobjectAdditional enrollment conditions
stepsarrayCampaign steps (on detail endpoint)
stop_conditionsobjectCampaign stop rules
quiet_hoursobjectQuiet hours configuration
steps_countintegerNumber of steps
enrolled_countintegerTotal customers enrolled
recovered_countintegerCustomers recovered
recovery_ratefloatRecovery rate (0.0 to 1.0)
statsobjectDetailed stats (on detail endpoint)
created_atstringCreation timestamp
activated_atstring | nullWhen the campaign was last activated
updated_atstringLast update timestamp

Next Steps

On this page