> ## Documentation Index
> Fetch the complete documentation index at: https://supastack.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For the full documentation corpus in one file, fetch: https://supastack.dev/llms-full.txt

# Task API and recovery

Recover an uncertain submission without creating a new task.

## Before you begin

Open your downloaded supastack project in Visual Studio Code using File → Open Folder, then choose Terminal → New Terminal. The repository root is the folder containing package.json, apps and packages. Run the command below there and leave its terminal open. If a command is not recognized, finish the tool installation guide before continuing.

Read the platform tutorial first. A server is the app process that answers browser or phone requests. Web reads apps/web/.env.local, Expo reads apps/mobile/.env.local, and database migration commands read root .env. The no-database /dashboard demonstration is separate from real /auth accounts, which need migrated Postgres. A phone or desktop-only checkout needs a separately running Web backend.

[Install the tools and get the code](https://supastack.dev/docs/web/before-you-start.md)

[Learn commands, files and configuration](https://supastack.dev/docs/web/terminal-basics.md)

[Complete the Web first-run tutorial](https://supastack.dev/docs/web/ship-in-5-minutes.md)

```
corepack pnpm --filter @supastack/web dev
```


## Setup and configuration

POST /api/ai/tasks requires an authenticated workspace and active entitlement. A keyed request reserves an immutable task before dispatch. Idempotency-Key accepts 16–128 ASCII letters, digits, underscores, or hyphens.

```
POST /api/ai/tasks
Idempotency-Key: a-stable-client-submission-key

Recovery body: { "resume": true }
Status: GET /api/ai/tasks/{taskId}
```


## Implementation workflow

Persist the recovery key before submitting. After uncertain dispatch, reuse the same key and the resume body; the server loads the original input and retries the same task-scoped Trigger identity. Changed input under the same key returns 409 idempotencyConflict.

HTTP 202 after an ambiguous enqueue means dispatch is uncertain. It does not prove Trigger accepted the work. Already running or terminal tasks return saved state without another enqueue. Recovery still requires authentication, ownership, and entitlement.


## Verification and troubleshooting

Exercise a lost response, changed-input conflict, foreign-workspace request, and refresh restoration. There is no automatic outbox dispatcher or end-to-end exactly-once guarantee. Do not reset a running task to queued without investigating its side effects.


## Next

[Trigger.dev jobs](https://supastack.dev/docs/modules/jobs.md)
