Skip to main content
POST
/
generate
Generate Content
curl --request POST \
  --url https://api.example.com/generate \
  --header 'Content-Type: application/json' \
  --data '
{
  "topic": "<string>",
  "style": "<string>",
  "length": "<string>"
}
'
{
  "success": true,
  "result": {
    "result.contentId": "<string>",
    "result.title": "<string>",
    "result.scheduledFor": "<string>"
  },
  "error": "<string>"
}

Endpoint

POST /generate

Description

Manually triggers the full content generation pipeline, including strategy development, script writing, thumbnail design, SEO optimization, and production processing. The generated content is saved to the database and scheduled for publishing.

Request Body

topic
string
The topic for the video content. If not provided, the Content Strategy Agent will automatically select a trending topic based on analytics and research.
style
string
The style or format for the video. Options depend on your channel configuration.Examples: "tutorial", "vlog", "review", "educational"
length
string
default:"medium"
Target length for the video content.Common values:
  • "short" - Short-form content (< 60 seconds)
  • "medium" - Standard content (5-15 minutes)
  • "long" - Long-form content (15+ minutes)

Response

success
boolean
required
Indicates whether content generation succeeded.
result
object
Contains the generated content details.
result.contentId
string
required
Unique identifier for the generated content. Use this ID with the /publish/:contentId endpoint.
result.title
string
required
The generated video title.
result.scheduledFor
string
required
ISO 8601 timestamp when the content is scheduled for automatic publishing.
error
string
Error message if success is false.

Example Requests

curl -X POST http://localhost:3456/generate \
  -H "Content-Type: application/json" \
  -d '{}'

Example Response

Success

{
  "success": true,
  "result": {
    "contentId": "content_1234567890abcdef",
    "title": "Master React Hooks in 10 Minutes - Complete Guide for Beginners",
    "scheduledFor": "2026-03-06T14:00:00.000Z"
  }
}

Error

{
  "success": false,
  "error": "Failed to generate script: API quota exceeded"
}

Response Codes

Status CodeDescription
200Content generation successful
500Server error during content generation

Generation Pipeline

The /generate endpoint executes the following steps:
  1. Content Strategy - Analyzes trends and generates content strategy
  2. Script Writing - Creates the video script based on the strategy
  3. Thumbnail Design - Generates an eye-catching thumbnail
  4. SEO Optimization - Optimizes title, description, tags, and metadata
  5. Production Processing - Processes all content for publishing
  6. Database Save - Stores the content and schedules automatic publishing
Content generation can take 30-90 seconds depending on the complexity and AI model response times. Consider implementing a timeout of at least 120 seconds for this endpoint.

Use Cases

Manual Content Creation

Generate content on-demand outside the automated schedule:
curl -X POST http://localhost:3456/generate \
  -H "Content-Type: application/json" \
  -d '{"topic": "Breaking News: Latest Tech Updates"}'

Batch Content Generation

Generate multiple pieces of content programmatically:
const topics = [
  'Introduction to Machine Learning',
  'Web Development Best Practices',
  'Cloud Computing Basics'
];

for (const topic of topics) {
  const response = await fetch('http://localhost:3456/generate', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ topic, length: 'medium' })
  });
  
  const result = await response.json();
  console.log(`Generated: ${result.result.title}`);
}

Error Handling

Common errors and their causes:
Error MessageCauseSolution
API quota exceededExternal API limits reachedWait for quota reset or upgrade API plan
Invalid credentialsYouTube API credentials missingRun npm run credentials:setup
Database errorDatabase connection failedCheck database configuration
Agent not initializedSystem still starting upWait for initialization to complete