What you can export, and from where
Lemon Squeezy’s migration guide tells every seller to export the data they will need before 31 March 2027. For license keys, the dashboard does not help. The table shows where each piece of data lives.
| Data | Where to get it | Notes |
|---|---|---|
| Orders, customers, tax | Export button on the Orders page | A CSV emailed to the store owner. No license key column. |
| License keys | GET /v1/license-keys |
Key, buyer, limit, status, expiry, order and product ids |
| Device activations | GET /v1/license-key-instances |
The instance id your app stored, a name and a date |
| Default limit and length per product | Variant objects | license_activation_limit, is_license_limit_unlimited, license_length_value, license_length_unit |
The order export lists identifier, order number, product and variant names, buyer name and email, location, card details, amounts, tax and date. That is useful for accounting and for rebuilding a customer list, and useless for keys. If you only run the order export, you have lost every key.
Set up the API key
Create an API key in your Lemon Squeezy account settings. Three details from the documentation matter here.
- Requests go to
https://api.lemonsqueezy.comover HTTPS and must sendAccept: application/vnd.api+jsonandContent-Type: application/vnd.api+json. - Authentication is a bearer token:
Authorization: Bearer {api_key}. - Keys exist in live mode and test mode, and generated keys are valid for a year. If your key is old, create a new one before you start, or the first request fails and you lose an hour looking for the cause.
Treat the key like a password. Put it in an environment variable, keep it out of the repository, and delete it in Lemon Squeezy once the export is verified. The data it reads includes your customers’ email addresses.
This API is not the License API your app calls. The License API (activate, validate, deactivate) needs no key and is limited to 60 requests per minute. The listing endpoints are part of the main JSON:API and need your account key.
How the listing endpoints behave
Lemon Squeezy’s list endpoints use page-based pagination. You ask for page[size] results, from 1 to 100 with a default of 10, and page[number] for the page. Each response carries a links.next URL while more pages exist, and a meta.page object with currentPage, lastPage, perPage and total. Follow links.next until it disappears, and compare your row count with meta.page.total at the end.
GET /v1/license-keys returns license keys ordered by id, newest first. It filters on store_id, order_id, order_item_id, product_id and status, written as ?filter[product_id]=123. Each key has these attributes you need:
key: the full key. It is a UUID such as80e15db5-c796-436b-850c-8f9c98a48abe, not the shortened form.user_nameanduser_email: the buyer.activation_limitandinstances_count: the limit and how many devices are active.status: one ofinactive,active,expiredordisabled.expires_at: an ISO 8601 date-time, ornullfor a perpetual key.created_at: when it was issued.
GET /v1/license-key-instances lists activations. Each has license_key_id, identifier, name and created_at. The identifier is the value the activate call returned as instance_id, and it is what your installed apps send in a validate request. This is the field you cannot lose.
The documentation shows a filter filter[license_key_id] for instances. Using it means one request per key, which for 5,000 keys is 5,000 requests. Listing all instances once and grouping them by license_key_id in memory needs a few dozen.
The script
This Node script (version 18 or later, no packages) reads both lists and writes a CSV to standard output. Its columns follow the layout in Clavem’s import documentation, which matches columns by name, so the order does not matter.
// node export-ls-keys.mjs > lemon-squeezy-licenses.csv
// Needs Node 18 or later. Set LS_API_KEY to a Lemon Squeezy API key (live mode for live keys).
const BASE = process.env.LS_API_BASE ?? 'https://api.lemonsqueezy.com';
const KEY = process.env.LS_API_KEY;
if (!KEY) throw new Error('Set LS_API_KEY');
const headers = {
Accept: 'application/vnd.api+json',
'Content-Type': 'application/vnd.api+json',
Authorization: `Bearer ${KEY}`,
};
async function getJson(url, attempt = 1) {
const res = await fetch(url, { headers });
if (res.status === 429 || res.status >= 500) {
if (attempt > 5) throw new Error(`Giving up on ${url}: HTTP ${res.status}`);
const wait = Number(res.headers.get('retry-after') ?? 2 ** attempt) * 1000;
await new Promise((r) => setTimeout(r, wait));
return getJson(url, attempt + 1);
}
if (!res.ok) throw new Error(`HTTP ${res.status} for ${url}`);
return res.json();
}
// Follows links.next until it is absent, as the JSON:API pagination docs describe.
async function listAll(path, filter = '') {
const rows = [];
let url = `${BASE}${path}?page[size]=100${filter}`;
let total = null;
while (url) {
const page = await getJson(url);
rows.push(...page.data);
total = page.meta?.page?.total ?? total;
url = page.links?.next ?? null;
}
if (total !== null && rows.length !== total) {
console.error(`Warning: ${path} returned ${rows.length} rows, meta.page.total says ${total}`);
}
return rows;
}
// Optional: LS_PRODUCT_ID exports one Lemon Squeezy product, so each CSV maps to one product.
const only = process.env.LS_PRODUCT_ID ? `&filter[product_id]=${process.env.LS_PRODUCT_ID}` : '';
const licenseKeys = await listAll('/v1/license-keys', only);
const instances = await listAll('/v1/license-key-instances');
// One pass over the instances, grouped by license key id.
const byKey = new Map();
for (const i of instances) {
const id = String(i.attributes.license_key_id);
if (!byKey.has(id)) byKey.set(id, []);
byKey.get(id).push(i.attributes);
}
const csv = (v) => {
const s = v === null || v === undefined ? '' : String(v);
return /[",;\t\n]/.test(s) ? `"${s.replaceAll('"', '""')}"` : s;
};
const join = (list) => list.map((s) => String(s ?? '').replaceAll('|', '/')).join('|');
console.log('key,email,name,activation_limit,status,expires_at,created_at,instance_id,instance_name,instance_created_at');
for (const k of licenseKeys) {
const a = k.attributes;
const devices = (byKey.get(k.id) ?? []).sort((x, y) => x.created_at.localeCompare(y.created_at));
if (devices.length !== a.instances_count) {
console.error(`Check ${a.key_short}: instances_count ${a.instances_count}, found ${devices.length}`);
}
console.log(
[
a.key, a.user_email, a.user_name,
a.activation_limit ?? -1, // null means no limit. An empty cell would mean "use the product's limit".
a.status, a.expires_at, a.created_at,
join(devices.map((d) => d.identifier)),
join(devices.map((d) => d.name)),
join(devices.map((d) => d.created_at)),
].map(csv).join(','),
);
}
Several devices on one key are joined with a pipe in instance_id, instance_name and instance_created_at, which is the convention the import format expects.
Edge cases that corrupt an export
| Case | What goes wrong | What the script does |
|---|---|---|
| Unlimited device limit | An empty activation_limit cell is read as “use the product’s default”, not “unlimited” |
Writes -1 when the API gives null |
| Disabled keys | The docs describe disabled as true or false, but their example shows 0 |
Uses status, which has four documented values |
| Subscription keys | The key expires when the subscription does, so expires_at may be a past date |
Exports it as is |
| Several stores or products | One CSV becomes one product in the new system | LS_PRODUCT_ID exports one product at a time |
| Test mode keys | Test mode has its own API key, so a live key does not return them | Run with a live key only, unless you need test data |
| Device names with commas, quotes or pipes | Columns shift | Quotes fields, and replaces the pipe character inside names with a slash |
instances_count differs from instances found |
A device was removed between the two requests, or a page was skipped | Prints a warning for that key |
| 429 or 5xx responses | A run stops half way and you do not notice | Retries up to five times, honouring Retry-After |
On unlimited limits: the key object’s documentation says only “the activation limit of this license key”. Variants carry a separate is_license_limit_unlimited flag. Open one key you know is unlimited and look at what the API returns before you trust the mapping. The script treats null as unlimited because the License API response shape does the same.
The documentation pages used here do not state a rate limit for the main API. Only the License API’s 60 requests per minute is documented. That is why the script backs off on 429 and keeps pages at 100 rows.
Check the file before you rely on it
- Count. Rows in the CSV should equal
meta.page.totalfor license keys, and the script warns if they do not. - Spot check. Pick five keys: a perpetual one, a subscription one, an expired one, a disabled one and one with two devices. Compare each with the dashboard.
- Keep the original. Store the CSV where you store backups, with the same care as a customer database. It contains email addresses.
- Re-run later. Keys sold between the export and the cut-over need a second pass. A good importer skips keys it already has, and Clavem’s does.
Doing this with Clavem
Clavem’s importer reads the same data without a script. In the dashboard, open Import, choose Lemon Squeezy and paste an API key. Clavem reads your stores, products, keys and activations page by page and uses the key for that run only. The other route is the CSV above through the file import, which needs no Lemon Squeezy key. Rows that cannot be read are listed with their number and the rest still import. Both routes are safe to run twice: a key already in your account is never overwritten, and it only gains devices it did not have.
Imported keys keep their string, status, limit, expiry, original issue date and device ids, and answer with Lemon Squeezy’s original store, product and order ids in meta. Expired and disabled keys do not count toward the plan limit. A batch that would pass the limit is refused whole, before anything is written. Imported licenses have no order page, so buyers get downloads through your app’s update check or your own site. Check the first page of results before you import everything. The migration guide covers the app change that comes next.
Questions
Does the Lemon Squeezy order export contain license keys?
No. The CSV that the Export button on the Orders page emails to the store owner lists order, customer, tax and payment columns. License keys are not among them, so you read them through the API.
How many license keys does the API return per request?
Up to 100. The default page size is 10, the maximum is 100, and you follow the next link in each response until it is absent.
Do I need the device activations as well as the keys?
Yes, if you want customers' installed apps to keep working without asking them to reactivate. An app stores the instance id it received at activation, and that id has to survive the move.
Sources
- Lemon Squeezy API requests, authentication and pagination (as of November 2026)
- Lemon Squeezy license key object (as of November 2026)
- Lemon Squeezy list all license keys (as of November 2026)
- Lemon Squeezy list all license key instances (as of November 2026)
- Lemon Squeezy exporting orders (as of November 2026)
- Lemon Squeezy License API, rate limits and statuses (as of November 2026)