API Documentation

Complete guide to integrating with the Animagent.ai Story Animation API

Version: 1.0.0
Base URL: https://app.sumatman.ai/api
Last Updated: January 2025

Table of Contents

Getting Started

Welcome to the Animagent.ai Story Animation API. This API allows you to programmatically create animated videos from text stories using advanced AI models.

To get started, you'll need to obtain an API key from your developer dashboard. Once you have your API key, you can begin making requests to create, manage, and retrieve your animation tasks.

The API supports multiple programming languages and provides both snake_case and camelCase parameter formats for maximum compatibility.

Obtain Your API Key

Follow these steps to get your API key:

1. Sign up at https://app.sumatman.ai
2. Navigate to the Developer section at https://app.sumatman.ai/developer
3. Generate your API key
4. Keep your API key secure and never share it publicly

Important Notes

  • All API requests require authentication via API key
  • The API currently supports one main endpoint: /api/task
  • Task status and management should be done through the web interface
  • Credits are automatically deducted when tasks are created

Authentication

Every API request must include your API key for authentication. The API supports three different methods for providing your API key, allowing you to choose the one that best fits your implementation.

Method 1: Bearer Token (Recommended)

Authorization: Bearer YOUR_API_KEY

Method 2: X-API-Key Header

X-API-Key: YOUR_API_KEY

Method 3: Request Body

{
  "api_key": "YOUR_API_KEY",
  ...other parameters
}

Example Request with Authentication

curl -X POST https://app.sumatman.ai/api/task \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "story_type": "fairytale_story",
    "input_story": "A magical garden story"
  }'

Task Creation API

The main endpoint for creating animation tasks. This powerful endpoint supports four different modes of operation: create, repeat, edit, and continue.

Endpoint: POST /api/task

The API supports both snake_case and camelCase parameter formats for maximum compatibility. You can use whichever format you prefer.

Create Mode - Full Example

{
  "mode": "create",
  "story_type": "fairytale_story",
  "input_story": "Your story prompt or content here",
  "voice_language": "english",
  "illustration_style": "Japanese Ghibli-inspired Style - Studio Ghibli animation style with soft colors, detailed backgrounds, whimsical characters, and dreamlike atmosphere",
  "video_duration": 10,
  "dimension_type": "landscape",
  "narrator_name": "optional_narrator_name",
  "narrator_voice_id": "optional_voice_id",
  "audience_age": "Children",
  "audience_gender": "All",
  "audience_location": "Global",
  "temperature": 0.7,
  "search_keywords": "magic, adventure, friendship",
  "watermark_enabled": false,
  "use_fixed_character": false,
  "character_name": null,
  "enable_subtitle": true,
  "enable_zoom_effect": true,
  "enable_chapter_transitions": true,
  "copy_to_email": "user@example.com",
  "triggered_by": "api_call"
}

Alternative Structure (Wrapped in taskData)

{
  "taskData": {
    "story_type": "fairytale_story",
    "input_story": "Your story here",
    "voice_language": "english",
    "dimension_type": "landscape"
  }
}

Parameters

ParameterTypeRequiredDescription
modestringOptionalOperation mode: create, repeat, edit, or continue (default: create)
story_typestringRequiredType of story to generate (see Reference Data)
input_storystringRequiredThe story prompt or content (minimum 10 characters)
voice_languagestringRequiredLanguage for narration: english or chinese
dimension_typestringRequiredVideo orientation: landscape or portrait
illustration_stylestringOptionalFull name of illustration style (see Reference Data)
video_durationnumberOptionalLength in minutes (3-30, default: 10)
narrator_namestringOptionalOptional narrator name
narrator_voice_idstringOptionalOptional specific voice ID
audience_agestringOptionalTarget audience age group
audience_genderstringOptionalTarget audience gender
audience_locationstringOptionalTarget audience location
temperaturenumberOptionalAI creativity level (0.0-1.0, default: 0.7)
search_keywordsstringOptionalKeywords for SEO and discovery
watermark_enabledbooleanOptionalEnable watermark on video (default: false)
use_fixed_characterbooleanOptionalUse consistent character throughout (default: false)
character_namestringOptionalName of fixed character if enabled
enable_subtitlebooleanOptionalAdd subtitles to video (default: true)
enable_zoom_effectbooleanOptionalAdd zoom effects (default: true)
enable_chapter_transitionsbooleanOptionalAdd chapter transitions (default: true)
copy_to_emailstringOptionalEmail to send completion notification
triggered_bystringOptionalSource of request (default: api_call)

Task Modes

The Task Creation API supports four different modes of operation, each designed for specific use cases.

Repeat Mode

