> ## 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.

# Retries & Failure Handling

> Durable Jobs retries transient failures, preserves completed steps, and gives failed work a clear recovery path.

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

## Goal

Configure retries without repeating completed side effects.

## Prerequisites

* A job with side effects wrapped in named steps

## Workflow

<Steps>
  <Step>
    Set max attempts for retryable work.
  </Step>

  <Step>
    Let StackShift retry transient failures with backoff.
  </Step>

  <Step>
    Inspect failed runs and dead-lettered jobs.
  </Step>

  <Step>
    Manually retry when the cause has been fixed.
  </Step>
</Steps>

## Automatic retries

```ts Set retry attempts theme={null}
await stackshift.queue('payments').enqueue(
  'provisionAfterPayment',
  { paymentId: 'pay_123', customerId: 'cus_123' },
  {
    maxAttempts: 6,
    idempotencyKey: 'payment:pay_123:provision',
  }
)
```

## Backoff and dead letters

* Retries use exponential backoff so transient failures do not hammer dependencies.
* After max attempts, the run is marked failed and can be routed to a dead-letter queue for inspection.
* The run keeps error details, attempts, logs, and timeline entries.

## Manual retry

* Use manual retry after fixing the missing credential, dependency outage, bad payload, or external state.
* Completed steps are reused when the job resumes, so successful side effects do not need to run again.
* Use idempotency keys around external calls that may have succeeded before the failure was reported.

## Expected result

<Check>
  Failures are visible, retryable, and safer because completed steps are remembered.
</Check>

## Related guides

<CardGroup cols={2}>
  <Card title="Observability" href="/durable-jobs/observability">
    Inspect each job run through status, attempts, logs, payload, result, errors, and timeline.
  </Card>

  <Card title="Idempotency" href="/durable-jobs/idempotency">
    Use idempotency keys so duplicate requests do not create duplicate work.
  </Card>
</CardGroup>
