Box Developerドキュメント

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

ガイド Box Doc Gen ファイルをBox Doc Genテンプレートとして設定

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

既存のドキュメントをBox Doc Genテンプレートとして設定し、それを使用してドキュメントを生成できます。

開始する前に

Box Doc Gen APIの使用を開始する前に、Box Doc Genの使い方ガイドに記載されている手順に従って、カスタムアプリとBox Doc Genテンプレートを作成してください。

リクエストの送信

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

パラメータ

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

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

ユースケース

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

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

ファイルは.docx形式である必要があります。

cURL
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 Gen
await client.docgenTemplate.createDocgenTemplateV2025R0({
  file: new FileReferenceV2025R0({ id: file.id }),
} satisfies DocGenTemplateCreateRequestV2025R0);
Python Gen
client.docgen_template.create_docgen_template_v2025_r0(FileReferenceV2025R0(id=file.id))
.NET Gen
await client.DocgenTemplate.CreateDocgenTemplateV2025R0Async(requestBody: new DocGenTemplateCreateRequestV2025R0(file: new FileReferenceV2025R0(id: file.Id)));

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

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

cURL
curl -L -X DELETE 'https://api.box.com/2.0/docgen_templates/12345678' \
     -H 'box-version: 2025.0' \
     -H 'Authorization: Bearer <ACCESS_TOKEN>'
TypeScript Gen
await client.docgenTemplate.deleteDocgenTemplateByIdV2025R0(
  createdDocgenTemplate.file!.id,
);
Python Gen
client.docgen_template.delete_docgen_template_by_id_v2025_r0(
    created_docgen_template.file.id
)
.NET Gen
await client.DocgenTemplate.DeleteDocgenTemplateByIdV2025R0Async(templateId: NullableUtils.Unwrap(createdDocgenTemplate.File).Id);