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

# Migrating From History To Stream

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>;
};

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

Box recommends that applications subscribing to live events through
`admin_logs` migrate to `admin_logs_streaming`. `admin_logs_streaming` provides
lower and more consistent latency, as well as ensures that late arriving
events will not be missed. Events can be deduplicated between `admin_logs` and
`admin_logs_streaming` by their event IDs.

## Enterprise `stream_type` comparison

### Benefits of `admin_logs_streaming`

* Ensures late arriving events are not missed by your subscribing application
* Provides 80% lower latency (during normal operations)
* Has much more consistent latency (during normal operations)
* Recovers much more gracefully from a fault, because your service no longer has to manage backfilling late events

### Differences between `admin_logs` and `admin_logs_streaming`

* Provides two weeks of event history (i.e. retention)
* Does not support the `created_after` and `created_before` filter parameters
* May contain duplicates (provides an 'at least once' guarantee)
* No longer returns events in chronological order (events are returned in roughly the order they are processed)

### Similarities between `admin_logs` and `admin_logs_streaming`

* Shares the same <Link href="/reference/events">`GET /events`</Link> API endpoint
* Returns the same events payload (events can be deduplicated across the two stream types by event ID)
* Enables filtering by `event_type`
* Allows paginating through events via a `stream_position`

## How to migrate from `admin_logs` to `admin_logs_streaming`

### 1. Existing requests will look something like the below

```sh theme={null}
curl https://api.box.com/2.0/events?stream_type=admin_logs&stream_position=1632893855 \
    -H "authorization: Bearer <ACCESS_TOKEN>"
```

### 2. Begin overlapping existing requests with `admin_logs_streaming`

* Start two weeks ago and backfill:

  ```sh theme={null}
  curl https://api.box.com/2.0/events?stream_type=admin_logs_streaming&stream_position=0 \
      -H "authorization: Bearer <ACCESS_TOKEN>"
  ```

or

* Start now and run in parallel:

  ```sh theme={null}
  curl https://api.box.com/2.0/events?stream_type=admin_logs_streaming&stream_position=now \
      -H "authorization: Bearer <ACCESS_TOKEN>"
  ```

### 3. Paginate through results until now and deduplicate with `admin_logs` events

```sh theme={null}
curl https://api.box.com/2.0/events?stream_type=admin_logs_streaming&stream_position=1632893855 \
    -H "authorization: Bearer <ACCESS_TOKEN>"
```

### 4. Continue to overlap until confident

### 5. Turn off old `admin_logs` requests

<Frame center shadow border>
  <img src="https://mintcdn.com/box/_tECS-SYBYV9K-kZ/images/guides/events/enterprise-events/migrate_to_stream.png?fit=max&auto=format&n=_tECS-SYBYV9K-kZ&q=85&s=e85b9690bbce576ff7bfd8836bd55697" alt="Stream Migration Flow" width="612" height="151" data-path="images/guides/events/enterprise-events/migrate_to_stream.png" />
</Frame>

<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" }
]}
/>
