curl -X PUT "https://api.tktchurch.com/v1/events/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"title": "Sunday Worship Service",
"description": "Weekly Sunday worship service",
"startDate": "2024-01-07T10:00:00Z",
"endDate": "2024-01-07T12:00:00Z",
"timezone": "America/New_York",
"location": {
"name": "Main Sanctuary",
"address": "123 Church Street",
"city": "New York",
"state": "NY",
"country": "USA",
"postalCode": "10001",
"coordinates": {
"latitude": 40.7128,
"longitude": -74.0060
}
},
"type": "service",
"recurrence": {
"frequency": "weekly",
"interval": 1,
"byDay": ["SU"]
},
"reminders": [
{
"type": "email",
"minutes": 1440
},
{
"type": "notification",
"minutes": 60
}
],
"tags": ["worship", "sunday-service"],
"maxCapacity": 500,
"requiresGeolocation": true,
"geofenceRadius": 100
}'
const updateEvent = async (accessToken, eventId, eventData) => {
const response = await fetch(
`https://api.tktchurch.com/v1/events/${eventId}`,
{
method: 'PUT',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(eventData)
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.json();
};
// Usage
try {
const event = await updateEvent(
accessToken,
'123e4567-e89b-12d3-a456-426614174000',
{
title: 'Sunday Worship Service',
description: 'Weekly Sunday worship service',
startDate: '2024-01-07T10:00:00Z',
endDate: '2024-01-07T12:00:00Z',
timezone: 'America/New_York',
location: {
name: 'Main Sanctuary',
address: '123 Church Street',
city: 'New York',
state: 'NY',
country: 'USA',
postalCode: '10001',
coordinates: {
latitude: 40.7128,
longitude: -74.0060
}
},
type: 'service',
recurrence: {
frequency: 'weekly',
interval: 1,
byDay: ['SU']
},
reminders: [
{
type: 'email',
minutes: 1440
},
{
type: 'notification',
minutes: 60
}
],
tags: ['worship', 'sunday-service'],
maxCapacity: 500,
requiresGeolocation: true,
geofenceRadius: 100
}
);
console.log('Updated event:', event);
} catch (error) {
console.error('Error:', error);
}
struct UpdateEventRequest: Codable {
let title: String
let description: String
let startDate: Date
let endDate: Date
let timezone: String
let location: Location
let type: String
let recurrence: Recurrence?
let reminders: [Reminder]
let tags: [String]
let maxCapacity: Int?
let requiresGeolocation: Bool
let geofenceRadius: Double?
}
func updateEvent(accessToken: String, eventId: UUID, event: UpdateEventRequest) async throws -> Event {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/events/\(eventId)")!)
urlRequest.httpMethod = "PUT"
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.httpBody = try JSONEncoder().encode(event)
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 200 {
let error = try JSONDecoder().decode(ErrorResponse.self, from: data)
throw error
}
return try JSONDecoder().decode(Event.self, from: data)
}
// Usage
do {
let event = try await updateEvent(
accessToken: accessToken,
eventId: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!,
event: UpdateEventRequest(
title: "Sunday Worship Service",
description: "Weekly Sunday worship service",
startDate: Date(),
endDate: Date().addingTimeInterval(7200),
timezone: "America/New_York",
location: Location(
name: "Main Sanctuary",
address: "123 Church Street",
city: "New York",
state: "NY",
country: "USA",
postalCode: "10001",
coordinates: Coordinates(
latitude: 40.7128,
longitude: -74.0060
)
),
type: "service",
recurrence: Recurrence(
frequency: "weekly",
interval: 1,
byDay: ["SU"]
),
reminders: [
Reminder(type: "email", minutes: 1440),
Reminder(type: "notification", minutes: 60)
],
tags: ["worship", "sunday-service"],
maxCapacity: 500,
requiresGeolocation: true,
geofenceRadius: 100
)
)
print("Updated event:", event)
} catch {
print("Error:", error)
}
data class UpdateEventRequest(
val title: String,
val description: String,
val startDate: Date,
val endDate: Date,
val timezone: String,
val location: Location,
val type: String,
val recurrence: Recurrence?,
val reminders: List<Reminder>,
val tags: List<String>,
val maxCapacity: Int?,
val requiresGeolocation: Boolean,
val geofenceRadius: Double?
)
suspend fun updateEvent(accessToken: String, eventId: String, event: UpdateEventRequest): Event {
val client = OkHttpClient()
val requestBody = Json.encodeToString(event)
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/events/$eventId")
.put(RequestBody.create(MediaType.parse("application/json"), requestBody))
.header("Authorization", "Bearer $accessToken")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Failed to update event")
}
return response.body?.string()?.fromJson<Event>()
?: throw Exception("Empty response")
}
}
// Usage
try {
val event = updateEvent(
accessToken = accessToken,
eventId = "123e4567-e89b-12d3-a456-426614174000",
event = UpdateEventRequest(
title = "Sunday Worship Service",
description = "Weekly Sunday worship service",
startDate = Date(),
endDate = Date().apply { time += 7200000 },
timezone = "America/New_York",
location = Location(
name = "Main Sanctuary",
address = "123 Church Street",
city = "New York",
state = "NY",
country = "USA",
postalCode = "10001",
coordinates = Coordinates(
latitude = 40.7128,
longitude = -74.0060
)
),
type = "service",
recurrence = Recurrence(
frequency = "weekly",
interval = 1,
byDay = listOf("SU")
),
reminders = listOf(
Reminder(type = "email", minutes = 1440),
Reminder(type = "notification", minutes = 60)
),
tags = listOf("worship", "sunday-service"),
maxCapacity = 500,
requiresGeolocation = true,
geofenceRadius = 100.0
)
)
println("Updated event: $event")
} catch (e: Exception) {
println("Error: ${e.message}")
}
import axios from 'axios';
interface UpdateEventRequest {
title: string;
description: string;
startDate: string;
endDate: string;
timezone: string;
location: {
name: string;
address: string;
city: string;
state: string;
country: string;
postalCode: string;
coordinates: {
latitude: number;
longitude: number;
};
virtualMeetingUrl?: string;
};
type: 'service' | 'meeting' | 'concert' | 'workshop' | 'conference' | 'social' | 'other';
recurrence?: {
frequency: 'daily' | 'weekly' | 'monthly' | 'yearly';
interval: number;
until?: string;
count?: number;
byDay?: string[];
byMonth?: number[];
byMonthDay?: number[];
excludeDates?: string[];
};
reminders: Array<{
type: 'email' | 'notification' | 'sms';
minutes: number;
}>;
tags: string[];
maxCapacity?: number;
requiresGeolocation: boolean;
geofenceRadius?: number;
thumbnailId?: string;
}
const updateEvent = async (
accessToken: string,
eventId: string,
event: UpdateEventRequest
): Promise<Event> => {
try {
const response = await axios.put(
`https://api.tktchurch.com/v1/events/${eventId}`,
event,
{
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
}
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Failed to update event');
}
throw error;
}
};
// Usage
try {
const event = await updateEvent(
accessToken,
'123e4567-e89b-12d3-a456-426614174000',
{
title: 'Sunday Worship Service',
description: 'Weekly Sunday worship service',
startDate: '2024-01-07T10:00:00Z',
endDate: '2024-01-07T12:00:00Z',
timezone: 'America/New_York',
location: {
name: 'Main Sanctuary',
address: '123 Church Street',
city: 'New York',
state: 'NY',
country: 'USA',
postalCode: '10001',
coordinates: {
latitude: 40.7128,
longitude: -74.0060
}
},
type: 'service',
recurrence: {
frequency: 'weekly',
interval: 1,
byDay: ['SU']
},
reminders: [
{
type: 'email',
minutes: 1440
},
{
type: 'notification',
minutes: 60
}
],
tags: ['worship', 'sunday-service'],
maxCapacity: 500,
requiresGeolocation: true,
geofenceRadius: 100
}
);
console.log('Updated event:', event);
} catch (error) {
console.error('Error:', error);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Sunday Worship Service",
"description": "Weekly Sunday worship service",
"startDate": "2024-01-07T10:00:00Z",
"endDate": "2024-01-07T12:00:00Z",
"timezone": "America/New_York",
"location": {
"name": "Main Sanctuary",
"address": "123 Church Street",
"city": "New York",
"state": "NY",
"country": "USA",
"postalCode": "10001",
"coordinates": {
"latitude": 40.7128,
"longitude": -74.0060
}
},
"type": "service",
"status": "scheduled",
"recurrence": {
"frequency": "weekly",
"interval": 1,
"byDay": ["SU"]
},
"reminders": [
{
"type": "email",
"minutes": 1440
},
{
"type": "notification",
"minutes": 60
}
],
"calendarLinks": {
"google": "https://calendar.google.com/...",
"apple": "webcal://...",
"outlook": "https://outlook.office.com/...",
"yahoo": "https://calendar.yahoo.com/...",
"ics": "https://api.tktchurch.com/v1/events/123/calendar.ics"
},
"tags": ["worship", "sunday-service"],
"maxCapacity": 500,
"requiresGeolocation": true,
"geofenceRadius": 100,
"createdByUserId": "456e7890-f12g-34h5-i678-912345678901",
"updatedByUserId": "456e7890-f12g-34h5-i678-912345678901",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
{
"error": {
"status": 400,
"reason": "Invalid ISO8601 format for startDate"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 403,
"reason": "Missing required permission: updateEvent"
}
}
{
"error": {
"status": 404,
"reason": "Event not found"
}
}
Events
Update Event
Update an existing event
PUT
/
events
/
{id}
curl -X PUT "https://api.tktchurch.com/v1/events/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"title": "Sunday Worship Service",
"description": "Weekly Sunday worship service",
"startDate": "2024-01-07T10:00:00Z",
"endDate": "2024-01-07T12:00:00Z",
"timezone": "America/New_York",
"location": {
"name": "Main Sanctuary",
"address": "123 Church Street",
"city": "New York",
"state": "NY",
"country": "USA",
"postalCode": "10001",
"coordinates": {
"latitude": 40.7128,
"longitude": -74.0060
}
},
"type": "service",
"recurrence": {
"frequency": "weekly",
"interval": 1,
"byDay": ["SU"]
},
"reminders": [
{
"type": "email",
"minutes": 1440
},
{
"type": "notification",
"minutes": 60
}
],
"tags": ["worship", "sunday-service"],
"maxCapacity": 500,
"requiresGeolocation": true,
"geofenceRadius": 100
}'
const updateEvent = async (accessToken, eventId, eventData) => {
const response = await fetch(
`https://api.tktchurch.com/v1/events/${eventId}`,
{
method: 'PUT',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(eventData)
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.json();
};
// Usage
try {
const event = await updateEvent(
accessToken,
'123e4567-e89b-12d3-a456-426614174000',
{
title: 'Sunday Worship Service',
description: 'Weekly Sunday worship service',
startDate: '2024-01-07T10:00:00Z',
endDate: '2024-01-07T12:00:00Z',
timezone: 'America/New_York',
location: {
name: 'Main Sanctuary',
address: '123 Church Street',
city: 'New York',
state: 'NY',
country: 'USA',
postalCode: '10001',
coordinates: {
latitude: 40.7128,
longitude: -74.0060
}
},
type: 'service',
recurrence: {
frequency: 'weekly',
interval: 1,
byDay: ['SU']
},
reminders: [
{
type: 'email',
minutes: 1440
},
{
type: 'notification',
minutes: 60
}
],
tags: ['worship', 'sunday-service'],
maxCapacity: 500,
requiresGeolocation: true,
geofenceRadius: 100
}
);
console.log('Updated event:', event);
} catch (error) {
console.error('Error:', error);
}
struct UpdateEventRequest: Codable {
let title: String
let description: String
let startDate: Date
let endDate: Date
let timezone: String
let location: Location
let type: String
let recurrence: Recurrence?
let reminders: [Reminder]
let tags: [String]
let maxCapacity: Int?
let requiresGeolocation: Bool
let geofenceRadius: Double?
}
func updateEvent(accessToken: String, eventId: UUID, event: UpdateEventRequest) async throws -> Event {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/events/\(eventId)")!)
urlRequest.httpMethod = "PUT"
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.httpBody = try JSONEncoder().encode(event)
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 200 {
let error = try JSONDecoder().decode(ErrorResponse.self, from: data)
throw error
}
return try JSONDecoder().decode(Event.self, from: data)
}
// Usage
do {
let event = try await updateEvent(
accessToken: accessToken,
eventId: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!,
event: UpdateEventRequest(
title: "Sunday Worship Service",
description: "Weekly Sunday worship service",
startDate: Date(),
endDate: Date().addingTimeInterval(7200),
timezone: "America/New_York",
location: Location(
name: "Main Sanctuary",
address: "123 Church Street",
city: "New York",
state: "NY",
country: "USA",
postalCode: "10001",
coordinates: Coordinates(
latitude: 40.7128,
longitude: -74.0060
)
),
type: "service",
recurrence: Recurrence(
frequency: "weekly",
interval: 1,
byDay: ["SU"]
),
reminders: [
Reminder(type: "email", minutes: 1440),
Reminder(type: "notification", minutes: 60)
],
tags: ["worship", "sunday-service"],
maxCapacity: 500,
requiresGeolocation: true,
geofenceRadius: 100
)
)
print("Updated event:", event)
} catch {
print("Error:", error)
}
data class UpdateEventRequest(
val title: String,
val description: String,
val startDate: Date,
val endDate: Date,
val timezone: String,
val location: Location,
val type: String,
val recurrence: Recurrence?,
val reminders: List<Reminder>,
val tags: List<String>,
val maxCapacity: Int?,
val requiresGeolocation: Boolean,
val geofenceRadius: Double?
)
suspend fun updateEvent(accessToken: String, eventId: String, event: UpdateEventRequest): Event {
val client = OkHttpClient()
val requestBody = Json.encodeToString(event)
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/events/$eventId")
.put(RequestBody.create(MediaType.parse("application/json"), requestBody))
.header("Authorization", "Bearer $accessToken")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Failed to update event")
}
return response.body?.string()?.fromJson<Event>()
?: throw Exception("Empty response")
}
}
// Usage
try {
val event = updateEvent(
accessToken = accessToken,
eventId = "123e4567-e89b-12d3-a456-426614174000",
event = UpdateEventRequest(
title = "Sunday Worship Service",
description = "Weekly Sunday worship service",
startDate = Date(),
endDate = Date().apply { time += 7200000 },
timezone = "America/New_York",
location = Location(
name = "Main Sanctuary",
address = "123 Church Street",
city = "New York",
state = "NY",
country = "USA",
postalCode = "10001",
coordinates = Coordinates(
latitude = 40.7128,
longitude = -74.0060
)
),
type = "service",
recurrence = Recurrence(
frequency = "weekly",
interval = 1,
byDay = listOf("SU")
),
reminders = listOf(
Reminder(type = "email", minutes = 1440),
Reminder(type = "notification", minutes = 60)
),
tags = listOf("worship", "sunday-service"),
maxCapacity = 500,
requiresGeolocation = true,
geofenceRadius = 100.0
)
)
println("Updated event: $event")
} catch (e: Exception) {
println("Error: ${e.message}")
}
import axios from 'axios';
interface UpdateEventRequest {
title: string;
description: string;
startDate: string;
endDate: string;
timezone: string;
location: {
name: string;
address: string;
city: string;
state: string;
country: string;
postalCode: string;
coordinates: {
latitude: number;
longitude: number;
};
virtualMeetingUrl?: string;
};
type: 'service' | 'meeting' | 'concert' | 'workshop' | 'conference' | 'social' | 'other';
recurrence?: {
frequency: 'daily' | 'weekly' | 'monthly' | 'yearly';
interval: number;
until?: string;
count?: number;
byDay?: string[];
byMonth?: number[];
byMonthDay?: number[];
excludeDates?: string[];
};
reminders: Array<{
type: 'email' | 'notification' | 'sms';
minutes: number;
}>;
tags: string[];
maxCapacity?: number;
requiresGeolocation: boolean;
geofenceRadius?: number;
thumbnailId?: string;
}
const updateEvent = async (
accessToken: string,
eventId: string,
event: UpdateEventRequest
): Promise<Event> => {
try {
const response = await axios.put(
`https://api.tktchurch.com/v1/events/${eventId}`,
event,
{
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
}
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Failed to update event');
}
throw error;
}
};
// Usage
try {
const event = await updateEvent(
accessToken,
'123e4567-e89b-12d3-a456-426614174000',
{
title: 'Sunday Worship Service',
description: 'Weekly Sunday worship service',
startDate: '2024-01-07T10:00:00Z',
endDate: '2024-01-07T12:00:00Z',
timezone: 'America/New_York',
location: {
name: 'Main Sanctuary',
address: '123 Church Street',
city: 'New York',
state: 'NY',
country: 'USA',
postalCode: '10001',
coordinates: {
latitude: 40.7128,
longitude: -74.0060
}
},
type: 'service',
recurrence: {
frequency: 'weekly',
interval: 1,
byDay: ['SU']
},
reminders: [
{
type: 'email',
minutes: 1440
},
{
type: 'notification',
minutes: 60
}
],
tags: ['worship', 'sunday-service'],
maxCapacity: 500,
requiresGeolocation: true,
geofenceRadius: 100
}
);
console.log('Updated event:', event);
} catch (error) {
console.error('Error:', error);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Sunday Worship Service",
"description": "Weekly Sunday worship service",
"startDate": "2024-01-07T10:00:00Z",
"endDate": "2024-01-07T12:00:00Z",
"timezone": "America/New_York",
"location": {
"name": "Main Sanctuary",
"address": "123 Church Street",
"city": "New York",
"state": "NY",
"country": "USA",
"postalCode": "10001",
"coordinates": {
"latitude": 40.7128,
"longitude": -74.0060
}
},
"type": "service",
"status": "scheduled",
"recurrence": {
"frequency": "weekly",
"interval": 1,
"byDay": ["SU"]
},
"reminders": [
{
"type": "email",
"minutes": 1440
},
{
"type": "notification",
"minutes": 60
}
],
"calendarLinks": {
"google": "https://calendar.google.com/...",
"apple": "webcal://...",
"outlook": "https://outlook.office.com/...",
"yahoo": "https://calendar.yahoo.com/...",
"ics": "https://api.tktchurch.com/v1/events/123/calendar.ics"
},
"tags": ["worship", "sunday-service"],
"maxCapacity": 500,
"requiresGeolocation": true,
"geofenceRadius": 100,
"createdByUserId": "456e7890-f12g-34h5-i678-912345678901",
"updatedByUserId": "456e7890-f12g-34h5-i678-912345678901",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
{
"error": {
"status": 400,
"reason": "Invalid ISO8601 format for startDate"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 403,
"reason": "Missing required permission: updateEvent"
}
}
{
"error": {
"status": 404,
"reason": "Event not found"
}
}
This endpoint requires authentication and the
updateEvent permission.Path Parameters
string
required
The unique identifier (UUID) of the event to update
Request Body
string
required
Event title
string
required
Event description
string
required
Event start date and time in ISO 8601 format
string
required
Event end date and time in ISO 8601 format
string
required
Event timezone (e.g., “America/New_York”)
object
required
Event location details
Show Location Object
Show Location Object
string
required
Event type. One of:
service: Church servicemeeting: Meetingconcert: Concertworkshop: Workshopconference: Conferencesocial: Social eventother: Other event type
string
Event status. One of:
scheduled: Default status for upcoming eventscancelled: Cancelled eventspostponed: Postponed eventsrescheduled: Rescheduled events
object
Event recurrence details
Show Recurrence Object
Show Recurrence Object
string
required
Recurrence frequency. One of:
daily, weekly, monthly, yearlyinteger
required
Interval between occurrences
string
End date for recurrence (ISO 8601)
integer
Number of occurrences
array
Days of week (SU, MO, TU, WE, TH, FR, SA)
array
Months (1-12)
array
Days of month
array
Excluded dates (ISO 8601)
array
array
array
Array of event tags
integer
Maximum number of attendees (if applicable)
boolean
Whether geolocation is required for attendance
number
Geofence radius in meters (if applicable)
string
UUID of the uploaded thumbnail file
Response
Returns the updated event object. See Get Event Details for the response format.Error Responses
object
Common error cases:
- 400 Bad Request: Invalid request body or validation errors
- 401 Unauthorized: Missing or invalid access token
- 403 Forbidden: Insufficient permissions
- 404 Not Found: Event not found
curl -X PUT "https://api.tktchurch.com/v1/events/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{
"title": "Sunday Worship Service",
"description": "Weekly Sunday worship service",
"startDate": "2024-01-07T10:00:00Z",
"endDate": "2024-01-07T12:00:00Z",
"timezone": "America/New_York",
"location": {
"name": "Main Sanctuary",
"address": "123 Church Street",
"city": "New York",
"state": "NY",
"country": "USA",
"postalCode": "10001",
"coordinates": {
"latitude": 40.7128,
"longitude": -74.0060
}
},
"type": "service",
"recurrence": {
"frequency": "weekly",
"interval": 1,
"byDay": ["SU"]
},
"reminders": [
{
"type": "email",
"minutes": 1440
},
{
"type": "notification",
"minutes": 60
}
],
"tags": ["worship", "sunday-service"],
"maxCapacity": 500,
"requiresGeolocation": true,
"geofenceRadius": 100
}'
const updateEvent = async (accessToken, eventId, eventData) => {
const response = await fetch(
`https://api.tktchurch.com/v1/events/${eventId}`,
{
method: 'PUT',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(eventData)
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error.reason);
}
return response.json();
};
// Usage
try {
const event = await updateEvent(
accessToken,
'123e4567-e89b-12d3-a456-426614174000',
{
title: 'Sunday Worship Service',
description: 'Weekly Sunday worship service',
startDate: '2024-01-07T10:00:00Z',
endDate: '2024-01-07T12:00:00Z',
timezone: 'America/New_York',
location: {
name: 'Main Sanctuary',
address: '123 Church Street',
city: 'New York',
state: 'NY',
country: 'USA',
postalCode: '10001',
coordinates: {
latitude: 40.7128,
longitude: -74.0060
}
},
type: 'service',
recurrence: {
frequency: 'weekly',
interval: 1,
byDay: ['SU']
},
reminders: [
{
type: 'email',
minutes: 1440
},
{
type: 'notification',
minutes: 60
}
],
tags: ['worship', 'sunday-service'],
maxCapacity: 500,
requiresGeolocation: true,
geofenceRadius: 100
}
);
console.log('Updated event:', event);
} catch (error) {
console.error('Error:', error);
}
struct UpdateEventRequest: Codable {
let title: String
let description: String
let startDate: Date
let endDate: Date
let timezone: String
let location: Location
let type: String
let recurrence: Recurrence?
let reminders: [Reminder]
let tags: [String]
let maxCapacity: Int?
let requiresGeolocation: Bool
let geofenceRadius: Double?
}
func updateEvent(accessToken: String, eventId: UUID, event: UpdateEventRequest) async throws -> Event {
var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/events/\(eventId)")!)
urlRequest.httpMethod = "PUT"
urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
urlRequest.httpBody = try JSONEncoder().encode(event)
let (data, response) = try await URLSession.shared.data(for: urlRequest)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode != 200 {
let error = try JSONDecoder().decode(ErrorResponse.self, from: data)
throw error
}
return try JSONDecoder().decode(Event.self, from: data)
}
// Usage
do {
let event = try await updateEvent(
accessToken: accessToken,
eventId: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!,
event: UpdateEventRequest(
title: "Sunday Worship Service",
description: "Weekly Sunday worship service",
startDate: Date(),
endDate: Date().addingTimeInterval(7200),
timezone: "America/New_York",
location: Location(
name: "Main Sanctuary",
address: "123 Church Street",
city: "New York",
state: "NY",
country: "USA",
postalCode: "10001",
coordinates: Coordinates(
latitude: 40.7128,
longitude: -74.0060
)
),
type: "service",
recurrence: Recurrence(
frequency: "weekly",
interval: 1,
byDay: ["SU"]
),
reminders: [
Reminder(type: "email", minutes: 1440),
Reminder(type: "notification", minutes: 60)
],
tags: ["worship", "sunday-service"],
maxCapacity: 500,
requiresGeolocation: true,
geofenceRadius: 100
)
)
print("Updated event:", event)
} catch {
print("Error:", error)
}
data class UpdateEventRequest(
val title: String,
val description: String,
val startDate: Date,
val endDate: Date,
val timezone: String,
val location: Location,
val type: String,
val recurrence: Recurrence?,
val reminders: List<Reminder>,
val tags: List<String>,
val maxCapacity: Int?,
val requiresGeolocation: Boolean,
val geofenceRadius: Double?
)
suspend fun updateEvent(accessToken: String, eventId: String, event: UpdateEventRequest): Event {
val client = OkHttpClient()
val requestBody = Json.encodeToString(event)
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/events/$eventId")
.put(RequestBody.create(MediaType.parse("application/json"), requestBody))
.header("Authorization", "Bearer $accessToken")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
val error = response.body?.string()?.fromJson<ErrorResponse>()
throw Exception(error?.reason ?: "Failed to update event")
}
return response.body?.string()?.fromJson<Event>()
?: throw Exception("Empty response")
}
}
// Usage
try {
val event = updateEvent(
accessToken = accessToken,
eventId = "123e4567-e89b-12d3-a456-426614174000",
event = UpdateEventRequest(
title = "Sunday Worship Service",
description = "Weekly Sunday worship service",
startDate = Date(),
endDate = Date().apply { time += 7200000 },
timezone = "America/New_York",
location = Location(
name = "Main Sanctuary",
address = "123 Church Street",
city = "New York",
state = "NY",
country = "USA",
postalCode = "10001",
coordinates = Coordinates(
latitude = 40.7128,
longitude = -74.0060
)
),
type = "service",
recurrence = Recurrence(
frequency = "weekly",
interval = 1,
byDay = listOf("SU")
),
reminders = listOf(
Reminder(type = "email", minutes = 1440),
Reminder(type = "notification", minutes = 60)
),
tags = listOf("worship", "sunday-service"),
maxCapacity = 500,
requiresGeolocation = true,
geofenceRadius = 100.0
)
)
println("Updated event: $event")
} catch (e: Exception) {
println("Error: ${e.message}")
}
import axios from 'axios';
interface UpdateEventRequest {
title: string;
description: string;
startDate: string;
endDate: string;
timezone: string;
location: {
name: string;
address: string;
city: string;
state: string;
country: string;
postalCode: string;
coordinates: {
latitude: number;
longitude: number;
};
virtualMeetingUrl?: string;
};
type: 'service' | 'meeting' | 'concert' | 'workshop' | 'conference' | 'social' | 'other';
recurrence?: {
frequency: 'daily' | 'weekly' | 'monthly' | 'yearly';
interval: number;
until?: string;
count?: number;
byDay?: string[];
byMonth?: number[];
byMonthDay?: number[];
excludeDates?: string[];
};
reminders: Array<{
type: 'email' | 'notification' | 'sms';
minutes: number;
}>;
tags: string[];
maxCapacity?: number;
requiresGeolocation: boolean;
geofenceRadius?: number;
thumbnailId?: string;
}
const updateEvent = async (
accessToken: string,
eventId: string,
event: UpdateEventRequest
): Promise<Event> => {
try {
const response = await axios.put(
`https://api.tktchurch.com/v1/events/${eventId}`,
event,
{
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
}
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
throw new Error(error.response?.data?.error?.reason || 'Failed to update event');
}
throw error;
}
};
// Usage
try {
const event = await updateEvent(
accessToken,
'123e4567-e89b-12d3-a456-426614174000',
{
title: 'Sunday Worship Service',
description: 'Weekly Sunday worship service',
startDate: '2024-01-07T10:00:00Z',
endDate: '2024-01-07T12:00:00Z',
timezone: 'America/New_York',
location: {
name: 'Main Sanctuary',
address: '123 Church Street',
city: 'New York',
state: 'NY',
country: 'USA',
postalCode: '10001',
coordinates: {
latitude: 40.7128,
longitude: -74.0060
}
},
type: 'service',
recurrence: {
frequency: 'weekly',
interval: 1,
byDay: ['SU']
},
reminders: [
{
type: 'email',
minutes: 1440
},
{
type: 'notification',
minutes: 60
}
],
tags: ['worship', 'sunday-service'],
maxCapacity: 500,
requiresGeolocation: true,
geofenceRadius: 100
}
);
console.log('Updated event:', event);
} catch (error) {
console.error('Error:', error);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Sunday Worship Service",
"description": "Weekly Sunday worship service",
"startDate": "2024-01-07T10:00:00Z",
"endDate": "2024-01-07T12:00:00Z",
"timezone": "America/New_York",
"location": {
"name": "Main Sanctuary",
"address": "123 Church Street",
"city": "New York",
"state": "NY",
"country": "USA",
"postalCode": "10001",
"coordinates": {
"latitude": 40.7128,
"longitude": -74.0060
}
},
"type": "service",
"status": "scheduled",
"recurrence": {
"frequency": "weekly",
"interval": 1,
"byDay": ["SU"]
},
"reminders": [
{
"type": "email",
"minutes": 1440
},
{
"type": "notification",
"minutes": 60
}
],
"calendarLinks": {
"google": "https://calendar.google.com/...",
"apple": "webcal://...",
"outlook": "https://outlook.office.com/...",
"yahoo": "https://calendar.yahoo.com/...",
"ics": "https://api.tktchurch.com/v1/events/123/calendar.ics"
},
"tags": ["worship", "sunday-service"],
"maxCapacity": 500,
"requiresGeolocation": true,
"geofenceRadius": 100,
"createdByUserId": "456e7890-f12g-34h5-i678-912345678901",
"updatedByUserId": "456e7890-f12g-34h5-i678-912345678901",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
{
"error": {
"status": 400,
"reason": "Invalid ISO8601 format for startDate"
}
}
{
"error": {
"status": 401,
"reason": "Invalid or expired access token"
}
}
{
"error": {
"status": 403,
"reason": "Missing required permission: updateEvent"
}
}
{
"error": {
"status": 404,
"reason": "Event not found"
}
}
