MessagingMessaging APIs

Transactional Push

Send transactional push notifications to your users

Overview

Flameup's transactional push API sends notifications directly to a user's registered devices. Use it for notifications triggered by user actions like order confirmations, password resets, and account alerts.

Transactional email is not sent through the public API key — send it via campaigns or the Flameup dashboard. See Campaigns.

Push Notifications

Send push notifications to a user's registered devices.

Required: User must have a registered device token. See Devices API for registration. Your API key must have access to the target workspace.

Send Push Notification

Endpoint: POST /api/v1/workspaces/{workspace_id}/push/send

async function sendPush(personId, title, body, options = {}) {
  const response = await fetch(
    `https://api.flameup.ai/api/v1/workspaces/${WORKSPACE_ID}/push/send`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${API_KEY}`
      },
      body: JSON.stringify({
        person_id: personId,
        title: title,
        body: body,
        ...options
      })
    }
  );

  return response.json();
}

// Example: Order confirmation
await sendPush('550e8400-e29b-41d4-a716-446655440000',
  'Order Confirmed!',
  'Your order #ORD-12345 has been confirmed. Total: $99.99',
  {
    action_url: 'myapp://orders/ORD-12345',
    ios_badge: 1
  }
);

Request Body

FieldTypeRequiredDescription
person_idstringYesFlameup person UUID
titlestringYesNotification title
bodystringYesNotification body text
platformstringNoTarget platform: ios, android, or all (default). Web coming soon.
image_urlstringNoURL for rich notification image
action_urlstringNoDeep link URL when notification is tapped
prioritystringNoDelivery priority: low, normal, high
ttlintegerNoTime to live in seconds
custom_dataobjectNoCustom key-value payload for your app

iOS Options

FieldTypeDescription
ios_badgeintegerApp badge count
ios_soundstringNotification sound (e.g., default)
ios_categorystringAction category for interactive notifications

Android Options

FieldTypeDescription
android_channel_idstringNotification channel ID
android_iconstringNotification icon resource name
android_colorstringIcon color (e.g., #FF0000)
android_soundstringNotification sound

Response

{
  "message_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "sent",
  "sent_at": "2024-01-15T10:30:00Z",
  "provider": "fcm",
  "provider_id": "projects/myapp/messages/abc123"
}
FieldDescription
message_idFlameup message ID
statuspending, sent, delivered, or failed
sent_atTimestamp when sent
providerPush provider used (fcm)
provider_idExternal message ID from provider
errorError message (only if failed)

Push Notification Examples

// Order confirmation
await sendPush(personId, 'Order Confirmed!',
  'Your order #ORD-12345 is confirmed. Total: $99.99', {
    action_url: 'myapp://orders/ORD-12345',
    ios_badge: 1
});

// Shipping notification
await sendPush(personId, 'Your order has shipped!',
  'Track your package: 1Z999AA10123456784', {
    action_url: 'myapp://tracking/1Z999AA10123456784'
});

// Delivered notification
await sendPush(personId, 'Package delivered!',
  'Your order #ORD-12345 has been delivered.', {
    action_url: 'myapp://orders/ORD-12345/review'
});

Error Handling

Handle these common error cases in your integration.

Push Errors

{
  "message_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "failed",
  "error": "No valid device tokens found for user"
}

Common push errors:

  • No device tokens registered for user
  • Invalid or expired device token
  • FCM configuration missing for workspace

Handling in Code

async function sendNotification(personId, title, body, options) {
  try {
    const result = await sendPush(personId, title, body, options);

    if (result.status === 'failed') {
      console.error('Push failed:', result.error);
      // Fallback to email or in-app notification
      return null;
    }

    return result;
  } catch (error) {
    console.error('Network error:', error);
    throw error;
  }
}

Best Practices

The Push API requires the Flameup person_id (UUID), not your external user ID. Look up the person first or store the person_id when you create users:

// When creating a user, store the person_id
const person = await createPerson({ userId: 'user_123', ... });
// Save person.id for later push notifications