API Reference
The Payhip API follows RESTful principles. It uses consistent, resource-based URLs, supports form-encoded request bodies, returns responses in JSON format, and adheres to standard HTTP methods and status codes.
Use the Payhip API to create, read, and update information on your Payhip account.
At the moment we only have support for interacting with the Coupon and License Key resources, but more will be added in future.
Authentication
You'll need an API key to authenticate your requests. Please login to your account and visit your Developer Settings page to view and manage your key.
Please do ensure you keep your API key secret, treat it like just any password. If you suspect it's been exposed then you can roll your key to prevent further access.
Coupons
A coupon lets you provide a discount to customers in the form of a percentage discount (like 20% off) or fixed amount discount (like $5 off).
You can specify the end date for a coupon, the minimum purchase amount and more.
Please note coupons for subscription priced products with a recurring amount aren't possible through the API yet.
The Coupon object
Attributes
-
idUnique identifier for the coupon object.
-
coupon_typeSpecifies if the coupon will be applied for a single product, all your products or a single collectionPossible enum values
single
Applies to a single product.multi
Applies to all your products.collection
Applies to a single collection. -
percent_offA positive float larger than 0, and smaller or equal to 100, that represents the discount the coupon will apply (required if
amount_off
is not passed). -
amount_offA positive integer representing the amount to subtract from the cart total (required if
percent_off
is not passed). For example if you'd like to give $5 off thenamount_off
would be 500 in cents. -
codeThe coupon code the customer is required to enter at checkout.
-
start_dateRFC 3339 datetime string of when this coupon begins to be valid. Coupons can not be redeemed before this date has been reached.
null
if this coupon does not require a start date. -
end_dateRFC 3339 datetime string of when this coupon expires. Coupons can no longer be redeemed after this date has been reached.
null
if this coupon can be redeemed forever. -
product_keyIf
coupon_type
is set tosingle
then the unique product key must be specified. To find out your product key, please follow these steps. -
collection_idIf
coupon_type
is set tocollection
then the unique collection ID must be specified. To find out collection ID you can learn more here. -
minimum_purchase_amountA positive integer representing the the minumum total of the customers cart before they can redeem this coupon. For example if you'd like to set the minimum as $5 then value would be 500 in cents.
-
usage_limitThe maximum number of times this coupon can be redeemed before it becomes invalid.
-
notesFor administrative purposes you can remind yourself why you created this coupon by adding a note - not visible to customers.
{
"amount_off": null,
"code": "example123",
"collection_id": null,
"coupon_type": "single",
"end_date": null,
"id": "1V6B72Lzra",
"minimum_purchase_amount": null,
"notes": null,
"percent_off": 50,
"product_key": "PtRJw",
"start_date": null,
"usage_limit": null
}
Create a coupon
A coupon has either a percent_off
or an amount_off
. If you set an amount_off
, that amount will be subtracted from the carts subtotal.
Parameters
-
percent_offA positive float larger than 0, and smaller or equal to 100, that represents the discount the coupon will apply (required if
amount_off
is not passed). -
amount_offA positive integer representing the amount to subtract from the cart total (required if
percent_off
is not passed). For example if you'd like to give $5 off thenamount_off
would be 500 in cents. -
coupon_typeSpecifies if the coupon will be applied for a single product, all your products or a single collectionPossible enum values
single
Applies to a single product.multi
Applies to all your products.collection
Applies to a single collection. -
codeThe coupon code the customer is required to enter at checkout.
-
product_keyIf
coupon_type
is set tosingle
then the unique product key must be specified. To find out your product key, please follow these steps.
More parameters
-
If
coupon_type
is set tocollection
then the unique collection ID must be specified. To find out collection ID you can learn more here. -
For administrative purposes you can remind yourself why you created this coupon by adding a note - not visible to customers.
-
The maximum number of times this coupon can be redeemed before it becomes invalid.
curl https://payhip.com/api/v2/coupons \ -d "code=example123" \ -d "coupon_type=single" \ -d "product_key=PtRJw" \ -d "percent_off=25" \ -X POST \ --header "payhip-api-key: YOUR_API_KEY_HERE"
{
"data": {
"amount_off": null,
"code": "example123",
"collection_id": null,
"coupon_type": "single",
"end_date": null,
"id": "1V6B72Lzra",
"minimum_purchase_amount": null,
"notes": null,
"percent_off": 50,
"product_key": "PtRJw",
"start_date": null,
"usage_limit": null
}
}
List all coupons
Retrieve a paginated list of all the coupons created on your account
Parameters
-
limitThe limit on the number of objects to be returned with the paginated results. Limit can range between 1 and 100, and the default is 10.
-
offsetTo move to the next results of paginated lists you can define an offet integer. By default this would be 0.
curl -G https://payhip.com/api/v2/coupons \ -d "limit=10" \ -d "offset=0" \ --header "payhip-api-key: YOUR_API_KEY_HERE"
{
"data": {
"coupons": [
{
"amount_off": null,
"code": "example123",
"collection_id": null,
"coupon_type": "single",
"end_date": null,
"id": "1V6B72Lzra",
"minimum_purchase_amount": null,
"notes": null,
"percent_off": 50,
"product_key": "PtRJw",
"start_date": null,
"usage_limit": null
}
]
}
}
Retrieve a coupon
Retrieves a coupon with the given ID.
Parameters
curl -G https://payhip.com/api/v2/coupons/1V6B72Lzra \ --header "payhip-api-key: YOUR_API_KEY_HERE"
{
"data": {
"amount_off": null,
"code": "example123",
"collection_id": null,
"coupon_type": "single",
"end_date": null,
"id": "1V6B72Lzra",
"minimum_purchase_amount": null,
"notes": null,
"percent_off": 50,
"product_key": "PtRJw",
"start_date": null,
"usage_limit": null
}
}
License Keys
A unique license key can be generated for each of your customers. You can then verify that their purchase is legitimate by requesting their license key. The is a great for software products to ensure security.
The License Key object
Attributes
-
license_keyUnique identifier for the license key object.
-
enabledYou can specify if this license key is valid by enabling or disabling it. When a refund takes place we automatically disable the license key.
-
product_linkThe product link (or product key) is the unique ID of the product this customer purchased. To find out your product key, please follow these steps.
-
buyer_emailThe email address the customer used for the purchase associated with this license key.
-
usesThe number of times this license key has been used.
-
dateRFC 3339 datetime string of when this license key was created.
{
"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"
}
Verify license key
Verify a license key with the given license key.
To find your product secret key to authenticate with this request please visit your edit product page and scroll down to the checkbox where you've enabled licenses and it will be listed there.
Parameters
-
license_keyUnique identifier for the license key object.
curl -G https://payhip.com/api/v2/license/verify \ -d "license_key=WTKP4-66NL5-HMKQW-GFSCZ" \ --header "product-secret-key: YOUR_PRODUCT_SECRET_KEY_HERE"
{
"data": {
"enabled": true,
"product_link": "mVT0",
"license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
"buyer_email": "contact@payhip.com",
"uses": 0,
"date": "2025-02-22T11:23:05+00:00"
}
}
Disable license key
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.
To find your product secret key to authenticate with this request please visit your edit product page and scroll down to the checkbox where you've enabled licenses and it will be listed there.
Parameters
-
license_keyUnique identifier for the license key object.
curl https://payhip.com/api/v2/license/enable \ -d "license_key=WTKP4-66NL5-HMKQW-GFSCZ" \ -X PUT \ --header "product-secret-key: YOUR_PRODUCT_SECRET_KEY_HERE"
{
"data": {
"enabled": false,
"product_link": "mVT0",
"license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
"buyer_email": "contact@payhip.com",
"uses": 1,
"date": "2025-02-22T11:23:05+00:00"
}
}
Enable license key
You might have previously disabled a license key for a customer (eg if they broke your terms). This endpoint can be used to re-enable a license key.
To find your product secret key to authenticate with this request please visit your edit product page and scroll down to the checkbox where you've enabled licenses and it will be listed there.
Parameters
-
license_keyUnique identifier for the license key object.
curl https://payhip.com/api/v2/license/enable \ -d "license_key=WTKP4-66NL5-HMKQW-GFSCZ" \ -X PUT \ --header "product-secret-key: YOUR_PRODUCT_SECRET_KEY_HERE"
{
"data": {
"enabled": true,
"product_link": "mVT0",
"license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
"buyer_email": "contact@payhip.com",
"uses": 1,
"date": "2025-02-22T11:23:05+00:00"
}
}
Increase usage for license key
You can record when a customer has used this license key by increasing the usage counter.
To find your product secret key to authenticate with this request please visit your edit product page and scroll down to the checkbox where you've enabled licenses and it will be listed there.
Parameters
-
license_keyUnique identifier for the license key object.
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"
{
"data": {
"enabled": true,
"product_link": "mVT0",
"license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
"buyer_email": "contact@payhip.com",
"uses": 2,
"date": "2025-02-22T11:23:05+00:00"
}
}
Decrease usage for license key
You can control the number of uses this license key had by the customer by decreasing the usage counter.
To find your product secret key to authenticate with this request please visit your edit product page and scroll down to the checkbox where you've enabled licenses and it will be listed there.
Parameters
-
license_keyUnique identifier for the license key object.
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"
{
"data": {
"enabled": true,
"product_link": "mVT0",
"license_key": "WTKP4-66NL5-HMKQW-GFSCZ",
"buyer_email": "contact@payhip.com",
"uses": 2,
"date": "2025-02-22T11:23:05+00:00"
}
}