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

# Manage Events

> Get, query, update, and delete events with SDK event repository APIs.

Use event repository APIs to observe a single event, query event collections, update event fields, and delete events.

<Info>
  Flutter does not currently expose public scheduled-event management APIs in the SDK source reviewed for this page.
</Info>

## Parameters

| Input                    | Methods              | Platforms                | Description                                                                            |
| ------------------------ | -------------------- | ------------------------ | -------------------------------------------------------------------------------------- |
| `eventId`                | Get, update, delete  | TypeScript, iOS, Android | Stable ID of the event to read or mutate.                                              |
| `originType`, `originId` | Query                | TypeScript, iOS, Android | Scope events to a community or user origin.                                            |
| `userId`, `onlyAttendee` | Query my RSVP events | TypeScript, iOS, Android | Filter events by attendee or user context.                                             |
| `status`                 | Query                | TypeScript, iOS, Android | Filter by scheduled, live, ended, or cancelled status.                                 |
| `type`                   | Query                | TypeScript, iOS, Android | Filter by virtual or in-person event type.                                             |
| `sortBy`, `orderBy`      | Query                | TypeScript, iOS, Android | Sort event lists by start time or creation time.                                       |
| Event fields             | Update               | TypeScript, iOS, Android | Mutable fields such as title, external URL, description, location, tags, and metadata. |

## Get an Event

Use this method for event detail screens or any flow that needs the latest state of one event. TypeScript and iOS expose observable objects; Android returns the requested event through the repository.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { EventRepository } from '@amityco/ts-sdk';

  const unsubscribe = EventRepository.getEvent(
    'event-123',
    ({ data: event, loading, error }) => {
      if (loading) return;
      if (error) {
        handleError(error);
        return;
      }
      if (!event) return;

      showSuccessMessage(event.title);
    },
  );

  unsubscribe();
  ```

  ```swift iOS theme={null}
  let repository = AmityEventRepository()

  token = repository.getEvent(id: "event-123").observe { eventObject, error in
      if let error {
          handleError(error)
          return
      }
      guard let event = eventObject.snapshot else { return }

      showSuccessMessage(event.title)
  }
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newEventRepository()
      .getEvent("event-123")
      .subscribe(
          { event: AmityEvent -> showSuccessMessage(event.getTitle()) },
          { error -> handleGeneralError(error) }
      )
  ```
</CodeGroup>

## Query Events

Use event queries to build calendar lists, community event lists, and upcoming-event surfaces. Pass origin, status, type, sort, and order filters that match the list your UI needs.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import {
    AmityEventOrderOption,
    AmityEventOriginType,
    AmityEventSortOption,
    AmityEventStatus,
    EventRepository,
  } from '@amityco/ts-sdk';

  const unsubscribe = EventRepository.getEvents(
    {
      originType: AmityEventOriginType.Community,
      originId: communityId,
      status: AmityEventStatus.Scheduled,
      sortBy: AmityEventSortOption.StartTime,
      orderBy: AmityEventOrderOption.Ascending,
    },
    ({ data: events, loading, error, hasNextPage, onNextPage }) => {
      if (loading) return;
      if (error) {
        handleError(error);
        return;
      }

      renderResults(events);

      if (hasNextPage) {
        onNextPage?.();
      }
    },
  );

  unsubscribe();
  ```

  ```swift iOS theme={null}
  let repository = AmityEventRepository()
  let options = AmityEventQueryOptions(
      originType: .community,
      originId: communityId,
      status: .scheduled,
      sortBy: .startTime,
      orderBy: .ascending
  )

  token = repository.getEvents(options: options).observe { collection, error in
      if let error {
          handleError(error)
          return
      }

      showSuccessMessage(collection.snapshots.map(\.title))
  }
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newEventRepository()
      .getEvents()
      .originType(AmityEventOriginType.COMMUNITY)
      .originId(communityId)
      .status(AmityEventStatus.SCHEDULED)
      .sortBy(AmityEventSortOption.START_TIME)
      .orderBy(AmityEventOrderOption.ASCENDING)
      .build()
      .query()
      .subscribe(
          { pagingData: PagingData<AmityEvent> -> showSuccessMessage(pagingData) },
          { error -> handleGeneralError(error) }
      )
  ```
</CodeGroup>

## Query My RSVP Events

