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

# Upload Video

> Upload videos to get URLs for use in video generation APIs

> [!NOTE]
>
> **中国本土のユーザー向け：** 中国本土のユーザーは `https://toapis.cn` を API エンドポイント（Base URL）としてご利用ください。本ドキュメント内の例では `https://toapis.com` を `https://toapis.cn` に置き換えてください。

> [!NOTE]
>
> **The docs Playground does not support file uploads**: Please use the cURL, Python, or JavaScript code examples below for testing.

## Why Upload First?

1. **Unified input flow** - Upload local videos once and reuse the returned public URL
2. **Less repeated transfer** - The same uploaded video can be referenced by multiple generation requests

## Authorizations

**Authorization** `string` *required*

Use Bearer Token for authentication

Get your API Key: Visit [API Key Management](https://toapis.com/console/token)

```
Authorization: Bearer YOUR_API_KEY
```

## Body

**file** `file` *required*

Video file

**Supported formats:**

* MP4 (.mp4)
* WebM (.webm)
* MOV (.mov)

**Limits:**

* Maximum file size: 50MB

**purpose** `string`

Upload purpose (optional)

Default: `generation`

## レスポンス

**success** `boolean`

Whether the request succeeded

**data** `object`

**レスポンス data**

**id** `string`

Upload record ID for tracking

**url** `string`

Public URL of the uploaded video, ready to use in video APIs

**mime\_type** `string`

MIME type of the video, e.g. `video/mp4`

**size** `integer`

File size in bytes

```bash cURL theme={null}
curl --request POST \
  --url https://toapis.com/v1/uploads/videos \
  --header 'Authorization: Bearer <token>' \
  --form 'file=@/path/to/your/video.mp4'
```

```python Python theme={null}
import requests

with open('video.mp4', 'rb') as f:
    response = requests.post(
        "https://toapis.com/v1/uploads/videos",
        headers={
            "Authorization": "Bearer your-ToAPIs-key"
        },
        files={
            "file": f
        }
    )

result = response.json()
video_url = result['data']['url']
print(f"Video URL: {video_url}")
```

```javascript JavaScript theme={null}
(async () => {
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.accept = 'video/mp4,video/webm,video/quicktime';
fileInput.click();
await new Promise(resolve => fileInput.onchange = resolve);

const formData = new FormData();
formData.append('file', fileInput.files[0]);

const uploadResponse = await fetch('https://toapis.com/v1/uploads/videos', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your-ToAPIs-key'
  },
  body: formData
});

const uploadResult = await uploadResponse.json();
console.log('Upload result:', uploadResult);
})();
```

```json 200 Success theme={null}
{
  "success": true,
  "message": "",
  "data": {
    "id": "upload_abc12345",
    "url": "https://files.toapis.com/uploads/123/videos/1737568800_abc12345.mp4",
    "mime_type": "video/mp4",
    "size": 1892345
  }
}
```

```json 400 Bad Request theme={null}
{
  "success": false,
  "message": "Unsupported or invalid video file. Allowed: MP4, WebM, MOV"
}
```

```json 400 File Too Large theme={null}
{
  "success": false,
  "message": "Video too large. Maximum size is 50MB"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.