> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate document using Box Doc Gen template

> Generates a document using a Box Doc Gen template.

<Note>
  Learn more about [Box SDK versioning strategy](/guides/tooling/sdks/sdk-versioning/).
</Note>


## OpenAPI

````yaml /box-openapi-v2025.0.json POST /docgen_batches
openapi: 3.0.2
info:
  title: Box Platform API
  description: >-
    [Box Platform](https://developer.box.com) provides functionality to provide
    access to content stored within [Box](https://box.com). It provides
    endpoints for basic manipulation of files and folders, management of users
    within an enterprise, as well as more complex topics such as legal holds and
    retention policies.
  termsOfService: https://cloud.app.box.com/s/rmwxu64h1ipr41u49w3bbuvbsa29wku9
  contact:
    name: Box, Inc
    url: https://developer.box.com
    email: devrel@box.com
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: '2025.0'
  x-box-commit-hash: 95117b97f9
servers:
  - url: https://api.box.com/2.0
    description: Box Platform API server.
security:
  - OAuth2Security: []
tags:
  - name: Archives
    description: A set of endpoints used to manage archives.
    x-box-tag: archives
  - name: Enterprise Configurations
    description: >-
      Enterprise configurations admins interact with to drive Box product
      behavior.
    x-box-tag: enterprise_configurations
  - name: Box Doc Gen
    description: Doc Gen is used to automatically generate documents.
    x-box-tag: docgen
  - name: Box Doc Gen templates
    description: Doc Gen templates are used as input to generate documents.
    x-box-tag: docgen_template
  - name: External Users
    description: External users are collaborators from outside of your enterprise.
    x-box-tag: external_users
  - name: Box Hubs
    description: A set of endpoints used to manage Box Hubs.
    x-box-tag: hubs
  - name: Box Hub Collaborations
    description: A set of endpoints used to manage collaborations within a Box Hub.
    x-box-tag: hub_collaborations
  - name: Box Hub Document
    description: >-
      A set of endpoints used to retrieve Box Hub Document elements (pages and
      content blocks).
    x-box-tag: hub_document
  - name: Box Hub Items
    description: A set of endpoints used to manage items within a Box Hub.
    x-box-tag: hub_items
  - name: Shield lists
    description: >-
      Shield List allow an administrator to create a list which will be shared
      between different Shield Smart Access and Threat Detection rules.
    x-box-tag: shield_lists
externalDocs:
  description: Box Developer Documentation.
  url: https://developer.box.com
paths:
  /docgen_batches:
    post:
      tags:
        - Box Doc Gen
      summary: Generate document using Box Doc Gen template
      description: Generates a document using a Box Doc Gen template.
      operationId: post_docgen_batches_v2025.0
      parameters:
        - $ref: '#/components/parameters/BoxVersionHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocGenBatchCreateRequest'
      responses:
        '202':
          description: The created Batch ID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocGenBatch--Base'
        '403':
          description: >-
            The client does not have access rights to the content or resource
            requested.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClientError'
        '429':
          description: The user has sent too many requests in a given amount of time.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClientError'
        default:
          description: An unexpected condition was encountered on the server.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClientError'
      x-codeSamples:
        - lang: curl
          label: Generate document using Box Doc Gen template
          source: |-
            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
                                        }
                                    ]
                                }
                            }
                        }
                    ]`
        - lang: dotnet
          label: Generate document using Box Doc Gen template
          source: >-
            await client.Docgen.CreateDocgenBatchV2025R0Async(requestBody: new
            DocGenBatchCreateRequestV2025R0(file: new FileReferenceV2025R0(id:
            uploadedFileDocx.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" }
            })})));
        - lang: swift
          label: Generate document using Box Doc Gen template
          source: >-
            try await client.docgen.createDocgenBatchV2025R0(requestBody:
            DocGenBatchCreateRequestV2025R0(file: FileReferenceV2025R0(id:
            uploadedFileDocx.id), inputSource: "api", destinationFolder:
            DocGenBatchCreateRequestV2025R0DestinationFolderField(id:
            folder.id), outputType: "pdf", documentGenerationData:
            [DocGenDocumentGenerationDataV2025R0(generatedFileName: "test",
            userInput: ["abc": "xyz"])]))
        - lang: java
          label: Generate document using Box Doc Gen template
          source: >-
            client.getDocgen().createDocgenBatchV2025R0(new
            DocGenBatchCreateRequestV2025R0(new
            FileReferenceV2025R0(uploadedFileDocx.getId()), "api", new
            DocGenBatchCreateRequestV2025R0DestinationFolderField(folder.getId()),
            "pdf", Arrays.asList(new DocGenDocumentGenerationDataV2025R0("test",
            mapOf(entryOf("abc", "xyz"))))))
        - lang: node
          label: Generate document using Box Doc Gen template
          source: |-
            await client.docgen.createDocgenBatchV2025R0({
              file: new FileReferenceV2025R0({ id: uploadedFileDocx.id }),
              inputSource: 'api',
              destinationFolder: new DocGenBatchCreateRequestV2025R0DestinationFolderField({
                id: folder.id,
              }),
              outputType: 'pdf',
              documentGenerationData: [
                {
                  generatedFileName: 'test',
                  userInput: { ['abc']: 'xyz' },
                } satisfies DocGenDocumentGenerationDataV2025R0,
              ],
            } satisfies DocGenBatchCreateRequestV2025R0);
        - lang: python
          label: Generate document using Box Doc Gen template
          source: |-
            client.docgen.create_docgen_batch_v2025_r0(
                FileReferenceV2025R0(id=uploaded_file_docx.id),
                "api",
                CreateDocgenBatchV2025R0DestinationFolder(id=folder.id),
                "pdf",
                [
                    DocGenDocumentGenerationDataV2025R0(
                        generated_file_name="test", user_input={"abc": "xyz"}
                    )
                ],
            )
components:
  parameters:
    BoxVersionHeader:
      name: box-version
      in: header
      description: Version header.
      allowEmptyValue: false
      required: true
      schema:
        type: string
        enum:
          - '2025.0'
      example: '2025.0'
  schemas:
    DocGenBatchCreateRequest:
      description: The schema for creating a Box Doc Gen job batch request.
      type: object
      properties:
        file:
          allOf:
            - $ref: '#/components/schemas/FileReference'
            - description: A Box Doc Gen template that is used to generate the document.
        file_version:
          allOf:
            - $ref: '#/components/schemas/FileVersion--Base'
            - description: File version of a template.
        input_source:
          description: >-
            Source of input. The value has to be `api` for all the API-based
            document generation requests.
          type: string
          example: api
        destination_folder:
          allOf:
            - description: Folder reference.
              type: object
              properties:
                type:
                  description: The value will always be `folder`.
                  type: string
                  example: folder
                  enum:
                    - folder
                  nullable: false
                id:
                  description: ID of the folder.
                  type: string
                  example: '42037322'
              required:
                - type
                - id
              title: Folder reference
            - description: Destination folder for the generated files.
        output_type:
          description: Type of the output file.
          type: string
          example: docx
        document_generation_data:
          type: array
          items:
            $ref: '#/components/schemas/DocGenDocumentGenerationData'
      required:
        - file
        - input_source
        - destination_folder
        - output_type
        - document_generation_data
      title: Create batch request
    DocGenBatch--Base:
      description: >-
        The basic representation of a Box Doc Gen batch object. A Box Doc Gen
        batch contains one or more Box Doc Gen jobs.
      type: object
      properties:
        id:
          description: The unique identifier that represents a Box Doc Gen batch.
          type: string
          example: '12345'
          nullable: false
        type:
          description: The value will always be `docgen_batch`.
          type: string
          example: docgen_batch
          enum:
            - docgen_batch
          nullable: false
      required:
        - id
        - type
      title: Box Doc Gen batch (Base)
      x-box-resource-id: docgen_batch_v2025.0--base
      x-box-tag: docgen
      x-box-variant: base
      x-box-variants:
        - base
    ClientError:
      description: A generic error.
      type: object
      properties:
        type:
          description: The value will always be `error`.
          type: string
          example: error
          enum:
            - error
          nullable: false
        status:
          description: The HTTP status of the response.
          type: integer
          format: int32
          example: 400
          nullable: false
        code:
          description: A Box-specific error code.
          type: string
          example: item_name_invalid
          enum:
            - created
            - accepted
            - no_content
            - redirect
            - not_modified
            - bad_request
            - unauthorized
            - forbidden
            - not_found
            - method_not_allowed
            - conflict
            - precondition_failed
            - too_many_requests
            - internal_server_error
            - unavailable
            - item_name_invalid
            - insufficient_scope
        message:
          description: A short message describing the error.
          type: string
          example: Method Not Allowed
          nullable: false
        context_info:
          description: >-
            A free-form object that contains additional context about the error.
            The possible fields are defined on a per-endpoint basis. `message`
            is only one example.
          type: object
          example:
            message: Something went wrong
          additionalProperties: {}
          nullable: true
        help_url:
          description: A URL that links to more information about why this error occurred.
          type: string
          example: >-
            https://developer.box.com/guides/api-calls/permissions-and-errors/common-errors/
          nullable: false
        request_id:
          description: >-
            A unique identifier for this response, which can be used when
            contacting Box support.
          type: string
          example: abcdef123456
          nullable: false
      title: Client error
      x-box-resource-id: client_error_v2025.0
    FileReference:
      description: File reference.
      type: object
      properties:
        type:
          description: The value will always be `file`.
          type: string
          example: file
          enum:
            - file
          nullable: false
        id:
          description: ID of the object.
          type: string
          example: '42037322'
          nullable: false
      required:
        - type
        - id
      title: File reference
    FileVersion--Base:
      description: >-
        The bare basic representation of a file version, the minimal amount of
        fields returned when using the `fields` query parameter.
      type: object
      properties:
        id:
          description: The unique identifier that represent a file version.
          type: string
          example: '12345'
          nullable: false
        type:
          description: The value will always be `file_version`.
          type: string
          example: file_version
          enum:
            - file_version
          nullable: false
      required:
        - id
        - type
      title: File version (Base)
    DocGenDocumentGenerationData:
      description: The schema for for creating a Box Doc Gen job request.
      type: object
      properties:
        generated_file_name:
          description: File name of the output file.
          type: string
          example: New_Template
        user_input:
          type: object
          example:
            name: Aaron Levie
          additionalProperties: {}
      required:
        - generated_file_name
        - user_input
      title: Document generation data
  securitySchemes:
    OAuth2Security:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://account.box.com/api/oauth2/authorize
          tokenUrl: https://api.box.com/oauth2/token
          scopes:
            root_readonly: Read all files and folders stored in Box
            root_readwrite: Read and write all files and folders stored in Box
            manage_app_users: Provision and manage app users
            manage_managed_users: Provision and manage managed users
            manage_groups: Manage an enterprise's groups
            manage_webhook: Create webhooks programmatically through the API
            manage_enterprise_properties: Manage enterprise properties
            manage_data_retention: Manage data retention polices
            manage_legal_hold: Manage Legal Holds

````