What you’ll accomplish
By the end of this guide, you’ll have:- ✅ Secure API integration setup
- ✅ Complete create → poll → download workflow
- ✅ Robust error handling
- ✅ Production-ready patterns
Before you start
Prerequisites:- API key from Developer Hub
- Your preferred SDK installed or direct HTTP client ready
Integration overview
Magic Hour APIs follow a simple 3-step pattern:- Create - Submit your job (image/video generation)
- Poll or webhook - Check status
- Download - Retrieve your generated content
Complete integration example
Here’s a full end-to-end example that demonstrates the complete workflow:This example uses the
create function to better demonstrate the full workflow. You can also use
the generate function in Python and Node SDKs if you want a simpler workflow.Working with input files
Magic Hour accepts input files in two ways:Option 1: URL references (Recommended)
The simplest approach is to pass file URLs:- Images: PNG, JPG, JPEG, WEBP, AVIF
- Videos: MP4, MOV, WEBM
- Audio: MP3, WAV, AAC, FLAC
Option 2: Upload to Magic Hour
For secure or temporary files, upload directly to Magic Hour storage:Input Files Guide
Complete guide to file uploads, formats, and storage options
Understanding job status
Every job goes through these states:| Status | Description | Action Required |
|---|---|---|
queued | Job is waiting for available server | ⏳ Keep polling |
rendering | Job is being processed | ⏳ Keep polling |
complete | Job finished successfully | ✅ Download result |
error | Job failed during processing | ❌ Handle error |
canceled | Job was manually canceled | 🛑 Job stopped |
- Images: Check every 2-3 seconds (usually complete within 30-60 seconds)
- Videos: Check every 5-10 seconds (can take 2-5 minutes depending on length)
Error handling
When a job fails (status: "error"), the response includes detailed error information:
Error handling example
For
unknown_error codes, contact support@magichour.ai with your
project ID for investigation.Status monitoring strategies
Choose the right approach based on your application’s needs:Option 1: Webhooks (Recommended for production)
Get real-time notifications when jobs complete. Best for:- ✅ Production applications
- ✅ Video processing (longer render times)
- ✅ Multiple concurrent jobs
- ✅ Better server resource usage
Webhook Setup Guide
Complete webhook implementation guide with examples
Option 2: Polling (Good for simple use cases)
Periodically check job status. Best for:- ✅ Simple integrations
- ✅ Single job processing
- ✅ Image generation (quick results)
Downloading results
When a job completes, thedownloads array is populated with secure, time-limited URLs:
Download outputs
Multiple outputs handling
Some tools generate multiple files (e.g., multiple images):File management
Cleaning up storage
Generated files are stored indefinitely. Clean up completed jobs to manage storage:Development and testing
Free testing with mock server
Avoid credit charges during development by using the mock API server:The mock server returns realistic sample data without processing jobs or charging credits.
Job cancellation
Cancel video jobs (with full refund) via the web dashboard:1
Open video details
Visit:
https://magichour.ai/my-library?videoId={project_id}2
Click cancel render

3
Confirm cancellation

4
Cancellation complete

- Image jobs cannot be cancelled (they complete too quickly)
- API-based cancellation is not currently available
- Full credit refund is provided for cancelled video jobs
Next steps
Webhook Integration
Set up real-time notifications for production apps
API Reference
Explore all available endpoints and parameters
File Management
Advanced file upload and management techniques
Need help? Join our Discord community or email support@magichour.ai