Stealth Agent Async Runs
Endpoints
Stealth Agent Async Runs
Create and poll asynchronous Stealth Agent runs with optional webhook callbacks
POST
Stealth Agent Async Runs
The async Stealth Agent API lets you start a long-running generation job, return immediately, and receive the final result later by polling or webhook callback. Use it for integrations, automations, UI backends, and agent platforms where a multi-minute HTTP request is unreliable.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.
If you need a simple one-off script and can keep the connection open for up to 10 minutes, use the synchronous
POST /api/stealthify/agent endpoint. For production integrations, prefer async runs.Flow
Create a run
Send
POST /api/stealthify/agent/runs with the same preset body as the synchronous endpoint. Optionally include webhookUrl and idempotency-key.Authentication
Your Stealth API token from the Stealth API dashboard.
Create a run
POST https://stealthgpt.ai/api/stealthify/agent/runs
Headers
Your Stealth API token.
Must be
application/json.Optional key, 1-255 characters. Reuse the same key when retrying the same create request to avoid enqueueing duplicate runs.
Request body
The async create body uses the same strictpreset discriminated union as POST /api/stealthify/agent, plus optional webhookUrl and webhookSecret.
One of
"academic", "seo", or "social".Topic or instructions for the document (non-empty).
Required only when
preset is "social". Must be "linkedin" or "medium".When
true, runs a fact-check pass on the draft and applies fixes before humanization.When
true, may embed generated images in the final markdown where supported.Optional URL that receives a
POST callback when the run reaches a terminal status.Optional signing secret, 16-255 characters. When present, StealthGPT signs webhook callbacks with HMAC-SHA256.
Response: 202 Accepted
Identifier of the queued Stealth Agent run.
Always
"queued" for a successful create response.Relative polling URL:
/api/stealthify/agent/runs/{runId}.Poll run status
GET https://stealthgpt.ai/api/stealthify/agent/runs/{runId}
Headers
Your Stealth API token. The run must belong to this token’s account.
Path parameters
The
runId returned from POST /api/stealthify/agent/runs.Queued response
Returned before the generation row has started.Running response
Run identifier.
academic, seo, or social."running".ISO timestamp for run creation.
ISO timestamp for the latest run update.
Current pipeline step, or
null while the run is starting. Possible step ids include web_research, keywords_research, competitor_analysis, social_research, generate_text, meta_generation, fact_check, humanize, image_generation, and citations.Human-readable current operation, or
null while the run is starting.Completed response
The completed polling response is also the successful webhook callback body.Identifier of the saved document record for this run.
Final content as markdown.
Word count of
result used for billing.Stealth API words charged for this request.
Prepaid word balance after this charge.
"prepaid" when covered from balance, or "payg" when metered usage was applied.Words billed to metered usage for this request (0 when fully prepaid).
Failed response
failed can mean generation failed or billing could not be completed after generation.
error.code values:
| Code | Meaning |
|---|---|
generation_failed | The generation pipeline failed before a completed document was available. |
payg_terms_required | Credits ran out and pay-as-you-go terms have not been accepted. |
payment_required | Credits or pay-as-you-go access were not available when billing was finalized. |
billing_delayed | Billing was temporarily delayed; create a new run later if needed. |
cancelled | The run was cancelled before completion. |
Cancelled response
Webhook callbacks
IfwebhookUrl is present in the create request, StealthGPT sends a best-effort POST when the run reaches a terminal status: completed, failed, or cancelled.
Headers
application/jsonStealthGPT-API-Webhook/1.0stealth_agent.run.completed, stealth_agent.run.failed, or stealth_agent.run.cancelled.The run id.
Unix timestamp in seconds. Present on every webhook callback.
Present when
webhookSecret was provided. Format: v1={hex_hmac_sha256}.Delivery behavior
- Webhook delivery uses a 10-second timeout.
- Network errors, timeouts,
429, and5xxresponses are retried up to 3 attempts. 4xxresponses other than429are treated as final failures.- Webhook delivery is best-effort: a failed callback does not change the run status.
- The callback body is the same terminal payload returned by
GET /api/stealthify/agent/runs/{runId}. - When
webhookSecretis provided, the signature is computed over${timestamp}.${rawBody}using HMAC-SHA256. - Reject signed callbacks with old timestamps. A 5-minute tolerance is recommended.
Verify a signature
Use the raw request body exactly as received. Re-serializing parsed JSON can change whitespace and produce a different signature.nodejs
Examples
Errors
| Endpoint | Status | Meaning |
|---|---|---|
POST /runs | 400 | Invalid request body or idempotency-key. |
POST /runs | 401 | Missing api-token header or token not found. |
POST /runs | 402 | Insufficient credits, pay-as-you-go not available, payment method missing, or billing cap delay. |
POST /runs | 500 | Server error while creating the run. |
GET /runs/{runId} | 400 | Invalid runId. |
GET /runs/{runId} | 401 | Missing api-token header or token not found. |
GET /runs/{runId} | 404 | Run not found or belongs to another account. |
GET /runs/{runId} | 500 | Server error while reading status. |
Usage notes
- Use
idempotency-keywhenever your create request can be retried by a queue, workflow engine, or HTTP client. - Poll every 5-15 seconds; there is no benefit to polling every second.
- Store
runId,statusUrl, and your own job id together so webhook handlers can reconcile callbacks with queued work. - Billing uses output words only: charged words =
ceil(outputWords × 10)toward your Stealth API balance.