Fermion offers an easy-to-use API for creating and managing eBook digital products. This guide will help you upload, encrypt, and publish eBooks via API step by step.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.
Overview
With Fermion’s eBook API, you can:- Create eBook products through code
- Securely upload PDF files to our cloud storage
- Apply automatic DRM protection and encryption
- Configure watermarks and control download permissions
- Update eBook metadata and descriptions
- Set up and edit pricing plans
- Manage multiple versions of any eBook
Prerequisites
Before you begin, make sure you have:- A valid Fermion API key
- A PDF file ready for upload (your eBook)
- Basic familiarity with HTTP requests and file uploads
Create an eBook Product
Create a new eBook product using the
create-ebook-product endpoint.Refer to the create-ebook endpoint for call details.Sample Response:Save the
slug value—it’s a unique, URL-friendly ID you’ll use for all later API calls.Get a Presigned Upload URL
See the get-presigned-url-for-ebook-upload for details.Sample Response:Key Points:
- Save
r2KeyForOriginalEbookPdf—you’ll need it next - The upload link is one-time and time-limited for security
- Requesting a new URL allows you to upload a new version
Process and Encrypt the Uploaded eBook
After uploading your PDF, trigger processing and encryption.See the process-uploaded-ebook.Sample Response:What Processing Does:
- Downloads your PDF from storage
- Encrypts the file with AES-128-CBC
- Generates encryption keys and initialization vectors
- Saves the encrypted eBook securely
- Logs encryption metadata to your product
Save the
ebookVersionIndex—you’ll need it to activate (publish) this version.Update eBook Metadata and Reader Settings
See API docs: update-ebook-metadataSample Request Body:Field Breakdown:
title(optional): eBook display titleshortDescription(optional): Summary for listingslongDescription(optional): Main description on product pageactiveVersionIndex(optional): Which uploaded version readers seeisBookDownloadable(optional): Allow download of PDF fileshouldEnableCenterWatermark(optional): Show watermark in middle of pagesshouldEnableHeaderWatermark(optional): Show watermark in headers
Watermark Options
Watermarks protect your content from unauthorized sharing:- Center Watermark: User’s email/ID in the center of every page
- Header Watermark: User info shown in each PDF header
- Watermarks are personalized for each downloader to trace misuse
Controlling Download Access
isBookDownloadable: true— Allow PDF downloads for offline readingisBookDownloadable: false— Restrict reading to browser-only
Add Pricing (Optional)
To set up paid access, use the digital product pricing API.See docs: create-custom-pricing-plan-for-a-product
Complete Example: JavaScript/Node.js Workflow
Below is a full eBook upload example using Node.js:Managing Multiple eBook Versions
You can upload new versions (such as updates or corrections) for the same eBook:Get New Presigned Upload URL
Call
get-presigned-url-for-ebook-upload again to get a fresh upload URL.Best Practices
Security
- Always use HTTPS for every API request and upload
- Never expose your API key in frontend or client code
- Enable watermarks to discourage piracy for premium content
- Disable file downloads (
isBookDownloadable: false) for sensitive material
Performance
- Upload large PDFs directly to storage with the presigned URL (not through your own server)
- If the upload fails or times out, request a new presigned URL and re-upload (do not reuse old links)
- Integrate uploads asynchronously if building user-facing dashboards
Content Organization
- Set clear and descriptive
ebookNamevalues for easy identification - Keep products in
Draftmode during setup and review - Review the eBook reader experience before publishing as “Active”
- Use
shortDescriptionfor SEO/discovery andlongDescriptionfor full details
Troubleshooting
”Uploaded eBook not found” Error
You may see this in Step 4 if:- The PDF failed to upload, or upload was incomplete
- The
r2KeyForOriginalEbookPdfyou used does not match the uploaded file - The presigned upload URL expired
”You can only mark an uploaded book as active” Error
This occurs if you try to activate a version that hasn’t been processed. Fix: Complete Step 4 (process-uploaded-ebook), then setactiveVersionIndex.
Upload Timed Out
Large PDFs can sometimes time out or stall. Fixes:- Use a stable and fast internet connection
- Adjust timeout settings in your HTTP client or tool
- Compress or optimize PDFs before uploading
Expired Upload URL
Fix: Simply request a new presigned URL using the API—there’s no limit to how many times you can do this.Getting Help
If you get stuck or have an edge-case issue:- See the API Reference for endpoint details
- Check the Webhooks Guide to track eBook purchases
- For product-specific issues, contact support and include your
fermionDigitalProductId
Next Steps
- Set up pricing plans
- Create coupons for your eBooks
- Enroll users programmatically
- Configure webhooks to track purchases and enrollments
