Generate document
well_generate_documentGenerate a document as a PDF and store it in the workspace. It never emails or sends anything, so a request to email or send a document is not a request to generate one. Pass exactly one source:
params: values you provide, with adocument_slug. Call well_list_generative_documents first: it gives each design's document_slug and the JSON Schema its params must satisfy. Values that do not match are refused with the path and reason of each problem, so fix them and call again. The design prints light unlessparams.themeis "dark". Each call prints and stores a new document, unless you passdocument_id.document_id(withparamsonly): when the user asks to change, fix or redo a document you already generated in this conversation, pass its document_id so it is replaced in place instead of adding a new file. Its document_id and links keep working and serve the new PDF. Only a document this tool generated from values can be replaced.invoice_id: an invoice already in Well. The PDF prints that invoice, in its own chosen ink, and is attached to it as its document. Pass adocument_slugto choose the design; without one, the invoice's own chosen design prints. Refused when the invoice already carries a file a user or connector supplied: a generated PDF never replaces one. Generating again updates that same document in place, so its document_id and links keep working.design(withinvoice_idonly): the options the invoice-design card returned, passed exactly as the card gave them.layout,themeandlocalechoose the design, the ink and the language of this print, on an issued invoice too.payment_terms_note_id,tax_rate_id,legal_mentions_note_idandpayment_means_idmust equal what is saved on the invoice, or be null when nothing is saved: an id that differs is refused, so save a change with well_update_invoice_design first. Each option is optional, and every option left out keeps the value the invoice already holds.themeis a key ofdesign, not a top-level input. Do not passdesign.layouttogether with a differentdocument_slug, ordesign.localetogether with a differentlocale: the call is refused.
Totals are never supplied: every sum is computed from the lines, so a printed total cannot disagree with the lines above it. The tool returns the stored PDF's document_id.
file carries the PDF's name and size plus the links to fetch it. The result renders as a card with Download and View in Well; when no card is shown, hand the user download_url.
download_urlsaves the PDF andsigned_urlopens it in a browser. Both work with a plain HTTP GET and no auth header, and stop working atexpires_at.preview_urlis a PNG image of the first page, for showing the document; addpage=Nfor page N, up topage_count. Same token and expiry as the other links.sheet_urlis the document's HTML sheet, which the card draws with zoom and pan. Same token and expiry.When the user wants to do more with a PDF already generated (attach it to an email, upload it elsewhere, read or analyse it, pass it to another tool), fetch
download_urlwith a plain HTTP GET to get the bytes.If the links have expired, call this tool again: with
paramsit prints a new document with fresh links; withinvoice_idit refreshes the same document and its links.app_urlopens the document in Well and never expires.The links grant access to the file on their own: share them only with the user, never in a public place.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| design | No | With invoice_id only: the design options the invoice-design card returned (layout, theme, locale and the ids of the payment terms, tax rate, legal mentions and payment means saved on the invoice), passed exactly as given. Omit an option to keep the invoice's own. | |
| locale | No | BCP 47 locale for words, figures and dates, e.g. fr-FR or en-GB. Defaults to fr-FR, or to the invoice's own locale with invoice_id. | |
| params | No | Values matching the document's params_json_schema. Omit when passing invoice_id. | |
| invoice_id | No | An invoice already in Well, to print and attach the PDF to. Omit when passing params. | |
| document_id | No | With params only: a document you generated earlier, to replace in place instead of adding a new file. Never with invoice_id. | |
| workspace_id | No | Target workspace. Omit when the token authorizes one workspace. Required when it authorizes several — a write lands in exactly one workspace and this call would not say which. | |
| document_slug | No | A document_slug from well_list_generative_documents. Required with params; optional with invoice_id. | |
| conversation_id | No | The conversation id returned by the previous Well result, in its meta under well/conversation_id, in its structuredContent, or in its JSON text block. Pass it back on every call in the same conversation, including a call a card makes, so the chosen workspace and the earlier answers still apply. It decides the conversation on its own: nothing the host states about the session replaces it. Omit it only on the first call of a conversation. | |
| idempotency_key | No | Optional client-supplied key. A retried write with the same key returns the original result instead of re-applying the operation. | |
| workspace_scope | No | Restrict this call to the family: the token's primary workspace plus the company workspaces under it that you are a member of. Unrelated authorized workspaces drop out of the read; row reads merge across the family, while a per-workspace figure still reports exactly one workspace. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | No | The stored PDF and the links to download it or open it in Well. | |
| error | No | ||
| issues | No | Each value that did not match the schema. | |
| success | Yes | ||
| filename | No | ||
| render_ms | No | ||
| invoice_id | No | The invoice the PDF was attached to, when generated from one. | |
| document_id | No | The stored PDF. | |
| document_slug | No | The design the PDF printed in. | |
| invoice_status | No | That invoice's lifecycle status when the PDF was printed: a draft still carries the Finalize action on its preview. | |
| refusal_reason | No | The WellError code when the request is refused. | |
| conversation_id | No | The conversation this result belongs to. Pass it back as the conversation_id argument on every later Well call in the same conversation. | |
| newly_connected | No | Tools that connected to this workspace since the last result and that no session was told about yet, oldest first. Present only when at least one tool is new. The connected-line rule says when to tell an entry; when it does, one line per entry, in the person's language: "<name> is connected.". Never fold several entries into one sentence. Each entry comes back once, on one result only: never repeat its line later. | |
| reference_number | No | That invoice's reference number. | |
| document_type_code | No | That invoice's document type code: 380 invoice, 381 credit note. | |
| conversation_id_note | No | Present only when the server opened a fresh lane, stating that no choice recorded earlier was read. | |
| conversation_id_source | No | Where the conversation id came from: the host's own request meta, the caller's argument, or a fresh lane the server opened. |