Create a new version of an existing task with regenerated content

{
  "mode": "repeat",
  "task_id": "web_1755877911087_ewf2efddz",
  "triggered_by": "api_call"
}

Edit Mode

Modify a pending or processing task

{
  "mode": "edit",
  "task_id": "web_1755877911087_ewf2efddz",
  "story_type": "educational_story",
  "input_story": "Updated story content",
  "video_duration": 15,
  "triggered_by": "api_call"
}

Continue Mode

Create a continuation or sequel of a completed task

{
  "mode": "continue",
  "task_id": "web_1755877911087_ewf2efddz",
  "input_story": "Additional prompt for the continuation",
  "triggered_by": "api_call"
}

Alternative Structure with sourceTaskId

You can also use sourceTaskId instead of task_id

{
  "sourceTaskId": "web_1755877911087_ewf2efddz",
  "taskData": {
    "mode": "repeat",
    "triggered_by": "api_call"
  }
}

Important Notes

  • Repeat mode: All parameters from the original task are inherited
  • Edit mode: Cannot edit completed tasks
  • Continue mode: Source task must be completed
  • All modes support parameter overrides

Task List API

Retrieve a list of tasks for a specific user.

Endpoint: GET /api/user/:userId/tasks

Get All Tasks

curl -X GET "https://app.sumatman.ai/api/user/YOUR_USER_ID/tasks" \
  -H "Authorization: Bearer YOUR_API_KEY"

Get Completed Tasks with Pagination

curl -X GET "https://app.sumatman.ai/api/user/YOUR_USER_ID/tasks?status=completed&limit=20&offset=20" \
  -H "Authorization: Bearer YOUR_API_KEY"

Parameters

ParameterTypeRequiredDescription
limitnumberOptionalNumber of tasks to return (default: 100, max: 100)
offsetnumberOptionalNumber of tasks to skip for pagination (default: 0)
statusstringOptionalFilter by status: pending, processing, completed, or failed

Response Example

{
  "success": true,
  "data": {
    "tasks": [
      {
        "id": 123,
        "task_id": "web_1755877911087_ewf2efddz",
        "user_id": "your-user-id",
        "user_email": "user@example.com",
        "process_status": "completed",
        "story_type": "fairytale_story",
        "input_story": "A brave knight saves a magical kingdom",
        "video_length_minutes": 10,
        "dimension_type": "landscape",
        "voice_language": "english",
        "youtube_video_title": "The Brave Knight's Adventure",
        "youtube_video_id": "abc123",
        "youtube_video_description": "An epic tale of courage and magic...",
        "youtube_video_hashtags": "#fairytale #knight #adventure",
        "final_video_url": "https://api.sumatman.ai/videos/web_1755877911087_ewf2efddz.mp4",
        "final_image_url": "https://api.sumatman.ai/thumbnails/web_1755877911087_ewf2efddz.jpg",
        "final_share_url": "https://app.sumatman.ai/share/web_1755877911087_ewf2efddz",
        "task_created_at": "2025-08-23T10:30:00.000Z",
        "task_updated_at": "2025-08-23T10:45:00.000Z",
        "task_completed_at": "2025-08-23T10:45:00.000Z",
        "mode": "create",
        "from_task_id": null
      }
    ],
    "total": 50,
    "limit": 100,
    "offset": 0
  }
}

Task Status API

Get detailed status and information for a specific task.

Endpoint: GET /api/task/:taskId/status

Get Task Status

curl -X GET "https://app.sumatman.ai/api/task/web_1755877911087_ewf2efddz/status" \
  -H "Authorization: Bearer YOUR_API_KEY"

Parameters

ParameterTypeRequiredDescription
userIdstringOptionalUser ID for security verification

Important Notes

  • Returns the complete task object with all fields
  • Includes download URLs when task is completed
  • Use this to poll for task completion

Task Deletion API

Delete a task that you own. Only tasks with status 'pending' or 'failed' can be deleted.

Endpoint: DELETE /api/task/:taskId

Delete a Task

curl -X DELETE https://app.sumatman.ai/api/task/web_1755877911087_ewf2efddz \
  -H "Authorization: Bearer YOUR_API_KEY"

Response Example

{
  "success": true,
  "message": "Task deleted successfully",
  "deletedTask": {
    "task_id": "web_1755877911087_ewf2efddz",
    "user_id": "your-user-id"
  }
}

Important Notes

  • You can only delete tasks that you own
  • Tasks can only be deleted if their status is 'pending' or 'failed'
  • Tasks with status 'processing' or 'completed' cannot be deleted
  • Deleting a task does not refund credits

Response Format

All API responses follow a consistent format for easy parsing and error handling.

