# AutoBlogWriter Documentation — Full Content
> AutoBlogWriter is an AI-powered blog content engine. The SDK works with any Node.js framework (Next.js, Remix, Astro, Express). It includes framework-agnostic helpers, Next.js App Router helpers with ISR cache tagging, React components, and webhook-based revalidation.
---
# Introduction
Welcome to the **AutoBlogWriter** documentation. AutoBlogWriter is an AI-powered content generation platform that automates blog post creation, scheduling, and publishing — integrated directly into your Next.js application through an official TypeScript SDK.
## What is AutoBlogWriter?
AutoBlogWriter combines advanced AI models with a complete content management workflow. You generate topics, create drafts, polish content, generate images, and publish — all from the AutoBlogWriter dashboard. Then your Next.js app fetches and renders that content using the `@autoblogwriter/sdk`.
### Platform Components
| Component | Description |
|:----------|:------------|
| **Dashboard** | Web UI for managing content, topics, scheduling, and analytics |
| **API** | REST API powering the dashboard and SDK |
| **SDK** | TypeScript package for fetching and rendering blog content in your app |
### Key Features
- **AI-Powered Content** — Generate full blog posts from keywords or topics using state-of-the-art LLMs.
- **Batch Generation** — Create dozens of posts at once with the auto-scheduler.
- **Smart Scheduling** — Schedule posts to publish at optimal times automatically.
- **Official SDK** — First-class TypeScript SDK with Next.js App Router support, React components, and SEO helpers.
- **Webhook Revalidation** — Automatic cache invalidation when content publishes.
- **SEO Built-In** — Sitemap generation, robots.txt, OpenGraph metadata, and structured data.
- **Markdown Rendering** — Lightweight, dependency-free HTML renderer with XSS protection.
- **Themeable Styles** — Default dark-theme CSS with full customization via CSS custom properties.
## How It Works
1. **Create a Workspace** — Sign up and create a workspace for your site.
2. **Generate Content** — Use the dashboard to generate topics, drafts, and images with AI.
3. **Publish** — Publish posts immediately or schedule them for later.
4. **Integrate** — Install the SDK in your Next.js app and fetch your posts with a few lines of code.
5. **Revalidate** — Set up a webhook so your site updates instantly when content changes.
## Quick Example
Here's what it looks like to display your blog with the SDK:
```tsx
// app/blog/page.tsx
import Link from "next/link";
import { fetchBlogPosts } from "@autoblogwriter/sdk/next";
import { BlogPostList } from "@autoblogwriter/sdk/react";
export default async function BlogPage() {
const { posts } = await fetchBlogPosts();
return ;
}
```
That's it — server-rendered, SEO-friendly, and automatically revalidated.
## LLMS Files
AutoBlogWriter publishes machine-readable documentation indexes for LLM tooling:
- [`/llms.txt`](/llms.txt) — lightweight docs index and link map.
- [`/llms-full.txt`](/llms-full.txt) — full plain-text docs content for ingestion.
## Next Steps
- [Installation](/docs/getting-started/installation) — Install the SDK and configure your environment.
- [Quickstart](/docs/getting-started/quickstart) — Build a full blog in 5 minutes.
---
# Installation
The `@autoblogwriter/sdk` is the official TypeScript SDK for fetching and rendering AutoBlogWriter content in your application.
## Prerequisites
- **Node.js 18+**
- **A Next.js 13.4+** project (for Next.js helpers — the core client works anywhere)
- **A AutoBlogWriter account** with a workspace and API key
## Install the SDK
```bash
npm install @autoblogwriter/sdk
```
```bash
yarn add @autoblogwriter/sdk
```
```bash
pnpm add @autoblogwriter/sdk
```
### Peer Dependencies
The SDK has **optional** peer dependencies:
| Package | Required For |
|:--------|:-------------|
| `react` >= 18 | React components (`@autoblogwriter/sdk/react`) |
| `next` >= 13.4 | Next.js helpers (`@autoblogwriter/sdk/next`) |
If you only use the core client, neither is required.
## Package Entry Points
The SDK ships multiple entry points for different use cases:
```typescript
// Core client, types, and utilities
import { createAutoBlogWriterClient } from "@autoblogwriter/sdk";
// Next.js App Router helpers (server-side)
import { fetchBlogPosts, fetchBlogPost } from "@autoblogwriter/sdk/next";
// React components
import { BlogPost, BlogPostList, Markdown } from "@autoblogwriter/sdk/react";
// Webhook signature verification (server-side)
import { verifyWebhookSignature } from "@autoblogwriter/sdk/revalidate";
// Default styles
import "@autoblogwriter/sdk/styles.css";
```
## Environment Variables
Add these to your `.env.local` file:
```bash
# Required
AUTOBLOGWRITER_API_KEY=ba_pk_your_api_key_here
AUTOBLOGWRITER_WORKSPACE_SLUG=your-workspace-slug
# Optional
AUTOBLOGWRITER_API_URL=https://api.autoblogwriter.app # Default API URL
AUTOBLOGWRITER_WORKSPACE_ID=ws_abc123 # Alternative to slug for internal use
SITE_URL=https://yoursite.com # Used for sitemap/robots generation
AUTOBLOGWRITER_REVALIDATE_SECRET=your_webhook_secret # For webhook verification
NEXT_PUBLIC_ANALYTICS_TOKEN=your_token # For analytics proxy
```
### Where to Find Your Credentials
1. Log in to the [AutoBlogWriter Dashboard](https://app.autoblogwriter.app).
2. Navigate to your workspace **Settings**.
3. Under **API Keys**, create a new key or copy an existing one.
4. Your **workspace slug** is shown in your workspace URL (e.g., `app.autoblogwriter.app/workspace/your-slug`).
## Setup Options
You have two ways to use the SDK:
### Option A: Environment-Based (Recommended for Next.js)
The simplest approach — the SDK reads configuration from environment variables automatically:
```typescript
// No setup file needed — just use the helpers directly
import { fetchBlogPosts } from "@autoblogwriter/sdk/next";
// In any server component:
const { posts } = await fetchBlogPosts();
```
The `@autoblogwriter/sdk/next` helpers call `createAutoBlogWriterFromEnv()` internally, which reads `AUTOBLOGWRITER_API_KEY`, `AUTOBLOGWRITER_WORKSPACE_SLUG`, and other env vars automatically.
### Option B: Manual Client (Framework-Agnostic)
For non-Next.js projects or when you need more control:
```typescript
// lib/blog.ts
import { createAutoBlogWriterClient } from "@autoblogwriter/sdk";
export const blog = createAutoBlogWriterClient({
apiUrl: "https://api.autoblogwriter.app",
apiKey: process.env.AUTOBLOGWRITER_API_KEY!,
workspaceSlug: process.env.AUTOBLOGWRITER_WORKSPACE_SLUG!,
});
```
See the [Client Reference](/docs/sdk/client) for all configuration options.
## Verify Installation
Run a quick test to make sure everything is wired up:
```typescript
import { createAutoBlogWriterClient } from "@autoblogwriter/sdk";
const client = createAutoBlogWriterClient({
apiUrl: "https://api.autoblogwriter.app",
apiKey: process.env.AUTOBLOGWRITER_API_KEY!,
workspaceSlug: process.env.AUTOBLOGWRITER_WORKSPACE_SLUG!,
});
const { posts } = await client.getPosts({ limit: 1 });
console.log("Connected! Found", posts.length, "posts");
```
## Next Steps
- [Quickstart](/docs/getting-started/quickstart) — Build a full blog page in minutes.
- [Client Reference](/docs/sdk/client) — Explore all client configuration options and methods.
---
# Quickstart
This guide walks you through adding a fully functional blog to your Next.js App Router project using the AutoBlogWriter SDK — from installation to a live blog with SEO, revalidation, and styled components.
## 1. Install the SDK
```bash
npm install @autoblogwriter/sdk
```
## 2. Set Environment Variables
Create or update `.env.local`:
```bash
AUTOBLOGWRITER_API_KEY=ba_pk_your_api_key
AUTOBLOGWRITER_WORKSPACE_SLUG=your-workspace
SITE_URL=https://yoursite.com
AUTOBLOGWRITER_REVALIDATE_SECRET=your_webhook_secret
```
## 3. Import the Styles
In your root layout (`app/layout.tsx`), import the default AutoBlogWriter styles:
```tsx
// app/layout.tsx
import "@autoblogwriter/sdk/styles.css";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
{children}
);
}
```
## 4. Create the Blog Listing Page
```tsx
// app/blog/page.tsx
import Link from "next/link";
import { fetchBlogPosts } from "@autoblogwriter/sdk/next";
import { BlogPostList } from "@autoblogwriter/sdk/react";
export default async function BlogPage() {
const { posts } = await fetchBlogPosts();
return (
);
}
```
## 5. Create the Blog Post Page
```tsx
// app/blog/[slug]/page.tsx
import { fetchBlogPost, generatePostMetadata } from "@autoblogwriter/sdk/next";
import { BlogPost } from "@autoblogwriter/sdk/react";
import type { Metadata } from "next";
type Props = { params: Promise<{ slug: string }> };
export async function generateMetadata({ params }: Props): Promise {
const { slug } = await params;
return generatePostMetadata(slug);
}
export default async function PostPage({ params }: Props) {
const { slug } = await params;
const post = await fetchBlogPost(slug);
return (
);
}
```
The `generatePostMetadata` function automatically generates ``, ``, OpenGraph, and Twitter Card metadata from your post's SEO fields.
## 6. Add the Revalidation Webhook
This API route receives webhooks from AutoBlogWriter when content changes, automatically clearing your Next.js cache:
```typescript
// app/api/autoblogwriter/revalidate/route.ts
import { createEnvRevalidateHandler } from "@autoblogwriter/sdk/next";
export const runtime = "nodejs";
export const POST = createEnvRevalidateHandler();
```
Then in your AutoBlogWriter dashboard, go to **Settings > Webhooks** and add:
- **URL:** `https://yoursite.com/api/autoblogwriter/revalidate`
- **Secret:** The same value as your `AUTOBLOGWRITER_REVALIDATE_SECRET` env var.
## 7. Add Sitemap and Robots
```typescript
// app/sitemap.ts
import { generateBlogSitemap } from "@autoblogwriter/sdk/next";
export const revalidate = 300; // Refresh every 5 minutes
export default function sitemap() {
return generateBlogSitemap();
}
```
```typescript
// app/robots.ts
import { generateBlogRobots } from "@autoblogwriter/sdk/next";
export default function robots() {
return generateBlogRobots();
}
```
## 8. Run Your App
```bash
npm run dev
```
Visit `http://localhost:3000/blog` to see your published posts.
## What You Get
With these ~50 lines of code, your blog now has:
- Server-rendered blog listing and post pages
- Automatic SEO metadata (title, description, OpenGraph, Twitter Cards)
- Automatic cache revalidation via webhooks
- Sitemap and robots.txt generation
- Styled components with a dark theme
- Cursor-based pagination support
- Reading time display
## Next Steps
- [React Components](/docs/sdk/react-components) — Customize the blog UI with props and render functions.
- [Styling](/docs/sdk/styling) — Theme the components with CSS custom properties.
- [Webhooks & Revalidation](/docs/sdk/webhooks) — Deep dive into cache invalidation.
- [Next.js Helpers](/docs/sdk/nextjs-helpers) — All available server-side helpers.
---
# Public API
This page documents direct REST access to the AutoBlogWriter public content API.
If you are using Next.js, the SDK is usually the fastest path to production. For direct API calls or custom platforms, use the endpoints below.
## Base URL
```text
https://api.autoblogwriter.app
```
## Authentication
Use your workspace API key (`ba_pk_...`) with one of the supported auth headers:
```http
Authorization: Bearer
```
or
```http
x-api-key:
```
## Workspace Slug Requirement
Public content endpoints are workspace-scoped and require a `workspaceSlug` in the URL path:
```text
/v1/public/:workspaceSlug/...
```
Find your workspace slug in the AutoBlogWriter dashboard workspace settings.
## Endpoint: List Published Posts
`GET /v1/public/:workspaceSlug/blogs`
Returns published blog posts with pagination metadata.
### Query Parameters
| Param | Type | Required | Default | Description |
|:------|:-----|:---------|:--------|:------------|
| `limit` | `number` | No | `20` | Page size |
| `page` | `number` | No | `1` | 1-based page number |
| `category` | `string` | No | — | Filter by category |
### cURL Example
```bash
curl --request GET \
--url "https://api.autoblogwriter.app/v1/public/my-blog/blogs?limit=10&page=1&category=SEO" \
--header "Authorization: Bearer ba_pk_your_api_key"
```
### Example Success Response
```json
{
"success": true,
"data": {
"items": [
{
"id": "post_1",
"title": "How to Scale Content Ops",
"slug": "scale-content-ops",
"excerpt": "A practical system for higher output.",
"content": "# ...",
"status": "PUBLISHED",
"categories": ["SEO", "Automation"],
"updatedAt": "2026-01-01T00:00:00.000Z"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 42,
"totalPages": 5,
"hasMore": true
}
}
}
```
## Endpoint: Get Post By Slug
`GET /v1/public/:workspaceSlug/blogs/:slug`
Returns a single published post by URL slug.
### cURL Example
```bash
curl --request GET \
--url "https://api.autoblogwriter.app/v1/public/my-blog/blogs/scale-content-ops" \
--header "x-api-key: ba_pk_your_api_key"
```
### Example Success Response
```json
{
"success": true,
"data": {
"post": {
"id": "post_1",
"title": "How to Scale Content Ops",
"slug": "scale-content-ops",
"content": "# ...",
"status": "PUBLISHED",
"categories": ["SEO"],
"relatedPosts": [
{
"id": "post_2",
"title": "Editorial Calendars That Ship",
"slug": "editorial-calendars-ship",
"updatedAt": "2026-01-02T00:00:00.000Z"
}
],
"updatedAt": "2026-01-01T00:00:00.000Z"
}
}
}
```
## Response Envelope and Errors
Successful JSON responses are wrapped as:
```json
{
"success": true,
"data": {}
}
```
When the API returns a non-2xx status, use the HTTP status code plus error body fields for handling.
Common practical cases:
- `401 Unauthorized`: invalid API key or header format.
- `404 Not Found`: slug does not exist for the workspace.
- `429 Too Many Requests`: retry with backoff.
- `5xx`: temporary server failure.
## Pagination Guidance (SDK Parity)
The official SDK exposes `nextCursor` for pagination, but the API uses `page` numbers.
- Start with `page=1`.
- If `pagination.hasMore` is `true`, request `page + 1`.
- Stop when `hasMore` is `false`.
## SDK vs Direct API
Use the SDK if you want typed helpers, Next.js cache tags, metadata utilities, and built-in error classes.
Use direct API calls when integrating from non-Next.js stacks or custom data pipelines.
See [Client Reference](/docs/sdk/client) for the SDK path.
---
# Workspaces
A **workspace** represents a single website or project in AutoBlogWriter. All your blog posts, topics, API keys, and settings belong to a workspace.
## Creating a Workspace
1. Log in to the [AutoBlogWriter Dashboard](https://app.autoblogwriter.app).
2. Click **New Workspace**.
3. Enter your website name and URL.
4. You'll be assigned a **workspace slug** (e.g., `my-tech-blog`) that you'll use in the SDK.
## Workspace Settings
Each workspace has its own configuration:
- **AI Personality** — Define the tone, style, and voice for AI-generated content.
- **Website Context** — Provide background about your site so the AI generates relevant content.
- **API Keys** — Create and manage API keys scoped to this workspace.
- **Webhooks** — Configure revalidation endpoints for your deployed sites.
- **Team Members** — Invite collaborators to manage content together.
## Workspace Identifiers
The SDK uses two identifiers to reference a workspace:
| Identifier | Format | Usage |
|:-----------|:-------|:------|
| `workspaceSlug` | `my-tech-blog` | **Required** for public API endpoints (what the SDK uses to fetch posts) |
| `workspaceId` | `ws_abc123` | Internal ID, used for authenticated dashboard endpoints |
When configuring the SDK, you must provide at least one:
```typescript
const client = createAutoBlogWriterClient({
apiUrl: "https://api.autoblogwriter.app",
apiKey: "ba_pk_...",
workspaceSlug: "my-tech-blog", // Required for fetching posts
});
```
## API Keys
API keys authenticate your SDK requests and are scoped to a single workspace.
### Key Format
All API keys use the prefix `ba_pk_` followed by a random string.
### Managing Keys
- **Create** — Dashboard > Settings > API Keys > Create New Key
- **Revoke** — Immediately invalidates a key. Existing requests using it will fail.
- **Delete** — Permanently removes the key record.
### Security Best Practices
- Store keys in environment variables, never in client-side code.
- Use different keys for development and production.
- Rotate keys periodically.
- Revoke compromised keys immediately.
## Next Steps
- [Blog Generation](/docs/core-concepts/blog-generation) — How AI content generation works.
- [Client Reference](/docs/sdk/client) — Configure the SDK client for your workspace.
---
# Blog Generation
AutoBlogWriter uses state-of-the-art language models to generate SEO-optimized blog content through a multi-stage pipeline.
## The Generation Pipeline
### 1. Topic Generation
The AI analyzes your niche, website context, and target keywords to suggest high-traffic blog topics. Topics are stored and can be reviewed, edited, or discarded before moving to the next stage.
### 2. Draft Creation
From an approved topic, the AI generates a full blog post draft including:
- Structured headings (H1–H4)
- Well-organized body paragraphs
- SEO-optimized meta description
- Target keywords naturally woven into the content
- Suggested excerpt
### 3. Content Polishing
Use the built-in editor to refine AI-generated content. The editor supports:
- AI-assisted rewriting of individual sections
- Grammar and tone adjustments
- Markdown formatting
- Image placement
### 4. Image Generation
AutoBlogWriter integrates with AI image generation to create:
- **Hero images** — Featured images for your posts
- **OG images** — OpenGraph images for social sharing
Images are automatically uploaded to S3 and associated with your post.
## Batch Generation
For scaling content production, AutoBlogWriter supports **batch generation** — creating multiple posts in a single operation.
### Auto-Schedule Generate
The most powerful batch feature combines topic generation, drafting, and scheduling:
1. Specify the number of posts, target keywords, and schedule preferences.
2. AutoBlogWriter generates topics, writes drafts, creates images, and schedules publication.
3. Monitor progress from the dashboard or via the API.
Batch jobs run asynchronously and can be monitored, polled, or cancelled.
## Blog Post Model
Every blog post contains:
| Field | Description |
|:------|:------------|
| `title` | Post title |
| `slug` | URL-friendly identifier (auto-generated or custom) |
| `content` | Markdown body content |
| `excerpt` | Short summary for listings and meta descriptions |
| `status` | `DRAFT`, `PUBLISHED`, or `HIDDEN` |
| `seo.title` | SEO-specific title (falls back to `title`) |
| `seo.description` | Meta description |
| `seo.keywords` | Target keyword array |
| `metadata.canonicalUrl` | Canonical URL for deduplication |
| `metadata.ogImageUrl` | OpenGraph image URL |
| `metadata.readingTimeMinutes` | Estimated reading time |
| `metadata.wordCount` | Word count |
| `publishedAt` | Publication timestamp |
| `updatedAt` | Last modification timestamp |
## Content Workflow
```
Topic → Draft → Polish → Schedule/Publish → Live on your site
```
Posts transition through these statuses:
- **DRAFT** — Work in progress, not visible to the public API.
- **PUBLISHED** — Live and returned by SDK queries.
- **HIDDEN** — Unpublished but retained. Not returned by the public API.
When a post is published, AutoBlogWriter sends a webhook to your site so the cache is automatically invalidated.
## SEO Features
AutoBlogWriter handles SEO automatically:
- **Keyword targeting** — AI naturally incorporates your target keywords.
- **Meta descriptions** — Generated and editable per post.
- **Header structure** — Proper H1–H4 hierarchy for crawlability.
- **Reading time** — Calculated and stored in metadata.
- **Sitemap integration** — Published posts are included in your sitemap via the SDK.
## Next Steps
- [Scheduling System](/docs/core-concepts/scheduling-system) — Automate your content calendar.
- [React Components](/docs/sdk/react-components) — Render posts with built-in components.
---
# Scheduling System
Consistent publishing is key to SEO success. AutoBlogWriter's scheduling system lets you plan your content calendar and automatically publish posts at the right time.
## How Scheduling Works
When you schedule a post, you set a future date and time. A background job checks for scheduled posts and automatically transitions them to `PUBLISHED` status when the time arrives.
### Scheduling a Post
From the dashboard editor:
1. Write or generate your post.
2. Click **Schedule** instead of **Publish**.
3. Pick a date, time, and timezone.
4. The post remains in `DRAFT` status until the scheduled time.
Scheduled posts include:
- `scheduledAt` — The target publication timestamp.
- `timezone` — The timezone for the schedule (e.g., `America/New_York`).
- `scheduledByUserId` — Who scheduled it.
## Auto-Scheduler
The **Auto-Scheduler** is AutoBlogWriter's most powerful scheduling feature. It combines AI content generation with intelligent scheduling:
1. Go to the **Auto-Scheduler** in your dashboard.
2. Configure:
- Number of posts to generate
- Target keywords or topics
- Publishing frequency (e.g., 3 times per week)
- Preferred posting windows
- Timezone
3. AutoBlogWriter creates a batch job that:
- Generates topics from your keywords
- Writes full drafts for each topic
- Generates hero and OG images
- Schedules each post at optimal intervals
### Batch Job States
| Status | Description |
|:-------|:------------|
| `pending` | Job created, waiting to start |
| `processing` | Actively generating content |
| `completed` | All posts generated and scheduled |
| `failed` | An error occurred during generation |
You can monitor batch jobs from the dashboard or poll the API for status updates.
## Manual Scheduling
For individual posts, use the editor's scheduling feature:
- **Schedule** — Set a specific date and time.
- **Publish Now** — Immediately transition to `PUBLISHED`.
- **Reschedule** — Change the scheduled time for a pending post.
- **Cancel Schedule** — Return the post to a regular draft.
## Calendar View
The dashboard includes a calendar view showing:
- Published posts (by publication date)
- Scheduled posts (by scheduled date)
- Draft posts in progress
This gives you a visual overview of your content pipeline and helps identify gaps in your publishing schedule.
## Publication Flow
```
Draft → Scheduled → [Background job runs at scheduled time] → Published → Webhook sent → Site revalidated
```
When a scheduled post is published:
1. The post status changes to `PUBLISHED`.
2. `publishedAt` is set to the current timestamp.
3. A webhook is sent to your configured endpoints.
4. Your Next.js site's cache is automatically cleared via the revalidation handler.
## Next Steps
- [Webhooks & Revalidation](/docs/sdk/webhooks) — How cache invalidation works when posts publish.
- [Next.js Helpers](/docs/sdk/nextjs-helpers) — Fetch scheduled and published content.
---
# Analytics
AutoBlogWriter integrates with **Google Analytics 4 (GA4)** to give you traffic and engagement data for your blog — all viewable directly in the AutoBlogWriter dashboard.
## How It Works
1. **Install GA4 on your site** — Add the Google Analytics 4 snippet to your site as you normally would (via `