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

# Ensure consistency with headers

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

Some Box APIs support headers used to ensure consistency between your
application and Box.

## `etag`, `if-match`, and `if-none-match`

Many of the file system items (files or folders) that can be requested via the
API return an `etag` value for the item.

For example, a file resource returns an `etag` in the JSON response.

```sh theme={null}
curl https://api.box.com/2.0/files/12345 \
    -H "authorization: Bearer ACCESS_TOKEN"
```

```json theme={null}
{
  "id": 12345,
  "etag": 1,
  "type": "file",
  "sequence_id": 3,
  "name": "Contract.pdf",
  ...
}
```

This `etag` can be used as the value of a `if-match` or `if-none-match`
header to either ensure a resource hasn't changed since the `etag` value was
received, or to prevent unnecessary downloads for items that haven't changed.

For example, to fetch the same file only if it has changed, pass in the `etag`
value in a `if-none-match` header.

```sh theme={null}
curl https://api.box.com/2.0/files/12345 \
    -H "authorization: Bearer ACCESS_TOKEN" \
    -H "if-none-match: 1"
```

This API call would result in an empty response if the file had not changed.

## Ensure consistent changes

The `if-match` header allows your application to ensure that no changes are
made to items when another application or a user has made changes to the item
since your application last inspected it. This helps ensure that
changes aren't lost when two applications or users are changing items at the
same time.

The following endpoints support this header.

| `if-match` capable endpoints                                                   |                                 |
| ------------------------------------------------------------------------------ | ------------------------------- |
| <Link href="/reference/post-files-id-content">`POST /files/:id/content`</Link> | Upload a new file version       |
| <Link href="/reference/put-files-id">`PUT /files/:id`</Link>                   | Update a file's information     |
| <Link href="/reference/delete-files-id">`DELETE /files/:id`</Link>             | Delete a file                   |
| <Link href="/reference/put-folders-id">`PUT /folders/:id`</Link>               | Update a folder's information   |
| <Link href="/reference/delete-folders-id">`DELETE /folders/:id`</Link>         | Delete a folder                 |
| <Link href="/reference/put-web-links-id">`PUT /web_links/:id`</Link>           | Update a web link's information |
| <Link href="/reference/delete-web-links-id">`DELETE /web_links/:id`</Link>     | Delete a web link               |

The response of these APIs calls depends on the existence of the item,
and whether the `etag` value matches the most recent version.

| Item found? | Etag match? | HTTP status |
| ----------- | ----------- | ----------- |
| Yes         | Yes         | 200         |
| Yes         | No          | 412         |
| No          | Yes         | 412         |
| No          | No          | 404         |

<Warning>
  **Moving items**

  The `if-match` header can not be used to prevent moving of files, folders,
  or web links. Instead, Box will always ensure that the latest item is moved to
  the new location.
</Warning>

## Prevent unnecessary request downloads

The `if-none-match` header allows your application to ensure that no information
is downloaded for items that have not changed since your application last
inspected it. This helps ensure no unnecessary information is downloaded,
speeding up your application and saving on bandwidth.

| `if-none-match` capable endpoints                                    |                                 |
| -------------------------------------------------------------------- | ------------------------------- |
| <Link href="/reference/get-files-id">`GET /files/:id`</Link>         | Get a file's information        |
| <Link href="/reference/get-folder-id">`GET /folders/:id`</Link>      | Get a folder's information      |
| <Link href="/reference/get-web-links-id">`GET /web_links/:id`</Link> | Get a web link's information    |
| <Link href="/reference/get-shared-items">`GET /shared_items`</Link>  | Get a shared item's information |

The response of these APIs calls depends on the existence of the item,
and whether the `etag` value matches the most recent version.

| Item found? | Etag match? | HTTP Status |
| ----------- | ----------- | ----------- |
| Yes         | Yes         | 304         |
| Yes         | No          | 200         |
| No          | Yes         | 404         |
| No          | No          | 404         |

<RelatedLinks
  title="RELATED APIS"
  items={[
{ label: translate("Upload file version"), href: "/reference/post-files-id-content", badge: "POST" },
{ label: translate("Update file"), href: "/reference/put-files-id", badge: "PUT" },
{ label: translate("Delete file"), href: "/reference/delete-files-id", badge: "DELETE" },
{ label: translate("Update folder"), href: "/reference/put-folders-id", badge: "PUT" },
{ label: translate("Delete folder"), href: "/reference/delete-folders-id", badge: "DELETE" },
{ label: translate("Update web link"), href: "/reference/put-web-links-id", badge: "PUT" },
{ label: translate("Remove web link"), href: "/reference/delete-web-links-id", badge: "DELETE" },
{ label: translate("Get file information"), href: "/reference/get-files-id", badge: "GET" },
{ label: translate("Get folder information"), href: "/reference/get-folders-id", badge: "GET" },
{ label: translate("Get web link"), href: "/reference/get-web-links-id", badge: "GET" },
{ label: translate("Find file for shared link"), href: "/reference/get-shared-items", badge: "GET" }
]}
/>
