> ## 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 Doc Genの使い方

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 Doc Gen APIを使用したドキュメントの生成を開始するには、Platformアプリケーションと、コールを認証するための開発者トークンが必要です。また、ドキュメントの入力ソースとして機能するDoc Genテンプレートも必要です。

## Box Doc Genの有効化

Box Doc Genを使用するには、管理者が管理コンソールで有効にしていることを確認してください。Box管理者の場合、[Enterprise設定: \[コンテンツと共有\] タブ][settings]のドキュメントで必要な情報を確認できます。

## Box Doc Genテンプレートの作成とアップロード

Box Doc Gen APIを使用してドキュメントを生成するには、Box Doc GenテンプレートがすでにBox内に存在する必要があります。テンプレートを作成するには、以下のオプションがあります。

* [Microsoft Word用Box Doc Gen Template Creatorアドイン][template-addin]をインストールする。
* [JSONファイルを使用][json-template]してBox Doc Genテンプレートを作成するか、手動で[テンプレートタグ][template-tags]を作成する。

## Platformアプリケーションの作成

まず、コールの実行に使用するPlatformアプリケーションを作成する必要があります。アプリケーションを作成するには、<Link href="/guides/applications/platform-apps/create">Platformアプリの作成</Link>に関するガイドに従ってください。

## 開発者トークンの生成

リクエストの送信時にアプリを認証するには、開発者トークンが必要です。

トークンを生成するには、以下の手順を実行します。

1. \[**開発者コンソール**] > \[**Platformアプリ**] に移動します。
2. 右側の**オプションメニュー**ボタン (\[…]) をクリックします。
3. \[**開発者トークンを生成**] を選択します。トークンが自動的に生成され、クリップボードに保存されます。

<Frame>
  <img src="https://mintcdn.com/box/_tECS-SYBYV9K-kZ/images/guides/docgen/developer-token.png?fit=max&auto=format&n=_tECS-SYBYV9K-kZ&q=85&s=501d22896841a0400230126f4c8a7682" alt="トークンの生成" width="1205" height="456" data-path="images/guides/docgen/developer-token.png" />
</Frame>

アプリを開いて、\[**構成**] > \[**開発者トークン**] に移動してトークンを生成することもできます。

<Note>
  開発者トークンの有効期限は1時間のみです。
</Note>

詳細については、<Link href="/guides/authentication/tokens/developer-tokens">開発者トークン</Link>を参照してください。トークンを生成したら、cURLや他のクライアント (<Link href="/guides/tooling/postman">Postman</Link>など) で使用してコールを実行できます。

## Webhookの使用

Webhookを作成して、Doc Genイベントを監視したり、ビジネスプロセスやワークフローを自動化したりできます。

<Link href="/guides/webhooks/v2/create-v2/">Webhookの追加</Link>手順に従います。コンテンツタイプは、Doc Genテンプレートファイルまたはフォルダです。

サポートされている<Link href="/guides/webhooks/triggers">イベント</Link>は以下のとおりです。

* `DOCGEN_DOCUMENT_GENERATION_STARTED`
* `DOCGEN_DOCUMENT_GENERATION_SUCCEEDED`
* `DOCGEN_DOCUMENT_GENERATION_FAILED`

<Frame>
  <img src="https://mintcdn.com/box/_tECS-SYBYV9K-kZ/images/guides/docgen/docgen-triggers.png?fit=max&auto=format&n=_tECS-SYBYV9K-kZ&q=85&s=c72ca45648da404e4477db8355612be6" alt="Doc Genのイベントトリガー" width="535" height="322" data-path="images/guides/docgen/docgen-triggers.png" />
</Frame>

通知に掲載される情報は以下のとおりです。

* トリガー名
* Webhookトリガーのタイムスタンプ
* テンプレートファイルID
* テンプレートファイルバージョンID
* テンプレートファイル名
* 保存先フォルダ
* 生成されたファイルのID (ドキュメント生成プロセスが成功した場合)
* 出力タイプ (DOCXまたはPDF)
* 理由 (ドキュメント生成プロセスが失敗した場合)

[settings]: https://support.box.com/hc/en-us/articles/4404822772755-Enterprise-Settings-Content-Sharing-Tab#h_01FYQGK5RW42T07GV985MQ9E9A

[template-addin]: https://support.box.com/hc/en-us/articles/36587535449747-Installing-Box-Doc-Gen-Add-in

[template-tags]: https://support.box.com/hc/en-us/articles/36151895655059-Creating-A-Box-Doc-Gen-Template-Manually

[json-template]: https://support.box.com/hc/en-us/articles/36148012877843-Creating-a-Box-Doc-Gen-Template-using-JSON-data

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("Generate documents"), href: "/guides/docgen/generate-document", badge: "GUIDE" },
{ label: translate("Mark file as Box Doc Gen template"), href: "/guides/docgen/mark-template", badge: "GUIDE" },
{ label: translate("Box Doc Gen jobs"), href: "/guides/docgen/docgen-jobs", badge: "GUIDE" },
{ label: translate("Box Doc Gen templates"), href: "/guides/docgen/docgen-templates", badge: "GUIDE" }
]}
/>
