Channels

Create channel

Create a new channel with specified videos and/or projects.

http
POST /v1/channels

Authentication

This endpoint requires authentication using a Bearer token.

http
Authorization: Bearer YOUR_API_KEY

Request Headers

Header / Value / Required
HeaderValueRequired
AuthorizationBearer YOUR_API_KEYYes
Content-Typeapplication/jsonYes

Request Body

Field / Type / Required / Description
FieldTypeRequiredDescription
namestringYesChannel name (max 100 characters)
descriptionstringNoChannel description (max 250 characters)
templateKeystringNoTemplate key to apply styling
videoKeysarrayNo*Array of video keys to include
projectKeysarrayNo*Array of project keys to include
privateLinkEnabledbooleanNoEnable private link access (default: true)

Request Example

json
{
  "name": "Getting Started Series",
  "description": "Beginner tutorials for new users",
  "templateKey": "tmpl_dark",
  "videoKeys": [
    "vid_abc123",
    "vid_def456",
    "vid_ghi789"
  ],
  "projectKeys": [
    "proj_xyz"
  ],
  "privateLinkEnabled": true
}

Response

Success Response

Status Code: 201 Created

The response includes a Location header with the URL of the created channel.

json
{
  "id": "new_channel_id",
  "key": "ch_newkey123",
  "name": "Getting Started Series",
  "description": "Beginner tutorials for new users",
  "accountId": "acc_789",
  "version": 1,
  "planType": 2,
  "templateKey": "tmpl_dark",
  "status": 1,
  "created": "2024-01-25T09:00:00Z",
  "updated": "2024-01-25T09:00:00Z"
}

Response Fields

Field / Type / Description
FieldTypeDescription
idstringInternal channel identifier
keystringPublic channel key (use for embedding)
namestringChannel display name
descriptionstringChannel description
accountIdstringOwner account identifier
versionintegerChannel version (starts at 1)
planTypeintegerAssociated plan type
templateKeystringApplied template key
statusintegerChannel status (1 = Published)
createddatetimeCreation timestamp (ISO 8601)
updateddatetimeLast update timestamp (ISO 8601)

Error Responses

Status Code / Description
Status CodeDescription
400Bad Request - Validation error
401Unauthorized - Invalid or missing API key
500Internal Server Error

Validation error examples

json
{
  "message": "Name is required."
}
json
{
  "message": "Provide at least one videoKey or projectKey."
}
json
{
  "message": "Invalid videoKeys provided.",
  "invalidVideoKeys": ["vid_invalid1", "vid_invalid2"]
}
json
{
  "message": "Invalid projectKeys provided.",
  "invalidProjectKeys": ["proj_invalid"]
}
json
{
  "message": "Template not found for this account."
}

Code Examples

cURL

bash
curl -X POST "https://api.dyntube.com/v1/channels" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Getting Started Series",
    "description": "Beginner tutorials for new users",
    "videoKeys": ["vid_abc123", "vid_def456"],
    "privateLinkEnabled": true
  }'

JavaScript

javascript
const newChannel = {
  name: 'Getting Started Series',
  description: 'Beginner tutorials for new users',
  videoKeys: ['vid_abc123', 'vid_def456', 'vid_ghi789'],
  privateLinkEnabled: true
};

const response = await fetch('https://api.dyntube.com/v1/channels', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(newChannel)
});

if (response.status === 201) {
  const channel = await response.json();
  console.log(`Created channel: ${channel.name}`);
  console.log(`Channel key for embedding: ${channel.key}`);
} else {
  const error = await response.json();
  console.error(`Error: ${error.message}`);
}

C#

csharp
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;

var channel = new
{
    name = "Getting Started Series",
    description = "Beginner tutorials for new users",
    videoKeys = new[] { "vid_abc123", "vid_def456" },
    privateLinkEnabled = true
};

var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "YOUR_API_KEY");

var response = await client.PostAsync(
    "https://api.dyntube.com/v1/channels",
    new StringContent(JsonSerializer.Serialize(channel), Encoding.UTF8, "application/json"));

if (response.IsSuccessStatusCode)
{
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
else
{
    Console.WriteLine($"Failed to create channel. Status: {response.StatusCode}");
}

Python

python
import requests

new_channel = {
    'name': 'Getting Started Series',
    'description': 'Beginner tutorials for new users',
    'videoKeys': ['vid_abc123', 'vid_def456', 'vid_ghi789'],
    'privateLinkEnabled': True
}

response = requests.post(
    'https://api.dyntube.com/v1/channels',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json=new_channel
)

if response.status_code == 201:
    channel = response.json()
    print(f"Created channel: {channel['name']}")
    print(f"Channel key for embedding: {channel['key']}")
else:
    error = response.json()
    print(f"Error: {error['message']}")

PHP

php
<?php
$newChannel = [
    'name' => 'Getting Started Series',
    'description' => 'Beginner tutorials for new users',
    'videoKeys' => ['vid_abc123', 'vid_def456', 'vid_ghi789'],
    'privateLinkEnabled' => true
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.dyntube.com/v1/channels');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($newChannel));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY',
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 201) {
    $channel = json_decode($response, true);
    echo "Created channel: " . $channel['name'] . "\n";
    echo "Channel key for embedding: " . $channel['key'] . "\n";
} else {
    $error = json_decode($response, true);
    echo "Error: " . $error['message'] . "\n";
}

Use Cases

Create Channel with Videos

javascript
// Create a channel containing specific videos
const channel = await createChannel({
  name: 'Product Demo Videos',
  description: 'Demonstrations of our product features',
  videoKeys: [
    'vid_intro',
    'vid_feature1',
    'vid_feature2',
    'vid_advanced'
  ]
});

Create Channel from Project

javascript
// Create a channel that includes all videos from a project
const channel = await createChannel({
  name: 'Marketing Campaign Q1',
  description: 'All marketing videos for Q1 2024',
  projectKeys: ['proj_marketing_q1']
});

Create Channel with Template

javascript
// First, get available templates
const templatesResponse = await fetch(
  'https://api.dyntube.com/v1/channels/templates',
  { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
);
const templates = await templatesResponse.json();

// Create channel with a specific template
const channel = await createChannel({
  name: 'Branded Channel',
  videoKeys: ['vid_abc123'],
  templateKey: templates[0].key  // Use first available template
});

Video Key Order

The order of video keys in the videoKeys array determines the display order in the channel. Videos are shown in the same order they appear in the request.

json
{
  "name": "Ordered Playlist",
  "videoKeys": [
    "vid_episode1",
    "vid_episode2",
    "vid_episode3"
  ]
}

See Also

  • List Templates - Get available templates
  • Update Channel - Modify a channel
  • Get Channel - Retrieve channel details
  • Channels API Overview - API overview and authentication

Something missing or wrong here? Tell us and we will correct it. New to DynTube? Start with uploading and embedding.