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

# Check Generation Status

> Poll a submitted request until content completes or fails.

Generation does not complete in the initial create request.

You poll the status endpoint using the `request_id` returned from the original generation call. This keeps the API predictable for long-running content jobs.

## Status Overview

<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '12px', margin: '1.5rem 0' }}>
  <div style={{ border: '1px solid rgba(128,128,128,0.20)', borderRadius: '14px', padding: '16px', background: 'rgba(255,255,255,0.04)' }}>
    <div style={{ fontWeight: 800 }}>Submit</div>
    <div style={{ fontSize: '13px', color: 'var(--colors-content-secondary)' }}>Start a generation request.</div>
  </div>

  <div style={{ border: '1px solid rgba(128,128,128,0.20)', borderRadius: '14px', padding: '16px', background: 'rgba(255,255,255,0.04)' }}>
    <div style={{ fontWeight: 800 }}>Store</div>
    <div style={{ fontSize: '13px', color: 'var(--colors-content-secondary)' }}>Save the returned request ID.</div>
  </div>

  <div style={{ border: '1px solid rgba(128,128,128,0.20)', borderRadius: '14px', padding: '16px', background: 'rgba(255,255,255,0.04)' }}>
    <div style={{ fontWeight: 800 }}>Poll</div>
    <div style={{ fontSize: '13px', color: 'var(--colors-content-secondary)' }}>Check status at intervals.</div>
  </div>

  <div style={{ border: '1px solid rgba(128,128,128,0.20)', borderRadius: '14px', padding: '16px', background: 'rgba(255,255,255,0.04)' }}>
    <div style={{ fontWeight: 800 }}>Resolve</div>
    <div style={{ fontSize: '13px', color: 'var(--colors-content-secondary)' }}>Return content or handle failure.</div>
  </div>
</div>

## Request

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
GET https://api.writerzroom.com/v1/generate/status/{request_id}
Authorization: Bearer YOUR_API_KEY
```

## Response: In Progress

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "request_id": "req_xyz789",
  "status": "processing",
  "stage": "writer",
  "progress": 60
}
```

## Response: Completed

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "request_id": "req_xyz789",
  "status": "completed",
  "content": {
    "id": "cnt_abc123",
    "title": "The Future of AI in Content Marketing",
    "body": "...",
    "word_count": 1842,
    "created_at": "2026-03-10T20:03:42Z"
  }
}
```

## Response: Failed

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "request_id": "req_xyz789",
  "status": "failed",
  "error": "Missing required input field: audience"
}
```

## How to Poll

```javascript theme={"theme":{"light":"github-light","dark":"github-dark"}}
async function pollStatus(requestId, apiKey) {
  const maxAttempts = 30;
  const intervalMs = 8000;

  for (let i = 0; i < maxAttempts; i++) {
    const res = await fetch(
      `https://api.writerzroom.com/v1/generate/status/${requestId}`,
      { headers: { Authorization: `Bearer ${apiKey}` } }
    );

    const data = await res.json();

    if (data.status === "completed") return data.content;
    if (data.status === "failed") throw new Error(data.error);

    await new Promise((resolve) => setTimeout(resolve, intervalMs));
  }

  throw new Error("Generation timed out");
}
```

## Polling Guidance

<Steps>
  <Step title="Submit the generation request">
    Send the original generation request and store the returned `request_id`.
  </Step>

  <Step title="Poll at a controlled interval">
    Check status every 5 to 10 seconds.
  </Step>

  <Step title="Stop on terminal status">
    Stop polling when status returns `completed` or `failed`.
  </Step>

  <Step title="Log unresolved jobs">
    If polling times out, log the `request_id` for support and audit review.
  </Step>
</Steps>

<Tip>
  Poll every **5–10 seconds** with a maximum of **20–30 attempts** covering roughly 3 minutes. If status is still `processing` after that, log the `request_id` and contact support.
</Tip>

<CardGroup cols={2}>
  <Card title="Generate Content" icon="wand-sparkles" href="/api/generate-content">
    Submit the request that creates a generation job.
  </Card>

  <Card title="Endpoints Reference" icon="route" href="/api/endpoints">
    Review available API endpoints.
  </Card>
</CardGroup>
