> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hooked.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Extend Video

> Extend videos using AI to continue and extend your content seamlessly

<Note>
  **Try it out!** Use the API playground on the right to test the Extend Video endpoint directly.
</Note>

## Overview

Extend Video uses AI (Veo 3.1) to intelligently continue and extend your videos. Perfect for:

* Creating longer content from short clips
* Generating smooth video continuations
* Extending storytelling sequences
* Producing extended versions of marketing videos
* Automating video length optimization

<Info>
  Extensions are generated in segments of 4-8 seconds each. The AI analyzes the last frame of your video and generates a seamless continuation based on your prompt.
</Info>

***

## Endpoint

```
POST /v1/project/create/extend-video
```

***

## Required Fields

<ParamField body="media" type="string" required>
  Media ID of the video to extend (as a string)
</ParamField>

<ParamField body="prompt" type="string" required>
  Describe how the AI should continue the video (1-2000 characters)

  Example: "The camera continues to zoom out, revealing a cityscape at sunset with birds flying across the sky"
</ParamField>

***

## Optional Fields

<ParamField body="name" type="string">
  Custom name for the project (max 100 characters)
</ParamField>

<ParamField body="targetDuration" type="number" default={4}>
  Total duration to extend in seconds (4-60 seconds, must be multiple of 4)

  * Minimum: 4 seconds
  * Maximum: 60 seconds
  * Default: 4 seconds
</ParamField>

<ParamField body="generateAudio" type="boolean" default={true}>
  Whether to generate audio for the extended portion
</ParamField>

<ParamField body="webhook" type="string">
  Webhook URL for status notifications (max 500 characters, must be HTTPS)
</ParamField>

<ParamField body="metadata" type="object">
  Custom metadata object (max 5KB JSON)
</ParamField>

***

## Request Examples

### Basic Video Extension

```javascript theme={null}
const response = await fetch('https://api.hooked.so/v1/project/create/extend-video', {
  method: 'POST',
  headers: {
    'x-api-key': process.env.HOOKED_API_KEY,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    media: 'media_video123',
    prompt: 'The camera slowly zooms out revealing a beautiful sunset over the ocean',
    targetDuration: 8,
    generateAudio: true
  })
});

const data = await response.json();
console.log('Video ID:', data.data.videoId);
console.log('Project ID:', data.data.projectId);
```

### Extended Duration with Webhook

```javascript theme={null}
const extendVideoLonger = async () => {
  const response = await fetch('https://api.hooked.so/v1/project/create/extend-video', {
    method: 'POST',
    headers: {
      'x-api-key': process.env.HOOKED_API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      media: 'media_marketing_clip',
      prompt: 'The product rotates smoothly as the background transitions from blue to purple with subtle particle effects',
      targetDuration: 16, // 16 seconds extension
      generateAudio: true,
      webhook: 'https://yoursite.com/webhook',
      metadata: {
        campaignId: 'product-launch-2024',
        videoType: 'marketing'
      }
    })
  });

  return await response.json();
};
```

### Multiple Extensions

```javascript theme={null}
const extendVideoMultiple = async () => {
  const response = await fetch('https://api.hooked.so/v1/project/create/extend-video', {
    method: 'POST',
    headers: {
      'x-api-key': process.env.HOOKED_API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Extended Story Video',
      media: 'media_story_video',
      prompt: 'The scene continues with smooth camera movement, transitioning through different environments while maintaining visual consistency',
      targetDuration: 32, // Will be processed in 4 segments of 8 seconds each
      generateAudio: true
    })
  });

  return await response.json();
};
```

***

