Software License Keys

⚠️ This article is about our newest version of the license key system which does not require an API key. Instead it uses a product secret key which is unique to each product. It's a good solution for public applications where you shouldn't expose your API key to everyone. Read this article to learn about our legacy license key system.

Selling license keys is very easy using Payhip.

You simply setup a digital product as usual, then scroll down to the advanced options section. Finally check the "Generate unique license keys for each sale" checkbox.

License key enforcement is completely up to you. As the seller, you can decide how many uses each key gets. We have two simple API calls for you to achieve this.

License Key Verification

To verify a license key in your application simply call the verify API method.

Example Request

curl "https://payhip.com/api/v2/license/verify?license_key=WTKP4-66NL5-HMKQW-GFSCZ" -X GET --header "product-secret-key: YOUR_PRODUCT_SECRET_KEY_HERE"

Example Response

{
 "data": {
 "enabled": true,
 "product_link": "mVT0",
 "license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
 "buyer_email": "contact@payhip.com",
 "uses": 0,
 "date": "2024-02-22T11:23:05+00:00"
 }
}

If verification fails, you will receive an empty response.

Enable or Disable a License Key

To enable a license key you can use the endpoint "license/enable" or to disable, use the endpoint "license/disable". You might want to disable a license key if a customer breaks your terms of service for example. We automatically disable the license key if the transaction has been refunded.

Example Request

curl https://payhip.com/api/v2/license/disable -d "license_key=WTKP4-66NL5-HMKQW-GFSCZ" -X PUT --header "product-secret-key: YOUR_PRODUCT_SECRET_KEY_HERE"

Example Response

{
 "data": {
 "enabled": false,
 "product_link": "mVT0",
 "license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
 "buyer_email": "contact@payhip.com",
 "uses": 1,
 "date": "2024-02-22T11:23:05+00:00"
 }
}

License Key Usage

To increase the license keys usage, simply call the usage endpoint

Example Increase License Request

curl https://payhip.com/api/v2/license/usage -d "license_key=WTKP4-66NL5-HMKQW-GFSCZ" -X PUT --header "product-secret-key: YOUR_PRODUCT_SECRET_KEY_HERE"

Example Increase License Response

{
 "data": {
 "enabled": true,
 "product_link": "mVT0",
 "license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
 "buyer_email": "contact@payhip.com",
 "uses": 1,
 "date": "2024-02-22T11:23:05+00:00"
 }
}

To decrease the license keys usage, simply call the usage endpoint

Example Decrease License Request

curl https://payhip.com/api/v2/license/decrease -d "license_key=WTKP4-66NL5-HMKQW-GFSCZ" -X PUT --header "product-secret-key: YOUR_PRODUCT_SECRET_KEY_HERE"

Example Decrease License Response

{  
 "data": {  
 "enabled": true,  
 "product_link": "mVT0",  
 "license_key": "WTKP4-66NL5-HMKQW-GFSCZ",  
 "buyer_email": "contact@payhip.com",  
 "uses": 0,  
 "date": "2024-02-22T11:23:05+00:00"  
 } 
}

If usage update fails, you will receive an empty response.

Key note

1) To find your product secret key, visit your edit product page, scroll down to the checkbox where you've enabled licenses and it will be listed there.

2) Most developers will be sending API requests to us from a secure sever that only they have access to. However if you're making license key API requests from an application which is publicly accessible, or easy to decompile then you'll need to protect your product secret key from being exposed. Please email contact@payhip.com and we'll be able to share an alternative integration for these cases.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.