Skip to main content

Starting a Thread

A thread represents a workflow execution instance (e.g., an order, a support ticket, a user onboarding). A thread is an execution graph containing all actions performed by services involved in delivery an outcome to a customer’s request
const thread = await threadify.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)
Non-contract threads remain “active” indefinitely unless explicitly ended. View Closing a Thread

Idempotency

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

Next Steps

Handling Failures

Learn how to handle and record failures

Closing Threads

Complete or cancel threads manually

External References

Link to external systems like Stripe or Shopify