File Downloads & License Keys
Relevant source files
The following files were used as context for generating this wiki page:
- server/polar/benefit/strategies/downloadables/service.py
- server/polar/benefit/strategies/license_keys/service.py
- README.md
- AGENTS.md
- clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts/dashboard/[organization]/(header)/products/new/ai/chat/route.ts)
- server/polar/organization_review/analyzer.py
File Downloads and License Keys are core "Benefits" within the Polar ecosystem. Polar operates as a Merchant of Record, allowing developers to sell digital products and automatically grant these benefits to customers upon successful purchase or subscription.
These systems are designed to automate the delivery of digital assets and software entitlements. File downloads support assets up to 10GB, while license keys provide a customizable mechanism for software activation and entitlement verification.
Sources: README.md:14-23, clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:98-105
System Architecture
The delivery of digital goods in Polar follows a "Product and Benefit" model. A customer purchases a Product, which is linked to one or more Benefits. When the transaction is complete, the associated benefit strategies (such as file delivery or key generation) are executed.
Relationship Model
The relationship between products and benefits allows for complex bundles, such as a subscription granting both a downloadable installer and a unique license key.
Sources: clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:86-95
File Downloads (Downloadables)
The File Download benefit allows creators to attach digital files to their products. Polar handles the secure storage and distribution of these files via an S3-compatible backend.
Functional Overview
- Storage Limits: Supports individual files up to 10GB.
- Fulfillment: Files are made available to customers immediately after a successful checkout.
- Verification: The system ensures the customer has an active entitlement before granting access to the file resource.
Sources: clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:98-105, server/polar/organization_review/analyzer.py:61-68
Components and Data Flow
The logic for managing downloadable assets is encapsulated within the DownloadablesBenefitService.
| Component | Responsibility |
|---|---|
DownloadablesBenefitService | Manages the lifecycle of file benefits, including creation and retrieval. |
S3/Minio | Provides the underlying storage for the binary files. |
BenefitRepository | Handles the database persistence for the benefit metadata. |
Sources: server/polar/benefit/strategies/downloadables/service.py, AGENTS.md:103-107
License Keys
License keys are used to verify software entitlements. Unlike generic custom benefits, License Keys have a dedicated strategy for generation and validation.
Key Features
- Automation: Polar can automatically generate unique keys for each customer.
- Customization: Keys can be customized to match specific software requirements or implementation patterns.
- Entitlement Verification: Developers can query the Polar API or utilize webhooks to verify the validity of a key held by a customer.
Sources: clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:98-105, server/polar/organization_review/analyzer.py:61-68
Lifecycle of a License Key
The fulfillment process ensures that keys are unique to the customer's purchase or subscription.
Sources: server/polar/benefit/strategies/license_keys/service.py, clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:114-118
Implementation Details
Benefit Strategies
Both systems are implemented as specific strategies within the modular backend. They reside in server/polar/benefit/strategies/.
- Downloadables: Located in
strategies/downloadables/. It relies on the project's S3 integration. - License Keys: Located in
strategies/license_keys/. It handles the logic for key string generation and state management (active, revoked, etc.).
Sources: server/polar/benefit/strategies/downloadables/service.py, server/polar/benefit/strategies/license_keys/service.py
Automated Configuration
The Polar Onboarding Assistant can help users define these benefits via chat, although complex configurations like specific file uploads require manual setup in the dashboard.
| Benefit Type | AI Chat Capability | Requirement for Activation |
|---|---|---|
| License Key | Fully Configurable | Product name and price |
| File Download | Informational/Route to Manual | File upload (up to 10GB) |
Sources: clients/apps/web/src/app/(main)/dashboard/[organization]/(header)/products/new/ai/chat/route.ts:114-124, server/polar/organization_review/analyzer.py:61-68
Summary
File Downloads and License Keys provide the fulfillment layer for digital products on Polar. By integrating storage management for files and a generation engine for license keys, Polar automates the "Benefits" portion of the monetization lifecycle, allowing developers to focus on product development while the platform handles delivery and tax compliance.