---
url: https://docs.sunlicense.com/integrations/lemon-squeezy.md
---
# Lemon Squeezy

Lemon Squeezy can generate license keys and email them to buyers. SunLicense mirrors each key, so the key
in the receipt validates with SunLicense, with your policy's machine limit.

## Setup

1. Lemon Squeezy: enable **license keys** for the product.
2. SunLicense: **Integrations → Lemon Squeezy → Connect**. Map **product or variant IDs** to policies, or
   `*`. SunLicense creates a signing secret.
3. Lemon Squeezy **Settings → Webhooks → +**: callback URL = the hook URL, signing secret = the one on the
   integration page, events `order_created`, `order_refunded`, `license_key_created`,
   `license_key_updated`, `subscription_expired`, `subscription_resumed`.

Test mode works the same way.

## Behaviour

| Event | With "Use Lemon Squeezy's license key" (default) | Turned off |
|---|---|---|
| `license_key_created` | Creates the license with that key | Ignored |
| `order_created` (paid) | Ignored (the key event follows) | Creates a license with a SunLicense key |
| `order_refunded` | Revokes | Revokes |
| `subscription_expired`, `license_key_updated` (disabled/expired) | Suspends | Suspends |
| `subscription_resumed` | Reinstates | Reinstates |

Every request's `X-Signature` (HMAC-SHA256 of the body with the signing secret) is checked.
