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

# Create Video with Template

> Create a video using a template with custom variables and settings.
Templates support various variable types including text, image, video, and script.


Create a video using a pre-designed template. Templates provide consistent branding and faster video creation.

## Example Usage

### Basic Example with Text and Script Variables

```bash theme={null}
curl -X POST 'https://api.jogg.ai/v2/create_video_with_template' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "template_id": 1234,
    "video_name": "Product Showcase",
    "avatar_id": 127,
    "avatar_type": 0,
    "voice_language": "english",
    "voice_id": "en-US-ChristopherNeural",
    "variables": [
      {
        "type": "text",
        "name": "product_name",
        "properties": {
          "content": "Amazing Smart Watch"
        }
      },
      {
        "type": "script",
        "name": "script",
        "properties": {
          "content": "Check out our amazing product!"
        }
      }
    ]
  }'
```

### Example with Image Variable (URL)

```bash theme={null}
curl -X POST 'https://api.jogg.ai/v2/create_video_with_template' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "template_id": 1234,
    "voice_language": "english",
    "variables": [
      {
        "type": "image",
        "name": "product_image",
        "properties": {
          "url": "https://example.com/product.jpg"
        }
      },
      {
        "type": "script",
        "name": "script",
        "properties": {
          "content": "Check out this amazing product!"
        }
      }
    ]
  }'
```

### Example with Image Variable (Asset ID)

```bash theme={null}
curl -X POST 'https://api.jogg.ai/v2/create_video_with_template' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "template_id": 1234,
    "voice_language": "english",
    "variables": [
      {
        "type": "image",
        "name": "product_image",
        "properties": {
          "asset_id": 5678
        }
      },
      {
        "type": "script",
        "name": "script",
        "properties": {
          "content": "Check out this amazing product!"
        }
      }
    ]
  }'
```

## Variable Properties

| Property   | Type    | Description                                                                                          |
| ---------- | ------- | ---------------------------------------------------------------------------------------------------- |
| `content`  | string  | For text/script type: Required, the text content. For image/video type: Optional, can be used as URL |
| `url`      | string  | Media resource URL for image/video type (choose url or asset\_id)                                    |
| `asset_id` | integer | Asset ID for image/video type, obtained from /v2/upload/asset (choose url or asset\_id)              |

## Related Guides

<CardGroup cols={2}>
  <Card title="Get Templates" href="/api-reference/v2/Template/GetTemplates">
    Browse available templates
  </Card>

  <Card title="Upload Media" href="/api-reference/v2/API Documentation/UploadMedia">
    Upload assets to get asset\_id
  </Card>
</CardGroup>


## OpenAPI

````yaml POST /v2/create_video_with_template
openapi: 3.0.1
info:
  title: JoggAI OpenAPI v2
  description: >
    JoggAI OpenAPI v2 provides a comprehensive suite of endpoints for creating
    and managing AI-powered video content.


    ## Authentication

    All API requests require authentication using an API key provided in the
    `x-api-key` header.


    ## Base URL

    Production: https://api.jogg.ai/v2


    ## Rate Limiting

    API calls are subject to rate limiting based on your subscription plan.


    ## Error Handling

    All endpoints return standard HTTP status codes along with detailed error
    messages in the response body.
  version: 2.0.0
  license:
    name: MIT
servers:
  - url: https://api.jogg.ai
    description: Production server
security:
  - apiKeyAuth: []
tags:
  - name: Video
    description: Video creation and management operations
  - name: Avatar
    description: Avatar management and creation operations
  - name: Voice
    description: Voice and timbre management operations
  - name: Asset
    description: Asset management including music, scripts, and uploads
  - name: Template
    description: Template management operations
  - name: Product
    description: Product management operations
  - name: User
    description: User account operations
  - name: Webhook
    description: Webhook endpoint management for event notifications
paths:
  /v2/create_video_with_template:
    post:
      tags:
        - Video
      summary: Create video from template
      description: >
        Create a video using a template with custom variables and settings.

        Templates support various variable types including text, image, video,
        and script.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - template_id
                - voice_language
                - variables
              properties:
                template_id:
                  type: integer
                  description: Template ID
                  example: 1234
                video_name:
                  type: string
                  description: Custom name for the video
                  example: My Template Video
                avatar_id:
                  type: integer
                  description: Digital person ID
                  example: 1
                avatar_type:
                  type: integer
                  description: |
                    Source type of the avatar:
                    * 0 - Public avatar
                    * 1 - Custom avatar
                  enum:
                    - 0
                    - 1
                  example: 0
                voice_language:
                  type: string
                  description: Voice language for text-to-speech
                  example: english
                voice_id:
                  type: string
                  description: Voice ID for text-to-speech
                  example: en-US-ChristopherNeural
                captions_enabled:
                  type: boolean
                  description: Enable captions/subtitles
                  example: true
                background_music_id:
                  type: integer
                  description: Background music ID
                  example: 1
                variables:
                  type: array
                  description: Variables to replace in the template
                  items:
                    type: object
                    required:
                      - type
                      - name
                      - properties
                    properties:
                      type:
                        type: string
                        description: Variable type
                        enum:
                          - text
                          - image
                          - video
                          - script
                      name:
                        type: string
                        description: Variable name
                      properties:
                        type: object
                        properties:
                          content:
                            type: string
                            description: >
                              Variable content:

                              * For text/script type: Required, the text content

                              * For image/video type: Optional, can be used as
                              URL (compatible with url field)
                            example: Product description text
                          url:
                            type: string
                            description: >
                              Media resource URL for image/video type.

                              Either url or asset_id is required for image/video
                              type.
                            format: uri
                            example: https://res.jogg.ai/media/image.jpg
                          asset_id:
                            type: integer
                            description: >
                              Asset ID for image/video type.

                              Obtained after uploading via /v2/upload/asset
                              endpoint.

                              Either url or asset_id is required for image/video
                              type.
                            example: 12345
                          webhook_url:
                            type: string
                            description: Webhook URL for status notifications
                            format: uri
                            example: https://example.com/webhook
                disable_random_trans:
                  type: boolean
                  description: Disable random transitions
                  example: false
                disable_random_moving:
                  type: boolean
                  description: Disable random image effects
                  example: false
                disable_trans:
                  type: boolean
                  description: Disable all transitions
                  example: false
                disable_moving:
                  type: boolean
                  description: Disable all image effects
                  example: false
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/BaseResponse'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          video_id:
                            type: string
                            description: Created video ID
                            example: video_123456
components:
  schemas:
    BaseResponse:
      type: object
      required:
        - code
        - msg
      properties:
        code:
          type: integer
          description: |
            Business status code:
            * 0 - Success
            * 10104 - Record not found
            * 10105 - Invalid API key
            * 18020 - Insufficient credit
            * 18025 - No permission to call APIs
            * 40000 - Parameter error
            * 50000 - System error
          example: 0
        msg:
          type: string
          description: Response message
          example: Success
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication. Obtain your key from the JoggAI dashboard.

````