> ## 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コラボレーションでは、Hubへのアクセス権限と役割を制御できます。ユーザーID、グループID、またはメールアドレス (ユーザーの場合) を指定してユーザーやグループを招待できます。役割は`editor`、`viewer`、および`co-owner`となります。Hubでのコラボレーションに招待できるのは、Boxアカウント (どのプランでも可) を持つユーザーのみです。

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

## Hubコラボレーションを作成

ユーザーまたはグループをHubに追加するには、<Link href="/reference/v2025.0/post-hub-collaborations">`POST /2.0/hub_collaborations`</Link>エンドポイントを呼び出し、以下を指定します。

* Hubの参照 (`HUB_ID`)
* コラボレータのIDおよびタイプ (`accessible_by`フィールド)
* Hubに付与されるアクセスレベル (`role`フィールド)

### ユーザーIDを指定して作成

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:collaborations:create HUB_ID --role viewer --user-id USER_ID
  ```

  ```sh cURL theme={null}
  curl -i -X POST "https://api.box.com/2.0/hub_collaborations" \
       -H "Authorization: Bearer <ACCESS_TOKEN>" \
       -H "box-version: 2025.0" \
       -H "Content-Type: application/json" \
       -d '{
         "hub": {
           "type": "hubs",
           "id": "HUB_ID"
         },
         "accessible_by": {
           "type": "user",
           "id": "USER_ID"
         },
         "role": "viewer"
       }'
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.hubCollaborations.createHubCollaborationV2025R0({
    hub: new HubCollaborationCreateRequestV2025R0HubField({ id: hub.id }),
    accessibleBy: {
      type: 'user',
      id: user.id,
    } satisfies HubCollaborationCreateRequestV2025R0AccessibleByField,
    role: 'viewer',
  } satisfies HubCollaborationCreateRequestV2025R0);
  ```

  ```python Python v10 theme={null}
  client.hub_collaborations.create_hub_collaboration_v2025_r0(
      CreateHubCollaborationV2025R0Hub(id=hub.id),
      CreateHubCollaborationV2025R0AccessibleBy(type="user", id=user.id),
      "viewer",
  )
  ```

  ```csharp .NET v10 theme={null}
  await client.HubCollaborations.CreateHubCollaborationV2025R0Async(requestBody: new HubCollaborationCreateRequestV2025R0(hub: new HubCollaborationCreateRequestV2025R0HubField(id: hub.Id), accessibleBy: new HubCollaborationCreateRequestV2025R0AccessibleByField(type: "user") { Id = user.Id }, role: "viewer"));
  ```

  ```swift Swift v10 theme={null}
  try await client.hubCollaborations.createHubCollaborationV2025R0(requestBody: HubCollaborationCreateRequestV2025R0(hub: HubCollaborationCreateRequestV2025R0HubField(id: hub.id), accessibleBy: HubCollaborationCreateRequestV2025R0AccessibleByField(type: "user", id: user.id), role: "viewer"))
  ```

  ```java Java v10 theme={null}
  client.getHubCollaborations().createHubCollaborationV2025R0(new HubCollaborationCreateRequestV2025R0(new HubCollaborationCreateRequestV2025R0HubField(hub.getId()), new HubCollaborationCreateRequestV2025R0AccessibleByField.Builder("user").id(user.getId()).build(), "viewer"));
  ```
</CodeGroup>

### ユーザーのメールアドレス (ログイン) を指定して作成

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:collaborations:create HUB_ID --role editor --login john@example.com
  ```

  ```sh cURL theme={null}
  curl -i -X POST "https://api.box.com/2.0/hub_collaborations" \
       -H "Authorization: Bearer <ACCESS_TOKEN>" \
       -H "box-version: 2025.0" \
       -H "Content-Type: application/json" \
       -d '{
         "hub": {
           "type": "hubs",
           "id": "HUB_ID"
         },
         "accessible_by": {
           "type": "user",
           "login": "john@example.com"
         },
         "role": "editor"
       }'
  ```

  ```python Python v10 theme={null}
  client.hub_collaborations.create_hub_collaboration_v2025_r0(
      CreateHubCollaborationV2025R0Hub(id=hub.id),
      CreateHubCollaborationV2025R0AccessibleBy(type="user", login="john@example.com"),
      "editor",
  )
  ```
</CodeGroup>

`HUB_ID`、`USER_ID`、およびメールアドレスを実際の値に置き換えます。`role`の有効な値は、`editor`、`viewer`、`co-owner`です。成功したレスポンスでは、新しい<Link href="/reference/v2025.0/resources/hub-collaboration">Hubコラボレーション</Link>オブジェクトが返されます。

## Hubコラボレーションのリストを取得

