Passer au contenu principal

Documentation Index

Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt

Use this file to discover all available pages before exploring further.

License keys are the License Key entitlement type. Create a License Key entitlement once with the activation limit, expiry, and instructions you want, attach it to any product, and Dodo Payments generates and delivers a key per purchase or subscription seat, automatically.

What are License Keys?

License keys are unique tokens that authorize access to your product. They’re ideal for:
  • Software licensing: Desktop apps, plugins, and CLIs
  • Per-seat controls: Limit activations per user or device
  • Digital goods: Gate downloads, updates, or premium features
Inside Dodo Payments, license keys are managed through the Entitlements system, meaning the lifecycle of every key (creation, expiry, revocation, regrant) is driven by the same payment and subscription events as your other deliverables.

Create a License Key Entitlement

1

Open Entitlements

Go to Entitlements in your Dodo Payments dashboard and click + to create a new entitlement.
2

Choose License Key

Select License Key as the integration. Configure how each issued key behaves:
  • Activations Limit: Maximum concurrent activations per key (e.g., 1 for single-user, 5 for team licenses, leave blank for unlimited).
  • Duration: How long the key stays valid after issuance (e.g., 30 days, 1 year). For subscription-issued keys, leave blank; keys remain valid as long as the subscription is active.
  • Activation Instructions: Customer-facing instructions emailed with the key. Examples: Paste the key in Settings → License or Run: mycli activate <key>.
License Key entitlement form with activation limit, duration, and instructions
3

Save the entitlement

Save. The entitlement is now available to attach to any product.

Attach to Products

Open a product, expand Advanced Settings → Entitlements & Credits, and select your License Key entitlement. A single product can deliver a license key alongside other entitlements (Discord access, file downloads, GitHub repo access, etc.) on the same purchase.
Product entitlements panel with License Key selected

How Keys Are Issued

Key issuance follows the standard grant lifecycle:
EventBehavior
payment.succeeded (one-time)Generate one key per quantity purchased. Key expiry honors the entitlement’s duration.
subscription.activeGenerate one key per subscription quantity (seat). Key has no expiry; validity is tied to subscription status.
subscription.renewedNo-op. Existing keys persist.
subscription.on_holdDisable the keys. They reactivate when the subscription comes off hold.
subscription.cancelled / expiredDisable the keys permanently.
subscription.plan_changedDisable the old keys; issue new ones for the new plan.
refund.succeeded (one-time)Disable the keys.
Manual revoke via API/dashboardDisable the keys with revocation_reason: manual. These are not auto-regranted on subscription renewal.
License key disabled directlyRevoke the grant with revocation_reason: license_key_disabled. Re-enabling the key re-activates the grant automatically.

Quantity behavior

  • Subscription products issue one key per seat (subscriptions.quantity).
  • One-time products issue one key per cart line item (product_cart.quantity).
  • Manual API grants issue exactly one key.

Activation, Validation, Deactivation

The activation/validation/deactivation API endpoints are public and require no API key. Use them directly from desktop software, CLIs, or browser-based clients to verify keys at runtime.
Public Endpoints: The activate, deactivate, and validate license endpoints are public and do not require an API key. Call them directly from your client applications without exposing your API credentials.

Activate a license

import DodoPayments from 'dodopayments';

// No API key needed for public license endpoints
const client = new DodoPayments();

const response = await client.licenses.activate({
  license_key: 'PRO-AAAA-BBBB-CCCC-DDDD',
  name: 'Device Name',
});

console.log(response.id);

Validate a license

const response = await client.licenses.validate({
  license_key: 'PRO-AAAA-BBBB-CCCC-DDDD',
});

console.log(response.valid);

Deactivate an activation instance

await client.licenses.deactivate({
  license_key: 'PRO-AAAA-BBBB-CCCC-DDDD',
  license_key_instance_id: 'instance_abc123',
});

Manage Keys

Open the License Key entitlement from your dashboard to see every grant (one row per customer key) with delivery date, activation count, and a revoke action. Each grant detail surfaces the underlying license key, expiry, activations used, and the activations limit. You can also list grants programmatically:
const grants = await client.entitlements.grants.list('ent_license_key_id', {
  status: 'delivered',
});

for (const grant of grants.items) {
  console.log(grant.license_key.key, grant.license_key.activations_used);
}

Import Existing License Keys via API

