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

# Postman Collection

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

export const Postman = ({env = null, anonymous = false, ...props}) => {
  const [showModal, setShowModal] = useState(false);
  const [showImportingModal, setShowImportingModal] = useState(false);
  const collectionId = "8119550-b5ea2aeb-c82a-425d-baff-ed5dfd1d7659";
  const workspaceId = "1a5945ff-a292-42c7-91c5-2cf3cdc68492";
  const referrer = "https%3A%2F%2Fdeveloper.box.com%2Fguides%2Ftooling%2Fpostman%2F%23latest-collection";
  const forkUrl = `https://elements.getpostman.com/view/fork?collection=${collectionId}&workspaceId=${workspaceId}&referrer=${referrer}`;
  const importUrl = `https://www.postman.com/collections/${collectionId}`;
  const handleForkCollection = () => {
    window.open(forkUrl, "_blank");
    setShowModal(false);
  };
  const handleImportCollection = () => {
    setShowImportingModal(true);
    setShowModal(false);
  };
  return <>
      {}
      <button onClick={() => setShowModal(true)} className="w-full px-8 py-4 my-4 text-lg font-medium text-white bg-orange-600 rounded-lg hover:bg-orange-700 transition-colors flex justify-between items-center" {...props}>
        Run in Postman
        <span className="text-2xl">›</span>
      </button>

      {}
      {showModal && <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50" onClick={() => setShowModal(false)}>
          {}
          <div className="relative w-full max-w-2xl mx-4 p-10 bg-white dark:bg-[#0E0E10] rounded-xl shadow-2xl border border-gray-200 dark:border-slate-800" onClick={e => e.stopPropagation()}>
            {}
            <button onClick={() => setShowModal(false)} className="absolute top-4 right-4 w-8 h-8 flex items-center justify-center text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-400 transition-colors" title="Close">
              ✕
            </button>

            {}
            <h2 className="mb-6 text-2xl font-semibold text-gray-900 dark:text-gray-100 mt-0">Fork collection into your workspace</h2>

            {}
            <div className="mb-8">
              <ul className="mb-6 space-y-4 list-none">
                <li className="text-sm text-gray-600 dark:text-gray-400 leading-relaxed flex">
                  <span>Work in your own workspace or with your team</span>
                </li>
                <li className="text-sm text-gray-600 dark:text-gray-400 leading-relaxed flex">
                  <span>Stay up to date with the latest changes to the source collection</span>
                </li>
                <li className="text-sm text-gray-600 dark:text-gray-400 leading-relaxed flex">
                  <span>Contribute to the source collection through pull requests</span>
                </li>
              </ul>

              <p className="mb-4 text-sm text-gray-600 dark:text-gray-400">
                <a href={`https://elements.getpostman.com/redirect?entityId=default&entityType=collection&workspaceId=1a5945ff-a292-42c7-91c5-2cf3cdc68492`} target="_blank" rel="noopener noreferrer">
                  View collection
                </a>{" "}
                in the workspace first if you'd like to.
              </p>

              <p className="text-sm text-gray-600 dark:text-gray-400">
                You can{" "}
                <a href="#" onClick={e => {
    e.preventDefault();
    handleImportCollection();
  }}>
                  import a copy
                </a>{" "}
                of the collection too.
              </p>
            </div>

            {}
            <div className="flex gap-3 justify-end">
              <button onClick={() => setShowModal(false)} className="px-6 py-2.5 text-sm font-medium text-gray-900 dark:text-gray-100 bg-gray-100 dark:bg-slate-800 rounded-lg border border-gray-300 dark:border-slate-700 hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors">
                Cancel
              </button>
              <button onClick={handleForkCollection} className="px-6 py-2.5 text-sm font-medium text-white bg-orange-600 rounded-lg hover:bg-orange-700 transition-colors">
                Fork Collection
              </button>
            </div>
          </div>
        </div>}

      {}
      {showImportingModal && <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50" onClick={() => setShowImportingModal(false)}>
          <div className="relative w-full max-w-md mx-4 p-8 bg-white dark:bg-[#0E0E10] rounded-xl shadow-2xl border border-gray-200 dark:border-slate-800" onClick={e => e.stopPropagation()}>
            {}
            <button onClick={() => setShowImportingModal(false)} className="absolute top-4 right-4 w-8 h-8 flex items-center justify-center text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-400 transition-colors" title="Close">
              ✕
            </button>

            {}
            <h2 className="mb-4 text-xl font-semibold text-gray-900 dark:text-gray-100 mt-0">Importing collection...</h2>

            {}
            <div className="mb-6">
              <p className="text-sm text-gray-600 dark:text-gray-400 mb-4">
                Your Postman desktop app should launch now and start importing the collection.
              </p>
              <br />
              <br />
              <p className="text-sm text-black dark:text-gray-300">
                Don't have the Postman desktop app?{" "}
                <a href="https://www.postman.com/downloads/" target="_blank" className="text-orange-600 dark:text-orange-500" rel="noopener noreferrer">
                  Download Desktop App ↗
                </a>
              </p>
            </div>
          </div>
        </div>}
    </>;
};

<Link href="https://postman.com">Postman</Link> is a tool that lets you build and test HTTP requests in an
easy-to-use interface without configuring a full development environment.

The **Box Postman Collection** is a set of preconfigured requests that make it
possible to get started with the Box API without having to manually configure
the requests.

## Quickstart

### Step 1: Install Postman

<Link href="https://www.postman.com/downloads/">Download</Link> and install the Postman app for your operating system
(Windows, Mac, or Linux). Optionally,
<Link href="https://identity.getpostman.com/signup">create a Postman account and sign in</Link>.

