> ## 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テンプレートとして設定し、それを使用してドキュメントを生成できます。

## 開始する前に

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

## リクエストの送信

質問を含むリクエストを送信するには、`POST /2.0/docgen_templates`エンドポイントを使用し、必須のパラメータを指定します。

### パラメータ

コールを実行するには、以下のパラメータを渡す必要があります。必須のパラメータは**太字**で示されています。

| パラメータ           | 説明                                | 例          |
| --------------- | --------------------------------- | ---------- |
| **`file.id`**   | Box Doc Genテンプレートとして設定するファイルのID。  | `12345678` |
| **`file.type`** | 指定した入力データの種類。値は常に**`file`**になります。 | `file`     |

## ユースケース

### ファイルをBox Doc Genテンプレートとして設定する

次のサンプルでは、ファイルがBox Doc Genテンプレートとして認識されるように設定する方法を示します。

<Note>
  ファイルは`.docx`形式である必要があります。
</Note>

<CodeGroup>
  ```sh cURL theme={null}
  curl -L 'https://api.box.com/2.0/docgen_templates' \
       -H 'box-version: 2025.0' \
       -H 'Authorization: Bearer <ACCESS_TOKEN>' \
       -H 'Content-Type: application/json' \
       -D '{
          "file": {
              "id": "12345678",
              "type": "file"
          }
  }'
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.docgenTemplate.createDocgenTemplateV2025R0({
    file: new FileReferenceV2025R0({ id: file.id }),
  } satisfies DocGenTemplateCreateRequestV2025R0);
  ```

  ```python Python v10 theme={null}
  client.docgen_template.create_docgen_template_v2025_r0(FileReferenceV2025R0(id=file.id))
  ```

  ```cs .NET v10 theme={null}
  await client.DocgenTemplate.CreateDocgenTemplateV2025R0Async(requestBody: new DocGenTemplateCreateRequestV2025R0(file: new FileReferenceV2025R0(id: file.Id)));
  ```

  ```swift Swift v10 theme={null}
  try await client.docgenTemplate.createDocgenTemplateV2025R0(requestBody: DocGenTemplateCreateRequestV2025R0(file: FileReferenceV2025R0(id: file.id)))
  ```

  ```java Java v10 theme={null}
  client.getDocgenTemplate().createDocgenTemplateV2025R0(new DocGenTemplateCreateRequestV2025R0(new FileReferenceV2025R0(file.getId())))
  ```
</CodeGroup>

### ファイルからBox Doc Genテンプレートの設定を削除する

ファイルのBox Doc Genテンプレートの設定が解除されるようにするには、`DELETE 2.0/docgen_templates/:template_id`リクエストを使用します。

<CodeGroup>
  ```sh cURL theme={null}
  curl -L -X DELETE 'https://api.box.com/2.0/docgen_templates/12345678' \
       -H 'box-version: 2025.0' \
       -H 'Authorization: Bearer <ACCESS_TOKEN>'
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.docgenTemplate.deleteDocgenTemplateByIdV2025R0(
    createdDocgenTemplate.file!.id,
  );
  ```

  ```python Python v10 theme={null}
  client.docgen_template.delete_docgen_template_by_id_v2025_r0(
      created_docgen_template.file.id
  )
  ```

  ```cs .NET v10 theme={null}
  await client.DocgenTemplate.DeleteDocgenTemplateByIdV2025R0Async(templateId: NullableUtils.Unwrap(createdDocgenTemplate.File).Id);
  ```

  ```swift Swift v10 theme={null}
  try await client.docgenTemplate.deleteDocgenTemplateByIdV2025R0(templateId: createdDocgenTemplate.file!.id)
  ```

  ```java Java v10 theme={null}
  client.getDocgenTemplate().deleteDocgenTemplateByIdV2025R0(createdDocgenTemplate.getFile().getId())
  ```
</CodeGroup>

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("Get started with Box Doc Gen"), href: "/guides/docgen/docgen-getting-started", badge: "GUIDE" },
{ label: translate("Box Doc Gen templates"), href: "/guides/docgen/docgen-templates", badge: "GUIDE" },
{ label: translate("Generate documents"), href: "/guides/docgen/generate-document", badge: "GUIDE" }
]}
/>
