Skip to content
Leadtime
English
Esc
navigateopen⌘Jpreview

Create new document

What are project documents? Project documents are structured documents automatically generated from project data. They can be estimates, specifications, or custom documents (contracts, NDAs, etc.) that pull in project, organization, and company data through variables.

Document creation workflow:

  1. Select project version: Documents must be linked to a saved project version (snapshot) for traceability. Use GET /projects//versions to get available versions.
  2. Choose document type: Estimate (commercial proposal), Specification (requirements), or CustomEditor (free-form document)
  3. Set basic properties: Title, description, status (usually starts as Draft)
  4. Assign contact person: Select from available contacts (use GET /projects//documents/contact-persons)
  5. Configure layout: Enable table of contents, title page, indication mode (marks as non-binding estimate)
  6. Set heading style: Controls automatic numbering of headings (important for legal documents)
  7. Add custom variables: If using a template with custom variables, provide values for each variable

Content format:

  • Description and customEditorContent accept HTML or Markdown
  • Content is automatically converted to internal IDoc format for storage
  • When retrieved, content is converted back to HTML for display
  • Supports rich formatting: headings, lists, tables, links, etc.

Custom variables: If your document template includes custom variables, provide them in the customVariables array:

  • Each variable needs: name, type, and value (matching the type)
  • Types: Text, LongText, Number, Boolean, Date, Select, MultiSelect
  • For Select/MultiSelect: provide options array and select value(s)
  • Required variables must have values provided

Validation:

  • Project version must exist and belong to the project
  • Contact person must be available for this project type
  • All required custom variables must have values
  • Document type and status must be valid enum values

What is returned: The created document with all fields, including converted HTML content and custom variable values.

Use cases:

  • Create new estimate for client approval
  • Generate specification document from project requirements
  • Create custom contract or agreement document
  • Automate document generation from project data
POST/projects/{projectId}/documents
Authorization
AuthorizationOAuth2 access token · headerrequired
Scopes:api:write
or
AuthorizationBearer token (JWT) · headerrequired
Path parameters
projectIdstringrequired
Project ID
Query parameters
fieldsToReturnstring
Comma-separated list of top-level response fields to return. Overrides the endpoint compact default unless responseShape=full is used.
responseShapestring
Advanced override. Omit for the endpoint compact default. Use full only when you need the complete endpoint response, including nested fields that are not selectable with fieldsToReturn.
Allowed:compactfull
Header parameters
LT-Response-Shapestring
Advanced override. Set to full only when you need the complete endpoint response, including nested fields that are not selectable with fieldsToReturn.
Allowed:full
Request body
requiredapplication/json
breakdownLevelstring
Controls how project components are broken down in the document. Complete: Shows all levels (Components → Epics → Work Packages). UpToEpics: Shows Components with totals and Epics with their effort. NoBreakdown: Shows only Components with total price/hours. Applies to both Letter and Document styles.
Allowed:CompleteUpToEpicsNoBreakdown
contactUserIdstringrequired
The user ID of the contact person who will receive this document. This person appears as the addressed recipient in the document header and recipient fields. Must be from the list of available contact persons for this project (use GET /projects/:id/documents/contact-persons). For external projects, must be an organization member. For internal projects, must be a workspace employee.
customEditorContentstring
Accepts Markdown or HTML for complex formatting. This content is rendered by the Leadtime rich editor, not by a plain Markdown viewer. For quick/simple text, Markdown is acceptable. For polished user-facing content from an agent or integration, prefer structured HTML because it preserves editor blocks, links, and layout more predictably. Use only the nodes and marks documented below for this field. Supported editor features differ by endpoint and field. Choose formatting for readability, not decoration: use headings for real sections, paragraphs for narrative text, lists or tables for structured facts, blockquotes for quoted context, callouts for important outcomes/risks/notes when supported, and explicit anchors for links. Do not rely on bare URLs or Markdown links when the link must be clickable; use explicit anchors such as <a href="https://example.com" target="_blank" rel="noopener noreferrer nofollow">link text</a>. In HTML you can use: ## Node Types and Marks ### Nodes **paragraph** Type: block Content: inline* (inline only — do not use block tags such as <p> inside; use e.g. <br>, <strong>, <em>, <span>…) Default paragraph. extraPlaceholder is an internal structure for the editor to show a ghost placeholder in empty “template” lines (ProseMirror JSON fragment or null). For normal agent output leave extraPlaceholder as null. Only set it if you are intentionally mirroring a field placeholder the user already has in the open editor; do not set random placeholder data for free-form answers. Atts: - extraPlaceholder: null ```html <p class="paragraph-base" extraplaceholder="null/some-value"></p> ``` **heading** Type: block Content: inline* (inline only — do not use block tags such as <p> inside; use e.g. <br>, <strong>, <em>, <span>…) Atts: - level: 1 ```html <h1 class="heading-base"></h1> ``` **bulletList** Type: block list Content: listItem+ Atts: none ```html <ul class="list-base"><li></li></ul> ``` **hardBreak** Type: inline Atts: none ```html <br> ``` **horizontalRule** Type: block Atts: none ```html <hr class="hr-base"> ``` **orderedList** Type: block list Content: listItem+ Atts: - start: 1 - type: null ```html <ol class="order-list-base" type="null/some-value"><li></li></ol> ``` **listItem** Content: (paragraph|list)* (paragraphs and/or lists, in any order) Atts: none ```html <li></li> ``` **blockquote** Type: block Content: block+ (one or more block child nodes (e.g. paragraph, list, …)) Atts: none ```html <blockquote class="blockquote-base"><p class="paragraph-base"></p></blockquote> ``` **table** Type: block Content: tableRow+ Atts: none ```html <table style="width: 0px;"><colgroup></colgroup><tbody><tr></tr></tbody></table> ``` **tableRow** Content: (tableCell | tableHeader)* Atts: none ```html <tr></tr> ``` **tableHeader** Content: block+ (one or more block child nodes (e.g. paragraph, list, …)) Atts: - colspan: 1 - rowspan: 1 - colwidth: null - align: null ```html <th colspan="1" rowspan="1" colwidth="null/some-value" style="text-align: null/some-value;"><p class="paragraph-base"></p></th> ``` **tableCell** Content: block+ (one or more block child nodes (e.g. paragraph, list, …)) Atts: - colspan: 1 - rowspan: 1 - colwidth: null - align: null ```html <td colspan="1" rowspan="1" colwidth="null/some-value" style="text-align: null/some-value;"><p class="paragraph-base"></p></td> ``` **variable** Type: inline Document/template variable token (span with data-type="variable" and data-id). - id: Variable key, often scoped (e.g. currentUser.firstName, project.name). Only use keys that exist for the document type you are in; product docs list the allowed variable ids. Do not invent new variable names in HTML for production templates. Atts: - id: null ```html <span data-type="variable" data-id="null/some-value" id="null/some-value"></span> ``` **pageBreak** Type: block Page break for PDF/print output (void <page-break> element). Inserts a hard page break when exporting. Use sparingly where the user asked for a new printed page, not for normal on-screen line breaks (use hardBreak/paragraphs instead). Atts: none ```html <page-break></page-break> ``` **condition** Type: block Content: conditionBody (a single condition body block) This node conditionally renders its content based on a set of rules. The rules are defined in the 'conditions' attribute. 'conditions' is an object like: { type: 'and' | 'or', expressions: Array<Expression | ConditionGroup> }. An 'Expression' is { field: string, operator: string, value: any }. A 'ConditionGroup' is a nested { type: 'and' | 'or', expressions: [...] }. Example for an expression: { field: 'invoice.total', operator: 'gt', value: 100 } means 'if invoice total is greater than 100'. Supported operators typically include: eq (equals), neq (not equals), gt (greater than), gte (greater than or equal to), lt (less than), lte (less than or equal to), contains, in, is_true, is_false, etc. Check editor UI for available fields and operators. ALL FIELDS CAN ONLY BE EXISTING VARIABLES. DO NOT INVENT NEW FIELDS. Atts: - conditions: { "type": "and", "expressions": [] } ```html <condition conditions="{&quot;type&quot;:&quot;and&quot;,&quot;expressions&quot;:[]}"><condition-body><p class="paragraph-base"></p></condition-body></condition> ``` **conditionBody** Content: block+ (one or more block child nodes (e.g. paragraph, list, …)) Atts: none ```html <condition-body><p class="paragraph-base"></p></condition-body> ``` ### Marks **link** Atts: - href: null - target: _blank - rel: noopener noreferrer nofollow - class: null - title: null ```html <a target="_blank" rel="noopener noreferrer nofollow" href="">link text example</a> ``` **bold** Atts: none ```html <strong>bold text example</strong> ``` **code** Atts: none ```html <code>code text example</code> ``` **italic** Atts: none ```html <em>italic text example</em> ``` **strike** Atts: none ```html <s>strike text example</s> ``` **underline** Atts: none ```html <u>underline text example</u> ``` ## Available Template Variables You can use the following variables in your document templates. Variables are represented as HTML spans: **workspace**: `workspace.vat`, `workspace.hourRate`, `workspace.invoiceDaysTillOverdue`, `workspace.standardReminderFee`, `workspace.baseInterestRate`, `workspace.interestRate` **company**: `company.companyName`, `company.legalForm`, `company.country`, `company.zip`, `company.city`, `company.street`, `company.houseNumber`, `company.phone`, `company.email`, `company.website`, `company.fax`, `company.taxNumber`, `company.registrationNumber`, `company.registrationCourt` **organization**: `organization.companyName`, `organization.shortName`, `organization.legalForm`, `organization.description`, `organization.country`, `organization.zip`, `organization.city`, `organization.street`, `organization.houseNumber`, `organization.phone`, `organization.email`, `organization.website`, `organization.fax`, `organization.taxNumber`, `organization.registrationNumber`, `organization.registrationCourt`, `organization.hourRate`, `organization.invoiceDaysTillOverdue`, `organization.standardReminderFee`, `organization.baseInterestRate`, `organization.interestRate` **project**: `project.name`, `project.category`, `project.status`, `project.defaultAccountable`, `project.country`, `project.projectId`, `project.activeVersionId`, `project.activeVersionName` **currentUser**: `currentUser.title`, `currentUser.degree`, `currentUser.email`, `currentUser.firstName`, `currentUser.lastName`, `currentUser.country`, `currentUser.zip`, `currentUser.city`, `currentUser.street`, `currentUser.houseNr`, `currentUser.birthday`, `currentUser.phone`, `currentUser.signature` **recipient**: `recipient.firstName`, `recipient.lastName`, `recipient.position`, `recipient.gender`, `recipient.title`, `recipient.degree`, `recipient.birthdate`, `recipient.activeVersionName`, `recipient.country`, `recipient.zip`, `recipient.city`, `recipient.street`, `recipient.houseNumber`, `recipient.phone`, `recipient.email`, `recipient.socialNetwork` **macros**: `macros.todaysDate`, `macros.dearCustomer` **Example HTML**: `<span data-type="variable" data-id="currentUser.firstName">John</span>`, `<span data-type="variable" data-id="project.name">Website Redesign</span>`
customVariablesDocumentCustomVariableDto[]
Array of custom variables defined for this document. Custom variables allow you to add project- or template-specific values that are not covered by standard system variables (like client name, project budget, contract duration, etc.). Each variable has a name, type, value, and optional description. Variables can be referenced in document templates using the syntax: custom.variable_name. If the document template includes custom variables, you must provide values for all required variables.
Show properties
Array of DocumentCustomVariableDto
descriptionstring
Human-readable label/description for this variable. This is displayed to users when they are prompted to fill in the variable value when generating a document.
idstring
Variable ID (UUID). Only required when updating an existing variable. Omit when creating a new variable.
namestringrequired
Variable name/key used to reference this variable in the template content. Use lowercase with underscores (e.g., "client_name", "project_budget"). This name is used in the variable reference: custom.variable_name.
optionsstring[]
Available options for Select or MultiSelect variable types. For Select, users choose one option. For MultiSelect, users can choose multiple options. This field is ignored for other variable types.
requiredboolean
Whether this variable must be filled in when generating a document from the template. If true, users cannot proceed without providing a value. If false, the variable is optional.
default: false
typestringrequired
The data type of this variable. Determines what kind of input is expected and how the value is validated. Available types: Text (short text), LongText (multi-line text), Number (numeric value), Date (date/time), Boolean (true/false), Select (single choice from options), MultiSelect (multiple choices from options).
Allowed:TextLongTextNumberDateBooleanSelectMultiSelect
valuestring | number | boolean | string[]
Default value for this variable. The type of value depends on the variable type: - Text/LongText/Select: string - Number: number - Boolean: boolean - Date: ISO 8601 date string (e.g., "2024-01-15") - MultiSelect: array of strings This value is pre-filled when generating a document, but users can override it.
Show properties
One of:
string
string
number
number
boolean
boolean
string[]
Array of string
string
descriptionstring
Optional document description or introduction text. Accepts HTML or Markdown format - will be automatically converted to internal IDoc format for storage. Supports rich formatting: headings, lists, tables, links, bold, italic. When retrieved via GET, content is returned as HTML for easy display.
documentStylestring
The document layout style. Letter: Invoice-like layout suitable for direct mailing. Document: Traditional multi-page document with TOC. Only applies to Estimate type documents. Defaults to Letter for new documents.
Allowed:LetterDocument
headingStylestring
Controls how headings are automatically numbered in the document. Normal: No automatic numbering. Sequential: Numbered from level 1 (1, 1.1, 1.1.1). SequentialFromSecondLevel: Numbering starts from level 2 (H1 unnumbered, then 1.1, 1.1.1). SequentialWithParagraphs: Same as SequentialFromSecondLevel but with paragraph sign prefix (§ 1, § 1.1). Important for legal documents and contracts. Numbering is dynamic and adjusts when conditional sections are shown/hidden.
Allowed:NormalSequentialSequentialFromSecondLevelSequentialWithParagraphs
includeTocboolean
Whether to include an automatically generated table of contents in the document. The TOC is built from document headings and appears at the beginning of the document. Useful for longer documents with multiple sections. Defaults to true.
default: true
indicationModeboolean
When enabled, marks the document as a non-binding cost indication or preliminary estimate. This is important for legal purposes to distinguish between binding offers and preliminary estimates. When false, the document is treated as a binding offer. Defaults to false.
default: false
introTextstring
Custom introduction text for the offer, in HTML or Markdown format. Overrides workspace/organization defaults. Supports rich formatting and template variables. When retrieved via GET, content is returned as HTML.
languageobject
BCP 47 language tag for generated document text (e.g. de, en). When omitted or null, workspace/organization defaults apply.
outroTextstring
Custom closing text for the offer, in HTML or Markdown format. Overrides workspace/organization defaults. Supports rich formatting and template variables. When retrieved via GET, content is returned as HTML.
snapshotIdstringrequired
The project version (snapshot) ID that this document is based on. Documents are always linked to a specific project version for traceability and audit purposes. Use GET /projects/:id/versions endpoint to retrieve available versions for a project. The snapshot must exist and belong to the project.
statusstringrequired
The workflow status of the document. Draft: Initial version, not yet finalized. WaitingForApproval: Sent to client for review. Final: Ready for signing. Accepted: Approved by client. Rejected: Declined by client. Parked: Temporarily set aside. Documents typically start as Draft and progress through the workflow.
Allowed:DraftFinalWaitingForApprovalAcceptedRejectedParked
titleobject
The title/name of the document. This appears in document lists, headers, and exports. Should be descriptive and unique enough to identify the document. For Letter-style Estimate documents, this field is optional and will be automatically cleared (title is not used in letter format).
titlePageboolean
Whether to include a title page at the beginning of the document. The title page typically includes document title, project information, contact details, and creation date. Useful for formal documents and exports. Defaults to true.
default: true
typestringrequired
The type/category of document. Estimate: Commercial proposals with services, quantities, and costs. Specification: Detailed requirement documents describing deliverables. CustomEditor: Free-form documents like contracts, NDAs, or custom agreements that can use templates with variables.
Allowed:EstimateSpecificationCustomEditor
validUntilstring<date-time>
The date until which this offer is valid. Used for Letter-style offers to indicate expiration date. Defaults to one month from creation date if not specified.
Responses
201Document created successfully
breakdownLevelstringrequired
Component breakdown level
Allowed:CompleteUpToEpicsNoBreakdown
contactUserIdstringrequired
The user ID of the contact person assigned to this document. This person appears as the addressed recipient in the document header and recipient fields. Empty string if no contact person is assigned.
createdAtstring<date-time>required
ISO 8601 timestamp indicating when the document was created. Used for sorting, filtering, and audit trails.
customEditorContentobject
Custom document content for CustomEditor document type, returned as HTML (converted from internal IDoc format). Contains rich formatting: headings, lists, tables, links, variables, conditional sections. Null if no custom content was provided.
customVariablesDocumentCustomVariableDto[]required
Array of custom variables with their current values. Each variable includes its definition (name, type, description, options) and the current value formatted according to the variable type. Empty array if no custom variables are defined.
Show properties
Array of DocumentCustomVariableDto
descriptionstring
Human-readable label/description for this variable. This is displayed to users when they are prompted to fill in the variable value when generating a document.
idstring
Variable ID (UUID). Only required when updating an existing variable. Omit when creating a new variable.
namestringrequired
Variable name/key used to reference this variable in the template content. Use lowercase with underscores (e.g., "client_name", "project_budget"). This name is used in the variable reference: custom.variable_name.
optionsstring[]
Available options for Select or MultiSelect variable types. For Select, users choose one option. For MultiSelect, users can choose multiple options. This field is ignored for other variable types.
requiredboolean
Whether this variable must be filled in when generating a document from the template. If true, users cannot proceed without providing a value. If false, the variable is optional.
default: false
typestringrequired
The data type of this variable. Determines what kind of input is expected and how the value is validated. Available types: Text (short text), LongText (multi-line text), Number (numeric value), Date (date/time), Boolean (true/false), Select (single choice from options), MultiSelect (multiple choices from options).
Allowed:TextLongTextNumberDateBooleanSelectMultiSelect
valuestring | number | boolean | string[]
Default value for this variable. The type of value depends on the variable type: - Text/LongText/Select: string - Number: number - Boolean: boolean - Date: ISO 8601 date string (e.g., "2024-01-15") - MultiSelect: array of strings This value is pre-filled when generating a document, but users can override it.
Show properties
One of:
string
string
number
number
boolean
boolean
string[]
Array of string
string
descriptionobject
Document description or introduction text, returned as HTML (converted from internal IDoc format). Contains rich formatting: headings, lists, tables, links. Null if no description was provided.
documentStylestringrequired
Document layout style
Allowed:LetterDocument
formattedOfferNumberobject
Fully formatted offer number string. Format: [ProjectShortcode]-v[Version]-[DDMMYYYY]-[OfferNumber]. Example: WKM-1-v2-27012026-1. Only populated for Estimate type documents.
headingStylestring
Heading style for document
Allowed:NormalSequentialSequentialFromSecondLevelSequentialWithParagraphs
idstringrequired
Unique identifier (UUID) for the document. Used to reference the document in subsequent API calls.
includeTocbooleanrequired
Include table of contents
indicationModebooleanrequired
Enable indication mode
introTextobject
Custom introduction text for the offer, returned as HTML (converted from internal IDoc format). Null if not set.
languageobject
Document language override (BCP 47 tag). Null when using workspace/organization default.
offerNumberobject
Auto-generated offer number (integer). Display format is computed as: [ProjectShortcode]-v[Version]-[DDMMYYYY]-[OfferNumber]. Only populated for Estimate type documents.
outroTextobject
Custom closing text for the offer, returned as HTML (converted from internal IDoc format). Null if not set.
projectIdstringrequired
The ID of the project this document belongs to. Documents are always associated with a specific project.
snapshotIdstringrequired
The project version (snapshot) ID that this document is based on. This ensures the document content is tied to a specific project state for traceability and audit purposes.
statusstringrequired
Document status
Allowed:DraftFinalWaitingForApprovalAcceptedRejectedParked
titleobject
The title/name of the document. This appears in document lists, headers, and exports. Null for Letter-style Estimate documents (title is not used in letter format).
titlePagebooleanrequired
Include title page
typestringrequired
Document type
Allowed:EstimateSpecificationCustomEditor
validUntilobject
The date until which this offer is valid. Used for Letter-style offers to indicate expiration date. Null if not set.
400Invalid input data
401Unauthorized - Invalid or missing authentication token
403Permission denied
Request
curl -X POST "https://leadtime.app/api/public/projects/string/documents" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "breakdownLevel": "Complete",
  "contactUserId": "123e4567-e89b-12d3-a456-426614174000",
  "customEditorContent": "<h1>Custom Document Content</h1><p>Details here...</p>",
  "customVariables": [
    {
      "description": "Client Company Name",
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "client_name",
      "options": [
        "Option 1",
        "Option 2",
        "Option 3"
      ],
      "required": false,
      "type": "Text",
      "value": "Acme Corp"
    }
  ],
  "description": "<p>Quarterly estimate for client approval</p>",
  "documentStyle": "Letter",
  "headingStyle": "Sequential",
  "includeToc": true,
  "indicationMode": false,
  "introText": "<p>Thank you for your inquiry. We are pleased to submit the following offer:</p>",
  "language": "de",
  "outroText": "<p>This offer is non-binding. We thank you for your interest.</p>",
  "snapshotId": "123e4567-e89b-12d3-a456-426614174000",
  "status": "Draft",
  "title": "Q4 2024 Project Estimate",
  "titlePage": true,
  "type": "Estimate",
  "validUntil": "2024-02-15T00:00:00Z"
}'
Response
{
  "breakdownLevel": "Complete",
  "contactUserId": "123e4567-e89b-12d3-a456-426614174000",
  "createdAt": "2024-01-15T10:30:00Z",
  "customEditorContent": "<h1>Custom Document Content</h1><p>Details here...</p>",
  "customVariables": [
    {
      "description": "Client Company Name",
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "client_name",
      "options": [
        "Option 1",
        "Option 2",
        "Option 3"
      ],
      "required": false,
      "type": "Text",
      "value": "Acme Corp"
    }
  ],
  "description": "<p>Quarterly estimate for client approval</p>",
  "documentStyle": "Letter",
  "formattedOfferNumber": "WKM-1-v2-27012026-1",
  "headingStyle": "Sequential",
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "includeToc": true,
  "indicationMode": false,
  "introText": "<p>Thank you for your inquiry. We are pleased to submit the following offer:</p>",
  "language": "de",
  "offerNumber": 1,
  "outroText": "<p>This offer is non-binding. We thank you for your interest.</p>",
  "projectId": "123e4567-e89b-12d3-a456-426614174000",
  "snapshotId": "123e4567-e89b-12d3-a456-426614174000",
  "status": "Draft",
  "title": "Q4 2024 Project Estimate",
  "titlePage": true,
  "type": "Estimate",
  "validUntil": "2024-02-15T00:00:00Z"
}