Invoices
Download Invoice PDF
GET
Download Invoice PDF
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.
Download Invoice PDF
Returns the PDF file for a given invoice. Two variants are available depending on whether the request is made by an authenticated customer or a guest using a one-time token:| Variant | URL | Auth |
|---|---|---|
| Authenticated customer | /api/public/billing/invoices/{invoiceId}/pdf?t={mediaJwt} | Bearer token + media JWT |
| Guest / token-based | /api/public/billing/invoices/{invoiceId}/pdfByToken?token={basketSessionGuid} | Basket session GUID only |
Authenticated Variant
Path Parameters
The unique identifier of the invoice.
Query Parameters
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.Obtaining the Media JWT
CallGET /api/auth/media/customer with a valid Bearer token. The endpoint returns a single-field JSON object:
- Short-lived – expires after approximately 60 seconds. In the portal, the token is cached and automatically refreshed every 50 seconds to ensure it is always valid when a download link is constructed.
- Scoped – it only grants access to protected binary/media resources and cannot be used in place of a regular API Bearer token.
- One-time style – a fresh token should be fetched for each user session; do not persist it across sessions.
Example: fetching and using the media JWT
withMediaJwt helper (src/states/withMediaJwt.ts), which wraps endpoints.system.mediaToken (/api/auth/media/customer) and keeps the token fresh:
Guest / Token Variant (pdfByToken)
Path Parameters
The unique identifier of the invoice.
Query Parameters
The basket session GUID associated with the completed checkout. This is the payment-gateway session ID (e.g. the Stripe, Spreedly, or PayPal
session ID) that was used to process the payment. It is available as
stripe_session_id, spreedly_session_id, or paypal_session_id in the
checkout completion URL and is passed directly to this endpoint — no authenticated session is required.How the basket session GUID is obtained
When a guest checkout completes, the payment gateway redirects back to the portal’s completion page with the session ID as a URL query parameter:token for both pdfByToken and registerByToken:
Response
Both variants return the raw PDF binary (application/pdf). The portal constructs a full URL and opens it in a new browser tab or as a direct link rather than fetching it through the API client.
Usage in Portal
These endpoints are used to generate PDF download links in two contexts:-
My Invoices section (authenticated customers) – constructs the
pdfURL using the media JWT.- File:
src/views/user/activity/invoices/MyInvoicesSection.tsx
- File:
-
Invoice basket summary – shows a download link during checkout.
- File:
src/views/checkout/components/InvoiceBasketSummary.tsx
- File:
-
Guest checkout complete page – uses
pdfByTokenwith the payment-gateway basket session GUID to allow PDF download without a session.- File:
src/views/public/checkout/complete/index.tsx
- File:
Typical integration pattern
Related Endpoints
GET /api/public/billing/invoices/{invoiceId}– Get full invoice detailsGET /api/auth/media/customer– Obtain a short-lived media JWT ({ jwt: string }) for authenticated downloads. See Obtaining the Media JWT above for full usage details.
Error Responses
The current user is not authenticated, or the media JWT or invoice token is invalid or expired.
Invoice with the given ID does not exist or is not accessible to the caller.
Download Invoice PDF