Use this flow when the current screen should show events connected to a user's RSVP or attendance state. The SDKs expose this through event query filters rather than a separate event object method.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { AmityEventResponseStatus, EventRepository } from '@amityco/ts-sdk';

  const unsubscribe = EventRepository.getMyEvents(
    { status: AmityEventResponseStatus.Going },
    ({ data: events, loading, error }) => {
      if (loading) return;
      if (error) {
        handleError(error);
        return;
      }

      renderResults(events);
    },
  );

  unsubscribe();
  ```

  ```swift iOS theme={null}
  let options = AmityEventQueryOptions(
      userId: "user-123",
      onlyAttendee: true,
      sortBy: .startTime,
      orderBy: .ascending
  )

  token = AmityEventRepository().getEvents(options: options).observe { collection, error in
      if let error {
          handleError(error)
          return
      }

      showSuccessMessage(collection.snapshots.count)
  }
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newEventRepository()
      .getEvents()
      .userId(userId)
      .onlyAttendee(true)
      .sortBy(AmityEventSortOption.START_TIME)
      .orderBy(AmityEventOrderOption.ASCENDING)
      .build()
      .query()
      .subscribe(
          { pagingData: PagingData<AmityEvent> -> showSuccessMessage(pagingData) },
          { error -> handleGeneralError(error) }
      )
  ```
</CodeGroup>

## Update an Event

Use update when the current user can edit the event and your app has collected the changed fields. The examples update the title and virtual-event URL.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { EventRepository } from '@amityco/ts-sdk';

  const { data: event } = await EventRepository.updateEvent('event-123', {
    title: 'Updated Community Workshop',
    externalUrl: 'https://example.com/updated-live',
  });

  showSuccessMessage(event.title);
  ```

  ```swift iOS theme={null}
  let repository = AmityEventRepository()
  let options = AmityEventUpdateOptions(
      title: "Updated Community Workshop",
      externalUrl: "https://example.com/updated-live"
  )

  let event = try await repository.updateEvent(id: "event-123", options: options)
  showSuccessMessage(event.title)
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newEventRepository()
      .updateEvent("event-123")
      .title("Updated Community Workshop")
      .externalUrl("https://example.com/updated-live")
      .build()
      .apply()
      .subscribe(
          { event: AmityEvent -> showSuccessMessage(event.getTitle()) },
          { error -> handleGeneralError(error) }
      )
  ```
</CodeGroup>

## Delete an Event

Use delete for event owner or moderator flows where removing the event is allowed by backend permissions. Handle errors in your UI because permission and lifecycle rules are enforced server-side.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { EventRepository } from '@amityco/ts-sdk';

  await EventRepository.deleteEvent('event-123');
  showSuccessMessage('Event deleted');
  ```

  ```swift iOS theme={null}
  try await AmityEventRepository().deleteEvent(id: "event-123")
  showSuccessMessage("Event deleted")
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newEventRepository()
      .deleteEvent("event-123")
      .subscribe(
          { showSuccessMessage("Event deleted") },
          { error -> handleGeneralError(error) }
      )
  ```
</CodeGroup>

## Query Filters

| Filter                   | TypeScript                                                 | iOS                                           | Android                                                    |
| ------------------------ | ---------------------------------------------------------- | --------------------------------------------- | ---------------------------------------------------------- |
| Origin                   | `originType`, `originId`                                   | `originType`, `originId`                      | `.originType(...)`, `.originId(...)`                       |
| Creator or attendee user | `userId`, `onlyAttendee`                                   | `userId`, `onlyAttendee`                      | `.userId(...)`, `.onlyAttendee(...)`                       |
| Status                   | `AmityEventStatus.Scheduled`, `Live`, `Ended`, `Cancelled` | `.scheduled`, `.live`, `.ended`, `.cancelled` | `AmityEventStatus.SCHEDULED`, `LIVE`, `ENDED`, `CANCELLED` |
| Type                     | `AmityEventType.Virtual`, `InPerson`                       | `.virtual`, `.inPerson`                       | `AmityEventType.VIRTUAL`, `IN_PERSON`                      |
| Sort                     | `AmityEventSortOption.StartTime`, `CreatedAt`              | `.startTime`, `.createdAt`                    | `AmityEventSortOption.START_TIME`, `CREATED_AT`            |
| Order                    | `AmityEventOrderOption.Ascending`, `Descending`            | `.ascending`, `.descending`                   | `AmityEventOrderOption.ASCENDING`, `DESCENDING`            |

<Note>
  TypeScript `deleteEvent` returns `void`. Android returns a `Completable`; iOS returns from an async throwing function when deletion completes.
</Note>

## Related Topics

<CardGroup cols={3}>
  <Card title="Create Event" href="./create-event" icon="calendar-plus">
    Create scheduled virtual or in-person events.
  </Card>

  <Card title="Event RSVP" href="./event-rsvp" icon="ticket-check">
    Work with RSVP responses on event objects.
  </Card>

  <Card title="Events Overview" href="./overview" icon="calendar">
    Review event fields, coverage, and common flows.
  </Card>
</CardGroup>
