License Keys

In Lemon Squeezy, a license key can be used to externally verify that customer has access to a product.

A license key belongs to a Store and is associated with an Order, an Order Item, a Product and can have many License Key Instances.

Note, if you're looking to integrate license keys into your application (e.g. activate/validate/deactivate license keys), see our separate license API documentation.


The license key object

Attributes


store_id

The ID of the store this license key belongs to.


customer_id

The ID of the customer this license key belongs to.


order_id

The ID of the order associated with this license key.


order_item_id

The ID of the order item associated with this license key.


product_id

The ID of the product associated with this license key.


user_name

The full name of the customer.


user_email

The email address of the customer.


key

The full license key.


key_short

A “short” representation of the license key, made up of the string “XXXX-” followed by the last 12 characters of the license key.


activation_limit

The activation limit of this license key.


instances_count

A count of the number of instances this license key has been activated on.


disabled

Has the value true if this license key has been disabled.


status

The status of the license key. One of

  • inactive
  • active
  • expired
  • disabled

status_formatted

The formatted status of the license key.


expires_at

An ISO 8601 formatted date-time string indicating when the license key expires. Can be null if the license key is perpetual.


created_at

An ISO 8601 formatted date-time string indicating when the object was created.


updated_at

An ISO 8601 formatted date-time string indicating when the object was last updated.

License key object

{ "type": "license-keys", "id": "1", "attributes": { "store_id": 1, "customer_id": 1, "order_id": 1, "order_item_id": 1, "product_id": 1, "user_name": "Darlene Daugherty", "user_email": "[email protected]", "key": "80e15db5-c796-436b-850c-8f9c98a48abe", "key_short": "XXXX-8f9c98a48abe", "activation_limit": 5, "instances_count": 0, "disabled": 0, "status": "inactive", "status_formatted": "Inactive", "expires_at": null, "created_at": "2021-05-24T14:15:07.000000Z", "updated_at": "2021-05-24T14:15:07.000000Z" }, }

Retrieve a license key

Retrieves the license key with the given ID.

GET /v1/license-keys/:id

curl "https://api.lemonsqueezy.com/v1/license-keys/1" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

Returns

Returns a license key object.

Response

{ "jsonapi": { "version": "1.0" }, "links": { "self": "https://api.lemonsqueezy.com/v1/license-keys/1" }, "data": { "type": "license-keys", "id": "1", "attributes": { "store_id": 1, "customer_id": 1, "order_id": 1, "order_item_id": 1, "product_id": 1, "user_name": "Darlene Daugherty", "user_email": "[email protected]", "key": "80e15db5-c796-436b-850c-8f9c98a48abe", "key_short": "XXXX-8f9c98a48abe", "activation_limit": 5, "instances_count": 0, "disabled": 0, "status": "inactive", "status_formatted": "Inactive", "expires_at": null, "created_at": "2021-05-24T14:15:07.000000Z", "updated_at": "2021-05-24T14:15:07.000000Z" }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/store", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/store" } }, "customer": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/customer", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/customer" } }, "order": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/order", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/order" } }, "order-item": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/order-item", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/order-item" } }, "product": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/product", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/product" } }, "license-key-instances": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/license-key-instances", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/license-key-instances" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/license-keys/1" } } }

Update a license key

Update a license key with the given ID.


activation_limit

The activation limit of this license key. Assign null to set the activation limit to "unlimited".

expires_at

An ISO 8601 formatted date-time string indicating when the license key expires. Can be null if the license key is perpetual.

disabled

If true, the license key will have "disabled" status.

PATCH /v1/license-keys/:id

curl "https://api.lemonsqueezy.com/v1/license-keys/1" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}' -d $'{ "data": { "type": "license-keys", "id": "1", "attributes": { "activation_limit": 5, "expires_at": "2024-04-20T10:30:00Z", "disabled": false } } }'

Returns

Returns a license key object.

Response

{ "jsonapi": { "version": "1.0" }, "links": { "self": "https://api.lemonsqueezy.com/v1/license-keys/1" }, "data": { "type": "license-keys", "id": "1", "attributes": { "store_id": 1, "customer_id": 1, "order_id": 1, "order_item_id": 1, "product_id": 1, "user_name": "Darlene Daugherty", "user_email": "[email protected]", "key": "80e15db5-c796-436b-850c-8f9c98a48abe", "key_short": "XXXX-8f9c98a48abe", "activation_limit": 5, "instances_count": 0, "disabled": false, "status": "inactive", "status_formatted": "Inactive", "expires_at": null, "created_at": "2021-05-24T14:15:07.000000Z", "updated_at": "2021-05-24T14:15:07.000000Z" }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/store", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/store" } }, "customer": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/customer", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/customer" } }, "order": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/order", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/order" } }, "order-item": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/order-item", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/order-item" } }, "product": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/product", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/product" } }, "license-key-instances": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/license-key-instances", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/license-key-instances" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/license-keys/1" } } }

List all license keys

Returns a paginated list of license keys.

Parameters


store_id

Only return license keys belonging to the store with this ID.


order_id

Only return license keys belonging to the order with this ID.


order_item_id

Only return license keys belonging to the order item with this ID.


product_id

Only return license keys belonging to the product with this ID.


status

Only return license keys with this status.

GET /v1/license-keys

curl "https://api.lemonsqueezy.com/v1/license-keys" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'
curl "https://api.lemonsqueezy.com/v1/license-keys?filter[order_id]=42" -H 'Accept: application/vnd.api+json' -H 'Content-Type: application/vnd.api+json' -H 'Authorization: Bearer {api_key}'

Returns

Returns a paginated list of license key objects ordered by id.

Response

{ "meta": { "page": { "currentPage": 1, "from": 1, "lastPage": 1, "perPage": 10, "to": 10, "total": 10 } }, "jsonapi": { "version": "1.0" }, "links": { "first": "https://api.lemonsqueezy.com/v1/license-keys?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=id", "last": "https://api.lemonsqueezy.com/v1/license-keys?page%5Bnumber%5D=1&page%5Bsize%5D=10&sort=id" }, "data": [ { "type": "license-keys", "id": "1", "attributes": { "store_id": 1, "customer_id": 1, "order_id": 1, "order_item_id": 1, "product_id": 1, "user_name": "Darlene Daugherty", "user_email": "[email protected]", "key": "80e15db5-c796-436b-850c-8f9c98a48abe", "key_short": "XXXX-8f9c98a48abe", "activation_limit": 5, "instances_count": 0, "disabled": 0, "status": "inactive", "status_formatted": "Inactive", "expires_at": null, "created_at": "2021-05-24T14:15:07.000000Z", "updated_at": "2021-05-24T14:15:07.000000Z" }, "relationships": { "store": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/store", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/store" } }, "customer": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/customer", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/customer" } }, "order": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/order", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/order" } }, "order-item": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/order-item", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/order-item" } }, "product": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/product", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/product" } }, "license-key-instances": { "links": { "related": "https://api.lemonsqueezy.com/v1/license-keys/1/license-key-instances", "self": "https://api.lemonsqueezy.com/v1/license-keys/1/relationships/license-key-instances" } } }, "links": { "self": "https://api.lemonsqueezy.com/v1/license-keys/1" } }, {...}, {...}, ] }