Draft2Live API
Generate, manage, and publish AI-powered content programmatically. Integrate Draft2Live into your workflows with our REST API.
Overview
The Draft2Live API allows you to generate, manage, and publish AI-powered content programmatically. Build custom integrations, automate content workflows, and manage your articles from any platform.
Base URL
https://draft2live.ai/api/v1/publicResponse Format
All successful responses are wrapped in a {"data": {...}} envelope. Lists include pagination metadata.
// Standard response envelope
{
"data": {
"id": 1234,
"title": "Your article title",
"status": "draft"
}
}
// List response with pagination
{
"data": [
{ "id": 1, "title": "Article 1" },
{ "id": 2, "title": "Article 2" }
],
"meta": {
"page": 1,
"per_page": 20,
"total": 47,
"total_pages": 3
}
}Authentication
Authenticate your API requests using an API key. You can create and manage API keys from your Account → API Keys page.
Keep your API keys secure
Do not share your API key in publicly accessible areas such as client-side code, GitHub, or public forums. Use environment variables on your server.
API Key (recommended)
Pass your API key via the X-API-Key header.
curl -X GET "https://draft2live.ai/api/v1/public/articles" \
-H "X-API-Key: d2l_your_key_here" \
-H "Content-Type: application/json"Bearer Token
JWT bearer tokens are also supported for session-based authentication.
curl -X GET "https://draft2live.ai/api/v1/public/articles" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
-H "Content-Type: application/json"Articles
Manage your generated articles. Retrieve, list, and filter your content library.
/articlesRetrieve a paginated list of your articles. Supports filtering by status and language.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| page | integer | Page number (default: 1) |
| per_page | integer | Items per page, max 100 (default: 20) |
| status | string | Filter by status: draft, published, archived |
| language | string | Filter by language code (e.g., uk, en, de) |
Response
{
"data": [
{
"id": 4821,
"title": "10 SEO-порад для просування інтернет-магазину",
"slug": "10-seo-porad-dlia-prosuvannia-internet-mahazyny",
"status": "published",
"language": "uk",
"word_count": 2450,
"model": "gpt-4o",
"created_at": "2026-04-15T10:23:00Z",
"updated_at": "2026-04-15T12:05:30Z"
},
{
"id": 4820,
"title": "How to Build a Content Strategy in 2026",
"slug": "how-to-build-content-strategy-2026",
"status": "draft",
"language": "en",
"word_count": 1800,
"model": "claude-sonnet",
"created_at": "2026-04-14T08:15:00Z",
"updated_at": "2026-04-14T08:15:00Z"
}
],
"meta": {
"page": 1,
"per_page": 20,
"total": 142,
"total_pages": 8
}
}/articles/{id}Retrieve full details of a single article including its HTML content.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
| id | integer | The article ID |
Response
{
"data": {
"id": 4821,
"title": "10 SEO-порад для просування інтернет-магазину",
"slug": "10-seo-porad-dlia-prosuvannia-internet-mahazyny",
"status": "published",
"language": "uk",
"word_count": 2450,
"model": "gpt-4o",
"content": "<h2>Вступ</h2><p>Просування інтернет-магазину...</p>",
"meta_title": "10 SEO-порад для інтернет-магазину | 2026",
"meta_description": "Дізнайтеся про найефективніші SEO-стратегії...",
"keywords": ["seo", "інтернет-магазин", "просування"],
"created_at": "2026-04-15T10:23:00Z",
"updated_at": "2026-04-15T12:05:30Z",
"publications": [
{
"site_id": 12,
"site_name": "My WordPress Blog",
"published_at": "2026-04-15T12:05:30Z",
"external_url": "https://myblog.com/10-seo-porad"
}
]
}
}Generation
Generate new articles using AI. Article generation is asynchronous -- submit a job and poll for completion.
/articles/generateStart a new article generation job. Returns a job ID for tracking progress.
Request Body
| Parameter | Type | Description |
|---|---|---|
| topic | string | The article topic or title |
| language_code | string | Target language (e.g., uk, en, de, fr) |
| word_count | integer | Target word count (default: 1500) |
| model | string | AI model: gpt-4o, claude-sonnet, gemini-pro (default: gpt-4o) |
| keywords | string[] | SEO keywords to include in the article |
| custom_instructions | string | Additional instructions for the AI writer |
Request Example
curl -X POST "https://draft2live.ai/api/v1/public/articles/generate" \
-H "X-API-Key: d2l_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"topic": "Як обрати CMS для інтернет-магазину у 2026 році",
"language_code": "uk",
"word_count": 2000,
"model": "gpt-4o",
"keywords": ["CMS", "інтернет-магазин", "WordPress", "Drupal"],
"custom_instructions": "Focus on e-commerce features and SEO capabilities"
}'Response
{
"data": {
"job_id": "gen_a1b2c3d4e5f6",
"status": "pending",
"estimated_seconds": 45,
"created_at": "2026-04-15T14:30:00Z"
}
}/articles/jobs/{job_id}Check the status of a generation job. Poll this endpoint until status is 'completed' or 'failed'.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
| job_id | string | The generation job ID returned from the generate endpoint |
Response (in progress)
{
"data": {
"job_id": "gen_a1b2c3d4e5f6",
"status": "in_progress",
"progress": 65,
"article_id": null
}
}Response (completed)
{
"data": {
"job_id": "gen_a1b2c3d4e5f6",
"status": "completed",
"progress": 100,
"article_id": 4822,
"completed_at": "2026-04-15T14:30:48Z"
}
}Response (failed)
{
"data": {
"job_id": "gen_a1b2c3d4e5f6",
"status": "failed",
"progress": 0,
"article_id": null,
"error": "Insufficient credits to complete generation"
}
}Images
Generate AI images using multiple models (Flux, GPT Image, Gemini) with style presets and auto-prompt enhancement. Requires the ai_image_generation feature on your plan.
/images/generateGenerate an AI image and save it to your media library.
Request body
| Parameter | Type | Description |
|---|---|---|
| prompt | string | Image description (3-1000 chars) |
| aspect_ratio | string | 1:1, 16:9, 9:16, 4:3, 3:4 (default: 1:1) |
| model | string | auto, flux-flex, flux-pro, flux-max, gpt-image, gemini (default: auto) |
| style | string | realistic, cartoon, watercolor, oil-painting, 3d-render, anime, sketch, pop-art, pixel-art, cyberpunk |
| auto_prompt | boolean | Auto-enhance prompt with AI (default: true) |
| folder_id | integer | Folder ID to save image to |
Example request
curl -X POST https://draft2live.ai/api/v1/public/images/generate \
-H "X-API-Key: d2l_your_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Modern office building at sunset, glass facade reflecting orange sky",
"aspect_ratio": "16:9",
"model": "flux-pro",
"style": "realistic"
}'Response
{
"data": {
"id": 142,
"url": "/uploads/users/4/media/2026/04/modern-office-building.png",
"filename": "modern-office-building.png",
"width": 1344,
"height": 768,
"cost_usd": 0.04,
"model_used": null
}
}/images/modelsList available image generation models with cost estimates.
Response
{
"data": {
"models": [
{
"key": "flux-klein",
"name": "Flux Klein",
"cost_estimate": 0.014
},
{
"key": "flux-flex",
"name": "Flux Flex",
"cost_estimate": 0.025
},
{
"key": "flux-pro",
"name": "Flux Pro",
"cost_estimate": 0.04
},
{
"key": "flux-max",
"name": "Flux Max",
"cost_estimate": 0.08
},
{
"key": "gpt-image",
"name": "GPT Image",
"cost_estimate": 0.04
},
{
"key": "gemini",
"name": "Gemini Image",
"cost_estimate": 0.04
}
]
}
}Sites
Manage your connected CMS sites (WordPress, Drupal). Sites are configured in the dashboard and referenced by ID when publishing.
/sitesList all CMS sites connected to your account.
Response
{
"data": [
{
"id": 12,
"name": "My WordPress Blog",
"type": "wordpress",
"url": "https://myblog.com",
"status": "connected",
"last_sync_at": "2026-04-15T09:00:00Z"
},
{
"id": 15,
"name": "Corporate Drupal Site",
"type": "drupal",
"url": "https://corporate.example.com",
"status": "connected",
"last_sync_at": "2026-04-14T18:30:00Z"
}
]
}Publishing
Publish generated articles to your connected CMS sites. Supports WordPress and Drupal with category assignment and publish status control.
/articles/{id}/publishPublish an article to a connected CMS site.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
| id | integer | The article ID to publish |
Request Body
| Parameter | Type | Description |
|---|---|---|
| site_id | integer | Target CMS site ID |
| publish_status | string | CMS post status: publish, draft, pending (default: draft) |
| categories | integer[] | Array of CMS category IDs |
Request Example
curl -X POST "https://draft2live.ai/api/v1/public/articles/4821/publish" \
-H "X-API-Key: d2l_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"site_id": 12,
"publish_status": "draft",
"categories": [5, 12]
}'Response
{
"data": {
"publication_id": 891,
"article_id": 4821,
"site_id": 12,
"site_name": "My WordPress Blog",
"external_id": 3456,
"external_url": "https://myblog.com/?p=3456",
"status": "draft",
"published_at": "2026-04-15T14:45:00Z"
}
}/articles/{id}/publicationsList all publications (CMS posts) created from a specific article.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
| id | integer | The article ID |
Response
{
"data": [
{
"publication_id": 891,
"site_id": 12,
"site_name": "My WordPress Blog",
"site_type": "wordpress",
"external_id": 3456,
"external_url": "https://myblog.com/10-seo-porad",
"status": "published",
"published_at": "2026-04-15T14:45:00Z"
}
]
}Hosted Sites
Programmatically build and manage hosted websites (served at {slug}.draft2blog.com) — sites, pages, blog posts, custom domains, outbound webhooks and images. These endpoints run the same validated code as the dashboard (ownership, quotas, moderation, sanitization), so nothing behaves less safely than the UI.
Interactive reference & MCP
Full request/response schemas live in the always-current Swagger UI at /api/v1/public/docs. The same endpoints back a remote MCP server so a model (e.g. Claude) can build sites in conversation — connect https://draft2live.ai/mcp with your API key.
Base path & auth
https://draft2live.ai/api/v1/public/hostedSame X-API-Key: d2l_… as above; requires a plan with API access. A read-only key may call GET only; mutations need a read+write key.
Discovery
/hosted/accountThe account behind the API key: email, plan tier, and key scopes (read vs read,write).
/hosted/templatesCurated site templates to start from. Each item's `key` feeds POST /hosted/sites/from-template. Optional ?category= and ?locale=.
Sites
/hosted/sitesList your hosted sites (id, name, slug, status, public URL, quota).
curl "https://draft2live.ai/api/v1/public/hosted/sites" -H "X-API-Key: d2l_your_key"/hosted/sitesCreate a BLANK site. Prefer from-template for a ready design.
| Parameter | Type | Description |
|---|---|---|
| name | string | Site display name. |
| slug | string | Becomes {slug}.draft2blog.com; unique + moderated. |
| template_key | string | Layout key, e.g. "minimal". |
| default_locale | string | e.g. "uk". |
| theme_config | object | Theme/settings object. |
/hosted/sites/from-templateCreate a site by cloning a curated template (no AI).
| Parameter | Type | Description |
|---|---|---|
| name | string | Site display name. |
| slug | string | Becomes {slug}.draft2blog.com; unique + moderated. |
| template_key | string | From GET /hosted/templates, e.g. "cafe-warm". |
| default_locale | string | Default "uk". |
curl -X POST "https://draft2live.ai/api/v1/public/hosted/sites/from-template" \
-H "X-API-Key: d2l_your_key" -H "Content-Type: application/json" \
-d '{"name":"My Cafe","slug":"my-cafe","template_key":"cafe-warm"}'/hosted/sites/{site_id}Get one site (theme, settings, status).
/hosted/sites/{site_id}Update a site. Only the fields you pass change.
| Parameter | Type | Description |
|---|---|---|
| name | string | Rename the site. |
| default_locale | string | Change default language. |
| template_key | string | Change layout. |
| theme_config | object | Theme/settings. |
| analytics_token | string | Analytics token. |
/hosted/sites/{site_id}Permanently delete a site and all its pages/posts. Irreversible.
Pages
/hosted/sites/{site_id}/pagesList a site's pages (id, title, slug, page_type, status).
/hosted/sites/{site_id}/pagesAdd a page. Sections (the page content) are validated + sanitized server-side.
| Parameter | Type | Description |
|---|---|---|
| title | string | Page title. |
| slug | string | URL slug. |
| locale | string | Page locale. |
| sections | array | List of section objects (page content). |
| page_type | string | "standard" or "blog_listing". |
| meta_description | string | SEO description. |
/hosted/sites/{site_id}/pages/{page_id}Update a page (title, slug, sections, SEO, status, nav_order, background). Only passed fields change.
/hosted/sites/{site_id}/pages/{page_id}Delete a page from a site.
Blog posts
/hosted/sites/{site_id}/postsList blog posts published to a site (id, title, slug, status).
/hosted/sites/{site_id}/postsPublish one of your articles to a site as a blog post.
| Parameter | Type | Description |
|---|---|---|
| article_id | integer | The article to publish. |
| slug | string | Custom post slug. |
| publish | boolean | false = draft. Default true. |
/hosted/sites/{site_id}/posts/{post_id}Update a post (slug, status live/draft, per-post SEO, noindex).
/hosted/sites/{site_id}/posts/{post_id}Unpublish / remove a blog post from a site.
Custom domains
/hosted/sites/{site_id}/domainsList custom domains connected to a site + their verification/SSL status.
/hosted/sites/{site_id}/domainsConnect a custom domain. Returns the DNS records to set.
| Parameter | Type | Description |
|---|---|---|
| hostname | string | e.g. "www.example.com". |
Webhooks (autopost)
Fire post.published / post.updated / post.unpublished as signed (HMAC-SHA256) JSON to your URL — fan out to Zapier / Make / n8n or your own endpoint. HTTPS only; each delivery carries X-D2L-Signature.
/hosted/sites/{site_id}/webhooksList a site's webhooks (the signing secret is shown only on create).
/hosted/sites/{site_id}/webhooksCreate a webhook. Returns the signing secret once.
| Parameter | Type | Description |
|---|---|---|
| name | string | Label. |
| url | string | Public HTTPS target (private/loopback rejected). |
| events | array | Subset of post.published, post.updated, post.unpublished. |
curl -X POST "https://draft2live.ai/api/v1/public/hosted/sites/24/webhooks" \
-H "X-API-Key: d2l_your_key" -H "Content-Type: application/json" \
-d '{"name":"zapier","url":"https://hooks.zapier.com/...","events":["post.published"]}'/hosted/sites/{site_id}/webhooks/{webhook_id}Delete a webhook.
/hosted/sites/{site_id}/webhooks/{webhook_id}/testSend a sample delivery now and return the result (throttled).
/hosted/sites/{site_id}/webhooks/{webhook_id}/logsRecent delivery attempts (event, status, error), newest first.
Images
/hosted/images/searchSearch real stock photos (Unsplash/Pexels) — returns ready image URLs to drop into sections.
curl "https://draft2live.ai/api/v1/public/hosted/images/search?query=coffee%20shop&count=6" \
-H "X-API-Key: d2l_your_key"/hosted/images/generateGenerate an original image with AI (needs the ai_image_generation plan feature + credits). Returns the hosted URL.
| Parameter | Type | Description |
|---|---|---|
| prompt | string | Image description (min 3 chars). |
| aspect_ratio | string | 1:1 | 16:9 | 9:16 | 4:3 | 3:4. |
| model | string | auto | flux-flex | flux-pro | gpt-image | gemini. |
MCP (Claude)
Connect a model (e.g. Claude in Claude Code) to build and manage your hosted sites in conversation — "list my sites", "create a site from the cafe template", "publish this article". The MCP tools wrap the SAME validated endpoints above, forwarding your API key, so the model goes through identical server-side checks and can't bypass anything.
Endpoint & auth
https://draft2live.ai/mcpStreamable HTTP. Authenticate with your d2l_ key in the connector header. Create a key in Account → API keys (needs a plan with API access). A read-only key exposes only the read tools.
Connect in Claude Code
claude mcp add --transport http draft2live https://draft2live.ai/mcp \
--header "Authorization: Bearer d2l_your_key"Or via .mcp.json
{
"mcpServers": {
"draft2live": {
"type": "http",
"url": "https://draft2live.ai/mcp",
"headers": { "Authorization": "Bearer d2l_your_key" }
}
}
}Tools
whoami, list_templates, list_sites, get_site, create_site, create_site_from_template, update_site, delete_site, list_pages, create_page, update_page, delete_page, list_posts, publish_post, update_post, unpublish_post, list_domains, add_domain, search_image, generate_image. A read-only key can call the list_* / get_* / whoami / search_image tools only.
Usage
Check your account credit balance and usage statistics.
/usage/creditsGet your current credit balance and usage for the current billing period.
Response
{
"data": {
"plan": "pro",
"credits_remaining": 847,
"credits_total": 1000,
"credits_used": 153,
"billing_period_start": "2026-04-01T00:00:00Z",
"billing_period_end": "2026-04-30T23:59:59Z",
"generations_this_period": 42
}
}Errors
The API uses standard HTTP status codes. Errors return a consistent JSON body with an error field.
{
"error": {
"code": "insufficient_credits",
"message": "You do not have enough credits to complete this request.",
"status": 402
}
}| Status | Code | Description |
|---|---|---|
| 401 | unauthorized | Invalid or missing API key |
| 402 | insufficient_credits | Not enough credits to complete the request |
| 403 | forbidden | Feature not available on your current plan |
| 404 | not_found | The requested resource does not exist |
| 422 | validation_error | Invalid request body or parameters |
| 500 | internal_error | An unexpected error occurred on our end |
Need help? Contact us at [email protected] or visit the dashboard.