Box Doc Genジョブ
Box Doc Genジョブ
Box Doc Genジョブは、ドキュメントを生成するリクエストを行うと実行されます。POST
リクエスト内のdocument_generation_data
パラメータは、ドキュメントを生成するためのBox Doc Genジョブの実行を表すエントリの配列です。
cURL
curl -L 'https://api.box.com/2.0/docgen_batches' \
-H 'box-version: 2025.0' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-D '{
"file": {
"id": "12345678",
"type": "file"
},
"input_source": "api",
"destination_folder": {
"id": "12345678",
"type": "folder"
},
"output_type": "docx",
"document_generation_data": [
{
"generated_file_name": "Image test",
"user_input": {
"order": {
"id": "12305",
"date": "18-08-2023",
"country": "US",
"expiryDate": "18-08-2024",
"currency": "$",
"amount": 5060.5,
"taxRate": 10,
"requester": "John",
"approver": "Smith",
"department": "Procurement",
"paymentTerms": "30 days",
"deliveryTerms": "30 days",
"deliveryDate": "18-09-2023",
"vendor": {
"company": "Example company",
"address": {
"street": "Example street",
"city": "Example city",
"zip": "EX-456"
}
},
"products": [
{
"id": 1,
"name": "A4 Papers",
"type": "non-fragile",
"quantity": 100,
"price": 29,
"amount": 2900
},
{
"id": 2,
"name": "Ink Cartridge",
"type": "non-fragile",
"quantity": 40,
"price": 39,
"amount": 1560
},
{
"id": 3,
"name": "Adhesive tape",
"type": "non-fragile",
"quantity": 20,
"price": 30,
"amount": 600.5
}
]
}
}
}
]`
TypeScript Gen
await client.docgen.createDocgenBatchV2025R0({
file: new FileReferenceV2025R0({ id: uploadedFile.id }),
inputSource: 'api',
destinationFolder: new DocGenBatchCreateRequestV2025R0DestinationFolderField({
id: folder.id,
}),
outputType: 'pdf',
documentGenerationData: [
{
generatedFileName: 'test',
userInput: { ['abc']: 'xyz' },
} satisfies DocGenDocumentGenerationDataV2025R0,
],
} satisfies DocGenBatchCreateRequestV2025R0);
Python Gen
client.docgen.create_docgen_batch_v2025_r0(
FileReferenceV2025R0(id=uploaded_file.id),
"api",
CreateDocgenBatchV2025R0DestinationFolder(id=folder.id),
"pdf",
[
DocGenDocumentGenerationDataV2025R0(
generated_file_name="test", user_input={"abc": "xyz"}
)
],
)
.NET Gen
await client.Docgen.CreateDocgenBatchV2025R0Async(requestBody: new DocGenBatchCreateRequestV2025R0(file: new FileReferenceV2025R0(id: uploadedFile.Id), inputSource: "api", destinationFolder: new DocGenBatchCreateRequestV2025R0DestinationFolderField(id: folder.Id), outputType: "pdf", documentGenerationData: Array.AsReadOnly(new [] {new DocGenDocumentGenerationDataV2025R0(generatedFileName: "test", userInput: new Dictionary<string, object>() { { "abc", "xyz" } })})));
Box Doc Gen APIを使用すると、Box Doc Genジョブに関する情報を取得できます。
前提条件
Box Doc Gen APIの使用を開始する前に、Box Doc Genの使い方ガイドに記載されている手順に従って、カスタムアプリとBox Doc Genテンプレートを作成してください。
すべてのBox Doc Genジョブのリストを取得
実行されたすべてのBox Doc Genジョブのリストを取得するには、GET /2.0/docgen_jobs
エンドポイントを使用します。追加のパラメータを指定する必要はありません。
cURL
curl -i -X GET "https://api.box.com/2.0/docgen_jobs" \
-H 'box-version: 2025.0' \
-H "authorization: Bearer <ACCESS_TOKEN>"
TypeScript Gen
await client.docgen.getDocgenJobsV2025R0();
Python Gen
client.docgen.get_docgen_jobs_v2025_r0()
.NET Gen
await client.Docgen.GetDocgenJobsV2025R0Async();
IDを指定してBox Doc Genジョブを取得
特定のBox Doc Genジョブを取得するには、GET /2.0/docgen_jobs_id
エンドポイントを使用して、job_id
を指定します。
cURL
curl -i -X GET "https://api.box.com/2.0/docgen_jobs/12345" \
-H 'box-version: 2025.0' \
-H "authorization: Bearer <ACCESS_TOKEN>"
TypeScript Gen
await client.docgen.getDocgenJobByIdV2025R0(docgenJobs.entries![0].id);
Python Gen
client.docgen.get_docgen_job_by_id_v2025_r0(docgen_jobs.entries[0].id)
.NET Gen
await client.Docgen.GetDocgenJobByIdV2025R0Async(jobId: NullableUtils.Unwrap(docgenJobs.Entries)[0].Id);
特定のIDを使用してバッチ内のGet Box Doc Genジョブを取得
単一のリクエストで複数のドキュメントを生成できます。このような場合、個別の生成ジョブが各ドキュメントに対して実行され、これらすべてのジョブが1つの「バッチ」(つまり、1つのリクエスト) に含まれます。1つのリクエスト内で実行されたすべてのジョブを取得するには、GET /2.0/docgen_batch_jobs_id
エンドポイントを使用し、batch_id
を指定します。
cURL
curl -i -X GET "https://api.box.com/2.0/docgen_jobs/12345" \
-H 'box-version: 2025.0' \
-H "authorization: Bearer <ACCESS_TOKEN>"
TypeScript Gen
await client.docgen.getDocgenJobByIdV2025R0(docgenJobs.entries![0].id);
Python Gen
client.docgen.get_docgen_job_by_id_v2025_r0(docgen_jobs.entries[0].id)
.NET Gen
await client.Docgen.GetDocgenJobByIdV2025R0Async(jobId: NullableUtils.Unwrap(docgenJobs.Entries)[0].Id);