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

# Calendar Redirects

> Redirect to various calendar services to add the event

These endpoints redirect users to various calendar services to add the event to their calendar.

## Google Calendar

<ParamField path="id" type="string" required>
  The unique identifier (UUID) of the event
</ParamField>

```
GET /events/{id}/calendar/google
```

Redirects to Google Calendar with the event details pre-filled.

## Apple Calendar

<ParamField path="id" type="string" required>
  The unique identifier (UUID) of the event
</ParamField>

```
GET /events/{id}/calendar/apple
```

Redirects to Apple Calendar (webcal://) with the event details.

## Outlook Calendar

<ParamField path="id" type="string" required>
  The unique identifier (UUID) of the event
</ParamField>

```
GET /events/{id}/calendar/outlook
```

Redirects to Outlook Calendar with the event details pre-filled.

## Yahoo Calendar

<ParamField path="id" type="string" required>
  The unique identifier (UUID) of the event
</ParamField>

```
GET /events/{id}/calendar/yahoo
```

Redirects to Yahoo Calendar with the event details pre-filled.

## Error Responses

<ResponseField name="error" type="object">
  Error details when the request fails

  <Expandable title="Error Object">
    <ResponseField name="status" type="integer">
      HTTP status code
    </ResponseField>

    <ResponseField name="reason" type="string">
      Error message explaining why the request failed
    </ResponseField>
  </Expandable>
</ResponseField>

<Note>
  Common error cases:

  * 404 Not Found: Event not found or calendar link not available
</Note>

<RequestExample>
  ```bash Google Calendar theme={null}
  curl -L "https://api.tktchurch.com/v1/events/123e4567-e89b-12d3-a456-426614174000/calendar/google"
  ```

  ```bash Apple Calendar theme={null}
  curl -L "https://api.tktchurch.com/v1/events/123e4567-e89b-12d3-a456-426614174000/calendar/apple"
  ```

  ```bash Outlook Calendar theme={null}
  curl -L "https://api.tktchurch.com/v1/events/123e4567-e89b-12d3-a456-426614174000/calendar/outlook"
  ```

  ```bash Yahoo Calendar theme={null}
  curl -L "https://api.tktchurch.com/v1/events/123e4567-e89b-12d3-a456-426614174000/calendar/yahoo"
  ```

  ```javascript JavaScript theme={null}
  const addToCalendar = async (eventId, service) => {
    window.location.href = `https://api.tktchurch.com/v1/events/${eventId}/calendar/${service}`;
  };

  // Usage
  try {
    // Add to Google Calendar
    await addToCalendar('123e4567-e89b-12d3-a456-426614174000', 'google');
    
    // Add to Apple Calendar
    await addToCalendar('123e4567-e89b-12d3-a456-426614174000', 'apple');
    
    // Add to Outlook Calendar
    await addToCalendar('123e4567-e89b-12d3-a456-426614174000', 'outlook');
    
    // Add to Yahoo Calendar
    await addToCalendar('123e4567-e89b-12d3-a456-426614174000', 'yahoo');
  } catch (error) {
    console.error('Error:', error);
  }
  ```

  ```swift Swift theme={null}
  enum CalendarService: String {
      case google
      case apple
      case outlook
      case yahoo
  }

  func addToCalendar(eventId: UUID, service: CalendarService) {
      if let url = URL(string: "https://api.tktchurch.com/v1/events/\(eventId)/calendar/\(service.rawValue)") {
          UIApplication.shared.open(url)
      }
  }

  // Usage
  let eventId = UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!

  // Add to Google Calendar
  addToCalendar(eventId: eventId, service: .google)

  // Add to Apple Calendar
  addToCalendar(eventId: eventId, service: .apple)

  // Add to Outlook Calendar
  addToCalendar(eventId: eventId, service: .outlook)

  // Add to Yahoo Calendar
  addToCalendar(eventId: eventId, service: .yahoo)
  ```

  ```kotlin Kotlin theme={null}
  enum class CalendarService {
      GOOGLE, APPLE, OUTLOOK, YAHOO
  }

  fun addToCalendar(context: Context, eventId: String, service: CalendarService) {
      val url = "https://api.tktchurch.com/v1/events/$eventId/calendar/${service.name.lowercase()}"
      val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
      context.startActivity(intent)
  }

  // Usage
  val eventId = "123e4567-e89b-12d3-a456-426614174000"

  // Add to Google Calendar
  addToCalendar(context, eventId, CalendarService.GOOGLE)

  // Add to Apple Calendar
  addToCalendar(context, eventId, CalendarService.APPLE)

  // Add to Outlook Calendar
  addToCalendar(context, eventId, CalendarService.OUTLOOK)

  // Add to Yahoo Calendar
  addToCalendar(context, eventId, CalendarService.YAHOO)
  ```

  ```typescript React Native theme={null}
  import { Linking } from 'react-native';

  type CalendarService = 'google' | 'apple' | 'outlook' | 'yahoo';

  const addToCalendar = async (eventId: string, service: CalendarService): Promise<void> => {
    const url = `https://api.tktchurch.com/v1/events/${eventId}/calendar/${service}`;
    const supported = await Linking.canOpenURL(url);
    
    if (supported) {
      await Linking.openURL(url);
    } else {
      throw new Error(`Cannot open URL: ${url}`);
    }
  };

  // Usage
  try {
    const eventId = '123e4567-e89b-12d3-a456-426614174000';
    
    // Add to Google Calendar
    await addToCalendar(eventId, 'google');
    
    // Add to Apple Calendar
    await addToCalendar(eventId, 'apple');
    
    // Add to Outlook Calendar
    await addToCalendar(eventId, 'outlook');
    
    // Add to Yahoo Calendar
    await addToCalendar(eventId, 'yahoo');
  } catch (error) {
    console.error('Error:', error);
  }
  ```
</RequestExample>

<ResponseExample>
  ```text Response theme={null}
  HTTP/1.1 302 Found
  Location: https://calendar.google.com/calendar/render?action=TEMPLATE&text=Sunday+Worship+Service&details=Weekly+Sunday+worship+service&location=Main+Sanctuary%2C+123+Church+Street%2C+New+York%2C+NY%2C+USA%2C+10001&dates=20240107T100000Z%2F20240107T120000Z&recur=FREQ%3DWEEKLY%3BINTERVAL%3D1%3BBYDAY%3DSU
  ```

  ```json 404 Not Found theme={null}
  {
    "error": {
      "status": 404,
      "reason": "Event not found"
    }
  }
  ```
</ResponseExample>
