Box Developerドキュメント
最新バージョン

Generate document using a Box Doc Gen template

post
https://api.box.com/2.0
/docgen_batches

Generates a document using a Box Doc Gen template.

リクエスト

bearer [ACCESS_TOKEN]
application/json

リクエストヘッダー

stringヘッダー内必須

Version header

次の値に固定: 2025.0

リクエスト本文

object本文内

Destination folder for the generated files.

string本文内必須
"42037322"

ID of the folder

string本文内必須
"folder"

folder

次の値に固定: folder

object array本文内必須
"New_Template"

File name of the output file.

{"name":"Aaron Levie"}
object本文内

A Box Doc Gen template that is used to generate the document.

string本文内必須
"42037322"

ID of the object

string本文内必須
"file"

file

次の値に固定: file

object本文内

File version of a template.

string本文内省略可能
"12345"

ファイルバージョンを表す一意の識別子。

string本文内省略可能
"file_version"

file_version

次の値に固定: file_version

string本文内必須
"api"

Source of input. The value has to be api for all the API-based document generation requests.

string本文内必須
"docx"

Type of the output file.

レスポンス

The created Batch ID.

The client does not have access rights to the content or resource requested.

The user has sent too many requests in a given amount of time.

An unexpected condition was encountered on the server.

post
Generate document using a Box Doc Gen template
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

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" } })})));

レスポンスの例

{
  "id": "12345",
  "type": "docgen_batch"
}