Already have license keys in another system? Use the Create License Key API to import them into Dodo Payments. This lets you migrate existing keys without disrupting your customers — they continue to activate, validate, and deactivate against the same key strings without re-issuance.
License keys created or updated through the API do not trigger email notifications to customers. If you need to notify customers about an imported key, handle that separately in your application.
const licenseKey = await client.licenseKeys.create({
  customer_id: 'cus_abc123',
  product_id: 'prod_456',
  key: 'YOUR-EXISTING-LICENSE-KEY',
  activations_limit: 5,
  expires_at: '2026-12-31T23:59:59Z',
});

How imported keys differ from auto-generated keys

FieldAuto-generated keyImported key
source"auto""import"
payment_idSet to the originating paymentnull (no Dodo Payments transaction)
subscription_idSet if the key was issued via a subscriptionnull unless explicitly linked
Customer email notificationSent on issuanceNot sent — handle separately
Use the source field on GET /license_keys responses to distinguish migrated inventory from organically issued keys when reconciling or auditing.
Migrating from Polar.sh or Lemon Squeezy? The dodo-migrate CLI automates bulk imports of products, customers, discounts, and license keys in a single command and maps external IDs to Dodo IDs automatically.

License Keys in Return URL

When a customer completes a purchase for a product with a License Key entitlement, the generated key is automatically appended to your return_url as a query parameter. This lets you display the key immediately on your success page without making an extra API call.
https://yoursite.com/return?payment_id=pay_xxx&status=succeeded&license_key=LK-001&email=customer%40example.com
If the purchase generates multiple keys (quantity > 1), they are comma-separated:
https://yoursite.com/return?payment_id=pay_xxx&status=succeeded&license_key=LK-001,LK-002&email=customer%40example.com
For subscriptions, subscription_id is used instead of payment_id:
https://yoursite.com/return?subscription_id=sub_xxx&status=active&license_key=LK-001&email=customer%40example.com
Parse the license_key parameter on your return page to show the key immediately, improving the post-purchase experience.

API Management

Activation, deactivation, and validation are public; no API key required.

Activate License

Create or record an activation instance for a license key.

Deactivate License

Revoke a prior activation to free up capacity.

Validate License

Check authenticity, status, and constraints before granting access.
Create, list, retrieve, and update individual license key records. Use these to import existing keys or fetch usage details.

Create License Key

Create a new license key or import an existing one.

List License Keys

Browse all keys with status and usage details.

Get License Key

Retrieve a specific key and its metadata.

Update License Key

Modify expiry, activation limits, or enable/disable a key.
Manage the License Key entitlement itself: its activation limit, duration, and instructions.

Create Entitlement

Create a License Key entitlement.

Update Entitlement

Update the entitlement’s configuration.

List Grants

List the keys issued for an entitlement.

Revoke Grant

Manually revoke a customer’s key.

Webhooks

License-key delivery and revocation fire the four entitlement_grant.* webhook events. The grant payload includes a populated license_key object with the key, expiry, activations used, and limit. The legacy license_key.* events (license_key.created) continue to fire for the underlying license-key record lifecycle; see the License Key webhook payload page.
For new integrations, listen to entitlement_grant.delivered rather than license_key.created. The entitlement event tells you delivery is complete across all integrations on the product, not just the license key.

Legacy License Keys

Products created with the older license_key_enabled flag have been automatically migrated to a License Key entitlement. The migration is transparent: existing customers’ keys continue to work unchanged, the public /licenses/activate, /licenses/validate, /licenses/deactivate endpoints continue to function, and the /license_keys/* API endpoints continue to read and write to the same key store.The standalone License Keys dashboard section remains available as a flat list of every key issued, useful for audit and search. New configuration (changing activation limits, durations, or instructions) should be done by editing the migrated License Key entitlement under Entitlements.

Best Practices

  • Keep activation limits clear: Choose sensible defaults (1 for single-user apps, 3–5 for team licenses) and document them.
  • Provide precise activation instructions: Customers paste these from their email, so exact paths and commands save support tickets.
  • Validate keys server-side: For network-connected products, validate via /licenses/validate rather than caching activation locally.
  • Use webhooks for revocation: Listen to entitlement_grant.revoked to disable in-app features immediately when a customer cancels or refunds.
  • Test with subscriptions and one-times: License key behavior differs subtly between the two, so test both before going live.
Last modified on May 14, 2026