Hubのすべてのコラボレーションのリストを取得するには、Hub IDを指定して<Link href="/reference/v2025.0/get-hub-collaborations">`GET /2.0/hub_collaborations`</Link>エンドポイントを呼び出します。

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:collaborations HUB_ID
  ```

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

  ```typescript Node/TypeScript v10 theme={null}
  await client.hubCollaborations.getHubCollaborationsV2025R0({
    hubId: hub.id,
  } satisfies GetHubCollaborationsV2025R0QueryParams);
  ```

  ```python Python v10 theme={null}
  client.hub_collaborations.get_hub_collaborations_v2025_r0(hub.id)
  ```

  ```csharp .NET v10 theme={null}
  await client.HubCollaborations.GetHubCollaborationsV2025R0Async(queryParams: new GetHubCollaborationsV2025R0QueryParams(hubId: hub.Id));
  ```

  ```swift Swift v10 theme={null}
  try await client.hubCollaborations.getHubCollaborationsV2025R0(queryParams: GetHubCollaborationsV2025R0QueryParams(hubId: hub.id))
  ```

  ```java Java v10 theme={null}
  client.getHubCollaborations().getHubCollaborationsV2025R0(new GetHubCollaborationsV2025R0QueryParams(hub.getId()));
  ```
</CodeGroup>

省略可能なクエリパラメータは`marker`および`limit`です。詳細については、[マーカーベースのページネーション](/guides/api-calls/pagination/marker-based)を参照してください。

## IDを指定してHubコラボレーションを取得

1つのHubコラボレーションを取得するには、コラボレーションIDを指定して<Link href="/reference/v2025.0/get-hub-collaborations-id">`GET /2.0/hub_collaborations/{hub_collaboration_id}`</Link>エンドポイントを呼び出します。

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:collaborations:get HUB_COLLABORATION_ID
  ```

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

  ```typescript Node/TypeScript v10 theme={null}
  await client.hubCollaborations.getHubCollaborationByIdV2025R0(hubCollaborationId);
  ```

  ```python Python v10 theme={null}
  client.hub_collaborations.get_hub_collaboration_by_id_v2025_r0(hub_collaboration_id)
  ```

  ```csharp .NET v10 theme={null}
  await client.HubCollaborations.GetHubCollaborationByIdV2025R0Async(hubCollaborationId: hubCollaborationId);
  ```

  ```java Java v10 theme={null}
  client.getHubCollaborations().getHubCollaborationByIdV2025R0(hubCollaborationId);
  ```
</CodeGroup>

## Hubコラボレーションを更新

コラボレータの役割を変更するには、HubコラボレーションIDと新しい`role`を指定して<Link href="/reference/v2025.0/put-hub-collaborations-id">`PUT /2.0/hub_collaborations/{hub_collaboration_id}`</Link>エンドポイントを呼び出します。

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:collaborations:update HUB_COLLABORATION_ID --role editor
  ```

  ```sh cURL theme={null}
  curl -i -X PUT "https://api.box.com/2.0/hub_collaborations/HUB_COLLABORATION_ID" \
       -H "Authorization: Bearer <ACCESS_TOKEN>" \
       -H "box-version: 2025.0" \
       -H "Content-Type: application/json" \
       -d '{
         "role": "editor"
       }'
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.hubCollaborations.updateHubCollaborationByIdV2025R0(hubCollaborationId, {
    role: 'editor',
  } satisfies HubCollaborationUpdateRequestV2025R0);
  ```

  ```python Python v10 theme={null}
  client.hub_collaborations.update_hub_collaboration_by_id_v2025_r0(hub_collaboration_id, role="editor")
  ```

  ```csharp .NET v10 theme={null}
  await client.HubCollaborations.UpdateHubCollaborationByIdV2025R0Async(hubCollaborationId: hubCollaborationId, requestBody: new HubCollaborationUpdateRequestV2025R0() { Role = "editor" });
  ```

  ```java Java v10 theme={null}
  client.getHubCollaborations().updateHubCollaborationByIdV2025R0(hubCollaborationId, new HubCollaborationUpdateRequestV2025R0.Builder().role("editor").build());
  ```
</CodeGroup>

## Hubコラボレーションを削除

Hubからコラボレータを削除するには、HubコラボレーションIDを指定して<Link href="/reference/v2025.0/delete-hub-collaborations-id">`DELETE /2.0/hub_collaborations/{hub_collaboration_id}`</Link>エンドポイントを呼び出します。

<CodeGroup>
  ```sh Box CLI theme={null}
  box hubs:collaborations:delete HUB_COLLABORATION_ID
  ```

  ```sh cURL theme={null}
  curl -i -X DELETE "https://api.box.com/2.0/hub_collaborations/HUB_COLLABORATION_ID" \
       -H "Authorization: Bearer <ACCESS_TOKEN>" \
       -H "box-version: 2025.0"
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.hubCollaborations.deleteHubCollaborationByIdV2025R0(hubCollaborationId);
  ```

  ```python Python v10 theme={null}
  client.hub_collaborations.delete_hub_collaboration_by_id_v2025_r0(hub_collaboration_id)
  ```

  ```csharp .NET v10 theme={null}
  await client.HubCollaborations.DeleteHubCollaborationByIdV2025R0Async(hubCollaborationId: hubCollaborationId);
  ```

  ```java Java v10 theme={null}
  client.getHubCollaborations().deleteHubCollaborationByIdV2025R0(hubCollaborationId);
  ```
</CodeGroup>

削除に成功した場合、返される本文はありません (HTTP 204)。

## ユースケース

* **オンボーディングの自動化:** HRISに新入社員を追加すると、「ウェルカムHub」を作成し、適切な役割を持つコラボレータとして追加します。
* **グループベースのアクセス:** <Link href="/reference/get-groups">BoxグループAPI</Link>を使用して適切なグループを検索し、そのグループをコラボレータとして追加して、すべてのメンバーがアクセスできるようにします。

<RelatedLinks
  title="関連するAPI"
  items={[
{ label: translate("Create hub collaboration"), href: "/reference/v2025.0/post-hub-collaborations", badge: "POST" },
{ label: translate("Get hub collaborations"), href: "/reference/v2025.0/get-hub-collaborations", badge: "GET" },
{ label: translate("Get hub collaboration by ID"), href: "/reference/v2025.0/get-hub-collaborations-id", badge: "GET" },
{ label: translate("Update hub collaboration"), href: "/reference/v2025.0/put-hub-collaborations-id", badge: "PUT" },
{ label: translate("Remove hub collaboration"), href: "/reference/v2025.0/delete-hub-collaborations-id", badge: "DELETE" }
]}
/>

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