EmitHQ

Documentation

Getting Started

1. Install the SDK

npm install @emithq/sdk

2. Get your API key

Sign up at app.emithq.com, create an organization, then generate an API key from the dashboard. Your key starts with emhq_.

3. Send your first event

import { EmitHQ } from '@emithq/sdk';

const emithq = new EmitHQ('emhq_your_api_key');

// Create an endpoint for your customer
const endpoint = await emithq.createEndpoint('app_123', {
  url: 'https://customer.com/webhooks',
});
// Save endpoint.signingSecret — shown only once

// Send a webhook event
const message = await emithq.sendEvent('app_123', {
  eventType: 'invoice.paid',
  payload: { invoiceId: 'inv_456', amount: 9900 },
});
console.log('Event queued:', message.id);

4. Verify webhooks (consumer side)

import { verifyWebhook } from '@emithq/sdk';

// In your webhook handler
const isValid = await verifyWebhook(rawBody, {
  'webhook-id': req.headers['webhook-id'],
  'webhook-timestamp': req.headers['webhook-timestamp'],
  'webhook-signature': req.headers['webhook-signature'],
}, 'whsec_your_endpoint_secret');
// Throws if invalid — catch to return 401