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

# Boxドキュメント分割

> Box APIを使用して、Boxに保存された複数ページのPDFを、より小さなサブドキュメントに分割し、その結果をBoxフォルダに保存します。

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

Boxドキュメント分割では、Boxに保存された複数ページのPDFを、より小さなサブドキュメントに分割し、その結果をBoxフォルダに保存します。

以下を実行する必要がある場合にBoxドキュメント分割を使用します。

* <Link href="/guides/docgen/manual-split">手動分割</Link>を使用して、複数ページのPDFを、自分で定義したページ範囲ごとのセグメントに分割する。
* <Link href="/guides/docgen/smart-split">スマート分割</Link>を使用して、自然言語による指示をBoxに解釈させ、ページのグループ化方法を決定する。

## ユースケースの例

| チーム | 例 |
| - | - |
| 営業 | 複数の案件がまとまっている資料を個々の見積書に分割する |
| 法務 | 契約書パッケージから署名ページや本人確認書類を分離する |
| 財務 | 複数の請求書が含まれるPDFから請求書を抽出する |
| 操作 | QRコードを区切りとして、一括スキャンされたドキュメントを分割する |
| 人事 | オンボーディング資料をセクションごとに分割する |

## 前提条件

使用を開始する前に、<Link href="/guides/docgen/docgen-getting-started">Box Doc Genの使い方</Link>ガイドに記載されている手順に従って、Platformアプリを作成し、アクセストークンを生成してください。

以下も必要です。

* Boxにすでに格納されているソースPDF
* アプリが書き込み可能なBox上の保存先フォルダ

## APIバージョン

Boxドキュメント分割のエンドポイントに対するすべてのリクエストでは、`box-version`ヘッダーを`2026.0`に設定して、有効なAPIバージョンを指定する必要があります。

詳細については、<Link href="/guides/api-calls/api-versioning-strategy">APIのバージョン戦略</Link>を参照してください。

## 分割タイプ

送信する`split_type`によって、残りのリクエスト本文が決まります。

| 分割タイプ | 最適な用途 | 指定する内容 |
| - | - | - |
| <Link href="/guides/docgen/manual-split">`manual`</Link> | 既知のページ範囲 | 開始ページと終了ページの`split_definition`配列 |
| <Link href="/guides/docgen/smart-split">`smart`</Link> | 内容やマーカーに基づいた境界 | 自然言語で記述した`prompt` |

<Tip>
  ページ番号がわかっている場合は、結果が決定的であるため、`manual`を使用します。境界を計算するよりも説明した方が簡単な場合は、`smart`を使用します。
</Tip>

<Note>
  スマート分割はAIユニットを消費します。Boxは、4ページ処理するごとに1 AIユニットを消費します。
</Note>

## Boxドキュメント分割の仕組み

Boxドキュメント分割は非同期に動作し、以下の2つのステップを実行します。

1. `POST`リクエストを`/2.0/document_splits`に送信して分割ジョブを作成します。レスポンスにはジョブIDが含まれています。
2. そのIDを使用して、`GET`リクエストを`/2.0/document_splits/{document_split_id}`に送信し、状態および生成されたファイルを取得します。

### 分割ジョブを作成する

リクエスト本文の構造はどちらの分割タイプも同じです。違いは`split_input`の内容のみです。

| パラメータ | 説明 |
| - | - |
| `source_file_id` | 分割対象のPDFのBoxファイルID |
| `destination_folder_id` | Boxが出力ドキュメントを保存するBoxフォルダID |
| `input_source` | 入力のソース。APIベースのすべてのリクエストで`api`を使用します |
| `split_input.split_type` | `manual`または`smart`のどちらか |
| `split_input.split_definition` | 手動分割の場合のページ範囲 |
| `split_input.prompt` | スマート分割の場合の自然言語プロンプト |

リクエストの詳細な例については、<Link href="/guides/docgen/manual-split">手動分割</Link>または<Link href="/guides/docgen/smart-split">スマート分割</Link>のガイドを参照してください。

レスポンスには、分割ジョブのIDが含まれています。

```json theme={null}
{
  "id": "11678",
  "type": "document_split"
}
```

### 分割ジョブの状態と結果を取得する

`POST`のレスポンスで返されたジョブIDを使用して、分割の詳細を取得します。

```sh cURL theme={null}
curl -L 'https://api.box.com/2.0/document_splits/128445' \
     -H 'box-version: 2026.0' \
     -H 'Authorization: Bearer <ACCESS_TOKEN>'
```

レスポンスには、生成されたファイル、Boxが適用した分割の定義、保存先フォルダ、およびリクエストに関するその他の詳細が含まれます。

```json theme={null}
{
  "output": {
    "generated_files": [
      { "id": "2404332574822", "type": "file" },
      { "id": "2404326035290", "type": "file" }
    ],
    "split_definition": [
      { "start": 1, "end": 5 },
      { "start": 7, "end": 9 }
    ]
  },
  "destination_folder": {
    "id": "408521968626",
    "type": "folder"
  },
  "created_by": {
    "id": "36302517035",
    "type": "user"
  },
  "enterprise": {
    "id": "1217301449",
    "type": "enterprise"
  }
}
```

スマート分割の場合、レスポンスに含まれる`split_definition`には、Boxがプロンプトから導き出したページ範囲が表示されます。split\_definitionを参照することで、プロンプトによって期待どおりのグループ化が行われたかどうかを確認できます。

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("Manual split"), href: "/guides/docgen/manual-split", badge: "GUIDE" },
{ label: translate("Smart split"), href: "/guides/docgen/smart-split", badge: "GUIDE" },
{ label: translate("Get started with Box Doc Gen"), href: "/guides/docgen/docgen-getting-started", badge: "GUIDE" }
]}
/>
