Get the workspace event key from Events → Set up tracking and keep it in your server’s secrets. The target contact must already exist with the matching User ID. In this Node.js example, order.completedAt is the stored time of the original action.
const response = await fetch(process.env.BETTERCOM_ORIGIN + '/events', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + process.env.BETTERCOM_EVENT_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
event_name: 'order-completed',
created_at: Math.floor(new Date(order.completedAt).getTime() / 1000),
user_id: String(order.customerId),
metadata: { order_id: String(order.id) }
})
});
if (response.status !== 202) throw new Error('Event HTTP ' + response.status);HTTP 202 has an empty body. In Events, check the contact, source, and metadata. On retry, reuse the original event name, contact, and Unix-second timestamp. Bettercom deduplicates that combination, including distinct same-name events for the same contact in the same second. An order ID in metadata does not change that deduplication key.