Skip to main content
Glama

Generate document

well_generate_document

Generate 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 a document_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 unless params.theme is "dark". Each call prints and stores a new document, unless you pass document_id.

  • document_id (with params only): 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 a document_slug to 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 (with invoice_id only): the options the invoice-design card returned, passed exactly as the card gave them. layout, theme and locale choose 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_id and payment_means_id must 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. theme is a key of design, not a top-level input. Do not pass design.layout together with a different document_slug, or design.locale together with a different locale: 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_url saves the PDF and signed_url opens it in a browser. Both work with a plain HTTP GET and no auth header, and stop working at expires_at.

  • preview_url is a PNG image of the first page, for showing the document; add page=N for page N, up to page_count. Same token and expiry as the other links.

  • sheet_url is 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_url with a plain HTTP GET to get the bytes.

  • If the links have expired, call this tool again: with params it prints a new document with fresh links; with invoice_id it refreshes the same document and its links.

  • app_url opens 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

TableJSON Schema
NameRequiredDescriptionDefault
designNoWith 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.
localeNoBCP 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.
paramsNoValues matching the document's params_json_schema. Omit when passing invoice_id.
invoice_idNoAn invoice already in Well, to print and attach the PDF to. Omit when passing params.
document_idNoWith params only: a document you generated earlier, to replace in place instead of adding a new file. Never with invoice_id.
workspace_idNoTarget 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_slugNoA document_slug from well_list_generative_documents. Required with params; optional with invoice_id.
conversation_idNoThe 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_keyNoOptional client-supplied key. A retried write with the same key returns the original result instead of re-applying the operation.
workspace_scopeNoRestrict 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

TableJSON Schema
NameRequiredDescriptionDefault
fileNoThe stored PDF and the links to download it or open it in Well.
errorNo
issuesNoEach value that did not match the schema.
successYes
filenameNo
render_msNo
invoice_idNoThe invoice the PDF was attached to, when generated from one.
document_idNoThe stored PDF.
document_slugNoThe design the PDF printed in.
invoice_statusNoThat invoice's lifecycle status when the PDF was printed: a draft still carries the Finalize action on its preview.
refusal_reasonNoThe WellError code when the request is refused.
conversation_idNoThe conversation this result belongs to. Pass it back as the conversation_id argument on every later Well call in the same conversation.
newly_connectedNoTools 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_numberNoThat invoice's reference number.
document_type_codeNoThat invoice's document type code: 380 invoice, 381 credit note.
conversation_id_noteNoPresent only when the server opened a fresh lane, stating that no choice recorded earlier was read.
conversation_id_sourceNoWhere the conversation id came from: the host's own request meta, the caller's argument, or a fresh lane the server opened.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedOutput schema / properties / newly_connected / description
      Previous value: -"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. Start the reply with 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."New value: +"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."
  2. Changed1 schema field changed
    • addedInput schema / properties / workspace_scope
      Added value: +{
      +  "description": "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.",
      +  "enum": [
      +    "family"
      +  ],
      +  "type": "string"
      +}
  3. Changed6 schema fields changed
    • changedInput schema / properties / design / properties / layout / description
      Previous value: -"The design: one of the document_slugs well_list_generative_documents returns."New value: +"The design: one of the document_slugs well_list_generative_documents returns, or \"template\" for the workspace's own design."
    • changedInput schema / properties / design / properties / layout / enum
      Previous value: -[
      -  "statement",
      -  "terminal",
      -  "proposal",
      -  "banking",
      -  "feenote",
      -  "studio",
      -  "masthead",
      -  "headline"
      -]New value: +[
      +  "statement",
      +  "terminal",
      +  "proposal",
      +  "banking",
      +  "feenote",
      +  "studio",
      +  "masthead",
      +  "headline",
      +  "template"
      +]
    • addedOutput schema / properties / invoice_status / anyOf
      Added value: +[
      +  {
      +    "enum": [
      +      "draft",
      +      "issued",
      +      "paid",
      +      "canceled"
      +    ],
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedOutput schema / properties / invoice_status / enum
      Removed value: -[
      -  "draft",
      -  "issued",
      -  "paid",
      -  "canceled"
      -]
    • removedOutput schema / properties / invoice_status / type
      Removed value: -"string"
    • addedOutput schema / properties / newly_connected
      Added value: +{
      +  "description": "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. Start the reply with 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.",
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "name": {
      +        "type": "string"
      +      },
      +      "service_id": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "name",
      +      "service_id"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
  4. Added

TDQS

Score is being calculated.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources