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

# Import Existing License Keys

> Move to AuthForge from another licensing service without reissuing keys: import your customers' keys from CSV, with expiry, seats, status and variables.

If you already have customers on another licensing service, or on a system you built yourself, you can bring their license keys into an AuthForge app as they are. Each customer keeps the key they have; your app starts checking it with the AuthForge SDK.

The import is free and open to every account. It reads a CSV file, checks it first, shows you what would happen, and only then writes.

Coming from Lemon Squeezy, which stops processing payments on March 31, 2027? [Migrate from Lemon Squeezy](https://docs.authforge.cc/guides/migrate-from-lemon-squeezy.md) maps its license key fields to the file described here.

## Before you start

* Export your keys from the old system as CSV. A spreadsheet saved as CSV works.
* Create the app in AuthForge that the keys belong to.
* Ship a build of your software that uses the [AuthForge SDK](https://docs.authforge.cc/sdk/overview.md). An imported key works the moment the import finishes, but only in a build that asks AuthForge.

## The file

The first line names the columns. Only `key` is required; leave out the columns you do not need.

```csv theme={null}
key,email,label,expires,seats,hwids,status,var.tier,var.maxUsers:number
ACME-7F3K-99QX,alice@example.com,Pro plan,2027-12-31,1,,active,pro,5
ACME-2B8D-41LM,,,,3,,revoked,basic,
ACME-TEAM-0001,team@example.com,Site license,,unlimited,,,,
```

| Column | Also accepted as | What it holds | |
| - | - | - | - |
| `key` | `license`, `license key`, `serial`, `serial key`, `product key` | The license key, exactly as the customer has it. Required. | |
| `email` | `customer email`, `email address` | The customer's email address. It lets them sign in to the [self-service portal](https://docs.authforge.cc/features/portal.md). Nothing is sent to it. | |
| `label` | `note` | A note of up to 128 characters. Not private: your app receives it as `licenseLabel` and the customer sees it in the portal. | |
| `expires` | `expires at`, `expiry`, `expiry date`, `expiration`, `expiration date`, `valid until` | When the license ends. Empty means it never expires. | |
| `seats` | `max hwid slots`, `hwid slots`, `max devices`, `device limit` | How many devices may use the key: `1` to `16`, or `unlimited` for a [shared key](https://docs.authforge.cc/features/unlimited-seats.md). Empty means 1. | |
| `hwids` | `hwid`, `hwid list` | Device IDs already bound to the key, separated by \` | `or`;\`. See [Device bindings](#device-bindings). |
| `status` | `state`, `license status` | `active` or `revoked`. Empty means active. See [Status](#status). | |
| `var.<name>` | none | One column for each [license variable](https://docs.authforge.cc/features/variables.md), for example `var.tier`. See [License variables](#license-variables). | |
| `variables` | none | All of a license's variables as one JSON object, the way the dashboard's **Download CSV** writes them. See [License variables](#license-variables). | |

Column names are matched without regard to upper and lower case, spaces or punctuation, so `License Key`, `license_key` and `licensekey` are the same column. The exception is the part of a `var.` column after the dot, which is the variable's name and is used exactly as written. Columns that match nothing are ignored, and the result tells you which ones.

The dashboard's own **Download CSV** file has these columns, so it can be imported as it is. Its `Created At` column is not read: an imported license is created at the moment of the import.

The file can be comma, semicolon or tab separated; the import uses whichever the first line uses most. Quoted fields follow the usual CSV rules (`"Smith, Bob"`, and `""` for a quote inside quotes).

### Key rules

* 8 to 64 characters.
* Letters, digits, hyphens, underscores and dots. The first character is a letter or a digit.
* Kept exactly as written. Keys are case-sensitive: `abcd-1234` and `ABCD-1234` are two different keys, and your customers must enter theirs the way it was imported.

A key that does not fit these rules is rejected, and that customer needs a new key. Signed keys that carry their own data (hundreds of characters, with `/`, `+` or `=`) cannot be imported.

### Dates

`expires` accepts:

* a date: `2027-12-31` (midnight UTC at the start of that day)
* a date and time: `2027-12-31T23:59:59Z`, with or without an offset; without one it is read as UTC
* Unix time: `1830297599` (seconds) or `1830297599000` (milliseconds)

Anything else, such as `31/12/2027` or `never`, is rejected rather than guessed at. A date in the past is imported as it is, and the license is expired from the start; the result marks those lines.

### Status

A key that was switched off in your old system can be imported switched off, so your app is told `revoked` for it and not `invalid_key`.

| In the `status` column | The license is imported |
| - | - |
| empty, `active`, `enabled`, `valid` | active |
| `revoked`, `disabled`, `suspended`, `banned`, `blocked` | revoked. It does not validate until you reactivate it, in the dashboard or with the [Developer API](https://docs.authforge.cc/api/licenses.md#re-activate-a-revoked-license) |
| `expired` | active, with the past date from `expires`, which is what makes it expired. Accepted only when `expires` holds a date in the past |
| anything else | not at all: the line is rejected |

Upper and lower case do not matter. The check report says how many keys will come in revoked before anything is written.

A word the import does not know is never guessed at. `inactive` is the usual case: Lemon Squeezy uses it for a valid key that has no activations yet, and another system may use it for a key that was switched off. Guessing wrong would either let a banned key in or lock a paying customer out, so change the word to `active` or `revoked` yourself.

AuthForge has no stored "expired" status: a license is expired when its expiry date has passed. That is why `expired` needs the date, and why a line that says `expired` with no date or a future date is rejected.

### License variables

A column named `var.` followed by a variable's name sets that [license variable](https://docs.authforge.cc/features/variables.md) on each license: `var.tier` sets `tier`. Your app receives it as part of `licenseVariables`, like a variable set in the dashboard.

* **A cell is kept as text**, whatever it looks like. `007`, `1.10` and `true` are imported as the strings `"007"`, `"1.10"` and `"true"`. This is also what the dashboard stores when you type a variable in by hand.
* **For a number or a true/false value, say so in the column name**: `var.maxUsers:number` or `var.beta:boolean`. The type is never worked out from the cells, so one odd cell cannot change the type of a whole column.
  * A `:number` cell is a decimal number such as `5`, `-2` or `2.5`. A whole number too large to be stored exactly (above 9,007,199,254,740,991) is rejected; import it as text.
  * A `:boolean` cell is `true`, `false`, `yes`, `no`, `1` or `0`.
  * A cell that does not fit rejects its line, and the message names the column.
* **An empty cell leaves that variable unset** on that license. Other licenses in the file can still have it.
* **The name is used exactly as written**, upper and lower case included: `var.Tier` and `var.tier` are two variables. Spaces around it are dropped.
* **The usual limits apply to each license**: a name of at most 64 characters, at most 50 variables, and at most 4,096 bytes for all of a license's variables together. A line over a limit is rejected.

A column named `variables` is read as well. It holds all of a license's variables as one JSON object, `{"tier":"pro","maxUsers":5}`, with the types JSON gives them. If a line has both, a `var.` column wins over the same name in the JSON.

Two columns that would set the same variable (`var.tier` and `var.tier:number`) stop the whole file, as two `key` columns would.

## What happens to each line

Every line of the file ends up as one of these:

| Result | When |
| - | - |
| **Imported** | The key did not exist. A new license is created with the fields from the line: active, or revoked if its `status` says so. |
| **Skipped** | The app already has this key. The existing license is left exactly as it is; the line's other columns are not applied to it. |
| **Cannot be imported** | The key breaks a key rule, a field is invalid, the same key appears earlier in the file (the first one is used), or the key already exists on AuthForge outside this app. |
| **Not written** | Rare. The line was fine but could not be saved in time. Import the same file again. |

A line with any invalid field is rejected whole; nothing is imported half-filled. An import never changes or overwrites a license that already exists.

> [!NOTE]
>
> License keys are unique across all of AuthForge, not per app. A long random key will never collide. A short or sequential one (`00000042`) may already be taken by someone else, and then it cannot be imported. If you have two apps of your own, a key can live in only one of them.

Importing the same file twice is safe: everything the first run created is skipped by the second.

## Import from the dashboard

1. Open the app and choose **Import Keys** above the license list.
2. Choose your CSV file and select **Check file**. Nothing is written yet.
3. Read the report: how many keys will be imported, how many of those as revoked, which license variables were read, how many keys are already in the app, how many cannot be imported and why. **Download this report** gives you one line for every line of your file.
4. Fix the file if you need to and check it again, or select **Import N licenses**.
5. **Download the result** for your records.

## Remove an import

If you imported the wrong file, you do not have to delete its licenses page by page.

1. Open the app and choose **Import Keys**.
2. Under **Earlier imports**, find the import by its date and number of licenses and choose **Remove**. Straight after an import, **Remove this import** on the result screen does the same.
3. Read the confirmation and choose **Delete N licenses**.

Removing an import deletes every license that import created and that is still in the app, including ones that have been used since (the confirmation tells you how many have a device bound). Licenses you generated, and licenses from other imports, are not touched. The keys are free again afterwards, so you can import a corrected file.

Like the import itself, a removal sends no email and fires no webhook (`license.deleted` does not fire). Licenses the removal deleted still count toward that day's import limit.

## Limits

These are the same for every account, free or paying:

* 5,000 rows and 2 MB per file. Split a larger list into several files.
* 50,000 imported licenses per account per day (UTC). This is separate from the daily limit on generated licenses.
* 10 import requests per account per minute, checks and removals included.

A file that would go over the daily limit is refused as a whole, and the check tells you so beforehand.

## What an import does not do

* **No emails.** Nothing is sent to your customers or to you. They already have their key.
* **No webhooks.** `license.created` does not fire for imported licenses, and `license.revoked` does not fire for one that is imported revoked.
* **No creation dates.** An imported license is created at the moment of the import, whatever the old system recorded.
* **No changes to licenses you already have.** A line whose key is already in the app is skipped whole, its status and variables included. To change existing licenses, use [bulk actions](#change-many-licenses-at-once) or the API.
* **No link to a payment provider.** [Commerce](https://docs.authforge.cc/features/commerce.md) never changes an imported license: a Stripe or Lemon Squeezy renewal, refund, chargeback or add-on purchase does not extend or revoke it, even when its email is the buyer's. Extend or revoke imported licenses yourself.
* **No credits.** Importing is free. A license costs a credit when it is validated, like any other.

## Change many licenses at once

After a migration you often need to act on thousands of licenses: revoke a batch that was refunded, extend everyone by a month, set a variable on a whole product line. The license list on the app page does that for every license that matches its search and status filter, not only for the 25 on the page.

1. Narrow the list with the search box and the **Status** filter, or leave both empty for every license in the app.
2. Tick the box in the table's header. That selects the page.
3. Choose **Select all N licenses that match the search and filter** in the bar that appears.
4. Choose the action: **Revoke**, **Reactivate**, **Extend 30d**, **Reset HWID**, **Delete** or **Set Variables**.
5. Read the confirmation. It says how many licenses, which ones (the filter and search in words), and how many of them have a device bound. For more than 100 licenses you confirm by typing the number.

The work is done from your browser, 100 licenses at a time, at up to 9,000 licenses a minute: 5,000 licenses take under a minute, 50,000 about six. Keep the tab open until it finishes. **Stop** ends it after the request that is under way.

* **Nothing is rolled back.** If part of a run fails, or you stop it, what was done stays done. The licenses that were not done stay selected, so choosing the action again retries exactly those. **Download the list** gives you each of them with the reason.
* **Each license has its own result.** A license that was deleted in the meantime, or that the server refused, is counted and listed while the run goes on with the rest.
* **Extend is never repeated blindly.** If a request to extend gets no answer, those licenses may or may not have their 30 days. They are listed as not confirmed and are not selected for a retry, because a second attempt could add the days twice.
* **Webhooks fire for every license**, as they do for a single one: `license.revoked`, `license.activated`, `license.deleted` and `license.hwid_reset`. Revoking 5,000 licenses sends 5,000 events to each webhook that listens for them, and the confirmation says so. Extending and setting variables send none.
* **Changing the search or the filter drops a selection of "everything that matches"**, so you never act on licenses the list is no longer showing.

To undo a whole import, [remove the import](#remove-an-import) instead: it sends no webhooks and does not need the licenses selected.

## Device bindings

Most migrations should leave `hwids` empty. The first time a customer runs your new build, the SDK binds their device to the key, as it does for a new license.

That works because an AuthForge device ID is computed by the AuthForge SDK (see [HWID locking](https://docs.authforge.cc/features/hwid-locking.md)); the IDs stored in your old system were computed differently and will not match. Import `hwids` only if your app sends its own identifier through the SDK's [HWID override](https://docs.authforge.cc/features/hwid-override.md), for example an account ID, and the file holds those same identifiers. A line may list at most as many device IDs as it has seats.

If you are worried about a key being shared during the changeover, import it with the right number of seats and no bindings: the first devices to run the new build take the seats, and you can [reset](https://docs.authforge.cc/api/licenses.md#reset-hwid-bindings) a key that was claimed by the wrong device.

## Import with the Developer API

`POST /v1/licenses/import` runs the same import from a script. See the [Licenses API reference](https://docs.authforge.cc/api/licenses.md#import-licenses).

```bash theme={null}
jq -Rs '{appId: "YOUR_APP_ID", csv: ., dryRun: true}' keys.csv | \
  curl -X POST https://api.authforge.cc/v1/licenses/import \
  -H "Authorization: Bearer af_live_your_key" \
  -H "Content-Type: application/json" \
  -d @-
```

Send `dryRun: true` first, read the report, then send the same body with `dryRun: false`. The answer to a real run carries an `importId`; `POST /v1/licenses/import/remove` with that id deletes what the import created.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.