codespar_invoice
Fiscal documents. Issue, read, or amend an NF-e, NFS-e, or an international invoice; the Brazilian fiscal rail for nfe and nfse, Stripe Invoicing internationally.
Fiscal documents (NFS-e default; NF-e, CFDI, Factura AR).
codespar_invoice3 actionsmoves no moneyalways required typeAn unknown action emits a document
Measured 2026-09-09: the dispatch ignores action, so a typo ("isue", "create") does not refuse; it issues a fiscal document as if you had passed issue. Issuance is a fiscal act with the tax authority. Pass action only from the three values below, and never retry a refused call by guessing another spelling. Tracked as ent#1178, open.
Actions
action | What it does | Money | Needs |
|---|---|---|---|
issueexample below | Emit a new fiscal document (the default): NF-e or NFS-e on the Brazilian rail, Stripe Invoicing internationally | no | recipientitems |
status | Read an existing document's fiscal state (autorizada, cancelada, ...) | no | invoice_id |
amend | Correct a document: a correction letter (CC-e) while the SEFAZ window is open, else cancel and reissue as a substitute | no | invoice_idreason |
Unknown action: NOT refused: the dispatch ignores `action` and EMITS a fiscal document anyway. A typo in `action` issues a note (ent#1178, open). Tracked. Measured 2026-09-09.
Names come from the published tool document (/v1/meta-tools.json, the same list the MCP server answers to tools/list); the one-line summaries and the money class are kept in the docs repository and checked against it on every build.
Example
action: "issue" of an NFS-e (a service invoice), the default action.
{
"name": "codespar_invoice",
"arguments": {
"type": "nfse",
"action": "issue",
"recipient": {
"name": "Example Buyer",
"document": "00000000000",
"email": "buyer@example.com"
},
"items": [
{ "description": "Example service", "quantity": 1, "unit_price": 10000 }
]
}
}Result shape: see runtime. The tool document says status returns the document's fiscal state (autorizada, cancelada, ...) and that an amend result indicates which mechanism applied (CC-e or cancel and reissue), and names no other field. The published document is /v1/meta-tools.json.
When to use
- Services (SaaS, consulting, anything service-driven):
type: "nfse", the Brazilian Nota Fiscal de Serviços. - Products:
type: "nfe". Issuance needs the operator's A1 certificate, state tax registration and per-item ICMS classification stamped in the dashboard first (see Notes). - Outside Brazil:
type: "invoice"routes to Stripe Invoicing. - After a settlement: the usual chain is charge → wait for settlement → invoice → ship → notify. The Webhook Listener cookbook issues the invoice from the settlement event.
- Reading or correcting:
statusreads the fiscal state byinvoice_id;amendwrites a correction letter (CC-e) while the SEFAZ amendment window is open, or cancels and reissues as a substitute (tipo 3) once it is not, and the result says which applied.
Arguments
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | nfe, nfse or invoice |
action | string | No | issue (emit, the default) | status (read the fiscal state) | amend (correct in place via CC-e, or cancel and reissue). See the warning above about unknown values. |
recipient | object | For issue | Recipient details: name, document, email |
items | array | For issue | Line items |
dueDate | string | No | Due date, ISO 8601 |
invoice_id | string | For status, amend | The existing document's id to read or amend |
correction | string | For amend (CC-e) | Correction text for an in-window correction letter |
reason | string | For amend | Why the document is being amended; drives correction letter versus cancel-and-reissue |
Errors and what to do
| Error | Cause | What to do |
|---|---|---|
invalid_args | items missing or empty (the dispatch also accepts products as an alias), or recipient absent when the connection has no default buyer. | Fix the call against the Arguments table. |
status: "rejected" with a SEFAZ code | The tax authority refused the NF-e or NFS-e (a validation on the buyer's document, the service code, the item classification). | Surface the code to the operator. Do not retry blindly: a corrected document is a new issuance, and an uncorrected retry is refused again. |
| Latency around 2s | Production SEFAZ authorization at peak load; issuance is synchronous from the agent's perspective. | Wait for the result; do not fire a second issue for the same order. |
Money and mandate
No money moves on this tool. It emits, reads and amends fiscal documents, which are irreversible acts with the tax authority: an authorized NF-e can be corrected or cancelled and reissued, never silently replaced. There is no mandate gate on issuance; the operator's fiscal credentials (see Notes) are what authorize it, so an agent that can reach this tool can issue documents in the operator's name. Keep the action value exact (see the warning at the top).
Related
codespar_charge: the settlement that usually precedes the invoicecodespar_shipandcodespar_notify: the next steps in the sell-side chain- E-Commerce Checkout cookbook: charge → invoice → ship → notify
- Webhook Listener cookbook: issue the invoice from a settlement event
- Glossary: SEFAZ, NF-e, NFS-e, CFDI
Notes
Sandbox status. NFS-e issuance is validated against the provider sandbox today; production SEFAZ authorization is on the roadmap.
Rails, as previously documented. The earlier page listed the fiscal partner and Bling for NFS-e (BRL, BR), the fiscal partner for NF-e (BRL, BR; needs A1 cert, state tax registration, per-item ICMS), Facturapi for CFDI 4.0 (MXN, MX), Siigo for factura electrónica (COP, CO) and AFIP for Factura A/B/C (ARS, AR). The published schema names only three type values (nfe, nfse, invoice), so how the Mexican, Colombian and Argentine rails are selected is not documented by the schema; this revision did not re-verify those lines.
Operator setup. The operator pre-stamps fiscal credentials in /dashboard/auth-configs: NFS-e needs the fiscal partner's API key and company id (service-rail tenants can stop here); NF-e adds the A1 digital certificate (most operators upload a PFX once and CodeSpar converts it to PEM and vaults it), the state tax registration (inscricao_estadual) and per-item ICMS / CFOP / NCM classifications; CFDI needs the Facturapi key and RFC; Factura AR needs the AFIP certificate, private key and CUIT.
Result shape (SDK), as previously documented. { id, access_key, number?, series?, pdf_url?, xml_url?, status: "authorized" | "pending" | "rejected", authorized_at? }, where access_key is the neutral field the per-rail raw keys (BR chave, CFDI uuid, Factura AR cae) normalize into. This revision did not re-verify that list against the runtime.
From the SDK. There is no typed wrapper; call session.execute("codespar_invoice", arguments) with the same arguments as the MCP call. The dispatch also accepts buyer for recipient and products for items; the schema names recipient and items, so use those.
codespar_charge
Inbound charges, the buyer pays the merchant. An immediate Pix, a cobrança com vencimento (boleto or Pix, with a due date), hosted card checkout or a wallet redirect; then read or cancel what you issued.
codespar_ship
Quote, label or track a shipment. Brazilian domestic shipping on Melhor Envio (Correios and private carriers) behind a neutral origin, destination and items shape; the router picks the cheapest carrier per request.