Note: The token is a standard JWT signed with EdDSA (Ed25519) by the same key as every licence answer. Any JWT library that supports EdDSA can check it offline.
#How it fits together
- The installation calls activate, or verify with its
activation_token, and keepsentitlementfrom the answer. - When it asks YOUR server for an update, it sends the token along, e.g.
Authorization: Bearer <entitlement>. - Your server checks the signature with the public key, then the claims:
iss,exp,item_id,domain,updates.active. - To get a fresh token, the installation calls verify again — at the latest every 24 hours.
Want to cut access before a token runs out? Subscribe to the licence webhooks and refuse tokens of a licence or site you were told about.
#Claims
{
"iss": "https://sellmycode.net",
"sub": "4b1f0c…e93a",
"iat": 1793073762,
"exp": 1793160162,
"item_id": 12345678,
"domain": "customer-site.com",
"license_type": "Regular",
"updates": { "active": true, "until": "2027-04-27T00:00:00+00:00", "lifetime": false }
}
| Claim | Type | Description |
|---|---|---|
iss |
string | always https://sellmycode.net — reject anything else |
sub |
string | SHA-256 (hex) of the purchase code. Match it against hash('sha256', $code) of the codes in your sale webhooks; the code itself is not in the token |
iat / exp |
integer | issued at / expires at, Unix seconds; exp is 24 hours after iat |
item_id |
integer | the item — check it is YOURS |
domain |
string | the activated domain: lower case, no scheme, no www. |
license_type |
string | "Regular" | "Extended" |
updates.active |
boolean | the buyer may download updates now |
updates.until |
string | null | end of the update period, ISO 8601 UTC; null when lifetime |
updates.lifetime |
boolean | updates never end |
The header is {"alg":"EdDSA","typ":"JWT","kid":"k1"}. Pick the key by kid.
#Keys
- Raw key and PEM: Signatures & fields.
- As a JWK set, for JWT libraries:
GET /api/license/jwks
{ "keys": [ { "kty": "OKP", "crv": "Ed25519", "x": "…", "kid": "k1", "alg": "EdDSA", "use": "sig" } ] }
#Verify on your server
// with the SDK (SellMyCodeLicense.php from /api-docs/licence-sdk)
$claims = SellMyCodeLicense::verifyEntitlement($token, [
'item_id' => 12345678,
'domain' => $requestingDomain,
]);
if (!$claims || !$claims['updates']['active']) {
http_response_code(403);
exit;
}
// npm install jose
import { createRemoteJWKSet, jwtVerify } from 'jose';
const JWKS = createRemoteJWKSet(new URL('https://sellmycode.net/api/license/jwks'));
const { payload } = await jwtVerify(token, JWKS, {
issuer: 'https://sellmycode.net',
algorithms: ['EdDSA'],
});
if (payload.item_id !== 12345678 || !payload.updates.active) throw new Error('Not entitled');
firebase/php-jwt:
$claims = (array) Firebase\JWT\JWT::decode($token, new Firebase\JWT\Key('5Uk3p1+J0PXzJkwS4wVFvTN9GcHpJzX5ClRI8zlI0yQ=', 'EdDSA'));
then check iss, item_id, domain and updates yourself.
Warning: A valid signature only proves the token came from SellMyCode. Always check iss, item_id and exp too, and domain when the request says which site it comes from — otherwise a token for another product or site would be accepted.
#When there is no token
The token opens your downloads, so a purchase code and a domain alone are not enough to get one — the same rule as licence updates:
| Answer | entitlement |
|---|---|
activate → activated, reactivated |
always (a new activation_token is issued with it) |
activate → already_activated, verify → valid |
only when the request includes this site's activation_token; otherwise null |
| any error | none — paused, revoked or blocked sites, blocked or refunded licences and removed items get no token |
A wrong activation_token does not fail the call, but counts towards the failed-lookup limit.
Developers