Integrations
Node.js

Node.js

Send events from your Node.js application using the native fetch API (Node 18+) or any HTTP client.

Using fetch

async function sendAlert(event: string, title: string, body?: string) {
  const res = await fetch('https://api.flowalert.io/v1/events', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Api-Key': process.env.FLOWALERT_API_KEY!,
    },
    body: JSON.stringify({ event, title, body, priority: 'NORMAL' }),
  });
 
  if (!res.ok) {
    const err = await res.json();
    throw new Error(`FlowAlert error: ${JSON.stringify(err)}`);
  }
 
  return res.json();
}
 
// Usage
await sendAlert('booking.created', 'New Booking — John Smith', 'Sunset Cruise · 4 guests');
await sendAlert('payment.failed', 'Payment failed', 'Order #5512 — card declined');

Using axios

import axios from 'axios';
 
const flowalert = axios.create({
  baseURL: 'https://api.flowalert.io/v1',
  headers: {
    'X-Api-Key': process.env.FLOWALERT_API_KEY,
    'Content-Type': 'application/json',
  },
});
 
await flowalert.post('/events', {
  event: 'order.created',
  title: 'New Order #5512',
  body: 'Total: $149.00 · Customer: Jane Doe',
  priority: 'NORMAL',
});

Express.js middleware example

A common pattern is to send an alert inside a route handler after a successful database write:

app.post('/bookings', async (req, res) => {
  const booking = await db.bookings.create(req.body);
 
  // Fire-and-forget alert — don't block the response
  fetch('https://api.flowalert.io/v1/events', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Api-Key': process.env.FLOWALERT_API_KEY!,
    },
    body: JSON.stringify({
      event: 'booking.created',
      title: `New Booking — ${booking.customerName}`,
      body: `${booking.tourName} · ${booking.guests} guests`,
      priority: 'NORMAL',
      data: { booking_id: booking.id },
    }),
  }).catch(console.error);
 
  res.status(201).json(booking);
});
💡

Store your API key in an environment variable (FLOWALERT_API_KEY) — never hardcode it in source code.