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

# Get User Events

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

To get a user's events, authenticate as any user and make a call to the
<Link href="/reference/get-events">`GET /events`</Link> API.

<CodeGroup>
  ```sh cURL theme={null}
  curl -i -X GET "https://api.box.com/2.0/events" \
       -H "authorization: Bearer <ACCESS_TOKEN>"
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.events.getEvents();
  ```

  ```python Python v10 theme={null}
  client.events.get_events()
  ```

  ```csharp .NET v10 theme={null}
  await client.Events.GetEventsAsync();
  ```

  ```swift Swift v10 theme={null}
  try await client.events.getEvents()
  ```

  ```java Java v10 theme={null}
  client.getEvents().getEvents()
  ```

  ```java Java v5 theme={null}
  EventStream stream = new EventStream(api);
  stream.addListener(new EventListener() {
    public void onEvent(BoxEvent event) {
        // Handle the event.
      }
  });
  stream.start();
  ```

  ```py Python v4 theme={null}
  stream_position = 0
  events = client.events().get_events(stream_position=stream_position)
  stream_position = events['next_stream_position']
  for event in events['entries']:
      print(f'Got {event.event_type} event that occurred at {event.created_at}')
  ```

  ```csharp .NET v6 theme={null}
  BoxEventCollection<BoxEnterpriseEvent> events = await client.EventsManager.UserEventsAsync();
  ```

  ```js Node v4 theme={null}
  client.events.get({stream_position: '1408838928446360'}, callback);
  ```
</CodeGroup>

<Info>
  The events returned will only be for the user who's access token the API was
  made with. To get the event feed for a different user either use the `as-user`
  header or an actual access token for that user.
</Info>

## Stream Types

The user event stream support 3 types of stream.

| Stream Type |                                                                                         |
| ----------- | --------------------------------------------------------------------------------------- |
| `all`       | Returns everything for a user (default)                                                 |
| `changes`   | Returns events that may cause file tree changes such as file updates or collaborations. |
| `sync`      | Is similar to changes but only applies to synced folders                                |

## Anonymous Users

In some cases, the event feed might list a user with an ID of `2`. This is Box's
internal identifier for anonymous users.

An anonymous user is a user that is not logged in. This can happen any time a
user interacts with content and they aren't asked to log in first. An example
would be when a user downloads a file through an open shared link.

## Limitations

Box does not store events indefinitely.

User events are stored for between two weeks and two months, after which the
user events are removed. Enterprise events are accessible for one year via the
API and seven years via exported reports in the Box Admin Console.

The emphasis of this feed is to return the complete results quickly, which means
that Box may return events more than once or out of order. Duplicate events can
be identified by their event IDs.

## Long Polling

The user event stream supports long-polling
<Link href="/guides/events/user-events/polling">through the `OPTIONS /events` API</Link>.

## Event Types

The following events can be triggered for a user. This list is not exhaustive,
so it is possible events appear that are not listed.

The following events are available in all feeds.

| Event name                   | Description                                                                     |
| ---------------------------- | ------------------------------------------------------------------------------- |
| `ITEM_CREATE`                | A folder or File was created                                                    |
| `ITEM_UPLOAD`                | A folder or File was uploaded                                                   |
| `ITEM_MOVE`                  | A file or folder was moved                                                      |
| `ITEM_COPY`                  | A file or folder was copied                                                     |
| `LOCK_CREATE`                | A file was locked                                                               |
| `LOCK_DESTROY`               | A file was unlocked. If a locked file is deleted, the source file will be null. |
| `ITEM_TRASH`                 | A file or folder was marked as deleted                                          |
| `ITEM_UNDELETE_VIA_TRASH`    | A file or folder was recovered out of the trash                                 |
| `COLLAB_ADD_COLLABORATOR`    | A collaborator was added to a folder                                            |
| `COLLAB_ROLE_CHANGE`         | A collaborator had their role changed                                           |
| `COLLAB_INVITE_COLLABORATOR` | A collaborator was invited on a folder                                          |
| `COLLAB_REMOVE_COLLABORATOR` | A collaborator was removed from a folder                                        |
| `ITEM_SYNC`                  | A folder was marked for sync                                                    |
| `ITEM_UNSYNC`                | A folder was unmarked for sync                                                  |
| `ITEM_RENAME`                | A file or folder was renamed                                                    |
| `ITEM_MAKE_CURRENT_VERSION`  | A previous version of a file was promoted to the current version                |
| `GROUP_ADD_USER`             | Added user to group                                                             |
| `GROUP_REMOVE_USER`          | Removed user from group                                                         |

The following events are only available in the `all` feed.

| Event name               | Description                                               |
| ------------------------ | --------------------------------------------------------- |
| `COMMENT_CREATE`         | A comment was created on a folder, file, or other comment |
| `COMMENT_DELETE`         | A comment was deleted on folder, file, or other comment   |
| `ITEM_DOWNLOAD`          | A file or folder was downloaded                           |
| `ITEM_PREVIEW`           | A file was previewed                                      |
| `TASK_ASSIGNMENT_CREATE` | A task was assigned                                       |
| `TASK_CREATE`            | A task was created                                        |
| `ITEM_SHARED_CREATE`     | A file or folder was enabled for sharing                  |
| `ITEM_SHARED_UNSHARE`    | A file or folder was disabled for sharing                 |
| `ITEM_SHARED`            | A folder was shared                                       |
| `TAG_ITEM_CREATE`        | A Tag was added to a file or folder                       |
| `ENABLE_TWO_FACTOR_AUTH` | 2 factor authentication enabled by user                   |
| `MASTER_INVITE_ACCEPT`   | Free user accepts invitation to become a managed user     |
| `MASTER_INVITE_REJECT`   | Free user rejects invitation to become a managed user     |
| `ACCESS_GRANTED`         | Granted Box access to account                             |
| `ACCESS_REVOKED`         | Revoke Box access to account                              |

## Event notifications

To reduce the noise of the event stream and optimize event consumption, the event types listed in the table trigger a limited number of notifications.

| Event type                                                                                                  | Notification behavior                                                                                                                                                            |
| ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `COLLAB_ADD_COLLABORATOR`, `COLLAB_REMOVE_COLLABORATOR`, `COLLAB_INVITE_COLLABORATOR`, `COLLAB_ROLE_CHANGE` | When these events take place, the content owner on the `changes` event stream is notified. Collaborators see an additional event that matches what they see on the `all` stream. |
| `ITEM_DOWNLOAD`                                                                                             | When an item is downloaded, only the content owner gets the notification. Collaborators are not notified.                                                                        |
| `ITEM_PREVIEW`                                                                                              | When an item is previewed, only the content owner gets the notification. Collaborators are not notified.                                                                         |

<RelatedLinks
  title="RELATED APIS"
  items={[
{ label: translate("List user and enterprise events"), href: "/reference/get-events", badge: "GET" },
{ label: translate("Get events long poll endpoint"), href: "/reference/options-events", badge: "OPTIONS" }
]}
/>

<RelatedLinks
  title="RELATED GUIDES"
  items={[
{ label: translate("Get Enterprise Events"), href: "/guides/events/enterprise-events/for-enterprise", badge: "GUIDE" },
{ label: translate("Long-Poll Events"), href: "/guides/events/user-events/polling", badge: "GUIDE" },
{ label: translate("Stream Position Pagination"), href: "/guides/events/parameters/pagination", badge: "GUIDE" }
]}
/>
