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

# Endpoints Reference

> Complete reference for WriterzRoom API endpoints.

The WriterzRoom API exposes generation, status tracking, content management, templates, style profiles, verticals, and dashboard usage endpoints through one versioned base URL.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
https://api.writerzroom.com/v1
```

All protected endpoints require Bearer token authentication.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
Authorization: Bearer YOUR_API_KEY
```

## Endpoint 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 }}>Generation</div>
    <div style={{ fontSize: '13px', color: 'var(--colors-content-secondary)' }}>Submit jobs and poll completion status.</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 }}>Content</div>
    <div style={{ fontSize: '13px', color: 'var(--colors-content-secondary)' }}>Retrieve, save, and manage generated drafts.</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 }}>Configuration</div>
    <div style={{ fontSize: '13px', color: 'var(--colors-content-secondary)' }}>Fetch templates, styles, and vertical settings.</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 }}>Usage</div>
    <div style={{ fontSize: '13px', color: 'var(--colors-content-secondary)' }}>Review account statistics and activity.</div>
  </div>
</div>

## Base URL

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
https://api.writerzroom.com/v1
```

## Core Endpoints

| Method | Endpoint                        | Description                                           |
| ------ | ------------------------------- | ----------------------------------------------------- |
| `POST` | `/generate`                     | Submit a generation request                           |
| `GET`  | `/generate/status/{request_id}` | Poll generation status and retrieve completed content |
| `GET`  | `/content`                      | List saved content for the authenticated user         |
| `GET`  | `/content/{contentID}`          | Retrieve a specific content item                      |
| `POST` | `/content/save`                 | Save or update a content item                         |
| `POST` | `/content/regenerate-section`   | Regenerate a specific section of existing content     |
| `GET`  | `/templates`                    | List available templates                              |
| `GET`  | `/templates/{slug}`             | Retrieve a specific template by slug                  |
| `GET`  | `/style-profiles`               | List available style profiles                         |
| `GET`  | `/style-profiles/{slug}`        | Retrieve a specific style profile by slug             |
| `GET`  | `/verticals`                    | List available verticals                              |
| `GET`  | `/verticals/{vertical_id}`      | Retrieve vertical configuration details               |
| `GET`  | `/dashboard/stats`              | Retrieve usage statistics and generation counts       |

## Request Example

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X GET https://api.writerzroom.com/v1/templates \
  -H "Authorization: Bearer YOUR_API_KEY"
```

## Error Response Example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "error": {
    "code": "unauthorized",
    "message": "Missing or invalid API key"
  }
}
```

## Integration Flow

<Steps>
  <Step title="Authenticate requests">
    Add the `Authorization: Bearer YOUR_API_KEY` header to every protected request.
  </Step>

  <Step title="Fetch valid configuration">
    Use `/templates`, `/style-profiles`, and `/verticals` to retrieve valid identifiers before submitting generation jobs.
  </Step>

  <Step title="Submit generation">
    Call `POST /generate` with the selected template, style profile, vertical, generation mode, and structured input.
  </Step>

  <Step title="Poll for completion">
    Use `/generate/status/{request_id}` to retrieve processing updates and completed content.
  </Step>

  <Step title="Save or manage content">
    Use content endpoints to retrieve, save, update, or regenerate content sections.
  </Step>
</Steps>

## Rate Limits

| Limit                      | Value                  |
| -------------------------- | ---------------------- |
| Per-account request rate   | 10 requests per minute |
| Rate limit response        | `429`                  |
| Recommended retry strategy | Exponential backoff    |
| Generation accounting      | Monthly plan usage     |

## Error Codes

| Status | Meaning                                         |
| ------ | ----------------------------------------------- |
| `400`  | Bad request, missing fields, or invalid payload |
| `401`  | Unauthorized, missing or invalid API key        |
| `403`  | Forbidden, plan does not include API access     |
| `404`  | Resource not found                              |
| `429`  | Rate limit exceeded                             |
| `500`  | Internal server error                           |

## Exponential Backoff Example

```javascript theme={"theme":{"light":"github-light","dark":"github-dark"}}
async function requestWithBackoff(fn, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      return await fn();
    } catch (error) {
      const isRateLimited = error.status === 429;

      if (!isRateLimited || attempt === maxRetries - 1) {
        throw error;
      }

      const delayMs = Math.pow(2, attempt) * 1000;
      await new Promise((resolve) => setTimeout(resolve, delayMs));
    }
  }
}
```

## Operational Guidance

<AccordionGroup>
  <Accordion title="Which base URL should integrations use?">
    Use `https://api.writerzroom.com/v1` for public API integrations.
  </Accordion>

  <Accordion title="Should identifiers be hardcoded?">
    Avoid hardcoding identifiers for large integrations. Fetch templates, style profiles, and verticals programmatically when possible.
  </Accordion>

  <Accordion title="How should rate limits be handled?">
    Treat `429` as a retryable response and apply exponential backoff. Do not retry immediately in tight loops.
  </Accordion>

  <Accordion title="What information should be included in support requests?">
    Include the endpoint, timestamp, request ID if available, response status, and sanitized error body.
  </Accordion>
</AccordionGroup>

<Warning>
  Do not send API keys in query parameters. Always use the `Authorization` header.
</Warning>

<CardGroup cols={2}>
  <Card title="API Authentication" icon="key" href="/api/authentication">
    Learn how to authenticate API requests.
  </Card>

  <Card title="Check Generation Status" icon="activity" href="/api/check-generation-status">
    Poll submitted generation jobs until completion.
  </Card>
</CardGroup>
