# Clips Export API

> Export or re-export existing clips from AI Clipping and Find Moments with new subtitle styles and render settings.

## Clips Export API

Use this API when you have already created an [AI Clipping](https://wayin.ai/api-docs/ai-clipping/) or [Find Moments](https://wayin.ai/api-docs/find-moments/) task and want to render clips later, or re-export them with a different subtitle style, aspect ratio, AI hook, or other export settings.

The `project_id` should be the original task ID returned by:

- `POST /api/v2/clips`
- `POST /api/v2/clips/find-moments`

---

## Submit Export Task

```
POST https://wayinvideo-api.wayin.ai/api/v2/clips/export
```

### Request Body

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `project_id` | string | Yes | — | The original AI Clipping or Find Moments task ID. |
| `clip_indices` | integer[] | No | `null` | Clip indices to export. When omitted, the system exports all clips in the project. |
| `target_lang` | string | No | `null` | Target language for output content including subtitles (see [Supported Languages](https://wayin.ai/api-docs/supported-languages/)). When `null`, the output language matches the source task language. |
| `resolution` | string | No | `SD_480` | Output resolution: `SD_480`, `HD_720`, `FHD_1080`, `QHD_2K`, `UHD_4K`. |
| `enable_caption` | boolean | No | `false` | Whether to add Animated Caption when rendering. When `true`, `caption_display` and `cc_style_tpl` take effect; when `false`, the export has no Animated Caption. |
| `caption_display` | string | No | `original` | Caption mode: `both`, `original`, `translation`. Only used when `enable_caption` is `true`. |
| `cc_style_tpl` | string | No | `temp-7` | Caption style template ID (see [Subtitle Styles](https://wayin.ai/api-docs/subtitles-style/)). Only used when `enable_caption` is `true`. |
| `enable_ai_hook` | boolean | No | `false` | Whether to add an automatically generated, attention-grabbing text hook at the beginning or end of each exported clip. When `true`, `ai_hook_script_style` and `ai_hook_position` take effect; when `false`, no AI hook is added. |
| `ai_hook_script_style` | string | No | `serious` | Style of the generated hook text. Allowed values: `serious`, `casual`, `informative`, `conversational`, `humorous`, `parody`, `inspirational`, `dramatic`, `empathetic`, `persuasive`, `neutral`, `excited`, `calm`. Only used when `enable_ai_hook` is `true`. |
| `ai_hook_position` | string | No | `beginning` | Position of the generated hook text. Allowed values: `beginning`, `end`. Only used when `enable_ai_hook` is `true`. |
| `ai_hook_keywords` | string | No | `null` | Optional keywords used to steer the generated AI hook text. Only used when `enable_ai_hook` is `true`. |
| `ai_hook_text_duration` | integer | No | `null` | Duration of the AI hook text overlay in milliseconds. Only used when `enable_ai_hook` is `true`. |
| `enable_ai_reframe` | boolean | No | `false` | Enable AI Reframe. When `true`, `ratio` is required; when `false`, the clip is exported with its original aspect ratio unchanged. |
| `ratio` | string | Yes when `enable_ai_reframe` is `true` | — | Aspect ratio: `RATIO_9_16`, `RATIO_1_1`, `RATIO_4_5`, `RATIO_16_9`. Required when `enable_ai_reframe` is `true`. |

### Example Request

```bash
curl -X POST https://wayinvideo-api.wayin.ai/api/v2/clips/export \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-wayinvideo-api-version: v2" \
  -d '{
    "project_id": "proj_abc123",
    "clip_indices": [0, 2],
    "resolution": "UHD_4K",
    "enable_caption": true,
    "caption_display": "both",
    "cc_style_tpl": "word-focus",
    "enable_ai_hook": true,
    "ai_hook_script_style": "serious",
    "ai_hook_position": "beginning",
    "enable_ai_reframe": true,
    "ratio": "RATIO_9_16"
  }'
```

### Submit Response

```json
{
  "data": {
    "export_task_id": "export_task_xyz789",
    "name": "sample export task",
    "status": "CREATED"
  }
}
```

| Field | Type | Description |
|-------|------|-------------|
| `export_task_id` | string | Unique export task identifier. Use this value to poll export progress. |
| `name` | string | Export task name |
| `status` | string | `CREATED`, `QUEUED`, `ONGOING`, `SUCCEEDED`, `FAILED` |

---

## Get Export Results

Poll the export task until `status` is `SUCCEEDED`.

```
GET https://wayinvideo-api.wayin.ai/api/v2/clips/export/{taskId}
```

### Path Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `taskId` | string | Yes | The `export_task_id` returned by the export submit endpoint |

### Example Request

```bash
curl -X GET https://wayinvideo-api.wayin.ai/api/v2/clips/export/export_task_xyz789 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-wayinvideo-api-version: v2"
```

### Example Response

```json
{
  "data": {
    "export_task_id": "export_task_xyz789",
    "name": "sample export task",
    "status": "SUCCEEDED",
    "expire_at": 1775831883112,
    "cost_usage": 48.0,
    "clips": [
      {
        "idx": 0,
        "title": "sample title",
        "begin_ms": 15000,
        "end_ms": 75000,
        "thumbnail": "https://cdn.example.com/thumb/clip_001.jpg",
        "tags": ["insight", "understanding"],
        "desc": "sample description",
        "score": 81,
        "export_link": "https://cdn.example.com/export/clip_001.mp4"
      }
    ]
  }
}
```

### Response Fields

| Field | Type | Description |
|-------|------|-------------|
| `export_task_id` | string | Unique export task identifier |
| `name` | string | Export task name |
| `status` | string | `CREATED`, `QUEUED`, `ONGOING`, `SUCCEEDED`, `FAILED` |
| `error_message` | string | Error reason (only present when `status` is `FAILED`) |
| `expire_at` | integer | Expiration timestamp in milliseconds (epoch). After this time, the task expires and results can no longer be retrieved via the export results endpoint. `-1` means the result does not expire while a paid subscription is active. After the paid subscription ends, the result is kept for one more month and then expires. |
| `cost_usage` | number | API units consumed for this export request |
| `clips` | array | List of exported clip objects. When `status` is `ONGOING`, this may contain partial export results; when `status` is `SUCCEEDED`, it contains all exported clips. |

The `clips` objects returned by the export results endpoint use the same structure as the clip objects in the main results endpoint, including `export_link` for each rendered clip.
