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

# Preview Next Invoice PDF

# Preview Next Invoice PDF

Returns a PDF preview of the customer's upcoming invoice. This allows members to see what their next invoice will look like before it is officially generated, including estimated charges from active contracts and pending items.

## Authentication

This endpoint requires a valid media JWT token obtained from `GET /api/auth/media/customer`.

## Query Parameters

<ParamField query="t" type="string" required>
  A short-lived media JWT obtained from `GET /api/auth/media/customer`. This token authorises temporary access to the binary file. Pass the `jwt`
  field from the response object directly as this query parameter value.
</ParamField>

## Response

Returns the raw PDF binary (`application/pdf`). The portal constructs the full URL and opens it in a new browser tab.

## Code Examples

<CodeGroup>
  ```ts TypeScript theme={null}
  // 1. Fetch a media JWT (requires a valid Bearer token)
  const { jwt } = await fetch('/api/auth/media/customer', {
    headers: { Authorization: `Bearer ${customerBearerToken}` },
  }).then((r) => r.json())

  // 2. Build the draft invoice PDF URL
  const draftUrl = `https://${business.WebAddress}/en/api/public/billing/invoices/draft/pdf?t=${jwt}`

  // 3. Open directly — no additional fetch needed
  window.open(draftUrl, '_blank')
  ```

  ```bash cURL theme={null}
  # First obtain a media JWT
  MEDIA_JWT=$(curl -s -H "Authorization: Bearer $TOKEN" \
    "https://your-space.nexudus.com/en/api/auth/media/customer" | jq -r '.jwt')

  # Then download the draft invoice PDF
  curl -o draft-invoice.pdf \
    "https://your-space.nexudus.com/en/api/public/billing/invoices/draft/pdf?t=$MEDIA_JWT"
  ```
</CodeGroup>

## Usage in Portal

This endpoint is used in the **My Invoices** section to provide a "Preview next invoice" link at the bottom of the invoices table.

* File: `src/views/user/activity/invoices/MyInvoicesSection.tsx`

## Related Endpoints

* `GET /api/public/billing/invoices/my` – List invoices
* `GET /api/public/billing/invoices/{invoiceId}/pdf` – Download a single invoice PDF
* `GET /api/public/billing/invoices/statements/pdf` – Download billing statement
* `GET /api/auth/media/customer` – Obtain a short-lived media JWT

## Error Responses

<ResponseField name="401 Unauthorized" type="error">
  Missing or invalid media JWT token.
</ResponseField>
