Developer, your orders have arrived. World Industries needs authority over their documents — and they need it now. Deep in their basement sits a generation engine: powerful, idle, and waiting. Its storage bays are empty. The blueprints and data that feed it have been lost somewhere in the archive. Before you can deliver, you'll need to assemble the stranded components and get that engine running:
Your job is to recover the lost components, load them into storage, and bring the engine to life with a single generation call. Empty bays, cold engine. Cold engine, no documents. No documents, no authority. The clock is running.
Objective: Load a template and data into storage, configure and run the generation, then collect the finished document.
Before running the steps, take a look at the two raw materials this mission works with:
Customer.Name, Customer.EffectiveDate, and Customer.LineItems.Knowing what's in both files before you start makes it much easier to see how they connect once you get to generation in Step 3.
This mission uses Doctavian Storage for everything: the template, the data, and the finished document. Storage is a short-term staging area, not an archive:
urn.More in Storage and File IDs.
Open the Doctavian Postman collection and navigate to the Mission 1 — Command and Conquer Your Document Empire folder. Run the steps in order. Each step below also shows the underlying request, so you can reproduce it in your own code.
Don't have the collection yet? Make sure you've completed the Quickstart and have a valid access token before starting.
This mission walks through connecting your data to a template and generating a finished contract, end to end.
Download the sample contract template, then open Step 1 — Upload the template in Postman, attach the file, and send the request. Under the hood it's a multipart upload:
POST https://api.doctavian.com/v1/documents/template/upload
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: multipart/form-data
file: mission-1-agreement.docxThe template reads from Customer.Name, Customer.EffectiveDate, and a Customer.LineItems collection. Article 3 — Scope of Services uses a Repeater over that collection, rendering one row per line item. Article 4 — Volume Discount is a conditional Paragraph that only appears if the total contract value — calculated with a sum() expression across all line items — exceeds $10,000.
A 201 Created confirms the template is in Storage. Note the storage id at result.data.files[0].id; the collection saves it as {{mission1.templateId}}.
Download the sample data file, then open Step 2 — Upload the data, attach the file, and send the request:
POST https://api.doctavian.com/v1/documents/data/upload
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: multipart/form-data
file: mission-1-data.jsonThe sample file already has the shape Doctavian expects: a root data object whose members are lists of records, with every value a string. When you prepare your own data, see Set up Data Sources.
A 201 Created confirms the data is uploaded. Note the storage id at result.data.files[0].id; the collection saves it as {{mission1.dataId}}.
Open Step 3 — Generate the document. This is where everything from the previous two steps comes together in a single call to POST /documents/document/generate (documents-document-generate). The body has three mandatory sections:
{{mission1.templateId}}, the contract template with its Repeater and conditional clause{{mission1.dataId}}, the customer data uploaded in Step 2The request the collection sends:
POST https://api.doctavian.com/v1/documents/document/generate
Authorization: Bearer <token>
x-api-key: <api-key>
Content-Type: application/json
{
"externalContext": {
"id": "mission-1-generate"
},
"template": {
"name": "mission-1-agreement.docx",
"urn": "{{mission1.templateId}}",
"fileFormat": "docx",
"loadMethod": "Storage",
"options": {}
},
"data": {
"loadMethod": "Storage",
"urn": "{{mission1.dataId}}"
},
"document": {
"name": "World-Industries-Contract",
"fileFormat": "pdf",
"deliveryMethod": "Storage",
"path": "root",
"locale": "en",
"timeZone": "Europe/Dublin",
"options": {}
}
}externalContext is optional: any JSON object you like, returned unchanged in the response so you can match it to the request. locale and timeZone control how dates and numbers render; see Locales and Timezones. For every other option, including OneDrive, Google Drive and GraphQL sources, see Generate Document.
Send the request. A 200 OK confirms the document is generated. Note the storage id of the generated file at result.data.document.urn; the collection saves it as {{mission1.generatedDocumentId}}.
This call is synchronous — the response arrives once the document is generated, no polling required. When you'd rather not hold the connection open, or your integration is callback-driven, see Async Generation.
Running Step 3 again? A
400TEMPLATE_NOT_FOUNDmeans the template id was already consumed by an earlier run, or is more than 24 hours old. Repeat Steps 1 and 2 for fresh ids.
Open Step 4 — Download the document and send the request. It uses {{mission1.generatedDocumentId}} from Step 3:
GET https://api.doctavian.com/v1/documents/document/{{mission1.generatedDocumentId}}/download
Authorization: Bearer <token>
x-api-key: <api-key>The response is the file itself, not JSON. Download within 24 hours; after that the file is gone.
Open it: the customer name, account ID, formatted effective date, line item table, and total contract value should all be populated — and the volume discount clause appears, since the total clears $10,000.
urnThe engine is running. The empire has its first document. Continue to Mission 2 — The Meridian Merger →