Videos
Video Upload via File (Server-Side)
Send a local video file to DynTube from a trusted server environment.
API URL
API Request
POST https://upload.dyntube.com/v1/videos
Headers
| Name | Type | Description |
|---|---|---|
| Authorization | String | Bearer YOUR_API_KEY |
Request Body
| Name | Type | Description |
|---|---|---|
| file* | File | File to upload (multipart/form-data, field name file) |
| projectId | String | Project ID (optional, will be created if omitted) |
| planType | Integer | See more details here (optional) |
| title | String | Video Title |
| videoId | String | To replace an existing video (optional) |
| description | String | Video description |
| tags | String | Video tags, add multiple tags by adding the 'tags' field multiple times in your POST request with different values. |
| uploadId | String | Optional client-generated id to track the upload |
Response
200: OK
example
{
"videoKey": "hgor6PnFQ",
"uploadId": "3060c035-95ec-76495564",
"videoId": "DTQ5It1KwNg",
"channelKey": "u3u0iNPlL1Bg",
"privateLink": "pheF3ukFQQ",
"iframeLink": "klGiWrxW0nPzxw"
}Code samples
C# Example
csharp
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public class FileUploader
{
private readonly string _bearerToken;
private readonly string _remoteServerUrl;
public FileUploader(string bearerToken, string remoteServerUrl)
{
_bearerToken = bearerToken;
_remoteServerUrl = remoteServerUrl;
}
public async Task<bool> UploadFile(string filePath)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", _bearerToken);
var form = new MultipartFormDataContent();
var fileContent = new StreamContent(File.OpenRead(filePath));
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
{
Name = "\"file\"",
FileName = Path.GetFileName(filePath)
};
form.Add(fileContent);
var response = await client.PostAsync(_remoteServerUrl, form);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
return true;
}
}
}
public class Program
{
public static async Task Main()
{
var uploader = new FileUploader(
"YOUR_API_KEY",
"https://upload.dyntube.com/v1/videos?projectId=PROJECT_ID&title=My%20Video&planType=1");
await uploader.UploadFile("/path/to/video.mp4");
}
}Node.js
javascript
import fs from 'fs';
import FormData from 'form-data';
import axios from 'axios';
const bearerToken = 'YOUR_API_KEY';
const filePath = './path-to-your-file.mp4';
const url = 'https://upload.dyntube.com/v1/videos';
const uploadFile = async () => {
const form = new FormData();
form.append('file', fs.createReadStream(filePath));
const res = await axios.post(url, form, {
headers: {
Authorization: `Bearer ${bearerToken}`,
...form.getHeaders()
}
});
console.log(res.data);
};
uploadFile();Python
python
import requests
class FileUploader:
def __init__(self, bearer_token, remote_server_url):
self.bearer_token = bearer_token
self.remote_server_url = remote_server_url
def upload_file(self, file_path):
with open(file_path, 'rb') as f:
# Create the form data
form = {
'file': (file_path, f)
}
# Add the bearer token to the request headers
headers = {
'Authorization': 'Bearer ' + self.bearer_token
}
# Send the request
response = requests.post(self.remote_server_url, headers=headers, files=form)
# Check the status code of the response
if response.status_code == 200:
print(f"File {file_path} uploaded successfully.")
return True
else:
print(f"File upload failed. Status code: {response.status_code}")
return FalsePHP
php
<?php
class FileUploader {
private $bearerToken;
private $remoteServerUrl;
public function __construct($bearerToken, $remoteServerUrl) {
$this->bearerToken = $bearerToken;
$this->remoteServerUrl = $remoteServerUrl;
}
public function uploadFile($filePath) {
$curl = curl_init();
$headers = array(
'Authorization: Bearer ' . $this->bearerToken
);
$formData = array(
'file' => new CURLFile($filePath)
);
curl_setopt($curl, CURLOPT_URL, $this->remoteServerUrl);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $formData);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($statusCode >= 200 && $statusCode < 300) {
echo $response;
return true;
}
echo "File upload failed. Status code: " . $statusCode . "\n";
return false;
}
}Notes
- Use videoId to replace an existing video; otherwise a new video is created.
- Accepts either file or url; for file uploads send file with multipart/form-data.
Common Next Steps
After starting an upload, use these endpoints to complete the playback workflow:
- Get video status to poll transcoding progress.
- Get video to retrieve playback URLs and embed fields after publishing.
- Add captions, subtitles, or chapters if you manage text tracks manually.
- Create expirable links or Token Authentication for controlled playback access.
Something missing or wrong here? Tell us and we will correct it. New to DynTube? Start with uploading and embedding.