Skip to main content
Embedding an eBook externally allows you to share your digital content on your own website or any other web platform while keeping it secure and protected. With Fermion, you can generate a secure embed token and integrate your eBook easily using an iframe. This guide walks you step by step through obtaining your eBook digital product ID, generating an authentication token, and embedding the eBook on your site so your audience can access it without leaving your platform. Before you begin embedding your eBook externally, make sure you have the following ready:

eBook Digital Product ID

This unique identifier lets Fermion know which eBook you want to embed. You can find this ID with the help of Step 1 below.

Fermion API Key

Used to authenticate your requests securely when generating the embed token. You can create or view your API key from the API Access section in your instructor dashboard sidebar.

Access to Your Website’s Codebase

You’ll need to add a small code snippet (iframe) to your website, so make sure you have editing access or a developer who can implement it.
Once you have these three essentials, you can proceed to generate your secure embed token and integrate your eBook directly on your website with the help of steps below:
1

Obtain the ebook digital product ID

Each ebook on fermion has a unique identifier. For example 6779080e80ec97e953a17971. First, go to Manage features tab on your instructor dashboard and enable Digital productsAfter that, go to eBooks inside Digital products to create and upload an ebook if you haven’t. Learn more about Creating eBooksYou can find the ebook digital product ID in the URL.
2

Generate an Embed Token

You’ll need to generate a JWT (JSON Web Token) to authenticate the embed. Here’s how to create one using the jsonwebtoken package:
import jwt from 'jsonwebtoken'

const payloadObject = {
	/* ... see the valid schema of the object below ... */
}

const jwtToken = jwt.sign(payloadObject, 'FERMION_API_KEY', {
	expiresIn: '10h',
})
The payloadObject must conform to the following zod schema:
z.object({
	ebookDigitalProductId: z.string().min(1),
	userEmail: z.string().email(),
	userId: z.string().min(1),
	userPhoneNumber: z.string().min(1).or(z.null()),
})
Important notes:
  • Replace FERMION_API_KEY with your actual API key and provide a unique user ID for each viewer.
  • Make sure to set a validity on JWT token (recommended validity is 10h-20h)
Fermion uses the same zod schema as above internally to validate your JWT payload.
3

Embed the ebook

Add this iframe to your website where you want to embed the ebook:
<iframe
	width="1280"
	height="720"
	src="https://acme.fermion.app/embed/ebook?token=your_token_here"
	title="Ebook"
	frameborder="0"
	allow="allow-same-origin; camera *;microphone *;display-capture *;encrypted-media;"
	referrerpolicy="strict-origin-when-cross-origin"
	allowfullscreen
>
</iframe>
Make sure you replace acme.fermion.app with your fermion school URL.
This should embed your ebook and display it on your website.
I