# Custom Templates API

> Save a reusable editing setup and apply it to AI Clipping and clip export with one template id.

## Custom Templates API

Save a set of editing settings as a template, then pass `custom_template_id` on [AI Clipping](https://wayin.ai/api-docs/ai-clipping/) or [Clips Export](https://wayin.ai/api-docs/clips-export/) to apply the whole set at once.

A template can include aspect ratio and layout, caption style, emoji, B-roll, AI Hook, speech enhancement, filler-word removal, silence removal, intro, outro, and logo.

Templates are the same records as **My Template** on the website. A template created on the website can be listed here, and a template created here appears on the website.

## Plan Limits

| Plan | Saved templates |
|------|-----------------|
| Free | Not available |
| Starter | 1 |
| Pro | 3 |
| Scale | 10. Purchasing 2 or more raises the limit to 20. |

Uploading a logo, intro, or outro also requires a paid plan and uses storage quota. See [Subscription Plans](https://wayin.ai/wayinvideo/settings/plan).

## Workflow

1. **Upload assets** only when the template needs a logo, intro, or outro. Caption, ratio, and the other settings do not need an upload.
2. **Create** a template. The platform places the logo, intro, and outro from the position you choose. Do not send coordinates.
3. **List or get** templates when you need the current configuration.
4. **Apply** the template by passing `custom_template_id` to `POST /api/v2/clips` or `POST /api/v2/clips/export`.
5. **Update** replaces the whole template. A capability omitted from the request is removed. Read the current template first, edit that copy, and submit the full configuration.
6. **Delete** a template you no longer need.

## Endpoints

| Method | Path | Description |
|--------|------|-------------|
| `POST` | `/api/v2/upload/single-file` | Request an upload URL for a logo, intro, or outro |
| `POST` | `/api/v2/upload/status` | Poll until the uploaded file is ready |
| `POST` | `/api/v2/custom-templates` | Create a template |
| `GET` | `/api/v2/custom-templates` | List templates |
| `GET` | `/api/v2/custom-templates/{id}` | Get one template |
| `PUT` | `/api/v2/custom-templates/{id}` | Replace a template |
| `DELETE` | `/api/v2/custom-templates/{id}` | Delete a template |

All requests require:

```http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
x-wayinvideo-api-version: v2
```

`GET` and `DELETE` do not need `Content-Type`.

---

## Upload a Logo, Intro, or Outro

Request a pre-signed URL, `PUT` the file to that URL, then poll until `status` is `DONE`. Use the returned `identity` as `resource.identify` in the template.

Skip this step when the template does not use a logo, intro, or outro. General video uploads are documented in the [Upload API](https://wayin.ai/api-docs/upload/).

```http
POST https://wayinvideo-api.wayin.ai/api/v2/upload/single-file
```

### Request Body

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `name` | string | Yes | File name with an extension. The extension is used to check the format. |
| `size` | integer | No | File size in bytes. Send it so the API can check the size limit and storage quota. |
| `resource_type` | string | Yes for template assets | How the file will be used. See the table below. If omitted, the file is treated as a normal video and cannot be used in a template. |

| `resource_type` | Used by | Formats | Size limit | Duration limit |
|-----------------|---------|---------|------------|----------------|
| `BRAND_KIT_LOGO` | `logo` | `.jpg`, `.jpeg`, `.png`, `.webp` | 10 MB | — |
| `BRAND_KIT_VIDEO` | `intro`, `outro` | `.mp4`, `.mov`, `.webm`, `.avi` | 5 GB | 60 minutes |

### Example Request

```bash
curl -X POST https://wayinvideo-api.wayin.ai/api/v2/upload/single-file \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-wayinvideo-api-version: v2" \
  -d '{
    "name": "brand-logo.png",
    "size": 204800,
    "resource_type": "BRAND_KIT_LOGO"
  }'
```

### Response

```json
{
  "data": {
    "upload_url": "https://storage.example.com/upload/presigned-url...",
    "identity": "EF_up_06wguq1afbwg1"
  }
}
```

| Field | Type | Description |
|-------|------|-------------|
| `upload_url` | string | Pre-signed upload URL. It expires, so upload soon after you receive it. |
| `identity` | string | File id. Put this value in `resource.identify` when you create or update a template. |

### Upload the File

```bash
curl -X PUT "https://storage.example.com/upload/presigned-url..." \
  --upload-file ./brand-logo.png
```

HTTP `200` means the file has been received. The platform then processes it. Poll the status endpoint until processing finishes.

### Check Upload Status

Poll every 3 to 5 seconds until `status` is `DONE` or `ERROR`. Only a file with `status` `DONE` can be used in a template.

```http
POST https://wayinvideo-api.wayin.ai/api/v2/upload/status
```

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `identify` | string | Yes | The `identity` returned by the upload URL request. |

```bash
curl -X POST https://wayinvideo-api.wayin.ai/api/v2/upload/status \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-wayinvideo-api-version: v2" \
  -d '{
    "identify": "EF_up_06wguq1afbwg1"
  }'
```

```json
{
  "data": {
    "status": "DONE",
    "file_name": "brand-logo.png",
    "url": "https://cdn.example.com/user/brand-logo.png"
  }
}
```

| Field | Type | Description |
|-------|------|-------------|
| `status` | string | `START`: the file has not arrived. Confirm the `PUT` succeeded. `UPLOADED`: the file arrived and is still processing. `DONE`: ready to use. `ERROR`: processing failed. Upload the file again. |
| `file_name` | string | File name. |
| `url` | string | File URL. |

---

<a id="create-a-template"></a>

## Create a Template

```http
POST https://wayinvideo-api.wayin.ai/api/v2/custom-templates
```

### Request Body

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `name` | string | Yes | Template name. Must not be empty. |
| `config` | object | Yes | Capabilities to store. Each key is one capability. See [Config fields](#config-fields). `{}` is allowed. `null` is not. `reframe` is required when you send any other capability. |

A capability present in `config` overrides the matching parameter on [AI Clipping](https://wayin.ai/api-docs/ai-clipping/) when the template is applied. A capability omitted from `config` keeps the value from that clipping or export request.

### Example Request

```bash
curl -X POST https://wayinvideo-api.wayin.ai/api/v2/custom-templates \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-wayinvideo-api-version: v2" \
  -d '{
    "name": "Brand A - Shorts",
    "config": {
      "reframe": {
        "ratio": "RATIO_9_16",
        "layout_type": "Fit",
        "auto_reframe": true
      },
      "caption_style": {
        "mode": "on",
        "template_id": "word-focus"
      },
      "emoji": { "operation": "add" },
      "broll": {
        "operation": "add",
        "resource_type": "RESOURCE_VIDEO_STOCK_BROLL"
      },
      "ai_hook": {
        "operation": "add",
        "template_id": "preset-1",
        "script_style": "casual",
        "position": "beginning"
      },
      "speech_enhance": { "operation": "clean" },
      "remove_filter": { "operation": "remove" },
      "remove_silence": {
        "operation": "remove",
        "silence_duration_ms": 500
      },
      "intro": {
        "operation": "add",
        "resource": { "identify": "EF_up_06wgintro0001" }
      },
      "outro": {
        "operation": "add",
        "resource": { "identify": "EF_up_06wgoutro0001" }
      },
      "logo": {
        "operation": "add",
        "items": [
          {
            "resource": { "identify": "EF_up_06wguq1afbwg1" },
            "position": "top_right"
          }
        ]
      }
    }
  }'
```

### Response

The response is the saved template. The shape matches [Get a Template](#get-a-template).

```json
{
  "data": {
    "id": "uctmpl06yf2m0m1b0pv",
    "name": "Brand A - Shorts",
    "config": {
      "reframe": {
        "ratio": "RATIO_9_16",
        "layout_type": "Fit",
        "auto_reframe": true
      }
    },
    "created": 1764057600000,
    "last_modified": 1764057600000
  }
}
```

---

## List Templates

Returns every template in the current account or workspace, newest first. `data` is `[]` when there are no templates.

```http
GET https://wayinvideo-api.wayin.ai/api/v2/custom-templates
```

### Example Request

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

### Example Response

```json
{
  "data": [
    {
      "id": "uctmpl06yf2m0m1b0pv",
      "name": "Brand A - Shorts",
      "config": {
        "reframe": {
          "ratio": "RATIO_9_16",
          "layout_type": "Fit",
          "auto_reframe": true
        }
      },
      "created": 1764057600000,
      "last_modified": 1764144000000
    }
  ]
}
```

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Template id. It starts with `uctmpl`. |
| `name` | string | Template name. |
| `config` | object | Stored configuration. See [Get a Template](#get-a-template). |
| `created` | integer | Created time, Unix timestamp in milliseconds. |
| `last_modified` | integer | Last modified time, Unix timestamp in milliseconds. |

---

<a id="get-a-template"></a>

## Get a Template

```http
GET https://wayinvideo-api.wayin.ai/api/v2/custom-templates/{id}
```

### Path Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `id` | string | Yes | Template id returned by create or list. |

### Example Request

```bash
curl -X GET https://wayinvideo-api.wayin.ai/api/v2/custom-templates/uctmpl06yf2m0m1b0pv \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-wayinvideo-api-version: v2"
```

### Example Response

```json
{
  "data": {
    "id": "uctmpl06yf2m0m1b0pv",
    "name": "Brand A - Shorts",
    "config": {
      "reframe": {
        "ratio": "RATIO_9_16",
        "layout_type": "Fit",
        "auto_reframe": true
      },
      "caption_style": {
        "mode": "on",
        "template_id": "word-focus"
      },
      "intro": {
        "operation": "add",
        "resource": {
          "identify": "EF_up_06wgintro0001",
          "url": "https://cdn.example.com/user/intro.mp4",
          "name": "intro"
        }
      },
      "logo": {
        "operation": "add",
        "items": [
          {
            "resource": {
              "identify": "EF_up_06wguq1afbwg1",
              "url": "https://cdn.example.com/user/brand-logo.png",
              "name": "brand-logo"
            },
            "position": "top_right"
          }
        ]
      }
    },
    "created": 1764057600000,
    "last_modified": 1764144000000
  }
}
```

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Template id. |
| `name` | string | Template name. |
| `config` | object | Template configuration. Besides the fields in this page, `config` may include internal fields such as `transform`, `operation`, and `extra`. You can send those fields back unchanged on update. A returned `transform` is reused. If a logo item also includes `position`, that item's `transform` is discarded and the placement is generated again from `position`. Asset objects may include `url` and `name`. The platform reads `identify` only. |
| `created` | integer | Created time, Unix timestamp in milliseconds. |
| `last_modified` | integer | Last modified time, Unix timestamp in milliseconds. |

A logo placed by dragging it on the website has no `position`. That item only has `transform`. Sending it back unchanged keeps the placement. Adding `position` places it again at the new position.

---

## Update a Template

Replaces `name` and `config` for the whole template. A capability omitted from `config` is removed. It is not a partial patch. Logo, intro, and outro placement is calculated again from the new configuration.

Read the template with [Get a Template](#get-a-template), edit that object, and submit the full body.

```http
PUT https://wayinvideo-api.wayin.ai/api/v2/custom-templates/{id}
```

The body matches [Create a Template](#create-a-template). `name` and `config` are both required.

### Example Request

This example keeps reframe, captions, and the logo, and moves the logo to the bottom right. An intro that was stored before is removed because it is not in this body.

```bash
curl -X PUT https://wayinvideo-api.wayin.ai/api/v2/custom-templates/uctmpl06yf2m0m1b0pv \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-wayinvideo-api-version: v2" \
  -d '{
    "name": "Brand A - Shorts v2",
    "config": {
      "reframe": {
        "ratio": "RATIO_9_16",
        "layout_type": "Fit",
        "auto_reframe": true
      },
      "caption_style": {
        "mode": "on",
        "template_id": "word-focus"
      },
      "logo": {
        "operation": "add",
        "items": [
          {
            "resource": { "identify": "EF_up_06wguq1afbwg1" },
            "position": "bottom_right"
          }
        ]
      }
    }
  }'
```

### Response

The updated template. The shape matches [Get a Template](#get-a-template).

---

## Delete a Template

```http
DELETE https://wayinvideo-api.wayin.ai/api/v2/custom-templates/{id}
```

Deletion cannot be undone. Later reads and applies with this id fail because the template does not exist. Clips already generated or exported with the template are unchanged. Files referenced by the template are not deleted.

### Example Request

```bash
curl -X DELETE https://wayinvideo-api.wayin.ai/api/v2/custom-templates/uctmpl06yf2m0m1b0pv \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-wayinvideo-api-version: v2"
```

### Response

```json
{
  "data": null
}
```

---

## Apply a Template

Add `custom_template_id` to the JSON body.

On [AI Clipping](https://wayin.ai/api-docs/ai-clipping/), `custom_template_id` is used only when `enable_export` is `true`. On [Clips Export](https://wayin.ai/api-docs/clips-export/), the export request itself is a render, so the id applies whenever you send it.

```json
{
  "video_url": "https://www.youtube.com/watch?v=example",
  "target_lang": "en",
  "enable_export": true,
  "custom_template_id": "uctmpl06yf2m0m1b0pv"
}
```

| Case | Result |
|------|--------|
| The template and the request both set the same capability | The template wins. For example, a template `caption_style` overrides `cc_style_tpl` on the request. |
| The request sets a capability the template does not include | The request value is used. |
| The template sets a capability the request does not include | The template value is used. |

The template is read when the task is submitted. Later edits or deletion do not change a task that was already submitted.

---

<a id="config-fields"></a>

## Config Fields

Each key is one capability. Omit a capability you do not want to store. `reframe` is required.

### `reframe`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `ratio` | string | Yes | `RATIO_16_9`, `RATIO_1_1`, `RATIO_4_5`, `RATIO_9_16`. |
| `layout_type` | string | Yes | Layout. Allowed values depend on `ratio`. Pass the names exactly, including spaces. |
| `auto_reframe` | boolean | No | Turn on AI subject tracking. |

| `ratio` | Allowed `layout_type` values |
|---------|------------------------------|
| `RATIO_16_9` | `Auto`, `Full`, `Fit`, `Grid 4`, `Split 2`, `Trio`, `PiP`, `OTS`, `Screen First` |
| `RATIO_9_16` | `Auto`, `Full`, `Fit`, `Grid 4`, `Split 2`, `Trio`, `PiP`, `Screen First`, `Gameplay A`, `Gameplay B` |
| `RATIO_4_5` | `Auto`, `Full`, `Fit`, `Grid 4`, `Split 2`, `Trio`, `PiP`, `Screen First`, `Gameplay A`, `Gameplay B` |
| `RATIO_1_1` | `Auto`, `Full`, `Fit`, `Grid 4`, `Trio` |

### `caption_style`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `mode` | string | Yes | `on` shows captions. `off` hides captions. `inherit` leaves captions to the clipping or export request. |
| `template_id` | string | Yes when `mode` is `on` | System template id. See [Subtitle Styles](https://wayin.ai/api-docs/subtitles-style/). |

### `emoji`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `operation` | string | Yes | `add` inserts emoji automatically. `remove` does not add emoji. |

### `broll`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `operation` | string | Yes | `add` inserts B-roll. `remove` does not add B-roll, and removes existing B-roll on export. |
| `resource_type` | string | No | `RESOURCE_VIDEO_AI_BROLL` generates B-roll. `RESOURCE_VIDEO_STOCK_BROLL` uses the stock library. |

### `ai_hook`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `operation` | string | Yes | `add` inserts an AI Hook. `remove` does not add one, and removes an existing hook on export. Other fields are not needed when this is `remove`. |
| `template_id` | string | Yes when `operation` is `add` | System template id. See [Hook Text Styles](https://wayin.ai/api-docs/hook-text-styles/). |
| `script_style` | string | No | Copy style. Default `serious`. Allowed values: `serious`, `casual`, `informative`, `conversational`, `humorous`, `parody`, `inspirational`, `dramatic`, `empathetic`, `persuasive`, `neutral`, `excited`, `calm`. |
| `position` | string | No | `beginning` or `end`. Default `beginning`. |
| `keywords` | string | No | Keywords the hook should follow. |
| `text_duration` | integer | No | How long the hook text stays on screen, in milliseconds. |

### `speech_enhance`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `operation` | string | Yes | `clean` turns on speech enhancement and noise reduction. `restore` keeps the original audio. |

### `remove_filter`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `operation` | string | Yes | `remove` cuts filler words such as "um" and "uh". `restore` keeps them. |

### `remove_silence`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `operation` | string | Yes | `remove` cuts silent stretches. `restore` keeps them. |
| `silence_duration_ms` | integer | No | Minimum silence to cut, in milliseconds. Default `500`. |

### `intro` and `outro`

Both objects use the same fields. An intro is placed at the start of each clip. An outro is placed at the end. The asset is fitted to the template aspect ratio.

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `operation` | string | Yes | `add` inserts the asset. `remove` strips an existing intro or outro when the template is applied. Other fields are not needed when this is `remove`. |
| `resource.identify` | string | Yes when `operation` is `add` | `identity` from the upload step. The upload `resource_type` must be `BRAND_KIT_VIDEO`. |

### `logo`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `operation` | string | Yes | `add` inserts logos. `remove` strips existing logos when the template is applied. `items` is not needed when this is `remove`. |
| `items` | array | Yes when `operation` is `add` | Logo list. At least one item. |
| `items[].resource.identify` | string | Yes when `operation` is `add` | `identity` from the upload step. The upload `resource_type` must be `BRAND_KIT_LOGO`. |
| `items[].position` | string | Yes | `top_left`, `top_right`, `center`, `bottom_left`, `bottom_right`. On update, you can omit `position` when you send back the `transform` from the template detail. That keeps the previous placement. Sending `position` places the logo again. |

Logo size and margin use platform defaults.
