MessagingCampaigns

Campaigns

Trigger dashboard-created messaging campaigns via the API

Overview

Campaigns are automated messaging workflows that send push notifications to your users based on triggers. Campaigns are created and managed in the Flameup dashboard — including their trigger type, audience, templates, and schedule. The API's role is to trigger a campaign so it runs for its configured audience.

Required Permission: campaigns:trigger to trigger a campaign via the API.

Trigger Types

When you build a campaign in the dashboard, you choose one of four trigger types:

  • Event — starts when a user performs a specific action (for example, a signup or purchase).
  • Webhook — started by calling the trigger endpoint below. Ideal for backend-initiated notifications and third-party integrations.
  • Schedule — runs at defined times (for example, a weekly digest).
  • Dynamic Schedule — sends relative to a per-user date (for example, a trial-expiration reminder).

The trigger type and its configuration are set in the dashboard. Any campaign can be started on demand from the API using the trigger endpoint — this is the primary path for webhook campaigns and is also useful for testing.

Trigger a Campaign

Start a campaign so it runs for its configured audience.

Endpoint: POST /api/v1/campaigns/{campaign_id}/trigger

Request Body

FieldTypeRequiredDescription
workspace_idstringYesThe workspace that owns the campaign. Must match your API key's workspace.
trigger_dataobjectNoCustom context data passed to the campaign workflow for personalization.
const response = await fetch(
  `https://api.flameup.ai/api/v1/campaigns/${campaignId}/trigger`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${API_KEY}`
    },
    body: JSON.stringify({
      workspace_id: WORKSPACE_ID,
      // Optional custom data for personalization
      trigger_data: {
        promo_code: 'SAVE20',
        expires: '2024-02-01'
      }
    })
  }
);

const result = await response.json();
console.log(`Triggered for ${result.people_queued} people`);

Response

A successful trigger returns HTTP 202 Accepted:

{
  "success": true,
  "campaign_id": "550e8400e29b41d4a716446655440000",
  "status": "processing",
  "triggered_at": "2024-01-15T10:30:00Z",
  "people_queued": 42,
  "message": "Campaign triggered for audience"
}
FieldDescription
successWhether the trigger was accepted
campaign_idThe campaign that was triggered
statusprocessing while the audience is being queued, or completed
triggered_atTimestamp when the trigger was accepted
people_queuedNumber of people in the campaign's audience
messageHuman-readable status message

Campaign Status

Campaigns move through the following statuses, all managed from the dashboard:

Draft

Initial state. Campaign is not active and won't trigger.

Scheduled

Campaign is scheduled to activate at a future time.

Active

Campaign is live and will trigger based on its configuration.

Paused

Campaign is temporarily stopped. Can be resumed.

Completed

Campaign has finished (for one-time campaigns).

Archived

Campaign has been archived and is no longer active.

Failed

Campaign failed due to an error.

A campaign must be Active to run when triggered. Activate, pause, and archive campaigns from the dashboard.