Prerequisites
Before you begin, you’ll need:
1. Install the SDK
2. Initialize the Client
Create a new Flux client with your API key:
import Flux from '@flux/node';
const flux = new Flux(process.env.FLUX_API_KEY);
Never hardcode your API key. Use environment variables to keep it secure.
3. Send an Event
Events in Flux have a type and a data payload. The type is a string that identifies the kind of event (we recommend using dot notation like user.signup).
const event = await flux.events.send({
type: 'order.completed',
data: {
orderId: 'ord_8x7kj2',
amount: 9900,
currency: 'usd',
customerId: 'cus_abc123'
}
});
console.log('Event sent:', event.id);
4. Verify It Worked
Head to the Events tab in your dashboard. You should see your event logged with its full payload and metadata.
Next Steps
Now that you’ve sent your first event, explore these guides: