Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDOC-1208: Add Box Doc Gen guides #666

Merged
merged 16 commits into from
Jan 13, 2025
Merged
2 changes: 1 addition & 1 deletion content/guides/box-ai/ai-tutorials/prerequisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ the Box AI APIs in your sandbox, request access
from the Box AI team using [this form][form].
</Message>

## Create an application
## Create a custom application

First you need to create a custom application
you will use to make calls. To create
Expand Down
71 changes: 71 additions & 0 deletions content/guides/docgen/docgen-getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
rank: 1
related_endpoints:
- post_docgen_templates_v2025.0
- post_docgen_batches_v2025.0
related_guides:
- docgen/generate-document
- docgen/mark-template
- docgen/docgen-jobs
- docgen/docgen-templates
---

# Get started with Box Doc Gen

To start generating documents with Box Doc Gen API you will need a custom application and a developer token to
authenticate your calls. You also need a Doc Gen template that will serve as an input source for your document.

## Enable Box Doc Gen

To use Box Doc Gen, make sure it is enabled by an
admin in the Admin Console.
If you are a Box Admin, you will find the necessary information in
[Enterprise Settings: Content & Sharing Tab][settings] documentation.

## Create and upload a Box Doc Gen template

To use Box Doc Gen API to generate documents, a Box Doc Gen template must already exist in Box. You have the following options to create a template:

* Install the [Box Doc Gen Template Creator add-in for Microsoft Word][template-addin].
* Create a Box Doc Gen template [using a JSON file][json-template] or manually create [template tags][template-tags].

## Create a custom application

First you need to create a custom application
you will use to make calls. To create
an application, follow the guide
on [creating custom apps][createapps].

## Generate a developer token

You need a developer token
to authenticate your app when sending requests.

To generate a token:

1. Go to **Developer Console** > **My Platform Apps**.
2. Click the **Options menu** button (…) on the right.
3. Select **Generate Developer Token**. The token will be automatically generated and saved to clipboard.

![generate token](./images/developer-token.png)

You can also open your app, go to
**Configuration** > **Developer Token**
and generate the token.

<Message type="notice">
A developer token is only valid for one hour.
</Message>

For additional details, see [developer token][token].
After you generate the token, you can use it in cURL
or other clients, such as [Postman][postman], to make
calls.

[token]: g://authentication/tokens/developer-tokens
[createapps]: g://applications/app-types/custom-apps
[postman]: g://tooling/postman
[settings]: https://support.box.com/hc/en-us/articles/4404822772755-Enterprise-Settings-Content-Sharing-Tab#h_01FYQGK5RW42T07GV985MQ9E9A
[template-addin]: https://support.box.com/hc/en-us/articles/36587535449747-Installing-Box-Doc-Gen-Add-in
[template-tags]: https://support.box.com/hc/en-us/articles/36151895655059-Creating-A-Box-Doc-Gen-Template-Manually
[json-template]: https://support.box.com/hc/en-us/articles/36148012877843-Creating-a-Box-Doc-Gen-Template-using-JSON-data
46 changes: 46 additions & 0 deletions content/guides/docgen/docgen-jobs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
rank: 5
related_endpoints:
- get_docgen_jobs_v2025.0
- get_docgen_batch_jobs_id_v2025.0
- get_docgen_jobs_id_v2025.0
related_guides:
- docgen/docgen-getting-started
- docgen/generate-document
---

# 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.

<Samples id='post_docgen_batches_v2025.0' />

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][docgen-prerequisites] 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.

<Samples id='get_docgen_jobs_v2025.0' />

## 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`.

<Samples id='get_docgen_jobs_id_v2025.0' />

## 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`.

<Samples id='get_docgen_jobs_id_v2025.0' />

