# Content Generation

Operations for generating content and managing generation jobs

## Generate content using the enhanced wizard workflow

> Creates and processes a content generation job using the enhanced wizard workflow.\
> This endpoint is the primary content generation endpoint with comprehensive\
> parameter support, advanced validation, and integrated file processing.\
> \
> \*\*Authentication Methods Supported:\*\*\
> \- Session-based authentication (primary)\
> \- API Key authentication via x-api-key header\
> \
> \*\*Key Features:\*\*\
> \- Automatic file processing from uploaded project files\
> \- Advanced subscription and usage limit validation\
> \- Comprehensive error handling and status tracking\
> \- Support for multiple content generation modes\
> \- Integration with enhanced research capabilities\
> \
> \*\*Workflow Integration:\*\*\
> \- Processes uploaded project files automatically\
> \- Generates signed URLs for research integration\
> \- Handles questions/answers from project database\
> \- Supports both free trial and subscription users<br>

```json
{"openapi":"3.0.3","info":{"title":"DeepWriter API","version":"2.0.0"},"tags":[{"name":"Content Generation","description":"Operations for generating content and managing generation jobs"}],"servers":[{"url":"/api","description":"API base path"}],"security":[{"apiKey":[]},{"bearerAuth":[]}],"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key for external service authentication."},"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token for user session authentication."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string","description":"A message describing the error"}},"required":["error"]}}},"paths":{"/generateWizardWork":{"post":{"summary":"Generate content using the enhanced wizard workflow","description":"Creates and processes a content generation job using the enhanced wizard workflow.\nThis endpoint is the primary content generation endpoint with comprehensive\nparameter support, advanced validation, and integrated file processing.\n\n**Authentication Methods Supported:**\n- Session-based authentication (primary)\n- API Key authentication via x-api-key header\n\n**Key Features:**\n- Automatic file processing from uploaded project files\n- Advanced subscription and usage limit validation\n- Comprehensive error handling and status tracking\n- Support for multiple content generation modes\n- Integration with enhanced research capabilities\n\n**Workflow Integration:**\n- Processes uploaded project files automatically\n- Generates signed URLs for research integration\n- Handles questions/answers from project database\n- Supports both free trial and subscription users\n","tags":["Content Generation","Wizard"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["projectId","prompt","author","email"],"properties":{"projectId":{"type":"string","format":"uuid","description":"ID of the project to generate content for"},"prompt":{"type":"string","description":"Main generation prompt describing the content to create","minLength":10,"maxLength":10000},"author":{"type":"string","description":"Author name for the document","minLength":1,"maxLength":100},"email":{"type":"string","format":"email","description":"Author email address"},"outline_text":{"type":"string","description":"Additional outline instructions or structure guidance","maxLength":5000},"has_technical_diagrams":{"type":"string","enum":["auto","on","off"],"default":"auto","description":"Whether to include technical diagrams in the content"},"has_tableofcontents":{"type":"string","enum":["auto","on","off"],"default":"auto","description":"Whether to include table of contents"},"use_web_research":{"type":"string","enum":["auto","on","off"],"default":"auto","description":"Whether to use web research for content enhancement"},"page_length":{"type":"string","description":"Desired document length specification"},"questions_and_answers":{"type":"string","description":"JSON string of follow-up questions and answers for content refinement"},"urls_for_research":{"type":"string","description":"Comma-separated URLs for additional research sources.\nNote: Project files are automatically included as research sources.\n"},"mode":{"type":"string","enum":["deepwriter"],"default":"deepwriter","description":"Generation mode (only 'deepwriter' available for regular users)"},"isDefault":{"type":"boolean","description":"Whether to use default system configuration.\nNote: API key submission is no longer required as of v0.14.2\n","default":true}}}}}},"responses":{"200":{"description":"Job created and started successfully","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"jobId":{"type":"string","format":"uuid","description":"ID of the created job for tracking progress"}}}}}},"400":{"description":"Bad Request - Missing required fields or invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized - Invalid or missing authentication","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden - Insufficient subscription limits or no active subscription","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"errorCode":{"type":"string"},"pagesRemaining":{"type":"number"},"pagesLimit":{"type":"number"},"pagesUsed":{"type":"number"}}}}}},"404":{"description":"Not Found - Project not found or no active subscription","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict - Another job is already in progress for this project","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Format and enhance prompts

> Processes and formats user prompts using AI to improve clarity and effectiveness.\
> \
> If a \`projectId\` is provided, any files uploaded to that project will be included as signed URLs\
> in the research URLs passed to the AI. The endpoint also increments the user's prompt generation\
> usage if they have an active subscription.<br>

```json
{"openapi":"3.0.3","info":{"title":"DeepWriter API","version":"2.0.0"},"tags":[{"name":"Content Generation","description":"Operations for generating content and managing generation jobs"}],"servers":[{"url":"/api","description":"API base path"}],"security":[{"apiKey":[]},{"bearerAuth":[]}],"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key for external service authentication."},"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token for user session authentication."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string","description":"A message describing the error"}},"required":["error"]}}},"paths":{"/formatPrompt":{"post":{"summary":"Format and enhance prompts","description":"Processes and formats user prompts using AI to improve clarity and effectiveness.\n\nIf a `projectId` is provided, any files uploaded to that project will be included as signed URLs\nin the research URLs passed to the AI. The endpoint also increments the user's prompt generation\nusage if they have an active subscription.\n","tags":["Content Generation"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","description":"The user's original prompt to enhance"},"projectId":{"type":"string","format":"uuid","description":"Optional project ID. If provided, includes uploaded project files as research URLs."},"page_length":{"type":"string","default":"0","description":"Desired document length"},"use_technical_drawings":{"type":"string","enum":["auto","on","off"],"default":"auto","description":"Whether to include technical diagrams"},"use_web_search":{"type":"string","enum":["auto","on","off"],"default":"auto","description":"Whether to use web search"},"include_table_of_contents":{"type":"string","enum":["auto","on","off"],"default":"auto","description":"Whether to include table of contents"},"urls_for_research":{"oneOf":[{"type":"string","description":"Comma-separated URLs to use for research"},{"type":"array","items":{"type":"string"},"description":"Array of URLs to use for research"},{"type":"object","properties":{"urls":{"type":"array","items":{"type":"string"}}},"description":"Object with a 'urls' array property"}],"description":"URLs to use for research (string, array, or object)"},"max_pages":{"type":"string","default":"0","description":"Maximum pages allowed for generation"}}}}}},"responses":{"200":{"description":"Prompt formatted successfully","content":{"application/json":{"schema":{"type":"object","properties":{"enhanced_prompt":{"type":"string","description":"The AI-enhanced version of the prompt. Returns \"Invalid prompt. Please provide a different prompt.\" if content is moderated."},"questions":{"type":"array","items":{"type":"string"},"description":"Follow-up questions to refine the prompt"}}}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Download generated content as PDF

