Blog Publishing API

REST API for automated blog post management. Accepts JSON, commits markdown files to the GitHub repo, and Vercel auto-deploys.

Authentication

All endpoints require a Bearer token in the Authorization header:

Authorization: Bearer YOUR_API_SECRET_KEY

Environment Variables

VariableDescription
GITHUB_TOKENFine-grained GitHub PAT with Contents: read/write scoped to this repo
GITHUB_REPO_OWNERGitHub org or username (e.g. youai1)
GITHUB_REPO_NAMERepository name
API_SECRET_KEYRandom 32+ char string for Bearer token auth

Endpoints

POST /api/blog — Create a blog post

Creates a new markdown file at src/content/blog/{slug}.md and commits it to main.

Request:

{
  "slug": "ai-agent-automation-guide",
  "title": "The Complete Guide to AI Agent Automation",
  "description": "Learn how to build AI agents that automate complex workflows covering tools, platforms, and best practices.",
  "publishDate": "2026-02-27",
  "content": "## Introduction\n\nAI agents are transforming...",
  "author": "MindStudio Team",
  "image": "https://i.mscdn.ai/blog-images/ai-agent-automation-guide.png?fm=auto&w=1200&fit=cover",
  "tags": ["AI Agents", "Automation"],
  "draft": false
}

Response (201):

{
  "success": true,
  "slug": "ai-agent-automation-guide",
  "url": "https://www.mindstudio.ai/blog/ai-agent-automation-guide",
  "commitSha": "abc123..."
}

PUT /api/blog/{slug} — Update a blog post

Updates an existing post. Only include the fields you want to change — everything else is preserved.

Request:

{
  "title": "Updated Title",
  "content": "## Updated content..."
}

Response (200):

{
  "success": true,
  "slug": "ai-agent-automation-guide",
  "url": "https://www.mindstudio.ai/blog/ai-agent-automation-guide",
  "commitSha": "def456..."
}

DELETE /api/blog/{slug} — Delete a blog post

Removes the markdown file from the repo.

Response (200):

{
  "success": true,
  "slug": "ai-agent-automation-guide",
  "deleted": true,
  "commitSha": "ghi789..."
}

Field Reference

FieldRequired (POST)TypeNotes
slugYesstringLowercase, letters/numbers/hyphens only. Becomes the URL path.
titleYesstringBlog post title
descriptionYesstring120-160 characters (SEO meta description)
publishDateYesstringYYYY-MM-DD format
contentYesstringMarkdown body content
authorNostringDefaults to "MindStudio Team"
imageNostringMust be a https://i.mscdn.ai/ CDN URL
tagsNostring[]Defaults to []
draftNobooleanDefaults to false. Draft posts are excluded from the blog listing.

Error Responses

StatusMeaning
400Validation failed — check details array for specific field errors
401Missing Authorization header
403Invalid API key
404Blog post not found (PUT/DELETE)
409Slug already exists (POST)
500GitHub API failure

Error body format:

{
  "error": "Validation failed",
  "details": [
    { "field": "description", "message": "Must be 120-160 characters for SEO (got 45)." }
  ]
}

How It Works

  1. Your agent sends a request to the API endpoint
  2. The API validates the input and generates a markdown file with proper frontmatter
  3. The file is committed to src/content/blog/{slug}.md on main via the GitHub API
  4. Vercel detects the commit and triggers a rebuild (~2-3 minutes)
  5. The new post appears at https://www.mindstudio.ai/blog/{slug}

Example (curl)

curl -X POST https://www.mindstudio.ai/api/blog \
  -H "Authorization: Bearer YOUR_API_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "test-post",
    "title": "Test Post",
    "description": "This is a test blog post created via the publishing API to verify the endpoint works correctly and all is well.",
    "publishDate": "2026-02-27",
    "content": "## Hello\n\nThis is a test post.",
    "tags": ["Test"]
  }'