Download ticket PDFs
Serve ticket PDFs to your customers from your own server
Every paid event booking has a ticket PDF containing all tickets for that booking. You can securely download the latest version through the API and then serve it through your own app, attach it to emails, or store a copy yourself. The PDF endpoint requires your Checkout Page API key, so it should only be called from your server - never directly from a customer's browser or email. Each download returns the current ticket PDF.
Prerequisites
To get the most out of this guide, you'll need:
- A Checkout Page API key
- An event with at least one paid booking
1. Install
Get the Checkout Page Node.js SDK, or skip this step and use plain fetch:
npm install @checkoutpage/sdk2. Get a booking id
Any of these gives you the id to download with:
- a
booking.paidwebhook, delivered when a booking is paid - List all bookings, filtered by customer, order or search
- Get booking details, if you already store booking ids
3. Download the PDF
curl https://api.checkoutpage.com/v1/bookings/{bookingId}/ticket-pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-o tickets.pdfThe response body is the PDF file itself (application/pdf), not JSON. It returns 404 when no PDF exists, for example while a booking is unpaid or abandoned.
4. Serving the ticket PDF from your app
Your API key must stay on your server. Never call this endpoint directly from a browser, email or mobile app - always proxy through your own server.
In your app, add a download button that calls your server; your server securely fetches the PDF and returns it.
import { createCheckoutPageClient, NotFoundError } from '@checkoutpage/sdk';
const client = createCheckoutPageClient({ apiKey: process.env.CHECKOUTPAGE_API_KEY });
app.get('/my-tickets/:bookingId', requireLogin, async (req, res) => {
try {
const pdf = await client.bookings.downloadTicketPdf(req.params.bookingId);
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Content-Disposition', 'attachment; filename="tickets.pdf"');
res.send(Buffer.from(pdf));
} catch (err) {
if (err instanceof NotFoundError) return res.sendStatus(404);
throw err;
}
});From there it's up to you: stream it as a download, render it inline, or attach it to an email you send.
Check that the booking belongs to the signed-in customer before returning the PDF. Your API key can download any booking's tickets, so your server is the place to enforce who sees what.