Skip to main content
Live. This area is documented as current, user-reliable behavior.

Goal

Copy a realistic starting point for common backend workflows.

Prerequisites

  • A StackShift client, queue, and handler route

Workflow

1
Pick the example closest to your flow.
2
Replace external services with your own app functions.
3
Keep the idempotency and event correlation patterns.

Send verification email

Signup flow
await stackshift.queue('emails').enqueue(
  'sendVerificationEmail',
  { userId: 'user_123', email: 'ada@example.com' },
  { idempotencyKey: 'verify:user_123' }
)

Payment to provisioning workflow

Payment confirmed
stackshift.job<{ paymentId: string; customerId: string }>('provisionAfterPayment', async ({ payload, step }) => {
  const payment = await step.run('verify-payment', () => verifyPayment(payload.paymentId))

  if (payment.status !== "paid") {
    throw new Error('Payment is not complete')
  }

  await step.run('provision-customer-resources', () => provisionCustomerResources(payload.customerId))
  await step.run('enable-plan', () => enablePaidPlan(payload.customerId))
  await step.run('send-receipt', () => sendReceipt(payment.customerEmail))

  return { provisioned: true }
})

File processing pipeline

Process upload
stackshift.job<{ fileId: string }>('processUpload', async ({ payload, step, state }) => {
  const file = await step.run('download-file', () => downloadFile(payload.fileId))
  const parsed = await step.run('parse-file', () => parseCsv(file))

  for (const batch of parsed.batches) {
    await importRows(batch)
    await state.increment(`files:${payload.fileId}:rows`, batch.length)
  }

  await step.run('mark-complete', () => markFileComplete(payload.fileId))

  return { rows: parsed.totalRows }
})

Expected result

You have practical templates for common production backend work.

Durable Jobs workflows

Use steps and events to build multi-step jobs that can retry, pause, and resume.

State Store

Use durable state for progress, deduplication, counters, TTL-backed markers, and locks.