Serial keys & redemption codes: list, generate, import/export, assign, redeem, revoke and delete.
Namespacewp ias serial-keys
Slugias-serial-keys
Version 1.1.15
Tier Commercial (licence required)
Commands 13
Conventions on this page
Every command accepts --format=<json|table|csv|yaml>. Commands marked Write accept --dry-run (resolve, audit, write nothing) and --yes (skip the prompt). Commands marked Irreversible additionally prompt unless --yes is passed, and any bulk delete refuses to run without an explicit scope argument rather than defaulting to delete-all.
The serial-key schema binds a customer to a key through a WooCommerce order, so this creates a $0 order for the customer, binds the named key to it via IAS\SerialKeys\Database::assign_key(), and completes the order (mirroring the redemption fulfillment path). Completing the order fires the normal fulfillment hooks (key-delivery email, and licence/ownership grants if the product is otherwise configured).
Options
Argument
Required
Type
Description
<key>
yes
positional
The serial key string (must currently be in the available pool).
<customer>
yes
positional
Customer reference — numeric WP user ID or email.
[--dry-run]
no
flag
Report what would happen without creating an order or assigning the key.
This command permanently destroys data or applies a terminal state that cannot be undone from the CLI. Preview the exact effect with --dry-run, then re-run with --yes once you are certain.
Resolves the key via IAS\SerialKeys\Database::get_key_by_serial() and removes the row with IAS\SerialKeys\Database::delete_key(). This is NON-RECOVERABLE: the key string and any pool/assignment record for it are gone. Use revoke instead if you want to retire a key while keeping the row for audit/history.
Note on --keep-audit: serial keys keep NO per-key history table, so this flag has no database effect — there is no per-key log to retain. It is accepted for cross-plugin CLI parity and recorded in the audit context for transparency.
Options
Argument
Required
Type
Description
<key>
yes
positional
The serial key string to delete.
[--keep-audit]
no
flag
No-op for serial keys (there is no per-key log to retain); recorded for cross-plugin CLI parity only.
[--dry-run]
no
flag
Report what would be deleted without removing anything.
This command permanently destroys data or applies a terminal state that cannot be undone from the CLI. Preview the exact effect with --dry-run, then re-run with --yes once you are certain.
Permanently delete every serial key matching a JSON filter (bulk, destructive).
This is a bulk destructive operation and therefore REQUIRES an explicit --filter=<json> selector; it refuses to run without one and has no --all escape hatch. The filter is resolved with IAS\SerialKeys\Database::get_keys() and each matched row is removed with IAS\SerialKeys\Database::delete_key(). NON-RECOVERABLE.
A single run processes at most 1000 keys. The true (uncapped) match count is reported as total_matching and, when it exceeds the per-run cap, capped is true and a warning is emitted — re-run the command after each batch to delete the remainder.
Options
Argument
Required
Type
Description
--filter=<json>
yes
flag (value)
Required JSON selector. Recognised keys: product_id (int), status (available|sold|revoked), search (substring of the key). Must select at least one constraint.
[--dry-run]
no
flag
Report how many keys match without deleting anything.
Reads keys via IAS\SerialKeys\Database::get_keys() (optionally filtered) and writes them to <path>. This mutates the filesystem (not the database) but is audited so exports are traceable. Honours the licensed ias_sk_can_export gate for the actual write. CSV cells are neutralised against spreadsheet formula injection, matching the admin export.
NOTE: unlike every other command, export --format selects the on-disk FILE format (csv|json) — not the suite-wide --format=<json|table|csv|yaml> output-rendering flag. The dry-run summary is always emitted as JSON.
Options
Argument
Required
Type
Description
--file=<path>
yes
flag (value)
Destination file path.
[--format=<format>]
no
flag (value)
Export FILE format (csv or json) — see the note above; this overloads the conventional output-format flag.
[--product=<product>]
no
flag (value)
Restrict to one product (numeric ID or SKU).
[--status=<status>]
no
flag (value)
Restrict to keys with this status (available or sold).
[--dry-run]
no
flag
Report how many keys would be exported without writing the file.
Mirrors the admin Generate screen: delegates to IAS\SerialKeys\Key_Generator::generate_keys(), which enforces the licensed batch ceiling (ias_sk_max_batch_size), pattern/prefix formatting and uniqueness. Keys land in the unassigned pool. With --customer the freshly generated keys are then assigned to that customer via a $0 order (mirroring the redemption fulfillment path).
Options
Argument
Required
Type
Description
<product>
yes
positional
Product reference — numeric ID or SKU.
<quantity>
yes
positional
Number of keys to generate.
[--customer=<customer>]
no
flag (value)
Assign the generated keys to this customer (numeric WP user ID or email).
[--prefix=<text>]
no
flag (value)
Override the key prefix for this batch.
[--dry-run]
no
flag
Validate and report what would be generated without writing anything.
Additive importer: delegates to IAS\SerialKeys\Database::import_keys(), which inserts new keys and skips any that already exist. The underlying importer is insert-only — there is no in-place update path — so --update-existing only affects how pre-existing keys are reported, not stored (existing keys are always skipped). Honours the licensed ias_sk_can_import gate for the actual write; the dry-run preview is always available.
Options
Argument
Required
Type
Description
--product=<product>
yes
flag (value)
Product the keys belong to (numeric ID or SKU).
--file=<path>
yes
flag (value)
Path to the import file (one key per line; first CSV column is used).
[--update-existing]
no
flag
Reserved. The importer is insert-only, so existing keys are still skipped; this flag is recorded for traceability only.
[--dry-run]
no
flag
Parse and classify each row (new vs already-present) without importing.
Delegates to IAS\SerialKeys\Database::redeem_code(), the exact two-phase atomic path the storefront uses: it claims the code, creates a $0 order, assigns a key, and completes the order.
Options
Argument
Required
Type
Description
<code>
yes
positional
The redemption code.
[--customer=<customer>]
no
flag (value)
Redeem on behalf of this account (numeric WP user ID or email). Omit to redeem as a guest, in which case --email is required.
[--email=<email>]
no
flag (value)
Guest email for the redemption when no --customer account is given.
This command permanently destroys data or applies a terminal state that cannot be undone from the CLI. Preview the exact effect with --dry-run, then re-run with --yes once you are certain.
Retire a serial key by setting a terminal revoked status.
Serial keys natively use only the available and sold statuses, and there is no public status setter, so this updates the row directly to a terminal revoked status. A revoked key is neither resold (the available pool query filters status='available') nor validated as sold, but the row is preserved (unlike delete). The product's available-pool cache is invalidated so the change takes effect immediately.
Options
Argument
Required
Type
Description
<key>
yes
positional
The serial key string to revoke.
[--reason=<text>]
no
flag (value)
Optional free-text reason, recorded in the audit context.
[--dry-run]
no
flag
Report what would be revoked without changing anything.
[--yes]
no
flag
Skip the confirmation prompt.
[--format=<format>]
no
flag (value)
Output format.
Returns
A JSON object: { dry_run, action, key, product_id, status_before, status_after, reason, revoked, already_applied }. already_applied is true when the key was already revoked (a no-op re-run); revoked is then false.