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

# Workflow patterns

> Three recommended ways to integrate the async Stealth Agent API

Stealth Agent and humanization runs are **asynchronous**: you start a run, get a `runId` immediately, and the long-running work (research, drafting, humanization, scoring) happens in the background. There are three recommended patterns for consuming it.

## 1. Queue and poll

Best for scripts, cron jobs, and simple backends.

1. **Start** a run: `POST /api/stealthify/runs` (humanize-only) or `POST /api/stealthify/agent/runs` (full pipeline) → `202` with `runId` + `statusUrl`.
2. **Poll** `GET .../runs/{runId}` every 5–15 seconds until `status` is `completed`, `failed`, or `cancelled`.
3. Read the final `result` and billing metadata from the completed response.

Use an `idempotency-key` header on create so retries never enqueue duplicate runs or double-charge.

→ [Humanizer async runs](/api-reference/endpoints/stealthify-runs) · [Stealth Agent async runs](/api-reference/endpoints/stealthify-agent-runs)

## 2. Fire and webhook

Best for no-code tools (n8n, Make, WordPress) and event-driven backends that don't want to poll.

1. **Start** a run and include `webhookUrl` (and optionally `webhookSecret`).
2. When the run reaches a terminal state, StealthGPT `POST`s the result (or terminal failure) to your `webhookUrl`.
3. Verify the `x-stealthgpt-signature` HMAC (when `webhookSecret` is set) and reconcile by `x-stealthgpt-run-id`.

Webhooks are best-effort with retries on `429`/`5xx`; treat delivery as at-least-once and dedupe by run id + status.

→ See the **Webhook callbacks** section on the [async runs](/api-reference/endpoints/stealthify-runs) page.

## 3. Agent / tool invocation

Best for AI agents and chat clients — let the model call StealthGPT as a tool via our MCP server (Cursor today; claude.ai web & ChatGPT via OAuth coming soon).

→ [Use Stealth Agent from MCP clients](/api-reference/integrations/mcp)

## Picking a pattern

| You are…                           | Use                           |
| ---------------------------------- | ----------------------------- |
| A backend / script                 | Queue and poll                |
| A no-code or event-driven workflow | Fire and webhook              |
| An AI agent / LLM client           | Agent / tool invocation (MCP) |
