Box Developer Documentation
 

    Box Doc Gen jobs

    Box Doc Gen jobs

    A Box Doc Gen job runs when you make a request to generate a document. The document_generation_data parameter in the POST request is an array of entries that represent Box Doc Gen jobs run to generate a document.

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

    Box Doc Gen API allows you to get information about the Box Doc Gen jobs.

    Prerequisites

    Before you start using Box Doc Gen API, follow the steps listed in the get started with Box Doc Gen guide to create a custom app and a Box Doc Gen template.

    List all Box Doc Gen jobs

    To get a list of all Box Doc Gen jobs that were run, use the GET /2.0/docgen_jobs endpoint. You don't have to provide any additional parameters.

    cURL
    curl -i -X GET "https://api.box.com/2.0/docgen_jobs" \
         -H 'box-version: 2025.0' \
         -H "authorization: Bearer <ACCESS_TOKEN>"

    Get a Box Doc Gen job by ID

    To get a specific Box Doc Gen job, use the GET /2.0/docgen_jobs_id endpoint and provide the 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>"

    Get Box Doc Gen jobs in batch with a specific ID

    A single request can generate several documents. In such a case, a separate generation job is run for each document and all these jobs are included in one "batch" meaning a request. To get all jobs performed within one request, use the GET /2.0/docgen_batch_jobs_id endpoint and provide the 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>"