> Downloads the generated content for a completed job as a PDF file

```json
{"openapi":"3.0.3","info":{"title":"DeepWriter API","version":"2.0.0"},"tags":[{"name":"Content Generation","description":"Operations for generating content and managing generation jobs"}],"servers":[{"url":"/api","description":"API base path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token for user session authentication."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string","description":"A message describing the error"}},"required":["error"]}}},"paths":{"/downloadPdf/{jobId}":{"get":{"summary":"Download generated content as PDF","description":"Downloads the generated content for a completed job as a PDF file","tags":["Content Generation"],"parameters":[{"in":"path","name":"jobId","required":true,"schema":{"type":"string","format":"uuid"},"description":"ID of the completed job"}],"responses":{"200":{"description":"PDF file","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Job not found or not completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## Preview generated content as PDF

> Previews the generated content for a completed job as a PDF in the browser

```json
{"openapi":"3.0.3","info":{"title":"DeepWriter API","version":"2.0.0"},"tags":[{"name":"Content Generation","description":"Operations for generating content and managing generation jobs"}],"servers":[{"url":"/api","description":"API base path"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token for user session authentication."}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"string","description":"A message describing the error"}},"required":["error"]}}},"paths":{"/previewPdf/{jobId}":{"get":{"summary":"Preview generated content as PDF","description":"Previews the generated content for a completed job as a PDF in the browser","tags":["Content Generation"],"parameters":[{"in":"path","name":"jobId","required":true,"schema":{"type":"string","format":"uuid"},"description":"ID of the completed job"}],"responses":{"200":{"description":"PDF file for preview","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Job not found or not completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```
