> ## 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.

# Delete Event

> Delete an existing event

<Note>
  This endpoint requires authentication and the `deleteEvent` permission.
</Note>

## Path Parameters

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

## Response

A successful request returns HTTP 204 No Content status.

## 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:

  * 401 Unauthorized: Missing or invalid access token
  * 403 Forbidden: Insufficient permissions
  * 404 Not Found: Event not found
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.tktchurch.com/v1/events/123e4567-e89b-12d3-a456-426614174000" \
    -H "Authorization: Bearer {access_token}"
  ```

  ```javascript JavaScript theme={null}
  const deleteEvent = async (accessToken, eventId) => {
    const response = await fetch(
      `https://api.tktchurch.com/v1/events/${eventId}`,
      {
        method: 'DELETE',
        headers: {
          'Authorization': `Bearer ${accessToken}`
        }
      }
    );

    if (!response.ok) {
      const error = await response.json();
      throw new Error(error.error.reason);
    }
  };

  // Usage
  try {
    await deleteEvent(
      'eyJhbGciOiJIUzI1NiIs...',
      '123e4567-e89b-12d3-a456-426614174000'
    );
    console.log('Event deleted successfully');
  } catch (error) {
    console.error('Error:', error);
  }
  ```

  ```swift Swift theme={null}
  func deleteEvent(accessToken: String, eventId: UUID) async throws {
      var urlRequest = URLRequest(url: URL(string: "https://api.tktchurch.com/v1/events/\(eventId)")!)
      urlRequest.httpMethod = "DELETE"
      urlRequest.setValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")
      
      let (_, response) = try await URLSession.shared.data(for: urlRequest)
      guard let httpResponse = response as? HTTPURLResponse else {
          throw URLError(.badServerResponse)
      }
      
      if httpResponse.statusCode != 204 {
          throw URLError(.badServerResponse)
      }
  }

  // Usage
  do {
      try await deleteEvent(
          accessToken: "eyJhbGciOiJIUzI1NiIs...",
          eventId: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
      )
      print("Event deleted successfully")
  } catch {
      print("Error:", error)
  }
  ```

  ```kotlin Kotlin theme={null}
  suspend fun deleteEvent(accessToken: String, eventId: String) {
      val client = OkHttpClient()
      
      val request = Request.Builder()
          .url("https://api.tktchurch.com/v1/events/$eventId")
          .delete()
          .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 delete event")
          }
      }
  }

  // Usage
  try {
      deleteEvent(
          "eyJhbGciOiJIUzI1NiIs...",
          "123e4567-e89b-12d3-a456-426614174000"
      )
      println("Event deleted successfully")
  } catch (e: Exception) {
      println("Error: ${e.message}")
  }
  ```

  ```typescript React Native theme={null}
  import axios from 'axios';

  const deleteEvent = async (accessToken: string, eventId: string): Promise<void> => {
    try {
      await axios.delete(
        `https://api.tktchurch.com/v1/events/${eventId}`,
        {
          headers: {
            'Authorization': `Bearer ${accessToken}`
          },
        }
      );
    } catch (error) {
      if (axios.isAxiosError(error)) {
        throw new Error(error.response?.data?.error?.reason || 'Failed to delete event');
      }
      throw error;
    }
  };

  // Usage
  try {
    await deleteEvent(
      'eyJhbGciOiJIUzI1NiIs...',
      '123e4567-e89b-12d3-a456-426614174000'
    );
    console.log('Event deleted successfully');
  } catch (error) {
    console.error('Error:', error);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 204 No Content theme={null}
  ```

  ```json 401 Unauthorized theme={null}
  {
    "error": {
      "status": 401,
      "reason": "Invalid or expired access token"
    }
  }
  ```

  ```json 403 Forbidden theme={null}
  {
    "error": {
      "status": 403,
      "reason": "Missing required permission: deleteEvent"
    }
  }
  ```

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