Skip to main content
Glama
themiguelamador

toconline-mcp

create_sales_document

Generate sales documents like invoices or credit notes with line items. Choose finalize=true to issue immediately (fiscally binding) or finalize=false to save as a draft.

Instructions

Create a sales document with line items.

Two code paths depending on finalize:

  • finalize=True — uses the v1 endpoint (POST /api/v1/commercial_sales_documents), which takes a flat body, embeds lines inline, and issues the document immediately (fiscally binding, irreversible). Customer identity fields are denormalized by fetching /api/customers/{customer_id} first.

  • finalize=False (default) — uses the legacy JSON:API endpoint multi-step: POST the header to /api/commercial_sales_documents, then POST each line to /api/commercial_sales_document_lines with document_id linking. The document stays as a draft (status 0) — editable, not yet fiscally valid. To issue later, call finalize_sales_document(id).

v1 ignores finalize=0 (the documented field), so the legacy path is the only way to actually leave a doc in draft state via this API.

Customer identity (name, tax number, address) is denormalized onto the header by TOCOnline server-side, on both paths — but only from the customer's main address. If the header comes back with an empty customer_address_detail, the customer has no main_address_id set; fix the customer's address rather than passing address fields here.

Date: on a certified series the date cannot precede the series' last issued document. The API enforces this; we don't pre-check it (a type can have multiple series, so a client-side guess would risk blocking valid emissions).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYesISO date, e.g. 2025-01-15. On a certified series the date cannot precede the last issued document's date — TOCOnline rejects back-dating before the most recent document in the series.
linesYesAt least one line item.
notesNoCustomer-visible notes on the document.
due_dateNoPayment due date (YYYY-MM-DD).
finalizeNoIf true, the document is issued immediately (fiscally binding). If false, it stays as a draft.
customer_idYesTOCOnline customer id.
document_typeYesDocument type code. Common: FT (invoice), FR (invoice-receipt), NC (credit note / rectificative), ND (debit note / rectificative), FT-FA (simplified invoice).
payment_mechanismNoTOCOnline payment mechanism code (e.g. MO, NUM, TRA, CC).
external_referenceNoExternal reference id (e.g. PO number).
parent_document_idNoFor rectificative documents (NC / ND): id of the original sales document this rectifies. Included via the `parent_documents_ids` attribute.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description fully discloses behavioral traits: two code paths, irreversible vs draft, customer address denormalization, date constraints, and API enforcement. No contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a summary and bullet points. It is slightly long but every sentence adds value. Front-loaded with one-line purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (10 params, nested lines, two code paths), the description is very complete. It covers edge cases (customer address, date constraints, v1 limitation) and output schema exists.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds significant meaning beyond schema, e.g., finalize behavior, document_type codes, date constraints, and parent_document_id usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it creates a sales document with line items, distinguishing it from sibling tools like create_sales_receipt. It explains two code paths, making the purpose very specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use finalize=True vs False, and notes the legacy path is needed for drafts. It also mentions alternatives like finalize_sales_document, but does not explicitly list when not to use this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/themiguelamador/toconline-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server