Skip to main content

Overview

License keys are automatically generated and granted to customers who purchase products with license key benefits. They support activation limits and expiration.

The License Key Object

id
string
required
Unique identifier
key
string
required
The license key string
status
enum
required
Status: granted, revoked, or disabled
customer_id
string
required
Customer who owns the key
user_id
string
Associated user ID
benefit_id
string
required
Benefit that granted this key
organization_id
string
required
Organization ID
expires_at
string
Expiration timestamp
limit_activations
integer
Maximum number of activations allowed
usage
integer
required
Current number of activations
limit_usage
boolean
required
Whether usage is limited
created_at
string
required
Creation timestamp

List License Keys

cURL
curl -X GET "https://api.polar.sh/v1/license-keys" \
  -H "Authorization: Bearer polar_pat_..."

Query Parameters

organization_id
string
Filter by organization
benefit_id
string
Filter by benefit

Get License Key

cURL
curl -X GET "https://api.polar.sh/v1/license-keys/{id}" \
  -H "Authorization: Bearer polar_pat_..."

Path Parameters

id
string
required
License key ID

Response

Includes activations array.

Update License Key

cURL
curl -X PATCH "https://api.polar.sh/v1/license-keys/{id}" \
  -H "Authorization: Bearer polar_pat_..." \
  -H "Content-Type: application/json" \
  -d '{
    "status": "disabled"
  }'

Request Body

status
enum
Update status: granted, revoked, or disabled
limit_activations
integer
Update activation limit

Validate License Key

cURL
curl -X POST "https://api.polar.sh/v1/license-keys/validate" \
  -H "Authorization: Bearer polar_pat_..." \
  -H "Content-Type: application/json" \
  -d '{
    "key": "PRO-XXXX-XXXX-XXXX",
    "organization_id": "org_123"
  }'
Validate a license key and get its details.

Request Body

key
string
required
License key to validate
organization_id
string
required
Organization ID
benefit_id
string
Specific benefit to validate against

Response

Returns the license key object if valid.

Activate License Key

cURL
curl -X POST "https://api.polar.sh/v1/license-keys/activate" \
  -H "Authorization: Bearer polar_pat_..." \
  -H "Content-Type: application/json" \
  -d '{
    "key": "PRO-XXXX-XXXX-XXXX",
    "organization_id": "org_123",
    "label": "MacBook Pro"
  }'
Activate a license key on a new device/instance.

Request Body

key
string
required
License key
organization_id
string
required
Organization ID
label
string
Device/instance label
metadata
object
Activation metadata

Response

Returns activation object.

Errors

403
Forbidden
Activation limit reached or key is revoked

Deactivate License Key

cURL
curl -X POST "https://api.polar.sh/v1/license-keys/deactivate" \
  -H "Authorization: Bearer polar_pat_..." \
  -H "Content-Type: application/json" \
  -d '{
    "key": "PRO-XXXX-XXXX-XXXX",
    "organization_id": "org_123",
    "activation_id": "activation_123"
  }'

Request Body

key
string
required
License key
organization_id
string
required
Organization ID
activation_id
string
required
Activation ID to deactivate

Get Activation

cURL
curl -X GET "https://api.polar.sh/v1/license-keys/{id}/activations/{activation_id}" \
  -H "Authorization: Bearer polar_pat_..."

Path Parameters

id
string
required
License key ID
activation_id
string
required
Activation ID

Examples

Validate and Activate

# First, validate the key
curl -X POST "https://api.polar.sh/v1/license-keys/validate" \
  -H "Authorization: Bearer polar_pat_..." \
  -H "Content-Type: application/json" \
  -d '{
    "key": "PRO-1234-5678-9ABC",
    "organization_id": "org_xyz"
  }'

# Then activate it
curl -X POST "https://api.polar.sh/v1/license-keys/activate" \
  -H "Authorization: Bearer polar_pat_..." \
  -H "Content-Type: application/json" \
  -d '{
    "key": "PRO-1234-5678-9ABC",
    "organization_id": "org_xyz",
    "label": "Production Server",
    "metadata": {
      "hostname": "prod-01.example.com",
      "ip": "192.168.1.100"
    }
  }'

Disable a License Key

curl -X PATCH "https://api.polar.sh/v1/license-keys/lk_123" \
  -H "Authorization: Bearer polar_pat_..." \
  -H "Content-Type: application/json" \
  -d '{"status": "disabled"}'

Build docs developers (and LLMs) love