@factucat/cli
v0.2.4
Published
CLI for Mexican CFDI 4.0 invoicing with FactuCat Cloud
Maintainers
Readme
FactuCat CLI
FactuCat CLI is the command-line interface for FactuCat, a cloud-only product for issuing Mexican CFDI 4.0 invoices.
It is designed for two use cases:
- interactive invoicing for humans who want a guided flow
- unattended automation for agents, scripts, and integrations that need stable
--jsonoutput
FactuCat CLI works with Mexican tax concepts and SAT terminology such as CFDI, timbrado, RFC, razón social, régimen fiscal, uso CFDI, XML, and PDF.
Install
npm install -g @factucat/cliVerify the installation:
factucat --helpUpdate to the latest version:
npm install -g @factucat/cli@latestAuthenticate
First generate an API key in FactuCat:
- Sign in to https://factucat.com
- Open the settings area
- On any settings screen, with no input focused, type the Konami code:
↑ ↑ ↓ ↓ ← → ← → B A - FactuCat unlocks the hidden
API keyssection in the settings sidebar - Open
API keys, create a new key, and copy it immediately
The full token is only shown once after creation.
Then save it locally:
factucat auth api-key setYou can also provide it explicitly:
factucat auth api-key set --value fc_live_xxxxxOr through standard input:
printf 'fc_live_xxxxx\n' | factucat auth api-key setValidate the current key:
factucat auth status
factucat auth status --jsonHow the workflow works
FactuCat CLI uses a remote draft workflow:
- Create a draft in FactuCat Cloud
- Assign the customer or receiver data
- Set invoice metadata such as
uso CFDI, payment method, and currency - Add line items
- Review the invoice preview
- Stamp the invoice
- Download the XML or PDF if needed
The server is always the source of truth. The CLI only remembers your current draft locally for convenience.
Interactive workflow
Create a draft:
factucat invoice createCreate a draft and automatically resolve a customer by name or RFC:
factucat invoice create --customer "Donde nacen las ideas"That command is a shortcut: it creates the draft and internally tries to find the customer before linking it to the draft.
Add a line item:
factucat invoice add-item \
--description "Desarrollo de sistema de facturación" \
--unit-price 10000If you omit SAT product code, SAT unit code, IVA, or retained ISR, FactuCat tries to infer them automatically.
Set invoice metadata:
factucat invoice set-meta \
--cfdi-use G03 \
--payment-method PUE \
--payment-form 03If you switch the invoice to USD without specifying an exchange rate, FactuCat automatically fetches the official DOF exchange rate:
factucat invoice set-meta --currency USDPreview the full invoice before stamping:
factucat invoice showStamp interactively:
factucat invoice stampIn an interactive terminal, invoice stamp shows the full preview first and can ask whether you want to send the stamped invoice through the customer contact channels registered in FactuCat.
Unattended workflow
For agents and scripts, prefer --json and --no-input.
Create a draft:
factucat invoice create --jsonSet receiver data:
factucat invoice set-receiver \
--draft-id dft_123 \
--rfc XAXX010101000 \
--legal-name "Público en general" \
--postal-code 06000 \
--tax-regime 616 \
--jsonSet invoice metadata:
factucat invoice set-meta \
--draft-id dft_123 \
--cfdi-use S01 \
--payment-method PUE \
--payment-form 01 \
--currency MXN \
--jsonAdd a line item with explicit taxes:
factucat invoice add-item \
--draft-id dft_123 \
--description "Servicios de consultoría" \
--quantity 1 \
--unit-price 1000 \
--iva 16 \
--isr-retenido 10 \
--jsonPreview the draft:
factucat invoice show --draft-id dft_123 --jsonStamp without prompts:
factucat invoice stamp --draft-id dft_123 --no-input --jsonStamp and request delivery to customer contacts:
factucat invoice stamp \
--draft-id dft_123 \
--send-to-customer-contacts \
--no-input \
--jsonOr request specific channels:
factucat invoice stamp \
--draft-id dft_123 \
--send-customer-email \
--send-customer-whatsapp \
--no-input \
--jsonCurrent draft helpers
Select an existing draft as your current one:
factucat invoice use dft_123Check which draft is currently selected:
factucat invoice currentDiscard the current draft:
factucat invoice discardCustomer commands
Search customers:
factucat customer search "Donde nacen"List customers:
factucat customer list --limit 20Create a customer:
factucat customer create \
--legal-name "Donde nacen las ideas" \
--rfc DNI240101AB1 \
--postal-code 45116 \
--tax-regime 601 \
--email [email protected]Review and artifact download
List issued invoices:
factucat invoice listGet a stamped invoice by UUID or folio:
factucat invoice get 019d231a-779b-771b-a666-ecefc6803fd2
factucat invoice get MIAU-00036Download XML:
factucat invoice download xml MIAU-00036
factucat invoice download xml MIAU-00036 --output ./facturas/Download PDF:
factucat invoice download pdf MIAU-00036
factucat invoice download pdf MIAU-00036 --output ./facturas/factura-marzo.pdfIf you do not pass --output, the file is saved in the current working directory.
Notes about inference
FactuCat automatically infers several values when possible:
invoice add-itemcan infer SAT product code, SAT unit code, IVA, and retained ISRinvoice set-meta --currency USDcan infer the official DOF exchange rate if you omit--exchange-rate
This mirrors the behavior of FactuCat's guided product flows and keeps the CLI aligned with the rest of the platform.
Troubleshooting
API key inválida o revocada
The configured API key is wrong, expired, or has been revoked. Save a valid key again:
factucat auth api-key set
factucat auth statusNo hay borrador activo
You tried to mutate a draft without selecting one first. Either create a draft or point to one explicitly:
factucat invoice create
factucat invoice use dft_123Customer lookup is ambiguous
If invoice create --customer "..." matches multiple customers, search first and then pass the exact customer id:
factucat customer search "Donde nacen"
factucat invoice create --customer-id cus_123Stamping fails
Review the draft before retrying:
factucat invoice showCommon causes are incomplete CFDI data, missing receiver information, or invalid concepts.
Downloaded artifact location
If you are unsure where a file was saved, use --output explicitly to control the destination path.
Learn more
- FactuCat: https://factucat.com
- Help page in npm package format: this README
