Skip to main content
References link threads to external system identifiers like order IDs, customer IDs, or support tickets. They enable you to query threads using identifiers from your existing systems.

Reference Types

  • Order IDs - E-commerce order numbers
  • Customer IDs - Customer account identifiers
  • Support Tickets - Zendesk, Jira, Salesforce ticket numbers
  • Transaction IDs - Payment processor transaction IDs
  • Application IDs - Loan applications, insurance claims
  • Custom IDs - Any business-relevant identifier

Reference Properties

  • Key - The reference type (e.g., “order_id”)
  • Value - The actual identifier (e.g., “ORD-789”)
  • Thread association - Links to a specific thread
  • Queryable - Can be used to find threads

Adding References

Link workflows to external systems (Stripe, Shopify, etc.):
const payment = await processStripePayment();

// Add references at thread level
await thread.addRefs({
  stripe_payment_id: payment.id,
  stripe_customer_id: payment.customer,
  order_id: 'ORD-12345'
});

// Then record the step
await thread.step('process_payment')
  .addContext({ amount: 299.99, currency: 'USD' })
  .success();

Querying by Reference

const threads = await connection.getThreadsByRef({
  refKey: 'stripe_payment_id',
  refValue: 'pi_1234567890'
});

Query Options

OptionTypeDescription
refKeystringReference key (e.g., ‘stripe_payment_id’)
refValuestringReference value (e.g., ‘pi_123’)
statusstringFilter by thread status
startedAfterstringISO timestamp filter
limitnumberMax results to return

Linking Threads

Link threads together to create relationships:
// Link to parent thread
await childThread.linkThread(parentThread.threadId, 'parent');

// Link to related thread
await thread.linkThread(relatedThread.threadId, 'related');

// Link to child thread
await parentThread.linkThread(childThread.threadId, 'child');

Relationship Types

TypeDescription
parentParent thread that spawned this workflow
childChild thread for sub-processes
relatedParallel or dependent workflow
followupContinuation of a previous thread

Use Cases

Customer Support

  • Support agent gets ticket: “Where’s my order?”
  • Query by order ID → Find thread → Show complete execution

Operations

  • Monitor specific high-value orders
  • Track problematic customer accounts
  • Investigate transaction failures

Analytics

  • Correlate thread data with business metrics
  • Link execution patterns to customer behavior

Best Practices

  • Add early - Add references as soon as they’re available
  • Use consistent keys - Standardize reference names across services
  • Multiple references - Add all relevant identifiers
  • Business context - Use IDs that teams already recognize

Next Steps