For authors
License API
Every purchase issues a key. Your product can ask this install three things: activate a site, check that a site is still allowed to run, and free the seat again. No SDK is needed — it is one JSON endpoint.
What your item must do if we handle licensing
This is the requirement behind leaving the box on the item form unticked. If you would rather do licensing yourself, tick I handle the license inside my item instead and none of this applies.
1. Ask for the key and activate the site
When the buyer installs the item or opens it for the first time, ask for their license key and have
them confirm the address the item will run on. From your server, send action=activate
with that key and the domain. If the answer has ok and valid both true,
save the key on the server and let the item run. If it does not, show the message in the answer and
do not treat the item as licensed.
Activating the same domain again is safe and does not use a second seat. A new domain uses a seat:
when every seat is taken the answer says limit_reached, and the buyer has to release
another site first.
2. Check the site again, at least once a day
On a schedule — once a day is the minimum, and also whenever the item checks for updates — send
action=validate with the key and the same domain. A true ok and
valid means the site may keep running. Anything else means it may not: close the
licensed parts of the item or show a clear notice that the license is not valid, and record the
error code. Do not ignore a failed check.
Validation covers the cases that change after purchase: a refunded order answers
refunded, a site whose seat was released answers deactivated, and an
unpaid order answers inactive. The item stays off until a valid answer comes back.
3. Give the owner a way to release the site
Put a button in the item's admin called something like Release this site. It sends
action=deactivate with the key and domain, from your server, only when the owner
chooses it. That frees the seat so the key can be used on another address. Calling it twice is
safe — the second answer adds already_deactivated: true.
Deactivating from your own code without the owner asking is not allowed. A buyer who moves a site should be able to do it themselves.
Rules for all three calls
- Server to server only. The key is the credential. Never call the API from JavaScript, never print the key in a page, and never ship the API secret inside the item.
- Send the domain as the buyer's site address, for example
example.com. The scheme,www., port and path are ignored, sohttps://www.example.com/shopandexample.comare the same seat. - Activate rarely, validate regularly. Activate when the key is entered or the site moves. Do not call activate in a loop or on every page load.
- Every error means "not licensed". That includes HTTP 400, 422 and 503, a timeout,
a reply that is not JSON, and any answer where
okorvalidis not true. Show themessagefrom the answer when there is one. - Verify the signature. Every answer carries an HMAC-SHA256
signatureover its sorted body, made with the secret under Admin → Licenses. Check it on your server so a modified host cannot fake a valid reply; if it does not match, treat the answer as invalid. - Keep the key on the server. Store it in your configuration or database, not in a cookie the buyer can edit, and do not write it into log files.
An item that cannot activate a site, cannot report that a license has stopped being valid, or gives the owner no way to release a site does not meet the requirement, whatever else it does.
Endpoint
POST https://codescripts.dev/api/license.php
Send JSON (or a normal form post). The key is the credential, so the call is made from your server, never from a browser where the key would be visible.
Actions
| Action | What it does | Seat used |
|---|---|---|
| activate | Registers the domain against the key. Calling it again from the same domain is safe. | Yes, if the domain is new |
| validate | Answers whether this domain may run the item right now. Call it on update checks or daily. | No |
| deactivate | Releases the domain's seat so it can be used elsewhere. Safe to call twice. | Frees one |
| updates | For an activated site: the newest version, the last five changelog entries, and whether
the version you send is behind. Read-only. |
No |
A request
curl -s -X POST 'https://codescripts.dev/api/license.php' \
-H 'Content-Type: application/json' \
-d '{"action":"activate","key":"CS-XXXX-XXXX-XXXX","domain":"example.com"}'
The update feed
Send the version the site runs and the answer says whether there is a newer one. The file is not streamed here: the buyer downloads it from their purchases page.
curl -s -X POST 'https://codescripts.dev/api/license.php' \
-H 'Content-Type: application/json' \
-d '{"action":"updates","key":"CS-XXXX-XXXX-XXXX","domain":"example.com","version":"1.2.0"}'
{
"ok": true,
"valid": true,
"status": "active",
"latest": "1.4.0",
"released_on": "2026-11-18",
"update_available": true,
"download_available": true,
"changelog": [
{ "version": "1.4.0", "released_on": "2026-11-18", "note": "Fixes the queue worker" }
],
"signature": "…"
}
A successful answer
{
"ok": true,
"valid": true,
"status": "active",
"key": "CS-XXXX-XXXX-XXXX",
"item": "Your item",
"slug": "your-item",
"license": "personal",
"domain": "example.com",
"activations": { "used": 1, "limit": 1 },
"issued_at": "2026-11-18T09:00:00+00:00",
"checked_at": "2026-11-18T09:05:00+00:00",
"signature": "…"
}
When it is not valid
The body is still JSON, ok is false, and error says why.
A license failure answers HTTP 422; a malformed request answers 400, and a site whose database
has not been upgraded answers 503 with not_installed. Treat every error as
"do not run".
| error | Meaning |
|---|---|
| invalid_key | No license has that key on this install. |
| domain_required | The request had no usable domain. |
| inactive | The order has not been paid yet. |
| refunded | The order was refunded; the license is dead. |
| limit_reached | Every seat is in use. Deactivate a site first. |
| not_activated | Validation asked about a domain that never activated. |
| deactivated | That domain's seat was released. |
Verifying the signature
Every answer is signed with HMAC-SHA256 over its own sorted JSON body (without the
signature field), using the license API secret shown under Admin → Licenses. Run
this on your server so a forged reply from a modified host does not pass:
$body = json_decode($reply, true);
$signature = $body['signature'] ?? '';
unset($body['signature']);
ksort($body);
$expected = hash_hmac('sha256', json_encode($body, JSON_UNESCAPED_SLASHES), $secret);
$trusted = hash_equals($expected, $signature);
Good to know
- A standard license includes the number of sites shown on your purchase; extended licenses include more. The limits are set by the marketplace owner.
- A refunded order invalidates its key immediately, on the next call.
- Domains are stored lowercase, without
www., scheme, port or path, sohttps://www.example.com/shopandexample.comare the same seat. - Keys are 12 characters from a 32-character alphabet, so guessing one is not practical. There is no request throttle in this release; if you expose activation to end users, keep it behind your own rate limit.
- Send
fingerprintif you want a second signal (a machine id, for example). It is stored and shown on the license page but does not change seat counting.
