API Reference

Webhook Overview

Receive webhook notifications about events from Assembly

Setup:
To set up a Webhook destination URL for any event, please contact [email protected] to register you URL and the team will share you the needed webhook specific client secret key.

Webhook Events:

enum AsemblyWebhookEventType {  
  // Swag event
  ORDER_CREATED: "ORDER_CREATED"
}

Webhook Format:
All Webhooks are sent as a POST message and have this format:

interface AssemblyWebhookEvent {  
  type: AsemblyWebhookEventType;
  data: any;
}

Webhook Signature:
All Webhooks include a x-webhook-signature header to validate that the webhook is indeed coming from us as well as x-webhook-idempotency-key, which is a unique key sent out per webhook. Webhooks are signed using the code below, where the secret is your client secret and the payload is the body of the POST request

import { createHmac } from 'crypto';  
function validatePayload(headers, payload) {  
  const signature = createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex');
  return headers['x-webhook-signature'] === signature;
}

Currently Supported Events

  • orderCreated