Skip to main content

Starting a Thread

A thread represents a workflow execution instance (e.g., an order, a support ticket).
const thread = await connection.start();

Recording Steps

Always create the step before executing business logic:
const step = thread.step('order_received');

// Execute business logic
const order = await receiveOrder();

// Record success with context
await step.addContext({ orderId: order.id, total: order.total }).success();

Step Methods

MethodDescription
.success()Mark step as successful
.success(data)Success with additional data
.failed(data)Mark step as failed with error data
.addContext(data)Add business context (analytics, debugging)

Idempotency

Threadify automatically handles idempotency - recording the same step multiple times only stores the first execution.

Next Steps