[docgen-prerequisites]: g://docgen/docgen-getting-started
49 changes: 49 additions & 0 deletions content/guides/docgen/docgen-templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
rank: 4
related_endpoints:
- get_docgen_templates_v2025.0
- get_docgen_templates_id_v2025.0
- get_docgen_templates_id_tags_v2025.0
- post_docgen_templates_v2025.0
related_guides:
- docgen/docgen-getting-started
- docgen/generate-document
---

# Box Doc Gen templates

Box Doc Gen API allows you to retrieve information related to Box Doc Gen templates.

## Prerequisites

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

## List Box Doc Gen templates

To get a list of all created Box Doc Gen templates,
use the `GET /2.0/docgen_templates` endpoint. You don't have to provide any additional parameters.

<Samples id='get_docgen_templates_v2025.0' />

The response will contain an `entries` array listing the already created Box Doc Gen templates.

## Get a Box Doc Gen template by ID

To get a specific Box Doc Gen template,
use the `GET /2.0/docgen_templates_id` endpoint and provide the `template_id`.

<Samples id='get_docgen_templates_id_v2025.0' />

The response will contain details of a file that was used as a Box Doc Gen template.

## List all document generation jobs for a template

To get a list of all created Box Doc Gen templates,
use the `GET /2.0/docgen_template_jobs_id` endpoint and provide the `template_id`.

<Samples id='get_docgen_template_jobs_id_v2025.0' />

The response will contain a list of Box Doc Gen jobs that were run to generate
documents.

[docgen-prerequisites]: g://docgen/docgen-getting-started
53 changes: 53 additions & 0 deletions content/guides/docgen/generate-document.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
rank: 3
related_guides:
- docgen/docgen-getting-started
- docgen/mark-template
related_endpoints:
- post_docgen_batches_v2025.0
- post_docgen_templates_v2025.0
---

# Generate documents

The `POST /2.0/docgen_batches` endpoint allows you to generate a document using Box Doc Gen template as input.

## Prerequisites

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

## Send a request

To generate a document or a set of documents,
use the `POST /2.0/docgen_batches` endpoint.

### Parameters

To make a call, you need to pass the following parameters.
Mandatory parameters are in **bold**.

| Parameter |Description | Example |
| ------------ | ------ | --- |
| **`file.id`** | ID of the file to be marked as Box Doc Gen template. | `12345678` |
| **`file.type`** | The type of provided input. The value is always **`file`**. | `file` |
| `file_version` | The file version of a template. | `12345` |
| **`input_source`** | The input source for generated document. The value has to be `api` for all the API-based document generation requests. | `api` |
| **`output_type`** | The output file type. | `docx` |
| **`destination_folder.id`** | The ID of the folder where the generated document will be stored. | `12345678` |
| **`destination_folder.type`** | The type of the destination item. Since the generated files are stored in folders, the value is always **`folder`**. | `file` |
| **`document_generation_data.generated_file_name`** | The name of the generated file. | `New_Template` |
| **`document_generation_data.user_input`** | The JSON data to be used to generate document. | `{"id": 2, "name": "Ink Cartridge", "type": "non-fragile"}`|

## Use case

When your Box Doc Gen template and JSON data is ready, you can make a request to Box Doc Gen API to generate documents.

A sample call looks as follows:

<Samples id='post_docgen_batches_v2025.0' />

When the request is being processed, each entry in the `document_generation_data` array is treated as a separate document generation job that Box Doc Gen adds to the document generation queue.

Generated documents will be saved in the designated folder.

[docgen-prerequisites]: g://docgen/docgen-getting-started
Binary file added content/guides/docgen/images/developer-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/guides/docgen/images/docgen-workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions content/guides/docgen/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
rank: 0
related_guides:
- docgen/docgen-getting-started
- docgen/docgen-templates
- docgen/docgen-jobs
- docgen/mark-template
- docgen/generate-document
related_endpoints:
- get_docgen_batch_jobs_id_v2025.0
- get_docgen_jobs_id_v2025.0
- get_docgen_jobs_v2025.0
- get_docgen_templates_v2025.0
- post_docgen_templates_v2025.0
---

