When you submit a video generation task to the Runway API, you can use the callBackUrl parameter to set a callback URL. The system will automatically push the results to your specified address when the task is completed.

Callback Mechanism Overview

The callback mechanism eliminates the need to poll the API for task status. The system will proactively push task completion results to your server.

Callback Timing

The system will send callback notifications in the following situations:
  • AI video generation task completed successfully
  • AI video generation task failed
  • Errors occurred during task processing

Callback Method

  • HTTP Method: POST
  • Content Type: application/json
  • Timeout Setting: 15 seconds
  • Retry Mechanism: Retry 3 times after failure, with intervals of 1 minute, 5 minutes, and 15 minutes respectively

Callback Request Format

When the task is completed, the system will send a POST request to your callBackUrl in the following format:
{
  "code": 200,
  "msg": "All generated successfully.",
  "data": {
    "task_id": "ee603959-debb-48d1-98c4-a6d1c717eba6",
    "video_id": "485da89c-7fca-4340-8c04-101025b2ae71",
    "video_url": "https://file.com/k/xxxxxxx.mp4",
    "image_url": "https://file.com/m/xxxxxxxx.png"
  }
}

Status Code Description

code
integer
required
Callback status code indicating task processing result:
Status CodeDescription
200Success - Video generation completed successfully
400Client Error - Inappropriate content, format error, quota limit, or other client-side issues
500Server Error - Internal server error during video generation
msg
string
required
Status message providing detailed status description. Common error messages include:
  • “Inappropriate content detected. Please replace the image or video.”
  • “Incorrect image format.”
  • “Please try again later. You can upgrade to Standard membership to start generating now.”
  • “Reached the limit for concurrent generations.”
  • “Unsupported width or height. Please adjust the size and try again.”
  • “Your prompt was caught by our AI moderator. Please adjust it and try again!”
data.task_id
string
required
Task ID, consistent with the taskId returned when you submitted the task
data.video_id
string
required
Generated video ID for identification and tracking
data.video_url
string
required
Accessible video URL, valid for 14 days. Empty on failure.
data.image_url
string
required
Cover image URL of the generated video. Empty on failure.

Callback Reception Examples

Here are example codes for receiving callbacks in popular programming languages:
const express = require('express');
const fs = require('fs');
const https = require('https');
const path = require('path');
const app = express();

app.use(express.json());

app.post('/runway-video-callback', (req, res) => {
  const { code, msg, data } = req.body;
  
  console.log('Received Runway video generation callback:', {
    taskId: data.task_id,
    videoId: data.video_id,
    status: code,
    message: msg
  });
  
  if (code === 200) {
    // Task completed successfully
    console.log('Runway video generation completed successfully');
    
    const { task_id, video_id, video_url, image_url } = data;
    
    console.log(`Video URL: ${video_url}`);
    console.log(`Cover Image URL: ${image_url}`);
    console.log('Note: Video URL is valid for 14 days');
    
    // Download video file
    if (video_url) {
      downloadFile(video_url, `runway_video_${task_id}.mp4`)
        .then(() => console.log('Video downloaded successfully'))
        .catch(err => console.error('Video download failed:', err));
    }
    
    // Download cover image
    if (image_url) {
      downloadFile(image_url, `runway_cover_${task_id}.png`)
        .then(() => console.log('Cover image downloaded successfully'))
        .catch(err => console.error('Cover image download failed:', err));
    }
    
  } else {
    // Task failed
    console.log('Runway video generation failed:', msg);
    
    // Handle specific error types
    if (code === 400) {
      console.log('Client error - check content, format, or quota');
    } else if (code === 500) {
      console.log('Server error - retry may be needed');
    }
  }
  
  // Return 200 status code to confirm callback received
  res.status(200).json({ status: 'received' });
});

// Helper function to download files
function downloadFile(url, filename) {
  return new Promise((resolve, reject) => {
    const file = fs.createWriteStream(filename);
    
    https.get(url, (response) => {
      if (response.statusCode === 200) {
        response.pipe(file);
        file.on('finish', () => {
          file.close();
          resolve();
        });
      } else {
        reject(new Error(`HTTP ${response.statusCode}`));
      }
    }).on('error', reject);
  });
}

app.listen(3000, () => {
  console.log('Callback server running on port 3000');
});

Best Practices

Callback URL Configuration Recommendations

  1. Use HTTPS: Ensure your callback URL uses HTTPS protocol for secure data transmission
  2. Verify Source: Verify the legitimacy of the request source in callback processing
  3. Idempotent Processing: The same task_id may receive multiple callbacks, ensure processing logic is idempotent
  4. Quick Response: Callback processing should return a 200 status code as quickly as possible to avoid timeout
  5. Asynchronous Processing: Complex business logic should be processed asynchronously to avoid blocking callback response
  6. Immediate Download: Video URLs are valid for only 14 days, download and save files immediately upon success

Important Reminders

  • Callback URL must be a publicly accessible address
  • Server must respond within 15 seconds, otherwise it will be considered a timeout
  • If 3 consecutive retries fail, the system will stop sending callbacks
  • Video URLs expire after 14 days - download immediately upon receiving callback
  • Please ensure the stability of callback processing logic to avoid callback failures due to exceptions
  • Handle both video_url and image_url fields for complete media management
  • Pay attention to error messages for specific failure reasons (content moderation, format issues, quotas)

Troubleshooting

If you do not receive callback notifications, please check the following:

Alternative Solution

If you cannot use the callback mechanism, you can also use polling:

Poll Query Results

Use the get AI video details endpoint to regularly query task status. We recommend querying every 30 seconds.