Success Response

{
  "success": true,
  "data": {
    "taskId": "web_1755877911087_ewf2efddz",
    "creditCost": 50,
    "sceneCount": 25,
    "mode": "create",
    "status": "pending",
    "createdAt": "2025-08-23T10:30:00.000Z"
  }
}

Parameters

ParameterTypeRequiredDescription
taskIdstringRequiredUnique identifier for the created task
creditCostnumberRequiredNumber of credits deducted for this task
sceneCountnumberRequiredNumber of scenes that will be generated
modestringRequiredThe mode used (create/repeat/edit/continue)
statusstringRequiredCurrent task status
createdAtstringRequiredTask creation timestamp

Error Handling

The API uses standard HTTP status codes and provides detailed error messages to help you handle errors gracefully.

Error Response Format

{
  "success": false,
  "error": "Detailed error message"
}

Invalid API Key

{
  "success": false,
  "error": "Invalid or inactive API key"
}

Missing Required Fields

{
  "success": false,
  "error": "Missing required fields: story_type and input_story"
}

Task Not Found

{
  "success": false,
  "error": "Source task not found or you do not have permission to access it"
}

Cannot Delete Processing Task

{
  "success": false,
  "error": "Cannot delete task with status 'processing'. Only tasks with status 'pending' or 'failed' can be deleted"
}

HTTP Status Codes

Status CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Access denied
404Not Found - Resource not found
500Internal Server Error

Reference Data

Complete reference for all valid values and options supported by the API.

Story Types

ValueLabelDescription
fairytale_storyπŸ§šβ€β™€οΈ Fairytale StoryMagical tales with wonder and moral lessons
adventure_storyπŸ—ΊοΈ Adventure StoryExciting journeys and heroic quests
educational_storyπŸ“š Educational StoryLearning through engaging narratives
cinematic_story🎬 Cinematic StoryDramatic, movie-like storytelling
sci_fi_storyπŸš€ Sci-Fi StoryFuturistic tales of technology and space
historical_storyπŸ›οΈ Historical StoryStories from different time periods
romantic_storyπŸ’• Romantic StoryTales of love and relationships
comics_storyπŸ’₯ Comics StorySuperhero and comic book adventures
bible_story✝️ Bible StoryReligious and spiritual narratives
book_storyπŸ“– Book StoryClassic literature adaptations
lyric_story🎡 Lyric StoryMusical and poetic narratives
poetry_storyπŸ“ Poetry StoryTransform poems into visual stories
fantasy_storyπŸ‰ Fantasy StoryEpic tales of magic and mythical creatures
dream_storyπŸ’­ Dream StorySurreal and imaginative dream narratives

Voice Languages

ValueDescription
englishEnglish narration (default)
chineseChinese (Mandarin) narration

Dimension Types

ValueResolutionAspect Ratio
landscape1024x576 pixels16:9 ratio
portrait576x1024 pixels9:16 ratio

Video Duration & Pricing

DurationStory LengthScene CountCredit Cost
3 minutes2000 chars10 scenes10 credits
5 minutes3000 chars15 scenes30 credits
10 minutes5000 chars25 scenes50 credits
15 minutes7000 chars32 scenes64 credits
20 minutes9000 chars40 scenes80 credits
25 minutes11000 chars47 scenes94 credits
30 minutes13000 chars55 scenes110 credits

Illustration Styles

Style NameDescription
Japanese Ghibli-inspired StyleStudio Ghibli animation style with soft colors, detailed backgrounds, whimsical characters, and dreamlike atmosphere
Cinematic LightingProfessional movie-quality lighting with dramatic shadows, volumetric light rays, and high contrast cinematography
Digital PaintingModern digital art with smooth brush strokes, rich colors, detailed textures, and professional illustration quality
WatercolorTraditional watercolor painting with flowing colors, soft edges, transparent layers, and organic paper texture
3D RenderingPhotorealistic 3D computer graphics with realistic materials, lighting, shadows, and high-quality textures
Comic Book StyleBold comic book illustration with strong outlines, vibrant colors, dynamic poses, and pop art aesthetics
Chinese Ink PaintingTraditional Chinese brush painting with flowing ink, minimalist composition, and elegant calligraphic strokes
PhotorealisticUltra-realistic photography style with sharp details, natural lighting, and lifelike textures and materials
Anime StyleJapanese anime and manga illustration with large expressive eyes, stylized features, and vibrant anime colors
Oil PaintingClassical oil painting technique with rich textures, layered brushstrokes, and traditional fine art composition

Code Examples

Complete code examples in multiple programming languages to help you get started quickly.

Python - Complete Example