# Box Doc Gen

Box Doc Gen allows you to generate business documents such as offer letters, sales contracts, invoices or agreements.
You can generate documents based on Box Doc Gen templates uploaded to Box, with data fields that can be dynamically filled using Box Doc Gen API.

<Message type='notice'>
Box Doc Gen only supports the ability to leverage English template tags when
using Box Doc Gen templates. We recommend that customers test and review that Box Doc Gen supports their desired language requirements.

</Message>

## Box Doc Gen API capabilities

Box Doc Gen API allows you to:

* mark documents as Box Doc Gen templates,
* generate documents based on Box Doc Gen templates you store in Box,
* examine the details of Box Doc Gen templates and document generation jobs.

## Box Doc Gen API version

Box Doc Gen API was released in Box API version `2025.0`. All API requests to Box Doc Gen API endpoints must specify a valid API version by setting the `box-version` header to `2025.0`.

For more details, see [Box API versioning][api-versioning].

## Box Doc Gen workflow

![A flow diagram representing Box Doc Gen workflow](./images/docgen-workflow.png)

1. Author your Doc Gen Template
* Use [Doc Gen Add-in for Microsoft Word][template-addin] to create a template without any code.
* You can also leverage [Doc Gen's tagging script][tagging-script] to author the template.

2. [Add the template to Box][upload-template] using the Box Doc Gen UI. At this point, you can:
* Mark an existing file In Box as Doc Gen template.
* Create or Upload a document and mark it as a Box Doc Gen template.
3. [Generate the document][generate-document] using Box Doc Gen API.

[template-addin]: https://support.box.com/hc/en-us/articles/36587535449747-Installing-Box-Doc-Gen-Add-in
[template-tags]: https://support.box.com/hc/en-us/articles/36151895655059-Creating-A-Box-Doc-Gen-Template-Manually
[json-template]: https://support.box.com/hc/en-us/articles/36148012877843-Creating-a-Box-Doc-Gen-Template-using-JSON-data
[tagging-script]: https://support.box.com/hc/en-us/articles/36149723736723-Template-tags-reference
[upload-template]: https://support.box.com/hc/en-us/articles/36587432368275-Managing-Box-Doc-Gen-Templates-in-Relay
[generate-document]: g://docgen/generate-document
[api-versioning]:g://api-calls/api-versioning-strategy
55 changes: 55 additions & 0 deletions content/guides/docgen/mark-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
rank: 2
related_guides:
- docgen/docgen-getting-started
- docgen/docgen-templates
- docgen/generate-document
related_endpoints:
- post_docgen_batches_v2025.0
- post_docgen_templates_v2025.0
---

# Mark file as Box Doc Gen template

You can mark an existing document as a Box Doc Gen template and use it to generate documents.

## Before you start

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

## Send a request

To send a request containing your question,
use the `POST /2.0/docgen_templates` endpoint and
provide the mandatory parameters.

### Parameters

To make a call you need to pass the following parameters.
Mandatory parameters are in **bold**.

| Parameter |Description | Example |
| ------------ | ------ | --- |
| **`file.id`** | ID of the file to be marked as the Box Doc Gen template. | `12345678` |
| **`file.type`** | The type of provided input. The value is always **`file`**. | `file` |

## Use cases

### Mark a file as Box Doc Gen template

The following sample show you how to mark a file to ensure it is recognized as a Box Doc Gen template.

<Message type='notice'>
The file must be in `.docx` format.
</Message>

<Samples id='post_docgen_templates_v2025.0' />

### Remove Box Doc Gen template marking from a file

To make sure a file is no longer marked as a Box Doc Gen template,
use the `DELETE 2.0/docgen_templates/:template_id` request.

<Samples id='delete_docgen_templates_id_v2025.0' />

[docgen-prerequisites]: g://docgen/docgen-getting-started
Loading