## Response

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true,
    "data": {
      "videoId": "vid_extend_abc123xyz",
      "projectId": "proj_extend_abc123xyz",
      "status": "STARTED"
    }
  }
  ```

  ```json Error Response - Invalid Media theme={null}
  {
    "success": false,
    "message": "media: A video is required"
  }
  ```

  ```json Error Response - Invalid Duration theme={null}
  {
    "success": false,
    "message": "extendVideoSettings.targetDuration: Target duration must be at least 4 seconds"
  }
  ```

  ```json Error Response - Invalid Prompt theme={null}
  {
    "success": false,
    "message": "extendVideoSettings.prompt: Prompt is required"
  }
  ```
</ResponseExample>

***

## Webhook Notification

When your extended video is ready, we'll POST to your webhook URL (if configured):

```json Webhook Payload theme={null}
{
  "status": "COMPLETED",
  "data": {
    "videoId": "vid_extend_abc123xyz",
    "status": "COMPLETED",
    "url": "https://cdn.hooked.so/videos/abc123xyz.mp4",
    "shareUrl": "https://cdn.hooked.so/shared/abc123xyz.mp4",
    "metadata": {
      "projectId": "proj_extend_abc123xyz",
      "originalDuration": "5s",
      "extendedDuration": "13s"
    }
  },
  "message": "Video completed"
}
```

***

## How It Works

<Steps>
  <Step title="Upload Source Video">
    Provide your source video that you want to extend
  </Step>

  <Step title="AI Analysis">
    Veo 3.1 analyzes the last frame and video motion patterns
  </Step>

  <Step title="Generate Extensions">
    AI generates extension segments (8 seconds each) based on your prompt
  </Step>

  <Step title="Seamless Concatenation">
    All segments are seamlessly concatenated with the source video
  </Step>

  <Step title="Final Output">
    Receive your extended video with smooth transitions
  </Step>
</Steps>

***

## Best Practices

<CardGroup cols={2}>
  <Card title="Clear Prompts" icon="message">
    Describe the continuation clearly and specifically for best results
  </Card>

  <Card title="Match Style" icon="palette">
    Reference the visual style of your source video in the prompt
  </Card>

  <Card title="Realistic Durations" icon="clock">
    Start with 8-16 seconds to ensure quality, then scale up
  </Card>

  <Card title="Audio Consistency" icon="volume">
    Enable generateAudio for better continuity with the source
  </Card>
</CardGroup>

***

## Prompt Writing Tips

### Good Prompts

✅ "The camera continues to pan right, revealing a mountain range at golden hour with soft clouds drifting across the sky"

✅ "The dancer spins gracefully as the lighting shifts from warm orange to cool blue"

✅ "The product rotates smoothly on the pedestal while particles float upward in the background"

### Avoid

❌ "Continue the video" (too vague)

❌ "Make it longer" (no direction)

❌ "Add random stuff" (unclear intent)

***

## Error Handling

| Error                                                        | Description                 | Solution                                            |
| ------------------------------------------------------------ | --------------------------- | --------------------------------------------------- |
| `media: A video is required`                                 | Missing or invalid media ID | Provide a valid video media ID                      |
| `Media not found`                                            | Media ID doesn't exist      | Check that the media ID is correct and exists       |
| `Media is not a video`                                       | Media is not a video type   | Ensure the media ID points to a video, not an image |
| `prompt: Prompt is required`                                 | Missing prompt              | Provide a descriptive prompt for the extension      |
| `targetDuration: Target duration must be at least 4 seconds` | Duration too short          | Use minimum 4 seconds                               |
| `targetDuration: Target duration cannot exceed 60 seconds`   | Duration too long           | Use maximum 60 seconds                              |
| `aspectRatio: Invalid enum value`                            | Invalid aspect ratio        | Use `ratio_9_16`, `ratio_16_9`, or `ratio_1_1`      |
| `Not enough credits`                                         | Insufficient credits        | Top up your account credits                         |

***

## Processing Time

Extension processing time varies based on:

* **Target Duration**: Longer extensions take more time (each 8-second segment \~2-3 minutes)
* **Audio Generation**: Enabling audio adds processing time
* **Queue Load**: Peak times may have longer waits

**Typical processing times:**

* 8 seconds: 2-3 minutes
* 16 seconds: 4-6 minutes
* 32 seconds: 8-12 minutes
* 60 seconds: 15-20 minutes

***

## Next Steps

<CardGroup cols={2}>
  <Card title="List Videos" icon="list" href="/api-reference/video/list">
    View all your created videos
  </Card>

  <Card title="Video Details" icon="video" href="/api-reference/video/details">
    Check your video processing status
  </Card>

  <Card title="Webhooks Guide" icon="webhook" href="/guides/webhooks">
    Learn how to handle webhook notifications
  </Card>

  <Card title="Examples" icon="code" href="/examples/extend-video">
    See more extend video examples
  </Card>
</CardGroup>


## OpenAPI

````yaml POST /v1/project/create/extend-video
openapi: 3.0.0
info:
  title: Hooked API
  version: 1.0.0
  description: AI Video Generation API
servers:
  - url: https://api.hooked.so
security:
  - ApiKeyAuth: []
paths:
  /v1/project/create/extend-video:
    post:
      tags:
        - Videos
      summary: Extend Video
      description: Extend videos using AI to continue and extend your content seamlessly
      operationId: extendVideo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - media
                - prompt
              properties:
                media:
                  type: string
                  description: Media ID from uploaded video
                prompt:
                  type: string
                  description: Describe how the AI should continue the video
                  minLength: 1
                  maxLength: 2000
                targetDuration:
                  type: number
                  description: Total duration to extend in seconds (must be multiple of 4)
                  minimum: 4
                  maximum: 60
                  default: 4
                generateAudio:
                  type: boolean
                  description: Whether to generate audio for the extended portion
                  default: true
                name:
                  type: string
                  description: Custom name for the project
                  maxLength: 100
                webhook:
                  type: string
                  description: HTTPS URL for status notifications (max 500 characters)
                  maxLength: 500
                metadata:
                  type: object
                  description: Custom metadata object (max 5KB)
            example:
              media: media_video123
              prompt: >-
                The camera slowly zooms out revealing a beautiful sunset over
                the ocean
              targetDuration: 4
              generateAudio: true
      responses:
        '200':
          description: Extend Video created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      videoId:
                        type: string
                      projectId:
                        type: string
                      status:
                        type: string
              example:
                success: true
                data:
                  videoId: vid_extend_abc123xyz
                  projectId: proj_extend_abc123xyz
                  status: STARTED
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
              example:
                success: false
                message: 'extendVideoSettings.prompt: Prompt is required'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  message:
                    type: string
              example:
                success: false
                message: Invalid API key
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````