> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fluxrate.co/llms.txt
> Use this file to discover all available pages before exploring further.

# PDF & Email Delivery

> Generate PDF invoices and email them to customers with payment links.

## Sending an Invoice by Email

```bash theme={null}
curl -X POST https://api.fluxrate.co/api/v1/invoices/<invoice_id>/send-email \
  -H "Cookie: access_token=<token>"
```

This will:

1. Generate a PDF of the invoice
2. If the invoice is in `DRAFT`, automatically finalize it to `OPEN`
3. Generate a payment link (if a payment gateway is configured)
4. Email the customer with the invoice PDF and payment link attached

### Response

```json theme={null}
{
  "success": true,
  "message": "Invoice email sent successfully",
  "payment_link": "https://checkout.stripe.com/..."
}
```

## Email Configuration

Configure SMTP settings in **Dashboard → Settings → Email**:

| Setting       | Description                |
| ------------- | -------------------------- |
| SMTP Host     | Your email server hostname |
| SMTP Port     | Port (usually 587 for TLS) |
| SMTP Username | Authentication username    |
| SMTP Password | Authentication password    |
| From Email    | Sender email address       |
| From Name     | Sender display name        |

<Note>
  If SMTP is not configured, sending emails will return `success: false`. The invoice itself is still finalized.
</Note>

## Finalization (Without Email)

To finalize an invoice without sending email:

```bash theme={null}
POST /api/v1/invoices/<invoice_id>/finalize
```

This transitions `DRAFT` → `OPEN` and generates a payment link if a gateway is configured.

## PDF Generation

Fluxrate generates professional PDF invoices that include:

* Your organization's logo and branding
* Customer billing details
* Itemized line items
* Tax breakdown
* Total due
* Bank payment information (if configured)
* Payment link

## Automatic Email on Finalization

When the background worker finalizes invoices (after the 1-hour grace period), it automatically sends an email notification to the customer. This behavior is configurable per organization.

## Payment Integrations

Connect a payment gateway in **Settings → Integrations** to automatically generate payment links that are included in emails and the public invoice page.

Supported gateways:

* **Stripe** — Generates Stripe Checkout links
* **Razorpay** — Generates Razorpay payment links
* **Chargebee** — Integrates with Chargebee billing
