Alegra automation · runs weekly
Create and email Alegra invoices from a job list
At the end of the week you have a list of finished jobs, and every row still has to become an Alegra sales invoice with the right contact, products and services, due date and numbering.
Cotlet does it in your own Alegra account with list_contacts, list_items, create_invoice and email_invoice, called by your AI agent, an n8n workflow or a script.
Hosted · nothing to install or maintain
Can Alegra do this on its own?
Alegra has an API that creates invoices and emails them, and Zapier has Create Invoice and Send Invoice actions (checked 14 Oct 2026). Alegra's official MCP server is read-only, so an agent cannot do this job through it. No Alegra feature builds invoices from a list of jobs.
How you do it in Alegra today
- You open the Ingresos menu, choose Facturas de venta and click + Nueva factura de venta.
- You pick the contact, which must already exist: a new client first goes through Contactos > + Nuevo Contacto.
- You add at least one product or service, set the quantities and prices, and check the Resolución field, which is the numbering the invoice uses.
- You expand the Guardar button and choose Guardar como borrador, Guardar e imprimir or Guardar y enviar por correo.
- The text of the email comes from the template under Configuración > Notificaciones y correos > Plantillas de correo y WhatsApp.
- This repeats for every client every week, and a skipped row means a late invoice.
How to create and email Alegra invoices from a job list
Here are this week's finished jobs with client, hours and rate. Create a draft sales invoice in Alegra for each client, due in 30 days, and show me the totals. After I say go, email each one to the contact on file. - 01
Match each client to a contact
The agent looks every client name up with list_contacts. A name with no match, or with two close matches, goes on your list, and a contact is created only when you ask for it.
- 02
Reuse the items you already sell
list_items returns your products and services, so a row like "Consulting, 10 hours" becomes a line with that item and its price. A row that fits no item is reported instead of guessed.
- 03
Draft one invoice per client
create_invoice runs with status draft, rows for the same client share one invoice, and the due date is the invoice date plus the days in your prompt. Nothing is sent to a client yet.
- 04
Check totals against your list
The agent reports subtotal, tax and total for every draft so you can compare them with your own numbers before anything leaves.
- 05
Email after your OK
When you say go, email_invoice sends each invoice to the contact's address. Each call asks for your confirmation by default, and a failed send is reported once and never retried on its own.
What you get back
Rows in the list: 4 across 3 clients
Drafts created: 2
- Northwind Studio: 2 x 400.00 + 1 x 150.00 = 950.00, tax 180.50, total 1,130.50, due 2026-11-19
- Lumen Dental: 6 x 80.00 = 480.00, tax 91.20, total 571.20, due 2026-11-19
Needs you: 1 client with no matching contact ("Acme" or "ACME Ltd")
Emailed: 0 (waiting for your go) Other ways to ask
- Create a draft invoice for Northwind Studio with 2 hours of design review and 1 hour of setup, due in 15 days.
- Email the three drafts from Monday to the contacts on file, with the subject "Invoice for October".
- Every Friday, draft invoices for the hours in this timesheet and send me the totals, but do not email anyone.
- Copy last month's invoice lines for each client and draft them for this month.
What Alegra allows, and what to know first
- Alegra requires each invoice to be linked to a contact and to contain at least one product or service.
- Without a status and without payments, an invoice created through the API is saved as a draft, which is also what Guardar como borrador does on screen.
- Alegra names the document differently by country: cuenta de cobro in Colombia, recibo de honorarios in Mexico and detalle de venta in Panama.
- When stamping an invoice with the tax authority fails, Alegra keeps the invoice as a draft and returns the error instead of issuing it.
- The email text comes from the template "Correo de envío de facturas de venta", and only the subject can be set per send.
create_invoice and email_invoice ask for your OK by default. To run it weekly without you, switch confirmation off for those tools in your dashboard.
Sources: Alegra Help: How to make a sales invoice · Alegra Help: Customize the emails for sending your documents · Alegra developers: Create a sales invoice · Alegra developers: Send an invoice by email
Call create_invoice from a script
curl -X POST https://cotlet.dev/api/v1/alegra/contacts/20/invoices \
-H "Authorization: Bearer $COTLET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"items":[{"item_id":"12","quantity":2,"price":400,"tax_ids":["3"]},{"item_id":"15","quantity":1,"price":150,"tax_ids":["3"]}],"date":"2026-10-20","due_date":"2026-11-19","status":"draft"}' {
"invoice_id": "1042",
"number": "FV-0042",
"status": "draft",
"date": "2026-10-20",
"due_date": "2026-11-19",
"currency": "USD",
"client": {
"contact_id": "20",
"name": "Northwind Studio"
},
"items": [
{
"item_id": "12",
"quantity": 2,
"price": 400,
"line_total": 800
},
{
"item_id": "15",
"quantity": 1,
"price": 150,
"line_total": 150
}
],
"subtotal": 950,
"tax_total": 180.5,
"total": 1130.5,
"balance": 1130.5
} MCP: add https://cotlet.dev/mcp/v1 with the same key; the call is alegra_write → create_invoice. Example data.
Schedule it in n8n, Make, Zapier or cronAlegra tools this automation uses
| Tool | Parameters |
|---|---|
| list_contacts | query, kind, limit, cursor |
| list_items | query, limit, cursor |
| create_invoice | contact_id, items, date, due_date, status, generate_stamp, number_template_id |
| email_invoice | invoice_id, emails, subject, send_copy_to_me, as_copy |
Frequently asked questions
Is it safe to connect Alegra to Cotlet?
Yes. You sign in to Alegra yourself, in your own Cloud Browser in the EU, and we never save your password. Your agents only get Alegra once you enable it, every background request is listed, and the browser profile is stored encrypted with AES-256-GCM, the cipher 1Password uses for its vaults. The AI model never sees a login, posts and messages wait for your OK, and Disable for agents cuts access in one click. Independent scanners grade cotlet.dev A+ on Qualys SSL Labs, securityheaders.com and Mozilla Observatory; live results are on https://cotlet.dev/security.
Give your agent access to Alegra.
Free 7-day trial with 2,000 credits, no card needed. Cotlet is independent and not affiliated with Alegra.