### Step 2: Configure a Box App

To use the Postman Collection, you need a **Box App** to authenticate
with the Box API. The following examples use OAuth 2.0, but other
authentication methods are available.

1. Go to the <Link href="https://cloud.app.box.com/developers/console">Developer Console</Link>.
2. Either:
   * Select your application and make sure it uses **Standard OAuth 2.0** as the authentication method, or
   * Select **New App**, then enter an **App Name** and select **OAuth 2.0** as the **App Type**.
3. In the **Configuration** tab, scroll to the **OAuth 2.0 Redirect URIs**
   section and set the **Redirect URI** to
   `https://oauth.pstmn.io/v1/callback`.

   <Info>
     If you are using the Postman web app rather than the desktop app, use
     `https://oauth.pstmn.io/v1/browser-callback` for all relevant instructions.
   </Info>
4. Scroll to the **Application Scopes** section to select your desired
   <Link href="/guides/api-calls/permissions-and-errors/scopes">scopes</Link>.
   Your application must have at least one of the following scopes:
   * `Manage users`
   * `Read all files and folders stored in Box`
   * `Read and write all files and folders in Box`
5. At the top of the page, click **Save Changes**.
6. From the **OAuth 2.0 Credentials** section, copy the **Client ID** and
   **Client Secret**.

### Step 3: Log in to Box

Use the **Client ID** and **Client Secret** from the previous step to
authenticate with Box through Postman's OAuth 2.0 flow.

1. In Postman, create a <Link href="https://learning.postman.com/docs/sending-requests/create-requests/request-basics/">new request</Link> or open an existing one.
2. Go to the **Authorization** tab.
3. Set the **Type** to **OAuth 2.0**.
4. If you are using the Postman desktop app, select **Authorize using
   browser**.
5. Fill in the **Configure New Token** fields:

| Field                     | Value                                                                                            |
| ------------------------- | ------------------------------------------------------------------------------------------------ |
| **Token Name**            | Any name, for example `Box Access Token`                                                         |
| **Grant Type**            | `Authorization Code`                                                                             |
| **Callback URL**          | `https://oauth.pstmn.io/v1/callback` (auto-filled when **Authorize using browser** is selected). |
| **Auth URL**              | `https://account.box.com/api/oauth2/authorize`                                                   |
| **Access Token URL**      | `https://api.box.com/oauth2/token`                                                               |
| **Client ID**             | Your app's Client ID from the Developer Console                                                  |
| **Client Secret**         | Your app's Client Secret from the Developer Console                                              |
| **Scope**                 | Leave empty                                                                                      |
| **State**                 | Leave empty                                                                                      |
| **Client Authentication** | `Send client credentials in body`                                                                |

6. Click **Get New Access Token**.
7. A browser window opens where you log in to your Box account and grant the
   app access.
8. Once approved, Postman receives your access token. Select
   **Use Token**.

### Step 4: Fork the Box Postman Collection

Click the button below to fork the **Box Postman Collection** into your
Postman workspace.

<Postman anonymous />

It is recommended to fork (rather than copy) the collection so you receive
updates when Box makes changes to it. Once imported, the collection appears
in Postman's left-hand sidebar. You can explore over 170 API endpoints
organized by resource type.

### Step 5: Configure the Box environment

The Box Postman Collection uses environment variables to authenticate API
requests. Before making calls, you need to populate these variables in the
**Box** environment that was imported with the collection.

1. In the lefthand sidebar of Postman, select **Box** from the **Environments** dropdown.
2. Complete the fields as follows:

| Variable        | Value                                               |
| --------------- | --------------------------------------------------- |
| `client_id`     | Your app's Client ID from the Developer Console     |
| `client_secret` | Your app's Client Secret from the Developer Console |
| `grant_type`    | `authorization_code`                                |

3. Click **Save**.

4. Next, you need to obtain an authorization `code` and exchange it for an
   access token. To get the code, visit the following URL in your browser,
   replacing `[CLIENT_ID]` with your Client ID:

`https://account.box.com/api/oauth2/authorize?response_type=code&client_id=[CLIENT_ID]&redirect_uri=https://oauth.pstmn.io/v1/callback
`

5. Log in and grant access. After the redirect, copy the `code` parameter from
   the end of the URL in your browser's address bar. The code expires after
   **30 seconds**, so complete the next steps quickly.
6. Back in Postman, in the Box environment, enter `code` as the **Variable** and paste the code into the **Value** field.
7. Open the **Authorization** folder, select **Refresh access token**, and click **Send**.
8. When successful, the response returns an `access_token` and `refresh_token`. Enter these into your Box environment.

### Step 6: Test your Box environment

1. In the Box Postman Collection, expand the **Folders** folder and select
   **List items in folder**.
2. The `folder_id` defaults to `0` (the root folder). Leave it as-is or
   change it to a specific folder ID.
3. Click **Send**.

The response **Body** tab displays the items in the folder.

<Warning>
  If Postman returns an authentication error, your access token may have
  expired. See <Link href="/guides/tooling/postman/refresh">Refresh an Access
  Token</Link> for details.
</Warning>

## Additional information

* Review the <Link href="https://learning.postman.com/docs/getting-started/overview/">official Postman documentation</Link> from the Postman
  team.
* Learn how to <Link href="/guides/tooling/postman/refresh">refresh an access
  token</Link> to handle token expiration, including automatic refresh.

<RelatedLinks
  title="RELATED GUIDES"
  items={[
{ label: translate("Box SDKs"), href: "/guides/tooling/sdks/index", badge: "GUIDE" },
{ label: translate("OAuth 2.0 Auth"), href: "/guides/authentication/oauth2/index", badge: "GUIDE" }
]}
/>
