Validate a License Key

POST

/v1/licenses/validate

Checks if a license key is valid and returns information about the license key and its associated instance.


Parameters

license_key Required

The license key to validate.

instance_id

If included, validate a license key instance, otherwise validate a license key. If no instance_id is provided, the response will contain "instance": null.


curl -X POST https://api.lemonsqueezy.com/v1/licenses/validate \
  -H "Accept: application/json" \
  -d "license_key=38b1460a-5104-4067-a91d-77b872934d51" \
  -d "instance_id=f90ec370-fd83-46a5-8bbd-44a241e78665"

Returns

valid

A boolean indicating whether the license was successfully validated.

error

An error message if the license could not be validated. This will be null if the license was validated successfully.

license_key

The information about the license that was deactivated.

instance

The information about the license key instance that was validated. If no instance_id was provided, this will be null.

meta

Additional information about the license key, including the order, product, variant, and customer information.


ID fields in the meta object can be used to fetch data related to the license key, such as relevant order/product information, from the Lemon Squeezy API. The meta object also contains convenience information from the license key, including product and variant names, and the customer’s name and email address.

{
  "valid": true,
  "error": null,
  "license_key": {
    "id": 1,
    "status": "active",
    "key": "38b1460a-5104-4067-a91d-77b872934d51",
    "activation_limit": 1,
    "activation_usage": 5,
    "created_at": "2021-01-24T14:15:07.000000Z",
    "expires_at": "2022-01-24T14:15:07.000000Z"
  },
  "instance": {
    "id": "f90ec370-fd83-46a5-8bbd-44a241e78665",
    "name": "Test",
    "created_at": "2021-02-24T14:15:07.000000Z"
  },
  "meta": {
    "store_id": 1,
    "order_id": 2,
    "order_item_id": 3,
    "product_id": 4,
    "product_name": "Lemonade",
    "variant_id": 5,
    "variant_name": "Citrus Blast",
    "customer_id": 6,
    "customer_name": "John Doe",
    "customer_email": "[email protected]"
  }
}

Was this page helpful?