Create Document
Creates a draft document on behalf of the key’s owner (the owner becomes the initiator), either from a template (template_id) or from a file the caller uploaded with FileService (file_id). Route and sending are separate steps.
Send an Idempotency-Key header to make a retry safe: the first call with a given key creates the document, and any repeat of the same request returns that same document instead of creating a second one. Keys live 24 hours and are scoped to the API key that used them. Reusing a key with a different body is refused rather than silently replayed.
Required scope: documents:write
Error Codes:
- DEVELOPER.SCOPE_INSUFFICIENT: The key lacks the documents:write scope.
- INVALID_ARGUMENT: Neither or both of template_id and file_id, or invalid type or field values.
- FILE_NOT_FOUND: No upload with that id belongs to the key owner.
- FILE.INVALID_STATUS_TRANSITION: The upload was never confirmed.
- FILE.ALREADY_LINKED: The upload is already attached to a document.
- DOCUMENT_INITIATOR_NOT_FOUND: The key owner is not an employee of the tenant.
- DEVELOPER.IDEMPOTENCY_KEY_CONFLICT: The Idempotency-Key was used with a different body.
- DEVELOPER.IDEMPOTENCY_IN_PROGRESS: An earlier call with this key is still running.
Authorizations
Body
Document title.
Document type id.
Document date, YYYY-MM-DD.
Id of a confirmed upload (FileService.ConfirmFileUpload) to build the document from, instead of a template. The file becomes the document's PDF and can be sent for signing as it is. Mutually exclusive with template_id.
Registration number to record on the document.
Legal entity to attribute the document to.
Employees the document is about (its subjects).
Template id and version the document is generated from. Discover these with ListDocumentTemplates (see DocumentTemplate.version). Required unless file_id is set.
Values for the template variables, keyed by variable id. Read the expected shape from the template's variable_schema (GetDocumentTemplate).
Version of the template to use; take it from DocumentTemplate.version.
Response
OK
The created draft document.