curl -X POST "https://api.tktchurch.com/v1/livestreams" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
-H "Content-Type: application/json" \
-d '{
"title": "Sunday Service",
"description": "Join us for our weekly Sunday service",
"youtubeUrl": "https://youtube.com/watch?v=abc123",
"scheduledStartTime": "2024-01-21T10:00:00Z",
"tags": ["sunday-service", "worship"],
"thumbnailUrl": "https://example.com/thumbnail.jpg"
}'
const createLivestream = async (accessToken, livestream) => {
const response = await fetch(
'https://api.tktchurch.com/v1/livestreams',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(livestream)
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.reason || 'Failed to create livestream');
}
return response.json();
};
// Usage
try {
const livestream = await createLivestream(
'eyJhbGciOiJIUzI1NiIs...',
{
title: 'Sunday Service',
description: 'Join us for our weekly Sunday service',
youtubeUrl: 'https://youtube.com/watch?v=abc123',
scheduledStartTime: '2024-01-21T10:00:00Z',
tags: ['sunday-service', 'worship'],
thumbnailUrl: 'https://example.com/thumbnail.jpg'
}
);
console.log('Created livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
struct CreateLivestreamRequest: Codable {
let title: String
let description: String
let youtubeUrl: String?
let customStreamUrl: String?
let scheduledStartTime: String?
let tags: [String]
let thumbnailUrl: String?
let thumbnailId: UUID?
}
func createLivestream(
accessToken: String,
request: CreateLivestreamRequest
) async throws -> Livestream {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/livestreams")!)
urlRequest.httpMethod = "POST"
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.httpBody = try JSONEncoder().encode(request)
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 200 {
throw URLError(.badServerResponse)
}
return try JSONDecoder().decode(Livestream.self, from: data)
}
// Usage
do {
let request = CreateLivestreamRequest(
title: "Sunday Service",
description: "Join us for our weekly Sunday service",
youtubeUrl: "https://youtube.com/watch?v=abc123",
customStreamUrl: nil,
scheduledStartTime: "2024-01-21T10:00:00Z",
tags: ["sunday-service", "worship"],
thumbnailUrl: "https://example.com/thumbnail.jpg",
thumbnailId: nil
)
let livestream = try await createLivestream(
accessToken: "eyJhbGciOiJIUzI1NiIs...",
request: request
)
print("Created livestream:", livestream)
} catch {
print("Error:", error)
}
data class CreateLivestreamRequest(
val title: String,
val description: String,
val youtubeUrl: String? = null,
val customStreamUrl: String? = null,
val scheduledStartTime: String? = null,
val tags: List<String>,
val thumbnailUrl: String? = null,
val thumbnailId: UUID? = null
)
suspend fun createLivestream(
accessToken: String,
request: CreateLivestreamRequest
): Livestream {
val requestBody = Json.encodeToString(request)
val httpRequest = Request.Builder()
.url("https://api.tktchurch.com/v1/livestreams")
.post(RequestBody.create(MediaType.parse("application/json"), requestBody))
.header("Authorization", "Bearer $accessToken")
.build()
return withContext(Dispatchers.IO) {
client.newCall(httpRequest).execute().use { response ->
if (!response.isSuccessful) {
throw IOException("Unexpected response ${response.code}")
}
val body = response.body?.string() ?: throw IOException("Empty response")
Json.decodeFromString<Livestream>(body)
}
}
}
// Usage
try {
val request = CreateLivestreamRequest(
title = "Sunday Service",
description = "Join us for our weekly Sunday service",
youtubeUrl = "https://youtube.com/watch?v=abc123",
scheduledStartTime = "2024-01-21T10:00:00Z",
tags = listOf("sunday-service", "worship"),
thumbnailUrl = "https://example.com/thumbnail.jpg"
)
val livestream = createLivestream(
"eyJhbGciOiJIUzI1NiIs...",
request
)
println("Created livestream: $livestream")
} catch (e: Exception) {
println("Error: ${e.message}")
}
interface CreateLivestreamRequest {
title: string;
description: string;
youtubeUrl?: string;
customStreamUrl?: string;
scheduledStartTime?: string;
tags: string[];
thumbnailUrl?: string;
thumbnailId?: string;
}
const createLivestream = async (
accessToken: string,
request: CreateLivestreamRequest
): Promise<Livestream> => {
try {
const response = await axios.post<Livestream>(
'https://api.tktchurch.com/v1/livestreams',
request,
{
headers: {
'Authorization': `Bearer ${accessToken}`
},
}
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.reason || 'Failed to create livestream');
}
throw error;
}
};
// Usage
try {
const livestream = await createLivestream(
'eyJhbGciOiJIUzI1NiIs...',
{
title: 'Sunday Service',
description: 'Join us for our weekly Sunday service',
youtubeUrl: 'https://youtube.com/watch?v=abc123',
scheduledStartTime: '2024-01-21T10:00:00Z',
tags: ['sunday-service', 'worship'],
thumbnailUrl: 'https://example.com/thumbnail.jpg'
}
);
console.log('Created livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Sunday Service",
"description": "Join us for our weekly Sunday service",
"youtubeUrl": "https://youtube.com/watch?v=abc123",
"customStreamUrl": null,
"status": "scheduled",
"scheduledStartTime": "2024-01-21T10:00:00Z",
"actualStartTime": null,
"endTime": null,
"tags": ["sunday-service", "worship"],
"thumbnailUrl": "https://example.com/thumbnail.jpg",
"thumbnail": null,
"createdByUserId": "123e4567-e89b-12d3-a456-426614174002",
"updatedByUserId": "123e4567-e89b-12d3-a456-426614174002",
"createdAt": "2024-01-20T15:00:00Z",
"updatedAt": "2024-01-20T15:00:00Z"
}
{
"error": {
"status": 400,
"reason": "Title is required"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 403,
"reason": "Missing required permission: createLivestream"
}
}
Livestreams
Create Livestream
Create a new livestream
POST
/
livestreams
curl -X POST "https://api.tktchurch.com/v1/livestreams" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
-H "Content-Type: application/json" \
-d '{
"title": "Sunday Service",
"description": "Join us for our weekly Sunday service",
"youtubeUrl": "https://youtube.com/watch?v=abc123",
"scheduledStartTime": "2024-01-21T10:00:00Z",
"tags": ["sunday-service", "worship"],
"thumbnailUrl": "https://example.com/thumbnail.jpg"
}'
const createLivestream = async (accessToken, livestream) => {
const response = await fetch(
'https://api.tktchurch.com/v1/livestreams',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(livestream)
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.reason || 'Failed to create livestream');
}
return response.json();
};
// Usage
try {
const livestream = await createLivestream(
'eyJhbGciOiJIUzI1NiIs...',
{
title: 'Sunday Service',
description: 'Join us for our weekly Sunday service',
youtubeUrl: 'https://youtube.com/watch?v=abc123',
scheduledStartTime: '2024-01-21T10:00:00Z',
tags: ['sunday-service', 'worship'],
thumbnailUrl: 'https://example.com/thumbnail.jpg'
}
);
console.log('Created livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
struct CreateLivestreamRequest: Codable {
let title: String
let description: String
let youtubeUrl: String?
let customStreamUrl: String?
let scheduledStartTime: String?
let tags: [String]
let thumbnailUrl: String?
let thumbnailId: UUID?
}
func createLivestream(
accessToken: String,
request: CreateLivestreamRequest
) async throws -> Livestream {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/livestreams")!)
urlRequest.httpMethod = "POST"
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.httpBody = try JSONEncoder().encode(request)
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 200 {
throw URLError(.badServerResponse)
}
return try JSONDecoder().decode(Livestream.self, from: data)
}
// Usage
do {
let request = CreateLivestreamRequest(
title: "Sunday Service",
description: "Join us for our weekly Sunday service",
youtubeUrl: "https://youtube.com/watch?v=abc123",
customStreamUrl: nil,
scheduledStartTime: "2024-01-21T10:00:00Z",
tags: ["sunday-service", "worship"],
thumbnailUrl: "https://example.com/thumbnail.jpg",
thumbnailId: nil
)
let livestream = try await createLivestream(
accessToken: "eyJhbGciOiJIUzI1NiIs...",
request: request
)
print("Created livestream:", livestream)
} catch {
print("Error:", error)
}
data class CreateLivestreamRequest(
val title: String,
val description: String,
val youtubeUrl: String? = null,
val customStreamUrl: String? = null,
val scheduledStartTime: String? = null,
val tags: List<String>,
val thumbnailUrl: String? = null,
val thumbnailId: UUID? = null
)
suspend fun createLivestream(
accessToken: String,
request: CreateLivestreamRequest
): Livestream {
val requestBody = Json.encodeToString(request)
val httpRequest = Request.Builder()
.url("https://api.tktchurch.com/v1/livestreams")
.post(RequestBody.create(MediaType.parse("application/json"), requestBody))
.header("Authorization", "Bearer $accessToken")
.build()
return withContext(Dispatchers.IO) {
client.newCall(httpRequest).execute().use { response ->
if (!response.isSuccessful) {
throw IOException("Unexpected response ${response.code}")
}
val body = response.body?.string() ?: throw IOException("Empty response")
Json.decodeFromString<Livestream>(body)
}
}
}
// Usage
try {
val request = CreateLivestreamRequest(
title = "Sunday Service",
description = "Join us for our weekly Sunday service",
youtubeUrl = "https://youtube.com/watch?v=abc123",
scheduledStartTime = "2024-01-21T10:00:00Z",
tags = listOf("sunday-service", "worship"),
thumbnailUrl = "https://example.com/thumbnail.jpg"
)
val livestream = createLivestream(
"eyJhbGciOiJIUzI1NiIs...",
request
)
println("Created livestream: $livestream")
} catch (e: Exception) {
println("Error: ${e.message}")
}
interface CreateLivestreamRequest {
title: string;
description: string;
youtubeUrl?: string;
customStreamUrl?: string;
scheduledStartTime?: string;
tags: string[];
thumbnailUrl?: string;
thumbnailId?: string;
}
const createLivestream = async (
accessToken: string,
request: CreateLivestreamRequest
): Promise<Livestream> => {
try {
const response = await axios.post<Livestream>(
'https://api.tktchurch.com/v1/livestreams',
request,
{
headers: {
'Authorization': `Bearer ${accessToken}`
},
}
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.reason || 'Failed to create livestream');
}
throw error;
}
};
// Usage
try {
const livestream = await createLivestream(
'eyJhbGciOiJIUzI1NiIs...',
{
title: 'Sunday Service',
description: 'Join us for our weekly Sunday service',
youtubeUrl: 'https://youtube.com/watch?v=abc123',
scheduledStartTime: '2024-01-21T10:00:00Z',
tags: ['sunday-service', 'worship'],
thumbnailUrl: 'https://example.com/thumbnail.jpg'
}
);
console.log('Created livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Sunday Service",
"description": "Join us for our weekly Sunday service",
"youtubeUrl": "https://youtube.com/watch?v=abc123",
"customStreamUrl": null,
"status": "scheduled",
"scheduledStartTime": "2024-01-21T10:00:00Z",
"actualStartTime": null,
"endTime": null,
"tags": ["sunday-service", "worship"],
"thumbnailUrl": "https://example.com/thumbnail.jpg",
"thumbnail": null,
"createdByUserId": "123e4567-e89b-12d3-a456-426614174002",
"updatedByUserId": "123e4567-e89b-12d3-a456-426614174002",
"createdAt": "2024-01-20T15:00:00Z",
"updatedAt": "2024-01-20T15:00:00Z"
}
{
"error": {
"status": 400,
"reason": "Title is required"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 403,
"reason": "Missing required permission: createLivestream"
}
}
This endpoint requires authentication and the
createLivestream permission.Request Body
string
required
Title of the livestream
string
required
Description of the livestream
string
YouTube URL for the livestream
string
Custom streaming URL
string
Scheduled start time in ISO 8601 format
array
required
Array of tags associated with the livestream
string
URL of the livestream thumbnail
string
UUID of the uploaded thumbnail file
Response
Returns the created livestream object.string
Livestream’s unique identifier (UUID)
string
Title of the livestream
string
Description of the livestream
string
YouTube URL for the livestream
string
Custom streaming URL
string
Current status of the livestream (defaults to “scheduled”)
string
Scheduled start time in ISO 8601 format
array
Array of tags associated with the livestream
string
URL of the livestream thumbnail
object
string
UUID of the user who created the livestream
string
UUID of the user who last updated the livestream
string
Creation timestamp in ISO 8601 format
string
Last update timestamp in ISO 8601 format
Error Responses
object
Common error cases:
- 400 Bad Request: Invalid request body
- 401 Unauthorized: Missing or invalid access token
- 403 Forbidden: Missing required permission
curl -X POST "https://api.tktchurch.com/v1/livestreams" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
-H "Content-Type: application/json" \
-d '{
"title": "Sunday Service",
"description": "Join us for our weekly Sunday service",
"youtubeUrl": "https://youtube.com/watch?v=abc123",
"scheduledStartTime": "2024-01-21T10:00:00Z",
"tags": ["sunday-service", "worship"],
"thumbnailUrl": "https://example.com/thumbnail.jpg"
}'
const createLivestream = async (accessToken, livestream) => {
const response = await fetch(
'https://api.tktchurch.com/v1/livestreams',
{
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(livestream)
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.reason || 'Failed to create livestream');
}
return response.json();
};
// Usage
try {
const livestream = await createLivestream(
'eyJhbGciOiJIUzI1NiIs...',
{
title: 'Sunday Service',
description: 'Join us for our weekly Sunday service',
youtubeUrl: 'https://youtube.com/watch?v=abc123',
scheduledStartTime: '2024-01-21T10:00:00Z',
tags: ['sunday-service', 'worship'],
thumbnailUrl: 'https://example.com/thumbnail.jpg'
}
);
console.log('Created livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
struct CreateLivestreamRequest: Codable {
let title: String
let description: String
let youtubeUrl: String?
let customStreamUrl: String?
let scheduledStartTime: String?
let tags: [String]
let thumbnailUrl: String?
let thumbnailId: UUID?
}
func createLivestream(
accessToken: String,
request: CreateLivestreamRequest
) async throws -> Livestream {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/livestreams")!)
urlRequest.httpMethod = "POST"
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.httpBody = try JSONEncoder().encode(request)
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 200 {
throw URLError(.badServerResponse)
}
return try JSONDecoder().decode(Livestream.self, from: data)
}
// Usage
do {
let request = CreateLivestreamRequest(
title: "Sunday Service",
description: "Join us for our weekly Sunday service",
youtubeUrl: "https://youtube.com/watch?v=abc123",
customStreamUrl: nil,
scheduledStartTime: "2024-01-21T10:00:00Z",
tags: ["sunday-service", "worship"],
thumbnailUrl: "https://example.com/thumbnail.jpg",
thumbnailId: nil
)
let livestream = try await createLivestream(
accessToken: "eyJhbGciOiJIUzI1NiIs...",
request: request
)
print("Created livestream:", livestream)
} catch {
print("Error:", error)
}
data class CreateLivestreamRequest(
val title: String,
val description: String,
val youtubeUrl: String? = null,
val customStreamUrl: String? = null,
val scheduledStartTime: String? = null,
val tags: List<String>,
val thumbnailUrl: String? = null,
val thumbnailId: UUID? = null
)
suspend fun createLivestream(
accessToken: String,
request: CreateLivestreamRequest
): Livestream {
val requestBody = Json.encodeToString(request)
val httpRequest = Request.Builder()
.url("https://api.tktchurch.com/v1/livestreams")
.post(RequestBody.create(MediaType.parse("application/json"), requestBody))
.header("Authorization", "Bearer $accessToken")
.build()
return withContext(Dispatchers.IO) {
client.newCall(httpRequest).execute().use { response ->
if (!response.isSuccessful) {
throw IOException("Unexpected response ${response.code}")
}
val body = response.body?.string() ?: throw IOException("Empty response")
Json.decodeFromString<Livestream>(body)
}
}
}
// Usage
try {
val request = CreateLivestreamRequest(
title = "Sunday Service",
description = "Join us for our weekly Sunday service",
youtubeUrl = "https://youtube.com/watch?v=abc123",
scheduledStartTime = "2024-01-21T10:00:00Z",
tags = listOf("sunday-service", "worship"),
thumbnailUrl = "https://example.com/thumbnail.jpg"
)
val livestream = createLivestream(
"eyJhbGciOiJIUzI1NiIs...",
request
)
println("Created livestream: $livestream")
} catch (e: Exception) {
println("Error: ${e.message}")
}
interface CreateLivestreamRequest {
title: string;
description: string;
youtubeUrl?: string;
customStreamUrl?: string;
scheduledStartTime?: string;
tags: string[];
thumbnailUrl?: string;
thumbnailId?: string;
}
const createLivestream = async (
accessToken: string,
request: CreateLivestreamRequest
): Promise<Livestream> => {
try {
const response = await axios.post<Livestream>(
'https://api.tktchurch.com/v1/livestreams',
request,
{
headers: {
'Authorization': `Bearer ${accessToken}`
},
}
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.reason || 'Failed to create livestream');
}
throw error;
}
};
// Usage
try {
const livestream = await createLivestream(
'eyJhbGciOiJIUzI1NiIs...',
{
title: 'Sunday Service',
description: 'Join us for our weekly Sunday service',
youtubeUrl: 'https://youtube.com/watch?v=abc123',
scheduledStartTime: '2024-01-21T10:00:00Z',
tags: ['sunday-service', 'worship'],
thumbnailUrl: 'https://example.com/thumbnail.jpg'
}
);
console.log('Created livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Sunday Service",
"description": "Join us for our weekly Sunday service",
"youtubeUrl": "https://youtube.com/watch?v=abc123",
"customStreamUrl": null,
"status": "scheduled",
"scheduledStartTime": "2024-01-21T10:00:00Z",
"actualStartTime": null,
"endTime": null,
"tags": ["sunday-service", "worship"],
"thumbnailUrl": "https://example.com/thumbnail.jpg",
"thumbnail": null,
"createdByUserId": "123e4567-e89b-12d3-a456-426614174002",
"updatedByUserId": "123e4567-e89b-12d3-a456-426614174002",
"createdAt": "2024-01-20T15:00:00Z",
"updatedAt": "2024-01-20T15:00:00Z"
}
{
"error": {
"status": 400,
"reason": "Title is required"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 403,
"reason": "Missing required permission: createLivestream"
}
}
