Send invoice via email
POST
https://app.speybooks.com/api/v1/invoice-email/{id}/emailSend a sales invoice to the contact's email address (or an override recipient). This is a multi-step operation:
- Validate the prefixed invoice ID (
inv_*) - Fetch invoice with contact and organisation details (filtered by
organisation_idfor multi-tenancy) - Confirm the invoice is a
salestype (purchase invoices cannot be emailed) - Resolve recipient: override
tofield → contact email - Fetch invoice line items ordered by ID
- Render branded HTML and plain text email bodies using organisation details (name, address, VAT number)
- Send via email service
- If invoice status is
draft, transition tosent - Write
INVOICE_EMAILEDaudit log entry with recipient and invoice number
Authentication
Requires a valid JWT. The authenticated user must belong to the organisation that owns the invoice. Multi-tenancy is enforced via organisation_id filtering on the query.
State Transition
| Before | After | Condition |
|---|---|---|
draft | sent | Email sent successfully |
sent | sent | No change (re-sending allowed) |
paid | paid | No change (re-sending allowed) |
overdue | overdue | No change (re-sending allowed) |
Only the draft → sent transition modifies invoice state. Re-sending an already-sent invoice is permitted and does not alter the status.
Override Fields
All body fields are optional:
to— override recipient email (defaults to contact email)subject— override email subject (defaults to "Invoice INV-XXXX from Org Name")message— custom message rendered in a highlighted block above the invoice details
Side Effects
- Email delivery — synchronous; returns 500 if send fails
- Audit log —
INVOICE_EMAILEDentry withsentToandinvoiceNumberin details JSON, includes IP address - Status mutation — draft invoices promoted to sent
Email Content
The HTML email includes:
- Organisation branding (name, address, VAT number)
- Recipient contact details
- Issue and due dates
- Line item table (description, quantity, unit price, VAT rate, total)
- Subtotal, VAT, and total summary
- Optional notes and terms sections
- Optional custom message in a highlighted block
Error responses:
400 { code: "invalid_id" }— malformed or wrong-prefix ID400 { code: "validation_error" }— no email available (contact has no email and notooverride provided)404 { code: "not_found" }— invoice does not exist, belongs to another organisation, or is a purchase invoice500 { code: "internal_error" }— email delivery failed
Idempotency: Not idempotent. Each call sends a new email, writes a new audit log entry, and (for drafts) transitions status. Clients should confirm before re-sending.
Path parameters
id string requiredInvoice ID (e.g., inv_42)
Body parameters
message string optionalCustom message to include
subject string optionalOverride email subject
to string optionalOverride recipient email
Response
200 Invoice sent successfully. If the invoice was in draft status, it is automatically moved to sent.
Show response fields
id stringPrefixed invoice ID (e.g. inv_42).
invoiceNumber stringInvoice number (e.g. INV-0042).
sentTo stringEmail address the invoice was sent to.
Error codes
400 Invalid invoice ID format, or no email address available for the contact.
404 Invoice not found, is not a sales invoice, or does not belong to this organisation.
500 Email delivery failed. The invoice status is not changed. Retry the request.