import requests
import json

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://app.sumatman.ai/api"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# Create a new task (snake_case format - recommended)
task_data = {
    "story_type": "fairytale_story",
    "input_story": "A brave knight saves a magical kingdom",
    "voice_language": "english",
    "video_duration": 10,
    "dimension_type": "landscape",
    "triggered_by": "api_call"
}

response = requests.post(f"{BASE_URL}/task", 
                         headers=headers, 
                         json=task_data)

if response.status_code == 200:
    result = response.json()
    task_id = result["data"]["taskId"]
    print(f"Task created: {task_id}")
    print(f"Credits used: {result['data']['creditCost']}")
else:
    print(f"Error: {response.json()}")

# Repeat an existing task
repeat_data = {
    "mode": "repeat",
    "task_id": task_id,
    "triggered_by": "api_call"
}

repeat_response = requests.post(f"{BASE_URL}/task",
                                headers=headers,
                                json=repeat_data)

# Alternative: Using camelCase (also supported)
task_data_camel = {
    "storyType": "fairytale_story",
    "inputStory": "A brave knight saves a magical kingdom",
    "voiceLanguage": "english",
    "videoDuration": 10,
    "dimensionType": "landscape",
    "triggeredBy": "api_call"
}

# This also works
response = requests.post(f"{BASE_URL}/task",
                         headers=headers,
                         json=task_data_camel)

JavaScript/Node.js - Complete Example

const axios = require('axios');

const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'https://app.sumatman.ai/api';

async function createTask() {
  try {
    // Create a new task
    const response = await axios.post(`${BASE_URL}/task`, {
      story_type: 'fairytale_story',
      input_story: 'A brave knight saves a magical kingdom',
      voice_language: 'english',
      video_duration: 10,
      dimension_type: 'landscape',
      triggered_by: 'api_call'
    }, {
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json'
      }
    });
    
    const taskId = response.data.data.taskId;
    console.log(`Task created: ${taskId}`);
    console.log(`Credits used: ${response.data.data.creditCost}`);
    
    return taskId;
  } catch (error) {
    console.error('Error:', error.response.data);
  }
}

async function continueTask(taskId) {
  try {
    // Continue an existing task
    const response = await axios.post(`${BASE_URL}/task`, {
      mode: 'continue',
      task_id: taskId,
      input_story: 'The knight discovers a hidden treasure',
      triggered_by: 'api_call'
    }, {
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json'
      }
    });
    
    console.log(`Continuation created: ${response.data.data.taskId}`);
  } catch (error) {
    console.error('Error:', error.response.data);
  }
}

// Run the examples
createTask().then(taskId => {
  if (taskId) {
    // Wait for task to complete before continuing
    // Note: You need to check task status through the web interface
    // continueTask(taskId);
  }
});

cURL - Complete Examples

# Create a new task
curl -X POST https://app.sumatman.ai/api/task \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "story_type": "fairytale_story",
    "input_story": "A brave knight saves a magical kingdom",
    "voice_language": "english",
    "video_duration": 10,
    "dimension_type": "landscape",
    "triggered_by": "api_call"
  }'

# Repeat an existing task
curl -X POST https://app.sumatman.ai/api/task \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "repeat",
    "task_id": "web_1755877911087_ewf2efddz",
    "triggered_by": "api_call"
  }'

# Edit a pending task
curl -X POST https://app.sumatman.ai/api/task \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "edit",
    "task_id": "web_1755877911087_ewf2efddz",
    "video_duration": 15,
    "triggered_by": "api_call"
  }'

# Continue a completed task
curl -X POST https://app.sumatman.ai/api/task \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "continue",
    "task_id": "web_1755877911087_ewf2efddz",
    "input_story": "The adventure continues in a new land",
    "triggered_by": "api_call"
  }'

Important Notes

Key information and best practices for using the Sumatman AI Animation API effectively.

Important Notes

  • Parameter Formats: Both snake_case (story_type) and camelCase (storyType) are supported
  • Required Fields: story_type and input_story (minimum 10 characters) are always required
  • Default Values: voice_language defaults to 'english', dimension_type to 'landscape', video_duration to 10 minutes
  • Task Management: Use the web interface at https://app.sumatman.ai for real-time status, downloads, and logs
  • Processing Time: Tasks typically take 5-15 minutes depending on video duration
  • API Key Security: Never share your API key publicly or commit it to version control
  • Credits System: Credits are deducted immediately upon task creation, refunded for failed tasks
  • Rate Limits: Maximum 10 requests per minute per API key, 100 tasks per day per account
  • Support: API Technical Support at support@sumatman.ai
  • Documentation Updates: Check this documentation regularly for updates