> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Real-World Examples

> Common backend flows that fit Durable Jobs: verification email, payment provisioning, and file processing.

<Tip>
  **Live.** This area is documented as current, user-reliable behavior.
</Tip>

## Goal

Copy a realistic starting point for common backend workflows.

## Prerequisites

* A StackShift client, queue, and handler route

## Workflow

<Steps>
  <Step>
    Pick the example closest to your flow.
  </Step>

  <Step>
    Replace external services with your own app functions.
  </Step>

  <Step>
    Keep the idempotency and event correlation patterns.
  </Step>
</Steps>

## Send verification email

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

## Payment to provisioning workflow

```ts Payment confirmed theme={null}
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

```ts Process upload theme={null}
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

<Check>
  You have practical templates for common production backend work.
</Check>

## Related guides

<CardGroup cols={2}>
  <Card title="Durable Jobs workflows" href="/durable-jobs/workflows">
    Use steps and events to build multi-step jobs that can retry, pause, and resume.
  </Card>

  <Card title="State Store" href="/durable-jobs/state-store">
    Use durable state for progress, deduplication, counters, TTL-backed markers, and locks.
  </Card>
</CardGroup>
