Problem
When a freelancer creates an invoice via POST /api/invoices, the client receives no notification. The payment link exists in the database but the client has no way to know they have an invoice to pay unless the freelancer manually shares the link.
What needs to be built
After the invoice is successfully created in app/api/invoices/route.ts, send an email to clientEmail with the payment link.
Email content (minimum viable)
- Subject:
Invoice from {freelancerName} — {invoiceNumber}
- Body:
- Freelancer name + amount + currency
- Due date (if set)
- Prominent CTA button linking to
invoice.paymentLink
Implementation
Use the existing lib/email.ts / Resend setup:
// lib/email.ts — add a new function
export async function sendInvoiceToClient(params: {
clientEmail: string
clientName: string | null
freelancerName: string
invoiceNumber: string
amount: number
currency: string
dueDate: string | null
paymentLink: string
})
Call it at the end of the POST /api/invoices handler (fire-and-forget — don't let email failure block the API response).
Acceptance criteria
Problem
When a freelancer creates an invoice via
POST /api/invoices, the client receives no notification. The payment link exists in the database but the client has no way to know they have an invoice to pay unless the freelancer manually shares the link.What needs to be built
After the invoice is successfully created in
app/api/invoices/route.ts, send an email toclientEmailwith the payment link.Email content (minimum viable)
Invoice from {freelancerName} — {invoiceNumber}invoice.paymentLinkImplementation
Use the existing
lib/email.ts/ Resend setup:Call it at the end of the
POST /api/invoiceshandler (fire-and-forget — don't let email failure block the API response).Acceptance criteria
clientEmailis invalid format (basic validation)sendInvoiceToClientis called with correct params on successful invoice creation