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

# Embed eBook

> Learn how to embed an eBook externally

Embedding an [eBook](/digital-products/introduction) 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:

<Columns cols={3}>
  <Card title="eBook Digital Product ID" icon="book">
    This unique identifier lets Fermion know which eBook you want to embed. You can find this ID with the help of <strong>Step 1</strong> below.
  </Card>

  <Card title="Fermion API Key" icon="key">
    Used to authenticate your requests securely when generating the embed token. You can create or view your API key from the <strong>API Access</strong> section in your instructor dashboard sidebar.
  </Card>

  <Card title="Access to Your Website’s Codebase" icon="code">
    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.
  </Card>
</Columns>

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:

<Steps>
  <Step title="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 products`

    ![](https://codedamn-website-assets.s3.us-east-1.amazonaws.com/uploads/10-03-2025/15%20PM.ugncgw.png)

    After that, go to `eBooks` inside `Digital products` to create and upload an ebook if you haven't. Learn more about [Creating eBooks](/digital-products/landing-page)

    ![](https://codedamn-website-assets.s3.us-east-1.amazonaws.com/uploads/10-03-2025/43%20PM.sapnvv.png)

    You can find the ebook digital product ID in the URL.

    ![](https://codedamn-website-assets.s3.us-east-1.amazonaws.com/uploads/10-03-2025/23%20PM.wulyuh.png)
  </Step>

  <Step title="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:

    ```javascript theme={null}
    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:

    ```js theme={null}
    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)

    <Info>
      Fermion uses the same zod schema as above internally to validate your JWT
      payload.
    </Info>
  </Step>

  <Step title="Embed the ebook">
    Add this iframe to your website where you want to embed the ebook:

    ```html theme={null}
    <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>
    ```

    <Warning>
      Make sure you replace `acme.fermion.app` with your fermion school URL.
    </Warning>

    This should embed your ebook and display it on your website.
  </Step>
</Steps>
