API reference

Assistant: Documents

Your document library, as the app's Documents page shows it: spreadsheets and the documents the assistant writes for you (letters, cancellation notices, invoices, proposals, reports), each kept as yours, on a track or on none. List them, make a spreadsheet or a document, change and download a document, and delete either. A spreadsheet's tabs and cells are read and changed under `/assistant/sheets`. 7 endpoints. Add your API key in the authentication panel to send test requests from this page.

List your documents

GET/api/external/v1/assistant/documents

Your spreadsheets and generated documents, the one changed last first, as items: id (ks_... for a spreadsheet, doc_... for a generated document), type (SHEET or DOCUMENT), title, url (where the app opens it), createdAt, updatedAt, tracks (the tracks it is attached to: id, title), and for a generated document kind, format and summary.

Filters: q (words in the title; for a generated document, the summary too) and type.

Errors: 400 DOCUMENT_INVALID for a type there is none of.

Parameters

  • qstringquery

    Only documents whose title (or summary) holds this.

  • typestringquery

    SHEET or DOCUMENT.

Responses

  • 200OK

Make an empty document

POST/api/external/v1/assistant/documents

Makes a new, empty document on no track and answers it (201, the shape of an entry of the list).

Fields: type (required: SHEET for a spreadsheet, DOCUMENT for an empty document) and title (required). To make a document with its content at once, use POST /assistant/documents/generated.

Rules: a spreadsheet needs Tracks on your plan (409 PLAN_FEATURE with feature and unlockLevel otherwise); at most 300 generated documents.

Errors: 400 MISSING_FIELD, DOCUMENT_INVALID; 409 PLAN_FEATURE, DOCUMENT_DISABLED.

Request body application/json

object

Responses

  • 200OK

Read a generated document

GET/api/external/v1/assistant/documents/{documentId}

A generated document (doc_...) whole, as POST /assistant/documents/generated answers it. A spreadsheet's content is read under /assistant/sheets/{sheetId}.

Errors: 404 DOCUMENT_NOT_FOUND.

Parameters

  • documentIdstringpathRequired

    The document's id, doc_...

Responses

  • 200OK

Change a generated document

PATCH/api/external/v1/assistant/documents/{documentId}

Changes what is sent of a generated document and renders its file again; answers it whole.

Fields, all optional: title, kind, format, summary, contentMarkdown (the whole content), recipientName, senderName, subject (null removes each of the last three).

Errors: 404 DOCUMENT_NOT_FOUND; 409 DOCUMENT_DISABLED.

Parameters

  • documentIdstringpathRequired

    The document's id, doc_...

Request body application/json

object

Responses

  • 200OK

Delete a document

DELETE/api/external/v1/assistant/documents/{documentId}

Deletes a document for good. A spreadsheet (ks_...) is first taken off every track it is attached to (noted on each track), which needs Tracks on your plan, as making one does. Answers 204.

Errors: 404 DOCUMENT_NOT_FOUND; 409 PLAN_FEATURE, DOCUMENT_TRANSIENT (it could not be taken off a track just now: try again).

Parameters

  • documentIdstringpathRequired

    The document's id: ks_... or doc_...

Responses

  • 200OK

Download a generated document's file

GET/api/external/v1/assistant/documents/{documentId}/download

The rendered file of a generated document (PDF, DOCX, HTML, Markdown or CSV, as its format), as an attachment named as the document's fileName.

Errors: 404 DOCUMENT_NOT_FOUND; 404 DOCUMENT_FILE_NOT_FOUND while it has no file (it could not be rendered: change it to render it again).

Parameters

  • documentIdstringpathRequired

    The document's id, doc_...

Responses

  • 200OK

Write a document

POST/api/external/v1/assistant/documents/generated

Makes a generated document from what you send - rendered to a file in its format - and answers it whole (201).

Fields: title (required, at most 200 characters); kind: FORMAL_LETTER, CANCELLATION_LETTER, INVOICE, PROPOSAL, BRIEFING_PACK, REPORT, CSV_EXPORT or MARKDOWN_DOC (the default); format: PDF (the default), DOCX, HTML, MARKDOWN or CSV; language (a code such as en, de, tr); summary (at most 500); bodyMarkdown (the content, in Markdown); for a letter senderName, recipientName, subject, salutation, closing, signatureName.

Answers id (doc_...), type, title, kind, format, language, summary, contentMarkdown, contentHtml, uploadUrl, fileName (both null when the file could not be rendered), meta (the letter's fields), createdAt, updatedAt. Download the file with GET .../{documentId}/download.

Rules: at most 300 generated documents.

Errors: 400 MISSING_FIELD, DOCUMENT_INVALID (the library is full); 409 DOCUMENT_DISABLED.

Request body application/json

object

Responses

  • 200OK