MessagingCampaigns
Messaging

Campaigns

Create automated messaging campaigns triggered by events, schedules, or API calls

Overview

Campaigns are automated messaging workflows that send push notifications to your users based on triggers. Flameup supports multiple trigger types to cover different use cases.

Required Permissions: campaigns:read to view, campaigns:write to create/modify, campaigns:trigger to manually trigger.

Campaign Object

A campaign in Flameup has the following structure:

{
  "id": "camp_550e8400e29b41d4a716446655440000",
  "workspace_id": "ws_abc123",
  "name": "Welcome Series",
  "status": "active",
  "trigger_type": "event",
  "trigger_config": {
    "event_name": "signed_up",
    "delay_minutes": 5
  },
  "segments": ["all_users"],
  "filters": {},
  "template_id": "tmpl_123",
  "subject": "Welcome!",
  "variables": {},
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-20T14:45:00Z"
}

Trigger Types

Flameup supports four types of campaign triggers:

Trigger when a user performs an action

Event-triggered campaigns start when a user performs a specific event. Perfect for:

  • Welcome messages after signup
  • Order confirmations
  • Feature adoption nudges
  • Re-engagement after inactivity
{
  "trigger_type": "event",
  "trigger_config": {
    "event_name": "signed_up",
    "delay_minutes": 0,
    "properties": {
      "plan": "free"
    }
  }
}
FieldTypeDescription
event_namestringThe event that triggers the campaign
delay_minutesintegerWait time in minutes before sending (0 = immediate)
propertiesobjectEvent property conditions (optional)

Create a Campaign

Create a new campaign.

Endpoint: POST /api/v1/workspaces/{workspace_id}/campaigns

const response = await fetch(
  `https://api.flameup.ai/api/v1/workspaces/${WORKSPACE_ID}/campaigns`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${API_KEY}`
    },
    body: JSON.stringify({
      name: 'Welcome Series',
      trigger_type: 'event',
      trigger_config: {
        event_name: 'signed_up',
        delay_minutes: 5
      },
      template_id: 'tmpl_welcome',
      subject: 'Welcome to {{app_name}}!',
      variables: {
        app_name: 'Acme',
        first_name: '{{first_name}}'
      },
      segments: ['all_users']
    })
  }
);

const campaign = await response.json();

List Campaigns

Retrieve all campaigns in a workspace.

Endpoint: GET /api/v1/workspaces/{workspace_id}/campaigns

Query Parameters

ParameterTypeDescription
statusstringFilter by status: draft, active, paused, completed, archived, scheduled, failed
trigger_typestringFilter by trigger type
limitintegerNumber of results (default 50)
offsetintegerPagination offset
const response = await fetch(
  `https://api.flameup.ai/api/v1/workspaces/${WORKSPACE_ID}/campaigns?status=active`,
  {
    headers: {
      'Authorization': `Bearer ${API_KEY}`
    }
  }
);

const { campaigns, total } = await response.json();

Get Campaign Details

Retrieve a specific campaign.

Endpoint: GET /api/v1/workspaces/{workspace_id}/campaigns/{campaign_id}

const response = await fetch(
  `https://api.flameup.ai/api/v1/workspaces/${WORKSPACE_ID}/campaigns/${campaignId}`,
  {
    headers: {
      'Authorization': `Bearer ${API_KEY}`
    }
  }
);

const campaign = await response.json();

Update a Campaign

Modify an existing campaign.

Endpoint: PUT /api/v1/workspaces/{workspace_id}/campaigns/{campaign_id}

const response = await fetch(
  `https://api.flameup.ai/api/v1/workspaces/${WORKSPACE_ID}/campaigns/${campaignId}`,
  {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${API_KEY}`
    },
    body: JSON.stringify({
      name: 'Welcome Series v2',
      trigger_config: {
        event_name: 'signed_up',
        delay_minutes: 10
      }
    })
  }
);

Campaign Status

Campaigns have the following statuses:

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.

Activate a Campaign

Update the campaign status to active using the PUT endpoint:

await fetch(
  `https://api.flameup.ai/api/v1/workspaces/${WORKSPACE_ID}/campaigns/${campaignId}`,
  {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${API_KEY}`
    },
    body: JSON.stringify({ status: 'active' })
  }
);

Pause a Campaign

Update the campaign status to paused using the PUT endpoint:

await fetch(
  `https://api.flameup.ai/api/v1/workspaces/${WORKSPACE_ID}/campaigns/${campaignId}`,
  {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${API_KEY}`
    },
    body: JSON.stringify({ status: 'paused' })
  }
);

Trigger a Campaign Manually

For webhook-triggered campaigns, or to test any campaign:

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

const response = await fetch(
  `https://api.flameup.ai/api/v1/workspaces/${WORKSPACE_ID}/campaigns/${campaignId}/trigger`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${API_KEY}`
    },
    body: JSON.stringify({
      // Target specific users
      user_ids: ['user_123', 'user_456'],

      // Or use filters
      filters: {
        plan: 'premium'
      },

      // Custom data for personalization
      data: {
        promo_code: 'SAVE20',
        expires: '2024-02-01'
      }
    })
  }
);

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

Templates & Variables

Campaigns reference templates by template_id and use variables for personalization with Handlebars-style syntax:

{
  "template_id": "tmpl_order_shipped",
  "subject": "Hi {{first_name}}!",
  "variables": {
    "first_name": "{{first_name}}",
    "order_id": "{{order_id}}"
  }
}

Available Variables

VariableSourceDescription
{{first_name}}PersonUser's first name
{{last_name}}PersonUser's last name
{{email}}PersonUser's email
{{attributes.*}}PersonAny user attribute
{{event.*}}EventEvent properties (event triggers)
{{data.*}}TriggerCustom trigger data

Fallback Values

Provide fallbacks for missing data:

{{first_name|default:"there"}}

Campaign Examples

Send a welcome message 5 minutes after signup:

{
  "name": "Welcome Series",
  "trigger_type": "event",
  "trigger_config": {
    "event_name": "signed_up",
    "delay_minutes": 5
  },
  "template_id": "tmpl_welcome",
  "subject": "Welcome to Acme!",
  "variables": {
    "first_name": "{{first_name}}"
  },
  "segments": ["all_users"]
}

Delete a Campaign

Endpoint: DELETE /api/v1/workspaces/{workspace_id}/campaigns/{campaign_id}

Deleting a campaign is permanent. Consider pausing instead if you may want to resume later.
curl -X DELETE "https://api.flameup.ai/api/v1/workspaces/{workspace_id}/campaigns/{campaign_id}" \
  -H "Authorization: Bearer your_api_key"
Was this page helpful?
Built with Documentation.AI

Last updated today