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

# Hubの項目の管理

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 = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

Box Hubの項目APIを使用すると、以下のことが可能です。

* [Hub内のすべての項目のリストを取得する](#list-hub-items)
* [Hubのファイル、フォルダ、ウェブリンクを追加または削除する](#add-or-remove-hub-items)

<Note>
  現時点で、このAPIはファイル、フォルダ、およびウェブリンクの管理のみをサポートしています。吹き出し、区切り線、段落、セクションなどの要素は、Box Hubsのウェブインターフェースで追加する必要があります。APIを介して追加されたコンテンツは、最初のコンテンツブロックに配置されます。
</Note>

<Warning>Box Hubs endpoints require the `box-version: 2025.0 header`. If you omit this header, the API returns a 400 error with the message `Missing required box-version header. Supported API versions: [2025.0].` For more information, see [Box API versioning strategy](/guides/api-calls/api-versioning-strategy/).</Warning>

<Note>
  <Link href="/reference/v2025.0/get-hub-items">`GET /2.0/hub_items`</Link>はHTTP `207` (複数のステータス) を返します。レスポンス本文には各操作 (追加または削除) のステータスが含まれます。レスポンス全体とエラー処理については、APIリファレンスを参照してください。
</Note>

## Hubの項目のリストを取得

Box Hubのすべての項目を取得するには、Hub IDを指定して<Link href="/reference/v2025.0/get-hub-items">`GET /2.0/hub_items`</Link>エンドポイントを呼び出します。

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:items 12345
  ```

  ```sh cURL theme={null}
  curl -i -X GET "https://api.box.com/2.0/hub_items?hub_id=HUB_ID" \
       -H "Authorization: Bearer <ACCESS_TOKEN>" \
       -H "box-version: 2025.0"
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.hubItems.getHubItemsV2025R0({
    hubId: createdHub.id,
  } satisfies GetHubItemsV2025R0QueryParams);
  ```

  ```python Python v10 theme={null}
  client.hub_items.get_hub_items_v2025_r0(created_hub.id)
  ```

  ```csharp .NET v10 theme={null}
  await client.HubItems.GetHubItemsV2025R0Async(queryParams: new GetHubItemsV2025R0QueryParams(hubId: createdHub.Id));
  ```

  ```swift Swift v10 theme={null}
  try await client.hubItems.getHubItemsV2025R0(queryParams: GetHubItemsV2025R0QueryParams(hubId: createdHub.id))
  ```

  ```java Java v10 theme={null}
  client.getHubItems().getHubItemsV2025R0(new GetHubItemsV2025R0QueryParams(createdHub.getId()));
  ```
</CodeGroup>

`HUB_ID`をHub IDに置き換えてください。ページネーションにはクエリパラメータ`marker`および`limit` を使用できます (省略可)。レスポンスにはHubの項目の`entries`配列が含まれます (各項目には`id`、`type`、`name`があります)。

## Hubの項目を追加または削除

Hubの項目を追加または削除するには、Hub IDと操作のリストを指定して<Link href="/reference/v2025.0/post-hubs-id-manage-items">`POST /2.0/hubs/{hub_id}/manage_items`</Link>エンドポイントを呼び出します。各操作には`action` (`add`または`remove`) と`item`参照 (`type`および`id`) があります。

### Hubにファイルを追加

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:items:manage 12345 --add id=11111,type=file
  ```

  ```sh cURL theme={null}
  curl -i -X POST "https://api.box.com/2.0/hubs/HUB_ID/manage_items" \
       -H "Authorization: Bearer <ACCESS_TOKEN>" \
       -H "box-version: 2025.0" \
       -H "Content-Type: application/json" \
       -d '{
         "operations": [
           {
             "action": "add",
             "item": {
               "type": "file",
               "id": "FILE_ID"
             }
           }
         ]
       }'
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.hubItems.manageHubItemsV2025R0(createdHub.id, {
    operations: [
      {
        action: 'add' as HubItemOperationV2025R0ActionField,
        item: new FileReferenceV2025R0({ id: file.id }),
      } satisfies HubItemOperationV2025R0,
    ],
  } satisfies HubItemsManageRequestV2025R0);
  ```

  ```python Python v10 theme={null}
  client.hub_items.manage_hub_items_v2025_r0(
      created_hub.id,
      operations=[
          HubItemOperationV2025R0(
              action=HubItemOperationV2025R0ActionField.ADD,
              item=FileReferenceV2025R0(id=file.id),
          )
      ],
  )
  ```

  ```csharp .NET v10 theme={null}
  await client.HubItems.ManageHubItemsV2025R0Async(hubId: createdHub.Id, requestBody: new HubItemsManageRequestV2025R0() { Operations = Array.AsReadOnly(new [] { new HubItemOperationV2025R0(action: HubItemOperationV2025R0ActionField.Add, item: new FileReferenceV2025R0(id: file.Id)) }) });
  ```

  ```java Java v10 theme={null}
  client.getHubItems().manageHubItemsV2025R0(createdHub.getId(), new HubItemsManageRequestV2025R0.Builder().operations(Arrays.asList(new HubItemOperationV2025R0(HubItemOperationV2025R0ActionField.ADD, new FileReferenceV2025R0(file.getId())))).build());
  ```
</CodeGroup>

### Hubにフォルダを追加

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:items:manage 12345 --add id=67890,type=folder
  ```

  ```sh cURL theme={null}
  curl -i -X POST "https://api.box.com/2.0/hubs/HUB_ID/manage_items" \
       -H "Authorization: Bearer <ACCESS_TOKEN>" \
       -H "box-version: 2025.0" \
       -H "Content-Type: application/json" \
       -d '{
         "operations": [
           {
             "action": "add",
             "item": {
               "type": "folder",
               "id": "FOLDER_ID"
             }
           }
         ]
       }'
  ```

  ```python Python v10 theme={null}
  client.hub_items.manage_hub_items_v2025_r0(
      created_hub.id,
      operations=[
          HubItemOperationV2025R0(
              action=HubItemOperationV2025R0ActionField.ADD,
              item=FolderReferenceV2025R0(id=folder.id),
          )
      ],
  )
  ```
</CodeGroup>

### Hubから項目を削除

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:items:manage 12345 --remove id=11111,type=file
  ```

  ```sh cURL theme={null}
  curl -i -X POST "https://api.box.com/2.0/hubs/HUB_ID/manage_items" \
       -H "Authorization: Bearer <ACCESS_TOKEN>" \
       -H "box-version: 2025.0" \
       -H "Content-Type: application/json" \
       -d '{
         "operations": [
           {
             "action": "remove",
             "item": {
               "type": "file",
               "id": "FILE_ID"
             }
           }
         ]
       }'
  ```

  ```python Python v10 theme={null}
  client.hub_items.manage_hub_items_v2025_r0(
      created_hub.id,
      operations=[
          HubItemOperationV2025R0(
              action=HubItemOperationV2025R0ActionField.REMOVE,
              item=FileReferenceV2025R0(id=file.id),
          )
      ],
  )
  ```
</CodeGroup>

`HUB_ID`、`FILE_ID`、および`FOLDER_ID`を実際のIDに置き換えます。ウェブリンクの場合は、`"type": "web_link"`とウェブリンクIDを使用します。1回のリクエストで複数の追加操作と削除操作を組み合わせることができます。

## ユースケース

* **Hub作成の自動化:** <Link href="/reference/get-search">Box検索API</Link>またはメタデータクエリを使用して条件に一致するコンテンツを見つけ、Hubの項目を管理エンドポイントを使用してフィルタ済みの結果をHubに追加します。
* **イベント駆動型の更新:** イベント (例: フォルダ内の新規ファイル) に反応する<Link href="/guides/webhooks">Webhook</Link>を使用して、そのコンテンツを自動的にHubに追加します。

<RelatedLinks
  title="関連するAPI"
  items={[
{ label: translate("Get hub items"), href: "/reference/v2025.0/get-hub-items", badge: "GET" },
{ label: translate("Manage hub items"), href: "/reference/v2025.0/post-hubs-id-manage-items", badge: "POST" }
]}
/>

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("Box Hubs overview"), href: "/guides/hubs-api", badge: "GUIDE" },
{ label: translate("Create a hub"), href: "/guides/hubs-api/hubs/create-hub", badge: "GUIDE" },
{ label: translate("Manage hub collaborations"), href: "/guides/hubs-api/hubs-collaborations/hub-collaborations", badge: "GUIDE" }
]}
/>
