import { EmitKit } from '@emitkit/js';
const client = new EmitKit('emitkit_xxxxxxxxxxxxxxxxxxxxx');
const result = await client.events.create({
channelName: 'payments',
title: 'Payment Received',
description: 'User upgraded to Pro plan',
icon: 'š°',
metadata: {
amount: 99.99,
currency: 'USD'
}
});
console.log('Event created:', result.data.id);{
"success": true,
"data": {
"id": "event_xxxxxxxxxxxxxxxxxxxxx",
"channelId": "ch_xxxxxxxxxxxxxxxxxxxxx",
"channelName": "payments",
"title": "Payment Received",
"createdAt": "2025-01-15T10:30:00.000Z"
},
"requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}Create Event
Creates a new event and optionally sends push notifications to connected devices.
Channel Auto-Creation
If the specified channel doesnāt exist, it will be automatically created. This reduces setup complexity for simple integrations.
Notifications
Set notify: true (default) to send push notifications to devices connected through PWA or browsers that have accepted notifications (e.g., Chrome).
import { EmitKit } from '@emitkit/js';
const client = new EmitKit('emitkit_xxxxxxxxxxxxxxxxxxxxx');
const result = await client.events.create({
channelName: 'payments',
title: 'Payment Received',
description: 'User upgraded to Pro plan',
icon: 'š°',
metadata: {
amount: 99.99,
currency: 'USD'
}
});
console.log('Event created:', result.data.id);{
"success": true,
"data": {
"id": "event_xxxxxxxxxxxxxxxxxxxxx",
"channelId": "ch_xxxxxxxxxxxxxxxxxxxxx",
"channelName": "payments",
"title": "Payment Received",
"createdAt": "2025-01-15T10:30:00.000Z"
},
"requestId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}Authorizations
API key authentication. Format: emitkit_xxxxxxxxxxxxxxxxxxxxx
Create API keys in your EmitKit dashboard. Keys are scoped to a specific organization and project.
Headers
Unique key to ensure idempotent request processing. Prevents duplicate events from retries or webhook replays. Valid for 24 hours.
1 - 255Body
Channel name for organizing events. Channels are automatically created if they don't exist. Use kebab-case for consistency (e.g., 'user-signups').
1 - 255"payments"
Event title - the main message
1 - 500"Payment Received"
Optional detailed description
5000"User upgraded to Pro plan"
Single emoji icon to display with the event
10"š°"
Array of tags for filtering and organization
2050["payment", "upgrade"]
Custom JSON metadata. Any valid JSON structure is accepted. Use this to attach custom data to events for filtering or display.
{
"amount": 99.99,
"currency": "USD",
"plan": "pro",
"userId": "user_123"
}
Optional user identifier to associate with this event. Supports both direct user IDs and aliases (email, username, etc.) created via the /v1/identify endpoint. Aliases are automatically resolved to canonical user IDs.
255"user_123"
Whether to send push notifications to connected devices (PWA or browsers with accepted notifications). Set to false for silent event logging.