Box Developer Documentation
Latest version

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.

Request

bearer [ACCESS_TOKEN]
application/json

Request Headers

stringin headerrequired

Version header

Value is always 2025.0

Request Body

objectin body

Destination folder for the generated files.

stringin bodyrequired
"42037322"

ID of the folder

stringin bodyrequired
"folder"

folder

Value is always folder

object arrayin bodyrequired
"New_Template"

File name of the output file.

associative arrayin body
objectin body
objectin body

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

stringin bodyrequired
"42037322"

ID of the object

stringin bodyrequired
"file"

file

Value is always file

objectin body

File version of a template.

stringin bodyoptional
"12345"

The unique identifier that represent a file version.

stringin bodyoptional
"file_version"

file_version

Value is always file_version

stringin bodyrequired
"api"

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

stringin bodyrequired
"docx"

Type of the output file.

Response

The created Batch ID.

application/jsonClient error

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

application/jsonClient error

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

application/jsonClient error

An unexpected condition was encountered on the server.

post
Generate document using a Box Doc Gen template
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

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
                            }
                        ]
                    }
                }
            }
        ]`

Response Example

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