# SellMyCode API > Developer documentation for the SellMyCode marketplace API: account, items, sales, the author write API (publish new versions, prices, changelogs), licence activation with signed answers, the WordPress Toolkit and sale webhooks. Full text of every page in one file: https://sellmycode.net/llms-full.txt ## Guides - [Introduction](https://sellmycode.net/api-docs/introduction.md): Integrate your applications with SellMyCode: read your account and items, pull your sales into your own dashboards, publish new versions of your items from a script or CI pipeline, and license your software with signed a... - [Authentication & tokens](https://sellmycode.net/api-docs/authentication.md): Every request needs a personal access token. Create named, scoped tokens in your workspace under Settings → API Key — each app gets its own token with only the permissions it needs, and you can revoke any of them at any... - [Errors & limits](https://sellmycode.net/api-docs/errors.md): How the API reports problems, the shape of an error answer, and how many requests you can make. Handle errors by their HTTP status and error code, and back off when you hit a rate limit. - [Build with AI](https://sellmycode.net/api-docs/build-with-ai.md): Every page of these docs is also available as plain Markdown, so a coding agent or chat assistant can read the exact API instead of guessing it. ## Author API - [Publishing guide](https://sellmycode.net/api-docs/publishing.md): Release new versions, edit descriptions and change prices of your items from a script or CI pipeline — with the same rules as the Workspace edit form. Using the write permissions means you accept the Author API policy. - [Author API policy](https://sellmycode.net/api-docs/policy.md): These rules apply to every token with items:write, items:price, items:upload, tickets:reply or tickets:note. You accept them when you create such a token. They add to our Terms of Service and the Author Agreement, which... - [Update item](https://sellmycode.net/api-docs/update-item.md): Change one of your live items. Send only the fields you want to change. The same rules as the Workspace edit form apply: when the site reviews updates, your change waits in the review queue (one pending update per item)... - [Add changelog](https://sellmycode.net/api-docs/add-changelog.md): Add a changelog entry to a live item. It is published at once, like in Workspace. To publish a changelog together with a new package, send it with the upload instead — it then appears when that version goes live. - [Review state](https://sellmycode.net/api-docs/review-state.md): Where an item stands: live version and prices, the update waiting for review, a price change waiting for your confirmation, the last 10 history events (approved / rejected with reason) and changelogs. Needs items:read. - [Upload new version](https://sellmycode.net/api-docs/upload.md): Send a new package of a live item, then complete it. We check the size and SHA-256 of the whole file and submit it like the Workspace form: it waits for review (one pending update per item) unless your account is trusted... - [Item media](https://sellmycode.net/api-docs/item-media.md): Change an item's images through the API: the thumbnail, the preview image (the large picture on the item page, also used when the item is shared) and the screenshot gallery. It takes two steps: ## Support - [Support tickets](https://sellmycode.net/api-docs/support-tickets.md): Read the support tickets buyers open about your items, reply as you, close or reopen them, and keep internal notes — from your own helpdesk or an AI assistant. Replies follow the same rules as Workspace → Support: the bu... - [AI support assistant](https://sellmycode.net/api-docs/ai-support.md): Let an AI assistant answer the support tickets of your items — and hand the hard ones to you. ## Account & Sales - [Account](https://sellmycode.net/api-docs/account.md): Returns the profile of the account that owns the token. Needs account:read; the balance is included only when the token also has balance:read. - [Items](https://sellmycode.net/api-docs/items.md): Your own approved items. Authors only, needs items:read. - [Sales](https://sellmycode.net/api-docs/sales.md): Your sales, newest first — build revenue dashboards or sync orders into your own tools. Paginated. Needs sales:read; purchase codes are included only when the token also has sales:codes. - [Balance](https://sellmycode.net/api-docs/balance.md): A read-only snapshot of your wallets: withdrawable earnings, earnings still in the clearing period, and Store Credit. Optionally include your statement history. Needs balance:read. - [My purchases](https://sellmycode.net/api-docs/purchases.md): Your own purchases as a buyer, newest first — check licences and download windows from your tooling. Paginated. Needs purchases:read (the answer includes your purchase codes). - [Public catalog](https://sellmycode.net/api-docs/catalog.md): Browse and search the whole approved catalog — open to every account, buyer or author. Build price trackers, portfolio showcases or category dashboards. Returns storefront data only: buyer-facing prices (discounts includ... ## Licences - [Purchase validation](https://sellmycode.net/api-docs/purchase-validation.md): Verify a purchase code a buyer gives you — the core of any licence system you run yourself. Returns the purchase details when the code belongs to one of your items and is still active; otherwise 404. Needs purchases:vali... - [Licence activation](https://sellmycode.net/api-docs/licence-activation.md): For software that phones home — PHP scripts, desktop or mobile apps. Your installation sends the purchase code and its domain; we confirm the licence and count how many sites it runs on, so you do not have to host a lice... - [Signatures & fields](https://sellmycode.net/api-docs/licence-signatures.md): Every licence answer — success or error — is an Ed25519-signed envelope. Verify the signature over the payload string first, then decode the payload. - [Slots & deactivation](https://sellmycode.net/api-docs/licence-slots.md): Send purchase_code, item_id, domain, nonce and the activation_token you stored at activation. Without the token the call is refused, so knowing a buyer's code and domain is not enough to pause their site. - [Licence updates](https://sellmycode.net/api-docs/licence-updates.md): Let your product update itself with nothing but its licence. The installation asks whether a newer version exists; if the buyer's update period is running, the answer carries a short-lived download link and the SHA-256 o... - [PHP SDK & WordPress](https://sellmycode.net/api-docs/licence-sdk.md): Two ready-made files that do the licence work for you: activate a site, check the licence, and install updates — with every answer's signature, nonce and package checksum verified. - [Entitlement tokens](https://sellmycode.net/api-docs/licence-entitlement.md): Already run your own update or download server? Let it trust SellMyCode licences without calling us: activate and verify answers carry an entitlement — a signed token, valid for 24 hours, that says which site holds which... - [Key rotation](https://sellmycode.net/api-docs/key-rotation.md): Every answer names its key in kid. GET /api/license/public-key lists every key with a status: ## Toolkit - [Item updates (Toolkit)](https://sellmycode.net/api-docs/item-updates.md): Let a WordPress site keep the themes and plugins it bought here up to date. Tell us which packages are installed, get back the ones with a newer version, then pull the installable ZIP. This is what the SellMyCode Toolkit... ## Webhooks - [Webhooks](https://sellmycode.net/api-docs/webhooks.md): Instead of polling the sales endpoint, register an HTTPS URL and we POST a signed JSON event to it the moment something happens. Manage endpoints in your workspace under Settings → API Key → Webhooks (up to 5, each with... ## Changelog - [API changelog](https://sellmycode.net/api-docs/changelog.md): New endpoints and changes that affect integrations. Existing fields keep their name and type; new fields may appear at any time — ignore fields you do not know. ======================================================================== # Introduction Integrate your applications with SellMyCode: read your account and items, pull your sales into your own dashboards, publish new versions of your items from a script or CI pipeline, and license your software with signed answers. | | | |---|---| | Base URL | `https://sellmycode.net/api` | | Format | JSON | | Rate limit | 60 requests per minute per token | | Version | v1 | ```bash curl https://sellmycode.net/api ``` The root answers with the API name, version and a directory of every endpoint. ## What you can build - [Publish from CI](https://sellmycode.net/api-docs/publishing.md) — upload new versions, edit descriptions, changelogs and prices with the same rules as Workspace. - [License your software](https://sellmycode.net/api-docs/licence-activation.md) — activate and verify purchase codes with Ed25519-signed answers, no licensing server to host. - [Sales dashboards](https://sellmycode.net/api-docs/sales.md) — pull your sales, earnings and balance, or get them pushed with [webhooks](https://sellmycode.net/api-docs/webhooks.md). - [Build with AI](https://sellmycode.net/api-docs/build-with-ai.md) — give your coding agent the whole API as Markdown in one link. ## Next steps 1. Create a token in Workspace → Settings → API with only the permissions you need — see [Authentication](https://sellmycode.net/api-docs/authentication.md). 2. Call `GET /api/account/details` to check it works. 3. Read [Errors & limits](https://sellmycode.net/api-docs/errors.md) before going to production. --- Source: https://sellmycode.net/api-docs/introduction ======================================================================== # Authentication & tokens Every request needs a personal access token. Create named, scoped tokens in your workspace under **Settings → API Key** — each app gets its own token with only the permissions it needs, and you can revoke any of them at any time. ## Permissions | Permission | Allows | |---|---| | `account:read` | View your account details | | `items:read` | List and view your items | | `sales:read` | List your sales (amounts and buyers, without purchase codes) | | `sales:codes` | Include buyers' purchase codes in your sales — they activate licences, grant only to tools you fully trust | | `purchases:validate` | Verify purchase codes of your buyers | | `purchases:read` | List your own purchases (as a buyer), including your purchase codes | | `balance:read` | View your wallet balances and earnings | | `catalog:read` | Browse and search the public item catalog | | `updates:read` | Check for and download updates of items you bought (SellMyCode Toolkit) | | `items:write` | Change your items: name, description, version, tags, demo link, changelog and images (goes through review like the web form) | | `items:price` | Change the prices of your items — a move of more than 30% waits for your confirmation by email | | `items:upload` | Upload new versions of your items' files and new images (goes through review like the web form) | | `tickets:read` | Read the support tickets buyers open about your items, with every message | | `tickets:reply` | Reply to support tickets of your items and close or reopen them — replies are sent to the buyer as you | | `tickets:note` | Add internal notes to support tickets — only you see them, never the buyer | > **Warning:** A token is a password, not a public key. Never put one in front-end JavaScript, a mobile app bundle or a public repository — whoever holds it acts as you within its permissions. Purchase codes are secrets too: they activate licences, so `sales:read` leaves them out and only a token that also has `sales:codes` receives them. `account:read` returns your balance only together with `balance:read`. Creating a token asks for your password again, and resetting your password revokes every token and the legacy key. Write permissions (`items:write`, `items:price`, `items:upload`) need a scoped token — the old single API key can read but never write — and come with the [Author API policy](https://sellmycode.net/api-docs/policy.md). ## Sending the token Send the token in the `Authorization` header (recommended). The `X-Api-Key` header works too. Tokens are **not** accepted in the query string or the request body: keys in URLs end up in proxy and CDN logs. The old single "API key" from the account page was retired on 2026-10-31 — every integration uses a scoped token. ```bash curl https://sellmycode.net/api/account/details \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```bash curl https://sellmycode.net/api/account/details \ -H "X-Api-Key: YOUR_API_KEY" ``` ## Keep tokens out of code Store the token in a file only you can read, and have your scripts read it from there: ```bash mkdir -p ~/.config/sellmycode && chmod 700 ~/.config/sellmycode printf '%s' 'smc_YOUR_TOKEN' > ~/.config/sellmycode/token && chmod 600 ~/.config/sellmycode/token ``` --- Source: https://sellmycode.net/api-docs/authentication ======================================================================== # Errors & limits How the API reports problems, the shape of an error answer, and how many requests you can make. Handle errors by their HTTP status and `error` code, and back off when you hit a rate limit. ## HTTP status codes | Code | Meaning | |---|---| | 200 | Success | | 201 / 202 | Created / accepted (for example an update waiting for review) | | 400 | Validation error — a required parameter is missing or malformed | | 401 | Invalid or missing API key | | 403 | The token does not have the permission this endpoint needs | | 404 | Resource not found (also returned for an invalid purchase code) | | 409 | Conflict — for example an update of this item is already waiting for review | | 422 | The request was understood but refused — the `error` field says why | | 429 | Rate limit exceeded — wait and retry | ## Error shape ```json { "status": "error", "error": "pending_update", "msg": "This item already has an update waiting for review." } ``` Older read endpoints return only `status` and `msg`. Write endpoints add a machine-readable `error` code — branch on it, never on the message text. ## Rate limits | Scope | Limit | |---|---| | Every token | 60 requests per minute | | Write calls (`PATCH` items, changelogs, start / complete uploads) | 30 per minute | | Upload parts | 240 part URLs or 120 relay chunks per minute | | Licence endpoints | see [Licence activation](https://sellmycode.net/api-docs/licence-activation.md#limits) | | Toolkit endpoints | 60 per minute | Invalid keys share one bucket per IP address (30 per 10 minutes) — a script that keeps sending a wrong key is blocked for a while. --- Source: https://sellmycode.net/api-docs/errors ======================================================================== # Build with AI Every page of these docs is also available as plain Markdown, so a coding agent or chat assistant can read the exact API instead of guessing it. ## Give your assistant the docs | What | Where | |---|---| | One page as Markdown | add `.md` to its address, for example `https://sellmycode.net/api-docs/upload.md` | | Index of every page | `https://sellmycode.net/llms.txt` | | The whole documentation in one file | `https://sellmycode.net/llms-full.txt` | On every page, the **Copy page** button copies the page as Markdown, and its menu opens the page directly in ChatGPT, Claude or Perplexity. ## A prompt that works ```text Read https://sellmycode.net/llms-full.txt. Write a release script for my SellMyCode item 123: upload ./dist/my-item.zip with transfer=direct, complete it with the version from package.json and the changelog from CHANGELOG.md, then poll the review state. Read the API token from ~/.config/sellmycode/token and never print it. ``` ## Keep your token safe with agents - Give the agent a token with only the permissions the task needs — `items:read` and `items:upload` for releases, never `items:price` unless it must change prices. - Never paste a token into a chat. Store it in a file and let the script read it — see [Authentication](https://sellmycode.net/api-docs/authentication.md#keep-tokens-out-of-code). - Every change made with a token is written to the item history with the token name and emailed to you, so you can see what an agent did. --- Source: https://sellmycode.net/api-docs/build-with-ai ======================================================================== # Publishing guide Release new versions, edit descriptions and change prices of your items from a script or CI pipeline — with the same rules as the Workspace edit form. Using the write permissions means you accept the [Author API policy](https://sellmycode.net/api-docs/policy.md). ## 1. Create a token with only what the script needs Workspace → Settings → API → New token. Pick only the scopes you need: | Scope | Allows | |---|---| | `items:read` | Read your items and their review state | | `items:write` | Name, description, version, tags, demo link, changelog | | `items:upload` | Upload a new package (main file, or installable zip for WordPress items) | | `items:price` | Change prices — give it only to tools that must do this | The old single API key can read but never write. Keep the token out of your code and repository — store it in a file only you can read: ```bash mkdir -p ~/.config/sellmycode && chmod 700 ~/.config/sellmycode printf '%s' 'smc_YOUR_TOKEN' > ~/.config/sellmycode/token && chmod 600 ~/.config/sellmycode/token ``` ## 2. What happens to a change - Changes to a live item go to the review queue, like the web form. Only one update per item can wait for review — a second one gets `409 pending_update`, unless you [replace the waiting one](#hotfixes-while-an-update-waits). - An update nobody reviews within 30 days is rejected automatically and its files are deleted; you are emailed and can submit it again. - Trusted authors (set by our team) publish at once; a replaced package is deleted — keep your own copies of old versions. - Every change is written to the item history (Workspace → item → History) with the token name, and emailed to you. - A new version number or package notifies your buyers once it is live; a changelog sent with an upload appears when that version goes live. - Prices stay within the site minimum and maximum. A move of more than 30% waits until you confirm it from the email we send (signed in, 24 hours, single use) — a leaked token alone cannot reprice your items. ## Hotfixes while an update waits Found a bug in a version that is still waiting for review? Send the fix with `replace_pending: true` — on the [upload](https://sellmycode.net/api-docs/upload.md) (start it with the flag) or on [`PATCH`](https://sellmycode.net/api-docs/update-item.md). - The fields you send replace those of the waiting update: a new package replaces the waiting package (which is deleted), a new version number and changelog replace the old ones. Changes you do not send — a new description from the Workspace form, for example — stay in the waiting update. - It keeps its `update_id` and its place for review, and its 30-day review clock starts again. The item history shows the replacement. - A reviewer who opened the old version cannot approve it by mistake: approving checks that the update has not changed since the page was loaded. - Answers say `"replaced_pending": true` when a waiting update was replaced. ## 3. A typical release 1. [Upload the new package](https://sellmycode.net/api-docs/upload.md) and complete it with the version and changelog. 2. Optionally [update the description or tags](https://sellmycode.net/api-docs/update-item.md) with `PATCH`. 3. Poll [the review state](https://sellmycode.net/api-docs/review-state.md) until `pending_update` is `null` and the history shows "Update Approved" (or "Update Rejected" with the reason). --- Source: https://sellmycode.net/api-docs/publishing ======================================================================== # Author API policy These rules apply to every token with `items:write`, `items:price`, `items:upload`, `tickets:reply` or `tickets:note`. You accept them when you create such a token. They add to our Terms of Service and the Author Agreement, which still apply in full. ## What the write API is for - Maintaining your own items that are already live: new versions of the same product, fixes, descriptions, changelogs, tags, demo links and prices. - New items are not created through the API — submit them in Workspace so they get a full first review. ## What every upload must be - A new version of the item it is uploaded to — the same product the buyers paid for, complete and working. Not a different product, not a placeholder, not an empty or partial package. - Your own work, or work you have the right to sell under your licence. No nulled, cracked or resold third-party code. - Free of malware, backdoors, obfuscated phone-home code, licence-bypass tools and hidden links. Every new package is scanned automatically and findings are reviewed by our team. - Within the item category file types; WordPress installable packages must be a real theme or plugin with a Version header. ## How changes go live - Changes to a live item wait for review like the Workspace form; one update per item can wait at a time. - Trusted authors, chosen by our team, publish at once. Trust can be withdrawn at any time, and published updates can still be reviewed afterwards. - An update not reviewed within 30 days is rejected automatically and its files deleted; you can submit it again. - A new package replaces the old one, which is deleted. We do not keep old versions for you — keep your own copies. - Prices stay within the site minimum and maximum; a move of more than 30% waits for your confirmation by email. ## Limits | Limit | Value | |---|---| | Requests per token | 60 per minute (write calls 30, relay chunks 120, part URLs 240 per minute) | | Upload volume | 10 GB per author per 24 hours | | Open uploads | 2 at a time; cancel the ones you will not finish, otherwise they are deleted after 6 hours | | Failed or abandoned uploads | 5 in 24 hours pause your uploads for a day | | File size | The site maximum for item files | ## Not allowed - Using uploads as file storage, backup or hosting, or uploading files unrelated to the item. - Starting uploads you do not intend to finish, or probing the limits. - Sharing a token, or letting a third-party service use it in a way you do not control. - Changing prices in quick succession to mislead buyers about discounts. ## AI Support in Workspace - Replies the built-in assistant sends in Auto reply mode are your replies; keep Draft only until you trust its answers for your items. - Your provider key is stored encrypted and used only to answer your own tickets and messages; buyer messages are sent to the provider you chose, under that provider's terms. - The assistant never answers refunds, disputes, tickets an administrator joined, or requests for credentials — those always wait for you. ## Support replies through the API - A reply sent with `tickets:reply` is a reply from you, with the same duties as one typed in Workspace — be accurate, polite and on topic. - Do not use tickets for marketing, upsells the buyer did not ask for, or bulk messages. - Never ask buyers for passwords, server logins or payment details in a ticket, and do not pass buyer messages to third parties beyond the tool that answers them. - Leave refunds, licence disputes and tickets an administrator joined to a person. ## Your token, your responsibility - Everything done with a token counts as done by you. Give each tool only the permissions it needs, keep tokens out of code and repositories, and revoke a token at once if it may have leaked (Workspace → Settings → API). - Every change is recorded in the item history with the token name and emailed to you — check those emails. ## When the rules are broken Depending on how serious it is, we may reject the update, delete the uploaded files, pause your uploads, revoke your tokens, withdraw trusted status, take the item down, or suspend the account. Malware or someone else's code ends API access for good. We may change this policy; material changes are announced to authors before they apply. --- Source: https://sellmycode.net/api-docs/policy ======================================================================== # Update item Change one of your live items. Send only the fields you want to change. The same rules as the Workspace edit form apply: when the site reviews updates, your change waits in the review queue (one pending update per item) — trusted authors publish at once. `PATCH /api/items/{id}` | Field | Scope | Description | |---|---|---| | `name` | items:write | Item name, max 200 characters | | `description` | items:write | HTML description; cleaned with the same filter as the editor | | `version` | items:write | e.g. 2.4.1 — a new version tells your buyers there is an update | | `demo_link` | items:write | Live preview URL | | `tags` · `files_included` · `framework` | items:write | Comma-separated lists | | `replace_pending` | — | `true` to replace the update that is waiting for review instead of getting `409 pending_update` — see [Hotfixes](https://sellmycode.net/api-docs/publishing.md#hotfixes-while-an-update-waits) | | `regular_price` · `extended_price` | items:price | Within the site minimum and maximum. A move of more than 30% (or setting a price that was 0) is held until you confirm it from the email we send — the link asks you to be signed in. Not possible while the item is on discount. | ```bash curl -X PATCH https://sellmycode.net/api/items/123 \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"version":"2.4.1","regular_price":29}' ``` ```php $res = (new GuzzleHttp\Client)->patch('https://sellmycode.net/api/items/123', [ 'headers' => ['Authorization' => 'Bearer ' . $token], 'json' => ['version' => '2.4.1', 'regular_price' => 29], ]); ``` ```node const res = await fetch("https://sellmycode.net/api/items/123", { method: "PATCH", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" }, body: JSON.stringify({ version: "2.4.1", regular_price: 29 }), }); ``` ```python res = requests.patch("https://sellmycode.net/api/items/123", headers={"Authorization": f"Bearer {token}"}, json={"version": "2.4.1", "regular_price": 29}) ``` ```json { "status": "success", "item_id": 123, "mode": "review", "changed": ["version", "regular_price"], "update_id": 845, "replaced_pending": false, "price_confirmation": null } ``` `mode` is `published` (live now), `review` (waiting for approval) or `unchanged`. When a price move needs your confirmation, `price_confirmation` carries the held prices and when the email link expires. ## Errors | Code | HTTP | Meaning | |---|---|---| | `pending_update` | 409 | Another update of this item is waiting for review — wait, or send `replace_pending: true` | | `discount_active` | 409 | Prices cannot change while the item is on discount | | `not_found` | 404 | No live item with this id in your account | | `nothing_to_change` | 422 | No known field was sent | | `validation` | 422 | A field is invalid — `errors` lists each one | --- Source: https://sellmycode.net/api-docs/update-item ======================================================================== # Add changelog Add a changelog entry to a live item. It is published at once, like in Workspace. To publish a changelog together with a new package, send it with the [upload](https://sellmycode.net/api-docs/upload.md) instead — it then appears when that version goes live. `POST /api/items/{id}/changelogs` | Parameter | Type | Description | |---|---|---| | `version` *required* | string | e.g. 2.4.1 — one entry per version (409 `changelog_exists`) | | `body` *required* | string | Plain text, shown as written | ```bash curl -X POST https://sellmycode.net/api/items/123/changelogs \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"version":"2.4.1","body":"Fixed checkout on PHP 8.4"}' ``` ```json { "status": "success", "changelog": { "id": 5521, "version": "2.4.1", "created_at": "2026-10-24T08:00:00Z" } } ``` --- Source: https://sellmycode.net/api-docs/add-changelog ======================================================================== # Review state Where an item stands: live version and prices, the update waiting for review, a price change waiting for your confirmation, the last 10 history events (approved / rejected with reason) and changelogs. Needs `items:read`. `GET /api/items/{id}/versions` ```bash curl https://sellmycode.net/api/items/123/versions \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "status": "success", "item": { "id": 123, "name": "My Item", "state": "live", "version": "2.4.0", "regular_price": 29, "extended_price": 0, "review_required": true }, "pending_update": { "id": 845, "version": "2.4.1", "main_file_changed": true, "submitted_at": "2026-10-24T08:00:00Z" }, "pending_price_confirmation": null, "history": [ { "title": "Update Submission", "note": "API upload (token \"ci\") — main_file, version", "at": "2026-10-24T08:00:00Z" } ], "changelogs": [ { "version": "2.4.0", "body": "…", "at": "2026-10-01T09:00:00Z" } ] } ``` Poll it after a release: the update is live when `pending_update` is `null` and the newest history entry is "Update Approved" — or "Update Rejected" with the reason in `note`. Or skip polling: subscribe a [webhook](https://sellmycode.net/api-docs/webhooks.md#review-events) to `item.update_approved` and `item.update_rejected`. --- Source: https://sellmycode.net/api-docs/review-state ======================================================================== # Upload new version Send a new package of a live item, then complete it. We check the size and SHA-256 of the whole file and submit it like the Workspace form: it waits for review (one pending update per item) unless your account is trusted, in which case it goes live and the old package is removed. Keep your own copies of old versions. Needs a token with `items:upload`. ## How it works 1. **Start an upload.** Declare the file name, size and SHA-256, and choose `transfer: "direct"`. 2. **Send the parts.** Ask for a signed URL per part and PUT the bytes straight to storage — fast from anywhere. 3. **Complete.** We check every part and the SHA-256; the new version then waits for review, or goes live for trusted authors. There are two ways to send the bytes: - **`transfer=direct`** — recommended. Each part goes straight to our storage with a short-lived URL we sign for you: fast from anywhere, no 100-second limit. Parts are 5–100 MB (default 50 MB; the last one is the remainder). - **`transfer=relay`** — the default for older scripts: chunks go through our servers (1–50 MB each). Every chunk must arrive within 100 seconds, which can be slow from far away. > **Tip:** From a slow or distant network, direct can be a hundred times faster than relay — measured from Vietnam: about 30 KB/s through our servers, 4 MB/s direct. ## 1. Start an upload `POST /api/items/{id}/uploads` | Field | Type | Description | |---|---|---| | `filename` *required* | string | Package file name, e.g. `my-item-2.5.0.zip` | | `size` *required* | integer | Bytes | | `sha256` *required* | hex | Checksum of the whole file | | `transfer` | enum | `direct` (recommended) or `relay` (default) | | `chunk_size` | integer | Bytes per part — direct 5–100 MB, relay 1–50 MB; default 50 MB | | `slot` | enum | `main_file` (default) or `installable_file` (WordPress items, zip) | | `replace_pending` | boolean | `true` when an update of this item is already waiting for review: this upload replaces its package (and the version and changelog you complete it with). See [Hotfixes](https://sellmycode.net/api-docs/publishing.md#hotfixes-while-an-update-waits) | ```bash curl -X POST https://sellmycode.net/api/items/123/uploads \ -H "Authorization: Bearer $(cat ~/.config/sellmycode/token)" \ -H "Content-Type: application/json" \ -d '{"filename":"my-item-2.5.0.zip","size":48211904,"sha256":"9f2c…e1","transfer":"direct"}' ``` ```php $res = (new GuzzleHttp\Client)->post('https://sellmycode.net/api/items/123/uploads', [ 'headers' => ['Authorization' => 'Bearer ' . $token], 'json' => ['filename' => basename($file), 'size' => filesize($file), 'sha256' => hash_file('sha256', $file), 'transfer' => 'direct'], ]); ``` ```node const res = await fetch("https://sellmycode.net/api/items/123/uploads", { method: "POST", headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" }, body: JSON.stringify({ filename, size, sha256, transfer: "direct" }), }); ``` ```python res = requests.post("https://sellmycode.net/api/items/123/uploads", headers={"Authorization": f"Bearer {token}"}, json={"filename": name, "size": size, "sha256": sha, "transfer": "direct"}) ``` ```json { "status": "success", "upload": { "id": "0d049a6c-…-2cda", "transfer": "direct", "chunk_size": 52428800, "chunk_count": 1, "received": 0, "missing": [0], "expires_at": "2026-10-24T14:00:00Z" } } ``` You can have 2 unfinished uploads at a time; an upload expires after 6 hours. ## 2. Send the parts ### Direct `GET /api/items/{id}/uploads/{upload}/parts/{index}` Returns a signed URL for part `index` (0 … chunk_count − 1), valid for 60 minutes. PUT exactly that part to it — **no Authorization header**, the URL is the permission. Ask again if it expires. ```json { "status": "success", "index": 0, "method": "PUT", "url": "https://…r2.cloudflarestorage.com/…", "headers": { "Content-Length": 52428800 }, "expires_at": "2026-10-24T09:00:00Z" } ``` > **Warning:** A part larger than planned cancels the whole upload and counts as a failed upload. ### Relay `PUT /api/items/{id}/uploads/{upload}/chunks/{index}` Raw request body, exactly `chunk_size` bytes (the last chunk is the remainder). The optional header `X-Chunk-Sha256` checks the chunk. Re-sending a chunk replaces it. ## 3. Check progress `GET /api/items/{id}/uploads/{upload}` Shows how many parts arrived and which are missing — use it to resume after a network error. ## 4. Complete `POST /api/items/{id}/uploads/{upload}/complete` | Field | Type | Description | |---|---|---| | `version` | string | e.g. 2.5.0 — an installable package uses its own Version header when omitted | | `changelog` | string | Shown to buyers when the version goes live | ```json { "status": "success", "item_id": 123, "mode": "review", "changed": ["main_file", "version", "changelog"], "update_id": 846, "replaced_pending": false, "sha256": "9f2c…e1", "version": "2.5.0" } ``` ## List and cancel uploads `GET /api/uploads` `DELETE /api/items/{id}/uploads/{upload}` List your unfinished uploads (all items) and cancel one you will not finish — it frees the slot at once and does not count as a failed upload. ## A complete release script ```bash F=my-item-2.5.0.zip; ID=123; API=https://sellmycode.net/api; AUTH="Authorization: Bearer $(cat ~/.config/sellmycode/token)" SIZE=$(stat -f%z "$F" 2>/dev/null || stat -c%s "$F"); SHA=$(shasum -a 256 "$F" | cut -d' ' -f1); CS=52428800 J=$(curl -s -X POST $API/items/$ID/uploads -H "$AUTH" -H "Content-Type: application/json" \ -d "{\"filename\":\"$F\",\"size\":$SIZE,\"sha256\":\"$SHA\",\"transfer\":\"direct\",\"chunk_size\":$CS}") UP=$(echo "$J" | python3 -c 'import sys,json;print(json.load(sys.stdin)["upload"]["id"])') N=$(echo "$J" | python3 -c 'import sys,json;print(json.load(sys.stdin)["upload"]["chunk_count"])') for i in $(seq 0 $((N-1))); do URL=$(curl -s $API/items/$ID/uploads/$UP/parts/$i -H "$AUTH" | python3 -c 'import sys,json;print(json.load(sys.stdin)["url"])') dd if="$F" bs=$CS skip=$i count=1 2>/dev/null | curl -sf -X PUT --data-binary @- "$URL" > /dev/null || echo "part $i failed — run it again" done curl -s -X POST $API/items/$ID/uploads/$UP/complete -H "$AUTH" -H "Content-Type: application/json" \ -d '{"version":"2.5.0","changelog":"Fixed checkout on PHP 8.4"}' ``` ## Errors | Code | HTTP | Meaning | |---|---|---| | `pending_update` | 409 | Another update of this item is waiting for review — wait, or start the upload with `replace_pending: true` | | `incomplete` | 409 | Parts are missing — the message lists them | | `checksum_mismatch` | 422 | The file differs from the declared size or SHA-256 — start a new upload | | `oversized_part` | 422 | A part was larger than planned; the upload was cancelled | | `chunk_size` | 422 | The part size is outside the allowed range | | `file_type` | 422 | The item category does not accept this file type | | `not_installable` | 422 | No WordPress theme or plugin with a Version header in the zip | | `too_many_uploads` | 429 | Finish or cancel your other uploads first | | `daily_limit` | 429 | 10 GB per author per 24 hours | | `upload_locked` | 429 | Five failed or abandoned uploads in 24 hours pause uploads for a day | | `busy` | 503 | Upload capacity is busy — try again in a few minutes | --- Source: https://sellmycode.net/api-docs/upload ======================================================================== # Item media Change an item's images through the API: the **thumbnail**, the **preview image** (the large picture on the item page, also used when the item is shared) and the **screenshot gallery**. It takes two steps: 1. Upload each new image with `POST /media/uploads`. It is checked and stored privately for 24 hours, and you get an upload id back. 2. Send one `PUT /media` that says what the item should show: new uploads, current screenshots you keep, in the order you want. The `PUT` is one change, like a [`PATCH`](https://sellmycode.net/api-docs/update-item.md): it waits for review unless your account publishes updates directly, and an item has at most one update waiting (send `replace_pending: true` to replace it). > **Note:** Screenshots have no captions on SellMyCode, so there is no caption field. ## Read the current media `GET /api/items/{id}/media` Needs `items:read`. Also shows what the waiting update would change, and the image rules of the item's category. ```bash curl https://sellmycode.net/api/items/123/media \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "status": "success", "item_id": 123, "media": { "thumbnail": { "url": "SellMyCode/files/items/ab12/thumb.webp" }, "preview": { "type": "image", "url": "SellMyCode/files/items/ab12/preview.webp" }, "screenshots": [ { "position": 0, "url": "SellMyCode/files/items/ab12/s1.webp" }, { "position": 1, "url": "SellMyCode/files/items/ab12/s2.webp" } ] }, "pending_update": null, "rules": { "formats": ["jpg", "png"], "max_bytes": 10485760, "thumbnail_min": { "width": 240, "height": 240 }, "preview_image_min": { "width": 1120, "height": 630, "ratio": "16:9" }, "screenshot_min_long_side": 600, "max_screenshots": 10, "staged_hours": 24 } } ``` ## Upload an image `POST /api/items/{id}/media/uploads` Needs `items:upload`. Send the image as `multipart/form-data`, one image per request. | Parameter | Type | Description | |---|---|---| | `file` *required* | file | JPG or PNG, at most 10 MB. The type is read from the file itself | | `slot` *required* | string | `thumbnail`, `preview_image` or `screenshot` | The same checks as the upload fields in Workspace: | Slot | Rule | |---|---| | `thumbnail` | At least the category's thumbnail size (see `rules`). Padded to a square and resized | | `preview_image` | At least 1120×630 and landscape 16:9. Within ±2 % it is kept as it is, up to ±10 % it is cropped to 16:9, beyond that it is refused (`wrong_ratio`) | | `screenshot` | At least 600 px on the longer side | Images are converted to WebP when the site does that for web uploads. Uploads you do not use expire after 24 hours; you can have 30 unused images at a time (`429 too_many_uploads`). ```bash curl -X POST https://sellmycode.net/api/items/123/media/uploads \ -H "Authorization: Bearer YOUR_API_KEY" \ -F slot=screenshot \ -F file=@dashboard.png ``` ```json { "status": "success", "upload": { "id": "k3Jx9Qw2LmPa", "slot": "screenshot", "width": 1600, "height": 900, "url": "SellMyCode/files/items/ab12/new.webp", "expires_at": "2026-11-15T09:00:00Z" } } ``` ## Set the media `PUT /api/items/{id}/media` Needs `items:write`. Send only what changes. | Parameter | Type | Description | |---|---|---| | `thumbnail` | string | Upload id of a `thumbnail` upload | | `preview_image` | string | Upload id of a `preview_image` upload (items with an image preview only) | | `screenshots` | array | The **whole** gallery, in order. Each entry is `{"keep": position}` (a current screenshot, positions from `GET /media`) or `{"upload": "id"}` (a `screenshot` upload). At least 1, at most the category's `max_screenshots` | | `replace_pending` | boolean | Replace the update that is waiting for review | Removing a screenshot = leaving it out of the list. Reordering = listing the entries in the new order. A gallery identical to the current one changes nothing (`mode: unchanged`). ```bash curl -X PUT https://sellmycode.net/api/items/123/media \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"screenshots":[{"upload":"k3Jx9Qw2LmPa"},{"keep":0},{"keep":1}]}' ``` ```json { "status": "success", "item_id": 123, "mode": "review", "changed": ["screenshots"], "update_id": 9912, "replaced_pending": false } ``` `mode` is `published` (live now, HTTP 200) or `review` (waiting for approval, HTTP 202). Follow the review with [Review state](https://sellmycode.net/api-docs/review-state.md) or the `item.update_*` [webhooks](https://sellmycode.net/api-docs/webhooks.md#review-events). When the change goes live, the images it no longer uses are deleted; images you kept stay as they are. If the update is rejected, its new uploads are deleted and the item keeps its current images. ## Errors | Code | HTTP | Meaning | |---|---|---| | `invalid_type` | 422 | Not a JPG or PNG | | `too_large` | 413 | Over 10 MB | | `too_small` / `wrong_ratio` | 422 | Below the minimum size, or not 16:9 (preview) | | `slot_unavailable` | 422 | The item's category has no gallery, or the item uses a video/audio preview | | `too_many_uploads` | 429 | 30 unused images are waiting | | `upload_not_found` | 422 | Unknown or expired upload id, or an upload made for another item | | `wrong_slot` | 422 | e.g. a `screenshot` upload sent as `thumbnail` | | `invalid_screenshot` / `duplicate_screenshot` | 422 | An entry without exactly one of `keep`/`upload`, a position that does not exist, or the same image twice | | `too_many_screenshots` | 422 | More than the category allows | | `pending_update` | 409 | An update is already waiting; send `replace_pending: true` to replace it | --- Source: https://sellmycode.net/api-docs/item-media ======================================================================== # Support tickets Read the support tickets buyers open about your items, reply as you, close or reopen them, and keep internal notes — from your own helpdesk or an AI assistant. Replies follow the same rules as Workspace → Support: the buyer is notified, and the conversation stays in their Support inbox. | Scope | Allows | |---|---| | `tickets:read` | List your tickets and read every message | | `tickets:reply` | Reply to the buyer as you, close and reopen tickets | | `tickets:note` | Add internal notes — only you see them, never the buyer | `tickets:reply` and `tickets:note` are write permissions: they need a scoped token and come with the [Author API policy](https://sellmycode.net/api-docs/policy.md). ## Ticket states | `state` | Meaning | |---|---| | `needs_reply` | Open, and the last message is from the buyer or an administrator — your turn | | `waiting` | Open, and you answered last — waiting for the buyer | | `closed` | Closed by you, the buyer or an administrator | `waiting` is not something you set: replying puts the ticket there. Use `close: true` on a reply, or `PATCH`, to close it. Open tickets you answered close on their own after a few quiet days. ## List tickets `GET /api/tickets` | Parameter | Type | Description | |---|---|---| | `status` | string | `open` (default) \| `needs_reply` \| `waiting` \| `closed` \| `all` | | `item_id` | integer | only tickets about this item | | `per_page` | integer | default 25, max 50 | ```bash curl "https://sellmycode.net/api/tickets?status=needs_reply" \ -H "Authorization: Bearer $(cat ~/.config/sellmycode/token)" ``` ```json { "status": "success", "pagination": { "page": 1, "per_page": 25, "total": 2, "last_page": 1 }, "tickets": [ { "id": 812, "subject": "Webhook not firing after update", "item": { "id": 22314, "name": "Perfex Connect" }, "buyer": "johndoe", "purchase": { "license_type": "Regular", "purchased_at": "2026-09-02T10:00:00Z", "support_until": "2027-03-02T10:00:00Z", "support_active": true }, "status": "open", "state": "needs_reply", "escalated": false, "closed_by_admin": false, "last_message": { "from": "buyer", "excerpt": "Since 1.1.0 the Zapier hook…", "at": "2026-10-24T08:12:00Z" }, "created_at": "2026-10-24T08:12:00Z", "last_reply_at": "2026-10-24T08:12:00Z", "url": "https://sellmycode.net/workspace/support/…" } ] } ``` ## Read a ticket `GET /api/tickets/{id}` Every message in order. `from` is `buyer`, `author` or `admin`. Item support tickets do not carry attachments, so `attachments` is always empty. With `tickets:note` the answer also includes your internal `notes`. ```json { "status": "success", "ticket": { "id": 812, "state": "needs_reply", "messages": [ { "id": 5011, "from": "buyer", "username": "johndoe", "body": "Since 1.1.0 the Zapier hook…", "attachments": [], "created_at": "2026-10-24T08:12:00Z", "edited": false } ], "notes": [ { "id": 31, "body": "Known issue, fixed in 1.1.2", "token": "support-bot", "created_at": "2026-10-24T08:13:00Z" } ] } } ``` ## Reply `POST /api/tickets/{id}/replies` | Field | Type | Description | |---|---|---| | `body` *required* | string | Plain text, up to 10,000 characters — sent to the buyer as you | | `close` | boolean | Reply and close the ticket in one go | ```bash curl -X POST https://sellmycode.net/api/tickets/812/replies \ -H "Authorization: Bearer $(cat ~/.config/sellmycode/token)" \ -H "Content-Type: application/json" \ -d '{"body":"Thanks! This is fixed in 1.1.2 — update from your Downloads page.","close":false}' ``` ```json { "status": "success", "message": { "id": 5012, "created_at": "2026-10-24T08:14:00Z" }, "ticket": { "id": 812, "state": "waiting", "…": "" } } ``` > **Warning:** One ticket accepts at most 10 replies per hour through the API (`reply_limit`) — a safety stop for a runaway bot. Let a person take over long conversations. ## Close or reopen `PATCH /api/tickets/{id}` | Field | Type | Description | |---|---|---| | `status` *required* | string | `closed` or `open` | A ticket closed by an administrator stays closed (`closed_by_admin`), and a ticket closed more than 7 days ago cannot be reopened (`reopen_window`). ## Internal notes `POST /api/tickets/{id}/notes` | Field | Type | Description | |---|---|---| | `body` *required* | string | Up to 5,000 characters | Notes appear in your Support inbox inside the ticket, marked "Internal note" with the token name — the buyer never sees them. Use them for an AI assistant's hand-over: what it found, what it suggests, why it did not answer. ## Get told about new messages Subscribe a [webhook](https://sellmycode.net/api-docs/webhooks.md) to `ticket.created` and `ticket.replied`. They fire for buyer and administrator messages only — never for your own replies, so a bot cannot answer itself in a loop. ## Errors | Code | HTTP | Meaning | |---|---|---| | `not_found` | 404 | No ticket with this id on your items | | `ticket_closed` | 409 | Reopen the ticket before replying | | `closed_by_admin` | 409 | Only an administrator can reopen it | | `reopen_window` | 409 | Closed too long ago to reopen | | `reply_limit` | 429 | 10 API replies on this ticket in the last hour | | `validation` | 422 | A field is invalid — `errors` lists each one | --- Source: https://sellmycode.net/api-docs/support-tickets ======================================================================== # AI support assistant Let an AI assistant answer the support tickets of your items — and hand the hard ones to you. > **Tip:** You do not need to build this yourself. **Workspace → AI Support** runs an assistant on SellMyCode with your own Claude, ChatGPT or Gemini key: paste the key, choose Draft only or Auto reply, add FAQs per item, and set spending limits. It is free — you only pay your AI provider. The rest of this page is for authors who want to run their own assistant through the API. ## How it fits together 1. **A buyer writes.** We POST `ticket.created` or `ticket.replied` to your webhook URL, signed, within seconds. 2. **Your assistant reads the case.** It fetches `GET /api/tickets/{id}` for the whole conversation, plus your docs, changelog and FAQ. 3. **It answers or hands over.** A confident answer goes out with `POST /api/tickets/{id}/replies`. Anything else becomes an internal note, and the ticket stays in your inbox as "needs reply". ## Set it up 1. Create a token with only `tickets:read`, `tickets:reply` and `tickets:note` (add `items:read` if the assistant should look up your items). Store it in `~/.config/sellmycode/token` — never in code. 2. In Workspace → Settings → API → Webhooks, add your assistant's HTTPS URL with the events `ticket.created` and `ticket.replied`, and keep the signing secret. 3. In your handler, [verify the signature](https://sellmycode.net/api-docs/webhooks.md#verifying-the-signature), answer 200 at once, and do the work in the background. ## Rules worth giving your assistant - Answer only from your documentation and changelog; when unsure, write an internal note instead of guessing. - Never ask for passwords, server logins or payment details in a ticket. - Check `purchase.support_active` — when support has ended, explain how to renew instead of debugging. - Leave refunds, licence disputes and anything an administrator joined (`escalated: true`) to you. - Sign replies so buyers know they may talk to an assistant, if your policy requires it. ## Example handler ```python # Flask — on ticket.created / ticket.replied import hmac, hashlib, time, json, requests from flask import Flask, request TOKEN = open("/home/me/.config/sellmycode/token").read().strip() SECRET = "whsec_..." API = "https://sellmycode.net/api" H = {"Authorization": f"Bearer {TOKEN}"} @app.post("/hooks/sellmycode") def hook(): sig = dict(p.split("=", 1) for p in request.headers.get("X-SMC-Signature", "").split(",") if "=" in p) body = request.get_data() good = hmac.compare_digest(hmac.new(SECRET.encode(), (sig.get("t", "") + ".").encode() + body, hashlib.sha256).hexdigest(), sig.get("v1", "")) if not good or abs(time.time() - float(sig.get("t", 0))) > 300: return "", 400 event = json.loads(body) if event["event"] in ("ticket.created", "ticket.replied"): queue.enqueue(handle_ticket, event["data"]["ticket_id"]) # do the work later return "", 200 def handle_ticket(ticket_id): t = requests.get(f"{API}/tickets/{ticket_id}", headers=H, timeout=20).json()["ticket"] if t["state"] != "needs_reply" or t["escalated"]: return answer, confident = my_ai_answer(t) # your model + your docs if confident: requests.post(f"{API}/tickets/{ticket_id}/replies", headers=H, json={"body": answer}, timeout=20) else: requests.post(f"{API}/tickets/{ticket_id}/notes", headers=H, json={"body": "AI draft:\n" + answer}, timeout=20) ``` Every reply the assistant sends is a reply from you. The buyer sees it in their inbox and can always ask for a person; you see the whole thread, notes included, in Workspace → Support. --- Source: https://sellmycode.net/api-docs/ai-support ======================================================================== # Account Returns the profile of the account that owns the token. Needs `account:read`; the balance is included only when the token also has `balance:read`. `GET /api/account/details` ```bash curl https://sellmycode.net/api/account/details \ -H "Authorization: Bearer YOUR_API_KEY" ``` --- Source: https://sellmycode.net/api-docs/account ======================================================================== # Items Your own approved items. Authors only, needs `items:read`. ## All items `GET /api/items/all` Newest first, paginated. | Parameter | Type | Description | |---|---|---| | `per_page` | integer | default 25, max 50 | | `page` | integer | page number | ```bash curl https://sellmycode.net/api/items/all \ -H "Authorization: Bearer YOUR_API_KEY" ``` ## Single item `GET /api/items/item?item_id={id}` | Parameter | Type | Description | |---|---|---| | `item_id` *required* | integer | The item ID (shown in your Workspace item list) | ```bash curl "https://sellmycode.net/api/items/item?item_id=123" \ -H "Authorization: Bearer YOUR_API_KEY" ``` To change an item, see [Update item](https://sellmycode.net/api-docs/update-item.md) and [Upload new version](https://sellmycode.net/api-docs/upload.md). --- Source: https://sellmycode.net/api-docs/items ======================================================================== # Sales Your sales, newest first — build revenue dashboards or sync orders into your own tools. Paginated. Needs `sales:read`; purchase codes are included only when the token also has `sales:codes`. `GET /api/sales` | Parameter | Type | Description | |---|---|---| | `from` | date | Y-m-d — only sales on or after this date | | `to` | date | Y-m-d — only sales on or before this date | | `item_id` | integer | filter by one of your items | | `status` | string | active \| refunded \| cancelled \| held | | `per_page` | integer | default 25, max 50 | | `page` | integer | page number | ```bash curl "https://sellmycode.net/api/sales?from=2026-01-01&status=active&per_page=25" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "status": "success", "pagination": { "page": 1, "per_page": 25, "total": 132, "last_page": 6 }, "sales": [ { "id": 981, "purchase_code": "8f14e45f-ce95-41d8-a2b6-72e5f13d81a7", "item": { "id": 123, "name": "My Theme" }, "buyer": "johndoe", "license_type": "Regular", "price": 29.0, "fee": 5.8, "earning": 23.2, "currency": "USD", "sale_status": "active", "cleared": true, "date": "2026-07-01T09:30:00+00:00" } ] } ``` Prefer being told instead of polling? Use [sale webhooks](https://sellmycode.net/api-docs/webhooks.md). --- Source: https://sellmycode.net/api-docs/sales ======================================================================== # Balance A read-only snapshot of your wallets: withdrawable earnings, earnings still in the clearing period, and Store Credit. Optionally include your statement history. Needs `balance:read`. `GET /api/balance` | Parameter | Type | Description | |---|---|---| | `statements` | boolean | 1 to include recent statements | | `wallet` | string | balance \| store_credit — filter statements by wallet | | `per_page` | integer | default 25, max 50 | ```bash curl "https://sellmycode.net/api/balance?statements=1&wallet=balance" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "status": "success", "currency": "USD", "wallets": { "balance": 1250.75, "pending_balance": 89.4, "store_credit": 12.5 }, "pagination": { "page": 1, "per_page": 25, "total": 57, "last_page": 3 }, "statements": [ { "id": 4021, "title": "[Sale] #981 (My Theme)", "wallet": "balance", "type": "credit", "amount": 29.0, "total": 23.2, "date": "2026-07-01T09:30:05+00:00" } ] } ``` --- Source: https://sellmycode.net/api-docs/balance ======================================================================== # My purchases Your own purchases as a buyer, newest first — check licences and download windows from your tooling. Paginated. Needs `purchases:read` (the answer includes your purchase codes). `GET /api/purchases` | Parameter | Type | Description | |---|---|---| | `status` | string | active \| refunded \| cancelled \| held | | `per_page` | integer | default 25, max 50 | | `page` | integer | page number | ```bash curl "https://sellmycode.net/api/purchases?status=active" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "status": "success", "pagination": { "page": 1, "per_page": 25, "total": 3, "last_page": 1 }, "purchases": [ { "purchase_code": "8f14e45f-ce95-41d8-a2b6-72e5f13d81a7", "item": { "id": 123, "name": "My Theme", "url": "https://sellmycode.net/item/my-theme/123" }, "license_type": "Regular", "price": 29.0, "currency": "USD", "purchase_status": "active", "download_expiry_at": "2027-01-01T00:00:00+00:00", "download_expired": false, "date": "2026-07-01T09:30:00+00:00" } ] } ``` --- Source: https://sellmycode.net/api-docs/purchases ======================================================================== # Public catalog Browse and search the whole approved catalog — open to every account, buyer or author. Build price trackers, portfolio showcases or category dashboards. Returns storefront data only: buyer-facing prices (discounts included) and ratings — never files, download links, sales counts or buyer identities. Needs `catalog:read`. > **Note:** Any registered account can create a token with the `catalog:read` permission — you do not need to be an author or have made a purchase. ## Search items `GET /api/catalog/items` | Parameter | Type | Description | |---|---|---| | `search` | string | full-text search across item names and tags | | `category` | string | a category slug (see the categories endpoint) | | `sort` | string | latest (default) \| popular \| rating | | `per_page` | integer | default 25, max 50 | | `page` | integer | page number | ```bash curl "https://sellmycode.net/api/catalog/items?search=woocommerce&sort=popular" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "status": "success", "pagination": { "page": 1, "per_page": 25, "total": 64, "last_page": 3 }, "items": [ { "id": 123, "name": "My Theme", "url": "https://sellmycode.net/item/my-theme/123", "thumbnail": "https://sellmycode.net/files/thumbnails/…", "category": { "id": 4, "name": "WordPress", "slug": "wordpress" }, "author": "janedoe", "price": { "regular": 29.0, "extended": 145.0 }, "currency": "USD", "rating": { "average": 4.8, "count": 36 }, "version": "2.1.0", "updated_at": "2026-07-10T08:00:00+00:00", "published_at": "2026-01-05T12:00:00+00:00" } ] } ``` ## One item `GET /api/catalog/items/{id}` Full public detail of one approved item — the list fields plus description, media previews, included files list and framework. ```bash curl https://sellmycode.net/api/catalog/items/123 \ -H "Authorization: Bearer YOUR_API_KEY" ``` ## Categories `GET /api/catalog/categories` All categories with their approved-item counts — use the slug as the `category` filter above. ```json { "status": "success", "categories": [ { "id": 4, "name": "WordPress", "slug": "wordpress", "url": "https://sellmycode.net/categories/wordpress", "items_count": 128 } ] } ``` --- Source: https://sellmycode.net/api-docs/catalog ======================================================================== # Purchase validation Verify a purchase code a buyer gives you — the core of any licence system you run yourself. Returns the purchase details when the code belongs to one of **your** items and is still active; otherwise 404. Needs `purchases:validate`. > **Tip:** Selling software that should check its own licence? [Licence activation](https://sellmycode.net/api-docs/licence-activation.md) does it without a token and with signed answers — usually the better choice. `POST /api/purchases/validation` | Parameter | Type | Description | |---|---|---| | `purchase_code` *required* | string | The code from the buyer (shown on their Purchases page and licence certificate) | ```bash curl -X POST https://sellmycode.net/api/purchases/validation \ -H "Authorization: Bearer YOUR_API_KEY" \ -d "purchase_code=BUYER_PURCHASE_CODE" ``` ```php // licence check from your app / plugin $ch = curl_init('https://sellmycode.net/api/purchases/validation'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'], CURLOPT_POSTFIELDS => http_build_query(['purchase_code' => $code]), ]); $res = json_decode(curl_exec($ch), true); $valid = ($res['status'] ?? '') === 'success'; ``` ```node // Node.js 18+ (built-in fetch) const res = await fetch('https://sellmycode.net/api/purchases/validation', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ purchase_code: code }), }); const data = await res.json(); const valid = res.ok && data.status === 'success'; ``` ```python # Python 3 + requests import requests res = requests.post( 'https://sellmycode.net/api/purchases/validation', headers={'Authorization': 'Bearer YOUR_API_KEY'}, data={'purchase_code': code}, timeout=10, ) valid = res.status_code == 200 and res.json().get('status') == 'success' ``` ```json { "status": "success", "buyer": "johndoe", "license_blocked": false, "item": { "purchase_code": "8f14e45f-ce95-41d8-a2b6-72e5f13d81a7", "license_type": "Regular", "price": 29.0, "currency": "USD", "item": { "…item fields…": "" }, "supported_until": "2026-12-01T00:00:00+00:00", "download_expiry": "2026-08-01T00:00:00+00:00", "downloaded": true, "date": "2026-07-01T09:30:00+00:00" } } ``` > **Warning:** A 404 is returned for BOTH an unknown code and a refunded or blocked purchase — treat any non-200 as "licence invalid". --- Source: https://sellmycode.net/api-docs/purchase-validation ======================================================================== # Licence activation For software that phones home — PHP scripts, desktop or mobile apps. Your installation sends the purchase code and its domain; we confirm the licence and count how many sites it runs on, so you do not have to host a licensing server yourself. > **Note:** These endpoints need NO API token — the purchase code is the credential, so the code you ship to buyers can call them directly. > **Warning:** Every answer is signed with Ed25519. Verify the signature and the nonce before trusting it. A module that only reads `status` can be fooled by a fake server or a hosts-file redirect that answers "success". See [Signatures & fields](https://sellmycode.net/api-docs/licence-signatures.md). > **Note:** The right to USE the software never expires. When update support ends, verify still returns valid — only the `updates` block reports that renewal is due. An expired update period must never break a live site. > **Important:** `item_id` is required on activate, verify and deactivate. Every call is scoped to the calling item, so a buyer who types the code of another product into yours gets `invalid_code` — nothing is activated on that other licence and no slot is taken. Calls without `item_id` are refused with `invalid_request`. ## Endpoints `POST /api/license/activate` `POST /api/license/verify` `POST /api/license/deactivate` `GET /api/license/public-key` | Parameter | Type | Description | |---|---|---| | `purchase_code` *required* | string | the code the buyer received | | `item_id` *required* | integer | the ID of YOUR item — the number at the end of its SellMyCode URL (also shown in Workspace → My Items). Hard-code it in your product. A purchase code of any other item is answered exactly like an unknown code (`invalid_code`) and never activates or holds a slot. | | `domain` *required* | string | the site running the software; scheme, www and path are stripped automatically | | `nonce` *required* | string | 16–128 random characters (A-Z a-z 0-9 _ -), new for EVERY call. It is echoed inside the signed answer, so an old answer cannot be replayed. | | `activation_token` | string | the token you received when this site was activated — required by deactivate; optional on verify and activate, where it adds an [entitlement token](https://sellmycode.net/api-docs/licence-entitlement.md) to the answer | ## What your software must do 1. Send a fresh random nonce with every call. 2. Verify the signature over the payload string with the public key. If it fails, ignore the answer completely. 3. Decode the payload and check that its nonce equals the one you sent, that `item.id` is YOUR item and that `domain` is this site. One key signs answers for every product on SellMyCode, so a relay could pass on a genuine answer about another item or another site with your nonce in it. 4. On activate, store `activation_token` — it is shown once, and deactivation, [updates](https://sellmycode.net/api-docs/licence-updates.md) and [entitlement tokens](https://sellmycode.net/api-docs/licence-entitlement.md) all need it. 5. On `activation_limit_reached`, show the hint and a button that opens `transfer_url` (the item's support page), where the buyer asks you to free a slot. 6. On `license_blocked` or `site_blocked`, switch the licensed features off and show the hint with `transfer_url` — these are authoritative signed answers, like `invalid_code`. 7. Keep the last verified answer. When we cannot be reached, answer 5xx, or rate limit you, keep running on it until its `grace_until` — never treat an outage as "licence invalid". A signed error such as `invalid_code` or `not_activated` is authoritative and should replace it. ```php // PHP 7.2+ (sodium is built in) function sellmycode_license(string $action, array $fields): ?array { // kid => raw 32-byte public key (Base64): the active key and the standby "next" key $keys = ['k1' => '5Uk3p1+J0PXzJkwS4wVFvTN9GcHpJzX5ClRI8zlI0yQ=', 'k2' => 'erOiojOdS5F/IfhPMO9gvjAvuEPVapIadTDaWU0z83o=']; $fields['nonce'] = bin2hex(random_bytes(16)); $ch = curl_init('https://sellmycode.net/api/license/' . $action); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, CURLOPT_POSTFIELDS => http_build_query($fields), ]); $res = json_decode((string) curl_exec($ch), true); // unreachable, 5xx, unsigned or forged: return null and keep the cached state if (!isset($res['payload'], $res['signature'], $keys[$res['kid'] ?? '']) || !sodium_crypto_sign_verify_detached(base64_decode($res['signature']), $res['payload'], base64_decode($keys[$res['kid']]))) { return null; } $data = json_decode($res['payload'], true); // must answer THIS request, not be an old answer replayed if (($data['nonce'] ?? '') !== $fields['nonce']) { return null; } // and be about THIS item and THIS site: one key signs for every product on SellMyCode if (isset($data['item']['id']) && (int) $data['item']['id'] !== (int) $fields['item_id']) { return null; } if (isset($data['domain']) && $data['domain'] !== sellmycode_domain($fields['domain'])) { return null; } return $data; } // the domain as SellMyCode stores it: lower case, no scheme, path or www. function sellmycode_domain(string $value): string { $host = parse_url(strpos($value, '://') === false ? 'http://' . $value : $value, PHP_URL_HOST); return preg_replace('/^www\./', '', strtolower(trim((string) $host, '.'))); } const ITEM_ID = 12345; // your item's ID on SellMyCode // first run: activate and keep the token $r = sellmycode_license('activate', ['purchase_code' => $code, 'item_id' => ITEM_ID, 'domain' => $_SERVER['HTTP_HOST']]); if ($r && $r['status'] === 'success' && $r['activation_token']) { save_setting('license_token', $r['activation_token']); } // daily: verify, cache the signed answer, run on it through an outage $r = sellmycode_license('verify', ['purchase_code' => $code, 'item_id' => ITEM_ID, 'domain' => $_SERVER['HTTP_HOST']]); if ($r && $r['code'] !== 'rate_limited') { save_setting('license_state', $r); } $state = get_setting('license_state'); $licensed = $state && $state['status'] === 'success' && strtotime($state['grace_until']) > time(); ``` ```node // Node.js 18+ import crypto from 'node:crypto'; // kid => raw public key (Base64): the active key and the standby "next" key const KEYS = {"k1":"5Uk3p1+J0PXzJkwS4wVFvTN9GcHpJzX5ClRI8zlI0yQ=","k2":"erOiojOdS5F/IfhPMO9gvjAvuEPVapIadTDaWU0z83o="}; const publicKey = (kid) => KEYS[kid] && crypto.createPublicKey({ format: 'jwk', key: { kty: 'OKP', crv: 'Ed25519', x: Buffer.from(KEYS[kid], 'base64').toString('base64url') }, }); async function sellmycodeLicense(action, fields) { const nonce = crypto.randomBytes(16).toString('hex'); let res; try { const r = await fetch('https://sellmycode.net/api/license/' + action, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ...fields, nonce }), }); res = await r.json(); } catch { return null; } if (!res.payload || !res.signature) return null; const key = publicKey(res.kid); if (!key) return null; const ok = crypto.verify(null, Buffer.from(res.payload), key, Buffer.from(res.signature, 'base64')); if (!ok) return null; const data = JSON.parse(res.payload); if (data.nonce !== nonce) return null; // one key signs for every product on SellMyCode: check the item and the site too if (data.item && data.item.id !== fields.item_id) return null; const host = new URL(fields.domain.includes('://') ? fields.domain : 'http://' + fields.domain).hostname.replace(/^www\./, ''); if (data.domain && data.domain !== host) return null; return data; } // fields always carry your item_id const r = await sellmycodeLicense('verify', { purchase_code: code, item_id: 12345, domain: 'example.com' }); ``` ```python # Python 3 + requests + cryptography import base64, json, secrets, requests from urllib.parse import urlparse from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey # kid => raw public key (Base64): the active key and the standby "next" key KEYS = {"k1":"5Uk3p1+J0PXzJkwS4wVFvTN9GcHpJzX5ClRI8zlI0yQ=","k2":"erOiojOdS5F/IfhPMO9gvjAvuEPVapIadTDaWU0z83o="} def sellmycode_license(action, fields): nonce = secrets.token_hex(16) try: res = requests.post("https://sellmycode.net/api/license/" + action, json=dict(fields, nonce=nonce), timeout=15).json() key = Ed25519PublicKey.from_public_bytes(base64.b64decode(KEYS[res["kid"]])) key.verify(base64.b64decode(res["signature"]), res["payload"].encode()) except Exception: return None # unreachable, unsigned or forged data = json.loads(res["payload"]) if data.get("nonce") != nonce: return None # one key signs for every product on SellMyCode: check the item and the site too if "item" in data and data["item"]["id"] != fields["item_id"]: return None host = urlparse(fields["domain"] if "://" in fields["domain"] else "http://" + fields["domain"]).hostname or "" if "domain" in data and data["domain"] != host.removeprefix("www."): return None return data # fields always carry your item_id r = sellmycode_license("verify", {"purchase_code": code, "item_id": 12345, "domain": "example.com"}) ``` ## Error codes | Error code | HTTP | Meaning | |---|---|---| | `invalid_code` | 403 | unknown, refunded or cancelled purchase code — or a code of another item than item_id (deliberately indistinguishable) | | `activation_limit_reached` | 403 | every slot is taken (paused sites included) — show hint and transfer_url; the author can free one | | `license_blocked` | 403 | the author blocked this whole licence over abuse — stop the licensed features and show the hint and transfer_url | | `site_blocked` | 403 | the author blocked this domain for the licence — it cannot activate again and still holds its slot (slot_bound = true); other domains of the code are unaffected | | `not_activated` | 403 | this domain is not licensed right now: never activated, paused (slot_bound = true — activate again) or revoked by the author (slot_released = true) | | `invalid_activation_token` | 403 | deactivate: the token does not belong to this site | | `invalid_request` | 400 | a parameter is missing or malformed — most often the nonce or item_id | | `invalid_domain` | 400 | the domain could not be parsed | | `rate_limited` | 429 | slow down and retry after retry_after seconds — not a licence problem, keep your cached state | | `signing_unavailable` | 503 | temporary, and the only unsigned answer — keep your cached state | ## Limits 30 calls per 10 minutes for each licence + domain, and 30 FAILED lookups per 10 minutes per IP. Valid calls do not count against the IP, so many sites sharing one hosting IP are not blocked. > **Note:** Set the number of allowed sites per licence when you publish the item (Activation limit, separately for Regular and Extended). Leave it empty for unlimited. --- Source: https://sellmycode.net/api-docs/licence-activation ======================================================================== # Signatures & fields Every licence answer — success or error — is an Ed25519-signed envelope. Verify the signature over the payload string first, then decode the payload. ## Public key Embed this key in your software. It is also served at `GET /api/license/public-key`; the `kid` in each answer tells you which key signed it, so a future key can be added without breaking installs. ```text 5Uk3p1+J0PXzJkwS4wVFvTN9GcHpJzX5ClRI8zlI0yQ= ``` Embed the standby key too — every key listed below as `next`. It does not sign anything today; it is there so that, if the active key ever had to be replaced in a hurry, your installations keep verifying answers without an update. See [Key rotation](https://sellmycode.net/api-docs/key-rotation.md). Keys published right now: | kid | status | public key | |---|---|---| | `k1` | active | `5Uk3p1+J0PXzJkwS4wVFvTN9GcHpJzX5ClRI8zlI0yQ=` | | `k2` | next | `erOiojOdS5F/IfhPMO9gvjAvuEPVapIadTDaWU0z83o=` | Libraries that want PEM/SPKI instead of the raw key (OpenSSL, Java, .NET) can use this — the same key wrapped in the standard 12-byte Ed25519 SPKI header: ```text -----BEGIN PUBLIC KEY----- MCowBQYDK2VwAyEA5Uk3p1+J0PXzJkwS4wVFvTN9GcHpJzX5ClRI8zlI0yQ= -----END PUBLIC KEY----- ``` ## Key and signature format | Item | Format | |---|---| | Algorithm | Ed25519 as defined in RFC 8032 (pure Ed25519 — no pre-hashing, no context string) | | Public key | the raw 32-byte Ed25519 public key, standard Base64 with padding (44 characters). Not PEM, not DER, not hex. | | Signature | the raw 64-byte Ed25519 signature, standard Base64 with padding (88 characters) | | Signed message | the exact UTF-8 bytes of the payload string as it appears in the envelope — verify before decoding; never re-encode the JSON and verify that | | kid | short string naming the key that signed this answer; pick the matching public key by it | | Timestamps | ISO 8601 with offset, always UTC (+00:00) | ## Response format ```json { "payload": "{\"status\":\"success\",\"code\":\"activated\", … }", "signature": "base64 Ed25519 signature of payload", "kid": "k1", "alg": "Ed25519" } ``` Decoded payload of an activate call: ```json { "status": "success", "code": "activated", "domain": "customer-site.com", "license_type": "Regular", "activation_limit": 2, "activations_used": 1, "updates": { "active": true, "until": "2027-01-30T10:00:00+00:00" }, "activation_token": "9f2c…e41a", "grace_until": "2026-10-16T08:00:00+00:00", "nonce": "the nonce you sent", "issued_at": "2026-10-09T08:00:00+00:00" } ``` ## Fields returned Envelope — the top level of every answer: | Field | Type | Description | |---|---|---| | `payload` | string | the signed JSON document, as a string | | `signature` | string | Base64 Ed25519 signature of payload | | `kid` | string | which key signed it | | `alg` | string | always "Ed25519" | Payload of a successful verify (HTTP 200, code "valid"). activate returns the same fields: | Field | Type | Description | |---|---|---| | `status` | string | "success" | | `code` | string | verify: "valid" · activate: "activated" (a new domain took a slot), "reactivated" (a paused domain resumed on the slot it already held) or "already_activated" | | `domain` | string | the domain as we stored it: lower case, no scheme, no www, no path | | `item.id` | integer | item id on SellMyCode — check it is YOUR item, so a code bought for another product is not accepted | | `item.name` | string | item title | | `item.version` | string | latest published version | | `item.url` | string | item page | | `license_type` | string | "Regular" \| "Extended" | | `purchased_at` | string | ISO 8601, UTC | | `activation_limit` | integer \| null | sites this licence may run on; null = unlimited | | `activations_used` | integer | slots in use: active and paused sites (a paused site keeps its slot) | | `slot_bound` | boolean | this domain holds one of the licence's slots | | `slot_released` | boolean | the author revoked this domain and its slot was freed | | `updates.active` | boolean | whether the buyer may still download updates — informational, never a reason to stop working | | `updates.until` | string \| null | end of the update period, ISO 8601 UTC; null = no end date | | `updates.renew_url` | string \| null | where to renew, set only once updates have ended | | `grace_until` | string | run on this answer until this time if we cannot be reached (currently 7 days ahead) | | `nonce` | string | the nonce you sent — must match | | `issued_at` | string | when we signed it, ISO 8601 UTC | | `activation_token` | string \| null | activate only: 48 hex characters on "activated"; null on "already_activated" | | `entitlement` | string \| null | a 24-hour JWT (EdDSA) for your own update server; on verify and "already_activated" only when you send `activation_token` — see [Entitlement tokens](https://sellmycode.net/api-docs/licence-entitlement.md) | | `hint` | string | activate only, with "already_activated" | Payload of deactivate (HTTP 200, code "deactivated"): status, code, domain, activations_used, activation_limit, slot_bound (true), slot_released (false), nonce, issued_at. Payload of every error: status ("error"), code, msg, nonce (null if yours was missing or malformed), issued_at — plus, depending on the code, activation_limit, activations_used, slot_bound, slot_released, hint, transfer_url (with activation_limit_reached, license_blocked and site_blocked) and retry_after (seconds, with rate_limited). > **Note:** New fields may be added to the payload over time; ignore fields you do not know. Existing fields keep their name and type. --- Source: https://sellmycode.net/api-docs/licence-signatures ======================================================================== # Slots & deactivation ## Deactivate pauses, only the author frees - Deactivate pauses the site: it stops being licensed but KEEPS its slot, so a licence cannot be cycled across new domains by deactivating and activating. - The same domain can always be activated again — code "reactivated", no extra slot used, a new activation_token issued. - A new domain needs a free slot. When none is left the answer is `activation_limit_reached` with a hint and transfer_url. - Only the author frees a slot, by revoking a site under Workspace → Licenses (searchable by item, site, purchase code and buyer). Buyers cannot release sites themselves. A revoked domain gets slot_released = true and needs a free slot to activate again. - If a licence is abused, the author can block one domain (`site_blocked`: that domain cannot activate the code again until unblocked and it keeps its slot, so the licence cannot be moved elsewhere; other sites keep working) or the whole licence (`license_blocked` on every call for that code). The buyer is told the reason and can appeal to SellMyCode, whose admins have the final word. Downloads are not affected. `/api/purchases/validation` reports license_blocked too. ## Deactivating a site `POST /api/license/deactivate` Send purchase_code, item_id, domain, nonce and the activation_token you stored at activation. Without the token the call is refused, so knowing a buyer's code and domain is not enough to pause their site. --- Source: https://sellmycode.net/api-docs/licence-slots ======================================================================== # Licence updates Let your product update itself with nothing but its licence. The installation asks whether a newer version exists; if the buyer's update period is running, the answer carries a short-lived download link and the SHA-256 of the package. > **Note:** No API token is needed. The credential is the purchase code PLUS the `activation_token` this site received from [activate](https://sellmycode.net/api-docs/licence-activation.md) — a purchase code and a domain alone cannot fetch your files. > **Tip:** The [PHP SDK & WordPress updater](https://sellmycode.net/api-docs/licence-sdk.md) do all of this for you — signature, nonce, token storage and checksum included. > **Warning:** Answers are signed exactly like the other licence endpoints. Verify the signature and the nonce first, then compare the downloaded file with `package.sha256` before you install it. See [Signatures & fields](https://sellmycode.net/api-docs/licence-signatures.md). ## Endpoints `POST /api/license/update` `GET /api/license/download/{ticket}` | Parameter | Type | Description | |---|---|---| | `purchase_code` *required* | string | the buyer's purchase code | | `item_id` *required* | integer | the ID of YOUR item, hard-coded in your product | | `domain` *required* | string | the activated domain | | `activation_token` *required* | string | the token returned when this site was activated | | `current_version` | string | the version that is running now, e.g. `1.2.0` — used to decide `update_available` | | `nonce` *required* | string | 16–128 random characters, new for every call | ## Example ```bash curl -X POST https://sellmycode.net/api/license/update \ -H "Content-Type: application/json" \ -d '{"purchase_code":"…","item_id":12345678,"domain":"shop.example.com","activation_token":"…","current_version":"1.2.0","nonce":"9f3c1d7e0a2b4c6d8e0f"}' ``` ```php $nonce = bin2hex(random_bytes(16)); $res = json_decode(file_get_contents('https://sellmycode.net/api/license/update', false, stream_context_create(['http' => [ 'method' => 'POST', 'header' => "Content-Type: application/json\r\n", 'content' => json_encode([ 'purchase_code' => $code, 'item_id' => 12345678, 'domain' => $domain, 'activation_token' => $token, 'current_version' => MY_VERSION, 'nonce' => $nonce, ]), ]])), true); $keys = ['k1' => '5Uk3p1+J0PXzJkwS4wVFvTN9GcHpJzX5ClRI8zlI0yQ=', 'k2' => 'erOiojOdS5F/IfhPMO9gvjAvuEPVapIadTDaWU0z83o=']; // kid => key: active + standby $publicKey = base64_decode($keys[$res['kid'] ?? ''] ?? ''); if (strlen($publicKey) !== 32 || !sodium_crypto_sign_verify_detached(base64_decode($res['signature']), $res['payload'], $publicKey)) { exit('Untrusted answer'); } $answer = json_decode($res['payload'], true); if ($answer['nonce'] !== $nonce) { exit('Replayed answer'); } if ((int) $answer['item']['id'] !== 12345678 || $answer['domain'] !== $domain) { exit('Answer for another item or site'); // $domain as stored: lower case, no www. } if ($answer['code'] === 'update_available' && $answer['package']['integrity'] === 'sha256') { $zip = file_get_contents($answer['package']['download_url']); if (!hash_equals($answer['package']['sha256'], hash('sha256', $zip))) { exit('Package checksum mismatch'); } file_put_contents(__DIR__ . '/update.zip', $zip); } ``` ```json { "status": "success", "code": "update_available", "domain": "shop.example.com", "item": { "id": 12345678, "name": "My Plugin", "version": "1.3.0", "url": "https://sellmycode.net/items/my-plugin/12345678" }, "current_version": "1.2.0", "latest_version": "1.3.0", "update_available": true, "changelog": { "version": "1.3.0", "body": "Fixed …", "released_at": "2026-10-20T08:00:00+00:00" }, "package": { "download_url": "https://sellmycode.net/api/license/download/Qx7…", "expires_at": "2026-10-27T03:10:00+00:00", "max_uses": 3, "sha256": "4f9c…", "size": 1843200, "integrity": "sha256" }, "updates": { "active": true, "until": "2027-04-27T00:00:00+00:00", "lifetime": false, "renew_url": null }, "nonce": "9f3c1d7e0a2b4c6d8e0f", "issued_at": "2026-10-27T03:00:00+00:00" } ``` ## Answer codes | `code` | Meaning | `package` | |---|---|---| | `update_available` | `current_version` is older than `latest_version` | download link | | `latest` | you sent no `current_version`; here is the latest package | download link | | `up_to_date` | the site already runs the latest version | `null` | | `update_window_expired` | the buyer's update period has ended — show `updates.renew_url` | `null` | | `no_package` | the item has no downloadable file right now | `null` | Every answer above is `"status": "success"` with HTTP 200 — only `update_available` and `latest` carry a `package`. `changelog` is the latest entry only, as plain text (HTML removed, at most 4,000 characters), or `null`. Check `item.id` and `domain` against your own values after the signature and the nonce. Errors use the codes of the other licence endpoints (`invalid_code`, `not_activated`, `site_blocked`, `license_blocked`, `rate_limited`) plus `invalid_activation_token` and `item_removed`. ## The download link - `download_url` lives **10 minutes** and works **3 times**, so a broken download can be resumed. After that, call `update` again for a fresh link. - Rights are checked again when the link is used: a refund, a hold, a blocked licence, a paused site or an expired update period after the link was issued all stop the download. - The link redirects to a short-lived storage URL. Follow redirects. ## Package integrity | `integrity` | What to do | |---|---| | `sha256` | compare `sha256` (and `size`) with the downloaded file before installing | | `pending` | the checksum of a newly published file is still being computed — try again in a few minutes, or install without it at your own risk | | `unverified` | the item's file is hosted outside SellMyCode and has no checksum; we recommend not installing automatically | > **Tip:** Upload packages through the [upload API](https://sellmycode.net/api-docs/upload.md) or the item form so they are stored on SellMyCode — those always get a checksum. ## Limits - 30 calls per licence and domain per 10 minutes (shared with the other licence endpoints). - 10 package downloads per licence per hour. - Invalid links count towards the same failed-lookup budget as invalid purchase codes. --- Source: https://sellmycode.net/api-docs/licence-updates ======================================================================== # PHP SDK & WordPress Two ready-made files that do the licence work for you: activate a site, check the licence, and install updates — with every answer's signature, nonce and package checksum verified. > **Note:** The SDK only calls the public licence endpoints ([activation](https://sellmycode.net/api-docs/licence-activation.md) and [updates](https://sellmycode.net/api-docs/licence-updates.md)). Your buyers need nothing but their purchase code; you need no API token. ## Download | File | What it is | |---|---| | [sellmycode-license-sdk.zip](https://sellmycode.net/api-docs/sdk/bundle) | both files below, in a `sellmycode/` folder | | [SellMyCodeLicense.php](https://sellmycode.net/api-docs/sdk/php) | the PHP client — any PHP product | | [class-sellmycode-wp-updater.php](https://sellmycode.net/api-docs/sdk/wordpress) | WordPress plugins and themes; needs `SellMyCodeLicense.php` next to it | The files you download from this page already contain the current public key (`k1`), so answers are verified out of the box. **Requirements:** PHP 7.4 or newer, `ext-sodium` (bundled with PHP since 7.2) or `paragonie/sodium_compat` (shipped with WordPress), and `ext-curl` or `allow_url_fopen`. `SellMyCodeLicense::requirements()` lists whatever is missing. ## What it does for you - Sends a fresh `nonce` with every call and rejects answers whose signature, key id or nonce do not check out. - Keeps the `activation_token` from [activate](https://sellmycode.net/api-docs/licence-activation.md) — updates and deactivation need it. - Remembers the last signed answer and keeps the site licensed until `grace_until` when SellMyCode cannot be reached. - Downloads update packages and compares them with the signed `sha256` and `size` before handing them to you. - Refuses packages without a checksum (`integrity` other than `sha256`) unless you set `allow_unverified`. ## PHP quick start 1. Copy `SellMyCodeLicense.php` into your product and `require` it. 2. Create the client with your item ID and a storage file outside the web root. 3. Activate once, when the buyer enters their purchase code. 4. Call `isLicensed()` wherever you gate features, and `checkUpdate()` when you look for updates. ```php require __DIR__ . '/vendor/sellmycode/SellMyCodeLicense.php'; $smc = new SellMyCodeLicense([ 'item_id' => 12345678, // YOUR item's ID on SellMyCode 'purchase_code' => $settings['purchase_code'], 'storage' => __DIR__ . '/storage/smc-license.json', ]); // once, from your licence screen $answer = $smc->activate(); if (!$answer->success) { echo $answer->message; // e.g. "This licence has used all of its site slots" } // anywhere if (!$smc->isLicensed()) { exit('Please activate your licence.'); } ``` > **Warning:** The storage file holds the site's activation token. Keep it outside the public web folder, or deny access to it. ## Checking the licence `isLicensed(int $maxAge = 43200): bool` - Reuses the last verified answer for up to `$maxAge` seconds (12 hours by default) without a network call. - After that it calls `verify`. A refused licence (blocked, refunded, paused, revoked) returns `false` at once. - If SellMyCode cannot be reached, or the answer cannot be trusted, the site keeps running on the last good answer until its `grace_until`. `verify()`, `activate()` and `deactivate()` return the full [answer](#the-answer-object) when you need the details. ## Installing updates ```php $update = $smc->checkUpdate(MY_PRODUCT_VERSION); if ($update->updateAvailable) { try { $zip = $smc->downloadUpdate($update); // path of the verified .zip // unpack and install it your way, then delete $zip } catch (SellMyCodeLicenseException $e) { error_log('Update failed: ' . $e->reason . ' — ' . $e->getMessage()); } } elseif ($update->code === 'update_window_expired') { echo 'Renew your update period: ' . $update->renewUrl; } ``` Unpacking and installing stay with you: every product installs differently. Make a backup first. ## The answer object Every call returns a `SellMyCodeLicenseAnswer`. | Property | Type | Description | |---|---|---| | `success` | bool | the server answered "success" | | `code` | string | the answer code (`valid`, `activated`, `update_available`, `invalid_code`, …) or a client-side one, see below | | `message` | string \| null | the error message | | `offline` | bool | no trustworthy answer: the server was not reached, or the answer failed verification | | `status` | int | HTTP status; `0` when the server was not reached | | `data` | array | the decoded, verified payload — see [Signatures & fields](https://sellmycode.net/api-docs/licence-signatures.md) | | `get($key)` | mixed | one payload field, dots for nested keys: `get('updates.until')` | | `updateAvailable` | bool | `checkUpdate()`: a newer package can be downloaded | | `latestVersion` | string \| null | latest published version | | `package` | array \| null | `download_url`, `expires_at`, `max_uses`, `sha256`, `size`, `integrity` | | `changelog` | array \| null | `version`, `body`, `released_at` | | `renewUrl` | string \| null | where the buyer renews once the update period has ended | | `entitlement` | string \| null | activate / verify: the [entitlement token](https://sellmycode.net/api-docs/licence-entitlement.md) | Client-side codes: `offline`, `untrusted_answer` (bad signature, unknown key id or wrong nonce), `no_activation_token` (activate first), `not_configured` (no purchase code or domain), `sodium_missing`. ## Options | Option | Default | Description | |---|---|---| | `item_id` *required* | — | your item's ID | | `storage` *required* | — | a JSON file path, or `['get' => fn(): ?array, 'set' => fn(?array $state)]` to keep the state in your database | | `purchase_code` | `''` | the buyer's purchase code | | `domain` | current host | the domain to activate; `www.` is dropped | | `allow_unverified` | `false` | let `downloadUpdate()` return packages that have no checksum | | `public_keys` | keys in the file | `['kid' => 'base64 key']`, for [key rotation](https://sellmycode.net/api-docs/key-rotation.md) | | `timeout` | `15` | seconds per licence call (downloads allow 300) | | `api` | `https://sellmycode.net/api` | the API base URL | | `transport` | curl / streams | your own HTTP function: `fn($method, $url, ?string $json, ?string $sinkPath): array{status, body}` | ## Download errors `downloadUpdate()` throws `SellMyCodeLicenseException`. `$e->reason` is one of: | Reason | Meaning | |---|---| | `unverified_package` | the package has no checksum and `allow_unverified` is off | | `checksum_mismatch` | the file does not match the signed `sha256` or `size` — it was deleted | | `no_package` | the answer carries nothing to download | | `bad_package_url` | the link does not point at the licence API | | `not_writable` | the download folder is not writable | | `download_failed` | no signed answer came back | | a server code | `invalid_ticket`, `ticket_used`, `package_changed`, `not_allowed`, `update_window_expired`, `item_removed`, `rate_limited` — see [Licence updates](https://sellmycode.net/api-docs/licence-updates.md) | `$e->answer` holds the signed answer when the server sent one. ## WordPress plugins and themes Put both files in a folder of your plugin or theme and create the updater once. **Plugin** — in the plugin main file: ```php require_once __DIR__ . '/sellmycode/class-sellmycode-wp-updater.php'; new SellMyCodeWpUpdater([ 'item_id' => 12345678, 'file' => __FILE__, 'settings_page' => true, // Settings → My Plugin licence ]); ``` **Theme** — in `functions.php`: ```php require_once get_template_directory() . '/sellmycode/class-sellmycode-wp-updater.php'; new SellMyCodeWpUpdater([ 'item_id' => 12345678, 'theme' => get_template(), 'settings_page' => true, ]); ``` What the buyer gets: - **A licence screen** (with `settings_page`): they paste the purchase code and click Activate. The code is shown masked afterwards, with the update period and a Deactivate button. - **Updates in WP admin**: a new version appears under Dashboard → Updates and on the Plugins / Themes screen like any other. "Update now" and WordPress auto-updates both work. - **A verified install**: the package is fetched through the licence API at the moment of the update and checked against the signed `sha256` before WordPress unpacks it. - **Clear reasons** when an update cannot be installed: a renew link once the update period has ended, or a pointer to their SellMyCode library when the package has no checksum. Checks are cached for 6 hours; "Check again" on Dashboard → Updates refreshes them. | Option | Description | |---|---| | `item_id` *required* | your item's ID | | `file` / `theme` | the plugin main file (`__FILE__`), or the theme folder name | | `settings_page` | `true` for a screen under Settings, or a parent menu slug of your own | | `purchase_code` | a string or callable, when your own settings screen stores the code | | `name` | shown on the licence screen; defaults to the plugin or theme name | | `allow_unverified` | install packages that have no checksum | | `public_keys`, `transport` | as in the PHP client; requests use the WordPress HTTP API by default | Using your own settings screen? Pass `purchase_code`, then call `$updater->license()->activate()` when the buyer saves. `$updater->license()` is the same PHP client, so `$updater->license()->isLicensed()` gates premium features. ## Your own update server If your files live on your own server, send it an [entitlement token](https://sellmycode.net/api-docs/licence-entitlement.md) instead of the purchase code: ```php // in the product $token = $smc->entitlement(); // reused for up to 23 hours, then refreshed through verify $zip = my_http_get('https://updates.example.com/latest.zip', ['Authorization: Bearer ' . $token]); // on updates.example.com $claims = SellMyCodeLicense::verifyEntitlement($bearer, ['item_id' => 12345678]); if (!$claims || !$claims['updates']['active']) { http_response_code(403); exit; } ``` ## Lost activation token The token is issued once. A site that lost it (database restored, storage deleted) still verifies, but can neither update nor deactivate. Revoke that site under Workspace → Licenses; the buyer activates again and gets a new token. --- Source: https://sellmycode.net/api-docs/licence-sdk ======================================================================== # Entitlement tokens Already run your own update or download server? Let it trust SellMyCode licences without calling us: activate and verify answers carry an `entitlement` — a signed token, valid for 24 hours, that says which site holds which licence and whether its update period is running. > **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 1. The installation calls [activate](https://sellmycode.net/api-docs/licence-activation.md), or verify with its `activation_token`, and keeps `entitlement` from the answer. 2. When it asks YOUR server for an update, it sends the token along, e.g. `Authorization: Bearer `. 3. Your server checks the signature with the public key, then the claims: `iss`, `exp`, `item_id`, `domain`, `updates.active`. 4. 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](https://sellmycode.net/api-docs/webhooks.md#licence-events) and refuse tokens of a licence or site you were told about. ## Claims ```json { "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](https://sellmycode.net/api-docs/webhooks.md); 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](https://sellmycode.net/api-docs/licence-signatures.md#public-key). - As a JWK set, for JWT libraries: `GET /api/license/jwks` ```json { "keys": [ { "kty": "OKP", "crv": "Ed25519", "x": "…", "kid": "k1", "alg": "EdDSA", "use": "sig" } ] } ``` ## Verify on your server ```php // 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; } ``` ```node // 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'); ``` ```text 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](https://sellmycode.net/api-docs/licence-updates.md): | 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. --- Source: https://sellmycode.net/api-docs/licence-entitlement ======================================================================== # Key rotation Every answer names its key in `kid`. `GET /api/license/public-key` lists every key with a status: | status | Meaning | |---|---| | `active` | signs every answer now — exactly one key at a time | | `next` | announced, not signing yet — add it to your software now | | `retired` | no longer signs; harmless to keep, never needed again | | `revoked` | its secret may have leaked — remove it and reject answers signed with it | Keys published right now: | kid | status | public key | |---|---|---| | `k1` | active | `5Uk3p1+J0PXzJkwS4wVFvTN9GcHpJzX5ClRI8zlI0yQ=` | | `k2` | next | `erOiojOdS5F/IfhPMO9gvjAvuEPVapIadTDaWU0z83o=` | > **Important:** Ship every `next` key in your software now, next to the active one. The `next` key is a standby: its secret is kept offline, away from our servers, so that if the active key were ever exposed it can take over at once — and installations that already know it keep working with no update. 1. Planned rotation: the new key is published as "next" at least 90 days before it starts signing, and every author with a licensed item is emailed. Ship an update that knows both keys during that window. 2. On the switch date the new key becomes "active" and the old one "retired". Installations that only know the old key can no longer verify new answers; they keep running on their cached answer until its grace_until, then report unlicensed. 3. Emergency rotation, if a secret is ever exposed: the standby `next` key signs immediately and the old one is marked "revoked". Installations that embed the standby key keep working; the others fall back to their cached answer until grace_until. Authors are emailed the same day and should release an update that removes the revoked key — and adds the new standby key we then publish. 4. A kid is never reused. > **Warning:** Embed the keys in your code (a kid → key map). Never download the key at runtime and trust it — a fake server would simply hand out its own key. The public-key endpoint is for building and checking your release, not for installations. An answer whose kid you do not know is unverified: keep your cached state. --- Source: https://sellmycode.net/api-docs/key-rotation ======================================================================== # Item updates (Toolkit) Let a WordPress site keep the themes and plugins it bought here up to date. Tell us which packages are installed, get back the ones with a newer version, then pull the installable ZIP. This is what the SellMyCode Toolkit plugin uses — you only need these endpoints if you are building your own updater. > **Note:** Requires a token with the `updates:read` permission. Updates are served while the update-support period of your purchase is still running; after it ends we still tell you a newer version exists, but the file is no longer available until you renew. > **Tip:** On WordPress? Skip the code. The Toolkit plugin already wires these endpoints into the normal Themes and Plugins update screens. Install it, paste a token, and purchased items update like anything else in WordPress. [Download the plugin](https://sellmycode.net/toolkit/download) · [Installation guide](https://sellmycode.net/toolkit) ## Check for updates `POST /api/updates/check` | Parameter | Type | Description | |---|---|---| | `packages` | array | installed packages, up to 100 per call | | `packages[].slug` | string | the theme or plugin folder name | | `packages[].type` | string | theme \| plugin | | `packages[].version` | string | the version currently installed (optional) | ```bash curl "https://sellmycode.net/api/updates/check" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"packages":[{"slug":"my-theme","type":"theme","version":"1.4.0"}]}' ``` ```json { "status": "success", "checked": 1, "updates": [ { "item_id": 123, "slug": "my-theme", "type": "theme", "name": "My Theme", "installed_version": "1.4.0", "new_version": "1.6.2", "changelog": { "version": "1.6.2", "body": "Fixed ..." }, "can_download": true, "reason": null, "update_window_ends_at": "2027-01-30T10:00:00+00:00", "download_url": "https://sellmycode.net/api/updates/download/123", "renew_url": null } ] } ``` > **Note:** Only items you actually bought are returned — anything else installed on the site is ignored, so it is safe to send your whole plugin list. ## Download the installable package `GET /api/updates/download/{id}` Responds with a 302 redirect to a short-lived storage URL (valid a few minutes). Follow redirects and save the ZIP — it contains only the theme or plugin, ready to install. ```bash curl -L -o update.zip "https://sellmycode.net/api/updates/download/123" \ -H "Authorization: Bearer YOUR_API_KEY" ``` | Error code | HTTP | Meaning | |---|---|---| | `not_purchased` | 403 | this account did not buy the item | | `update_window_expired` | 403 | update support has ended — renew_url is included in the response | | `no_installable_file` | 404 | the author has not provided an installable package for this item | | `item_removed` | 410 | the item is no longer available | > **Warning:** These endpoints are limited to 60 requests per minute. A site normally needs only a few calls per day — check once, then download what changed. --- Source: https://sellmycode.net/api-docs/item-updates ======================================================================== # Webhooks Instead of polling the sales endpoint, register an HTTPS URL and we POST a signed JSON event to it the moment something happens. Manage endpoints in your workspace under **Settings → API Key → Webhooks** (up to 5, each with its own signing secret shown once at creation). | Event | Sent when | |---|---| | `sale.created` | One of your items, bundles or courses is sold | | `sale.refunded` | One of your sales is refunded or cancelled — revoke the licence on your side | | `ticket.created` | A buyer opens a support ticket about one of your items | | `ticket.replied` | A buyer or an administrator replies on a support ticket of your items (never your own replies) | | `license.activated` | A site activates a licence of one of your items (also a paused site coming back) | | `license.deactivated` | A site pauses itself, or you revoke it | | `license.blocked` | You or an administrator block a licence or one of its sites | | `license.unblocked` | You or an administrator lift such a block | | `item.update_approved` | An update of one of your items passed review and is live | | `item.update_rejected` | An update of one of your items was rejected, or expired unreviewed after 30 days | ## Delivery Each delivery is an HTTP POST with a JSON body. Respond with any 2xx status within 10 seconds; do heavy work asynchronously. Failed deliveries are retried 3 times (after 1 minute, 15 minutes and 1 hour). After 10 consecutive failures — or a 410 Gone response — the endpoint is disabled automatically and you are notified. | Header | Description | |---|---| | `X-SMC-Event` | The event name, e.g. sale.created | | `X-SMC-Delivery` | Unique delivery ID (UUID) — deduplicate retries with it | | `X-SMC-Signature` | `t=,v1=` — HMAC-SHA256 signature (see below) | ```json { "id": "1c2f6a7e-9d31-4c3e-8f5b-2d9f8f4f1a10", "event": "sale.created", "created_at": "2026-07-18T10:30:00+00:00", "data": { "sale_id": 981, "purchase_code": "8f14e45f-ce95-41d8-a2b6-72e5f13d81a7", "type": "item", "item": { "id": 123, "name": "My Theme" }, "buyer": "johndoe", "license_type": "Regular", "price": 29.0, "earning": 23.2, "currency": "USD", "date": "2026-07-18T10:30:00+00:00" } } ``` Support ticket events carry the ticket and the new message — see [Support tickets](https://sellmycode.net/api-docs/support-tickets.md): ```json { "id": "6b1d…", "event": "ticket.replied", "created_at": "2026-10-24T08:12:00+00:00", "data": { "ticket_id": 812, "subject": "Webhook not firing after update", "item": { "id": 22314, "name": "Perfex Connect" }, "buyer": "johndoe", "status": "open", "escalated": false, "message": { "id": 5011, "from": "buyer", "body": "Since 1.1.0 the Zapier hook…", "created_at": "2026-10-24T08:12:00Z" }, "url": "https://sellmycode.net/workspace/support/…", "api_url": "https://sellmycode.net/api/tickets/812" } } ``` ## Licence events The `license.*` events let a self-hosted update server react at once instead of waiting for an [entitlement token](https://sellmycode.net/api-docs/licence-entitlement.md) to expire. New endpoints must tick them; existing endpoints keep the events they chose. ```json { "id": "0e4c…", "event": "license.blocked", "created_at": "2026-10-27T04:02:42+00:00", "data": { "purchase_code_hash": "3c9d…e1f2", "purchase_code_hint": "…81a7", "item": { "id": 123, "name": "My Script" }, "license_type": "Regular", "buyer": "johndoe", "scope": "site", "domain": "customer-site.com", "by": "author", "reason": "Running on a reseller's demo server", "activation_limit": 2, "activations_used": 1, "date": "2026-10-27T04:02:42+00:00" } } ``` | Field | Description | |---|---| | `scope` | `site` — one domain; `licence` — the whole purchase code (then `domain` is null) | | `domain` | the site, lower case, without `www.` | | `by` | `site` (the installation, through the licence API), `author` or `admin` | | `state` | `license.activated`: `activated` or `reactivated` · `license.deactivated`: `paused` (the site keeps its slot) or `revoked` (slot freed) | | `reason` | `license.blocked` only: the reason given when blocking | | `purchase_code_hash` | SHA-256 of the purchase code, lowercase hex — match it against `hash('sha256', $code)` on your side; `license.*` events never carry the code itself, because the code is what activates licences | | `purchase_code_hint` | the last four characters of the code, for logs and support screens | | `activation_limit` / `activations_used` | the licence's slots after the change; limit null = unlimited | ## Verifying the signature Compute HMAC-SHA256 over the string `timestamp.rawBody` with your signing secret and compare it (constant-time) to the v1 value. Reject deliveries whose timestamp is older than about 5 minutes to prevent replays. ```php $secret = 'whsec_...'; // from Settings → API Key → Webhooks $body = file_get_contents('php://input'); $header = $_SERVER['HTTP_X_SMC_SIGNATURE'] ?? ''; parse_str(str_replace(',', '&', $header), $sig); // ['t' => ..., 'v1' => ...] $expected = hash_hmac('sha256', $sig['t'] . '.' . $body, $secret); if (!hash_equals($expected, $sig['v1'] ?? '') || abs(time() - (int) $sig['t']) > 300) { http_response_code(400); exit; } http_response_code(200); // ack fast, process async ``` ```node // Express: use express.raw() so the RAW body is available for the HMAC const crypto = require('crypto'); const SECRET = 'whsec_...'; // from Settings → API Key → Webhooks app.post('/webhooks/sellmycode', express.raw({ type: 'application/json' }), (req, res) => { const header = req.get('X-SMC-Signature') || ''; const sig = Object.fromEntries(header.split(',').map(p => p.split('='))); const expected = crypto.createHmac('sha256', SECRET) .update(sig.t + '.' + req.body.toString('utf8')).digest('hex'); const fresh = Math.abs(Date.now() / 1000 - Number(sig.t)) < 300; const valid = sig.v1 && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(sig.v1)); if (!valid || !fresh) return res.sendStatus(400); const event = JSON.parse(req.body); // { id, event, created_at, data } res.sendStatus(200); // ack fast, process async }); ``` ```python # Flask — request.get_data() is the RAW body needed for the HMAC import hmac, hashlib, time from flask import Flask, request SECRET = 'whsec_...' # from Settings → API Key → Webhooks @app.route('/webhooks/sellmycode', methods=['POST']) def webhook(): header = request.headers.get('X-SMC-Signature', '') sig = dict(p.split('=', 1) for p in header.split(',') if '=' in p) body = request.get_data() # bytes, unparsed expected = hmac.new( SECRET.encode(), (sig.get('t', '') + '.').encode() + body, hashlib.sha256 ).hexdigest() fresh = abs(time.time() - float(sig.get('t', 0))) < 300 if not (hmac.compare_digest(expected, sig.get('v1', '')) and fresh): return '', 400 event = request.get_json() # { id, event, created_at, data } return '', 200 # ack fast, process async ``` ```ruby # Rails / Rack — request.body.read is the RAW body needed for the HMAC SECRET = 'whsec_...' # from Settings → API Key → Webhooks def webhook header = request.headers['X-SMC-Signature'].to_s sig = header.split(',').to_h { |p| p.split('=', 2) } body = request.body.read expected = OpenSSL::HMAC.hexdigest('SHA256', SECRET, "#{sig['t']}.#{body}") fresh = (Time.now.to_i - sig['t'].to_i).abs < 300 valid = sig['v1'] && ActiveSupport::SecurityUtils.secure_compare(expected, sig['v1']) return head :bad_request unless valid && fresh event = JSON.parse(body) # { id, event, created_at, data } head :ok # ack fast, process async end ``` ## Missed deliveries Every event is tried 4 times in about 75 minutes (once, then after 1 minute, 15 minutes and 1 hour). After that it is dropped — there is no replay. Treat webhooks as a fast signal and reconcile now and then with the API: | Events | Reconcile with | |---|---| | `sale.created`, `sale.refunded` | [`GET /api/sales?from=…`](https://sellmycode.net/api-docs/sales.md) — the `sale_status` of each sale | | `ticket.created`, `ticket.replied` | [`GET /api/tickets?status=needs_reply`](https://sellmycode.net/api-docs/support-tickets.md) | | `item.update_approved`, `item.update_rejected` | [`GET /api/items/{id}/versions`](https://sellmycode.net/api-docs/review-state.md) | | `license.*` | refuse what verify refuses — an [entitlement token](https://sellmycode.net/api-docs/licence-entitlement.md) expires within 24 hours anyway | ## Review events `item.update_approved` and `item.update_rejected` tell a release pipeline the review result of an update — one sent through the [upload API](https://sellmycode.net/api-docs/upload.md), [`PATCH`](https://sellmycode.net/api-docs/update-item.md) or the Workspace form — so it no longer has to poll. Updates that trusted authors publish at once fire nothing: the API answer already says `mode: "published"`. ```json { "id": "5a0e…", "event": "item.update_rejected", "created_at": "2026-10-27T09:00:00+00:00", "data": { "item": { "id": 123, "name": "My Script" }, "update_id": 846, "version": "2.5.0", "package_changed": true, "by": "reviewer", "reason": "The demo link is broken.", "submitted_at": "2026-10-26T08:00:00+00:00", "date": "2026-10-27T09:00:00+00:00", "api_url": "https://sellmycode.net/api/items/123/versions" } } ``` | Field | Description | |---|---| | `update_id` | the `update_id` you got from the upload or `PATCH` answer | | `version` | approved: the version now live · rejected: the version the update carried, when it set one | | `package_changed` | the update replaced a file | | `by` | `admin`, `reviewer`, or `auto` — rejected because nobody reviewed it within 30 days | | `reason` | rejected only: why | > **Note:** Endpoints must be public HTTPS URLs. Deliveries never follow redirects. Use the `X-SMC-Delivery` ID to deduplicate — a retry after a timeout can arrive even though you already processed the original. --- Source: https://sellmycode.net/api-docs/webhooks ======================================================================== # API changelog New endpoints and changes that affect integrations. Existing fields keep their name and type; new fields may appear at any time — ignore fields you do not know. ## 2026-11-14 — Item media - [Item media](https://sellmycode.net/api-docs/item-media.md): `GET /api/items/{id}/media`, `POST /api/items/{id}/media/uploads` and `PUT /api/items/{id}/media` change the thumbnail, the preview image and the screenshot gallery (keep, add, remove, reorder) in one reviewed change. Uses the existing `items:read`, `items:upload` and `items:write` scopes. ## 2026-10-31 - **Legacy API keys retired.** The single plaintext key from the account page and the `api_key` query/body parameter no longer authenticate (`401 legacy_key_retired`). Create a scoped token under Workspace → Settings → API key and send it as `Authorization: Bearer`. - `license.*` [webhooks](https://sellmycode.net/api-docs/webhooks.md) carry `purchase_code_hash` (SHA-256) and `purchase_code_hint` instead of the purchase code — the code activates licences, so it stays out of third-party endpoints. `sale.*` events are unchanged. - Price changes through `items:price` are measured against the price the item had **24 hours before the first API change**, not the live price: a chain of small steps that adds up to more than ±30 % now needs the same e-mail confirmation as one big step. - Webhook endpoints must use port 443 or 8443. - One upload may declare at most 10 GB in flight per author; quota checks are serialised, so parallel `POST /uploads` cannot overshoot them. ## 2026-10-29 - `replace_pending: true` on [uploads](https://sellmycode.net/api-docs/upload.md) and [`PATCH`](https://sellmycode.net/api-docs/update-item.md) replaces the update that is waiting for review — ship a hotfix without waiting for the first review. See [Hotfixes](https://sellmycode.net/api-docs/publishing.md#hotfixes-while-an-update-waits). - A standby signing key `k2` is published as `next`. Embed it next to `k1` — the [SDK](https://sellmycode.net/api-docs/licence-sdk.md) download already does. See [Key rotation](https://sellmycode.net/api-docs/key-rotation.md). ## 2026-10-27 — Review webhooks - Webhook events [`item.update_approved` and `item.update_rejected`](https://sellmycode.net/api-docs/webhooks.md#review-events): the review result of an update, without polling `/versions`. - Licence code samples (and the PHP SDK, 1.1.1) also check that `item.id` and `domain` in a signed answer are yours. ## 2026-10-27 — Licence updates - [`POST /api/license/update`](https://sellmycode.net/api-docs/licence-updates.md) tells an activated site whether a newer version exists and, while its update period runs, returns a 10-minute download link with the package's SHA-256. - [PHP SDK & WordPress updater](https://sellmycode.net/api-docs/licence-sdk.md): ready-made client for activation, licence checks and verified updates; WordPress plugins and themes update from WP admin. - activate and verify answers carry an [`entitlement`](https://sellmycode.net/api-docs/licence-entitlement.md) token (JWT, EdDSA, 24 hours) that your own update server checks offline; keys also at `GET /api/license/jwks`. - Webhook events [`license.activated`, `license.deactivated`, `license.blocked`, `license.unblocked`](https://sellmycode.net/api-docs/webhooks.md#licence-events). ## 2026-10-31 — AI Support - **Workspace → AI Support:** answer item tickets (and, optionally, pre-sale messages) with your own Claude, ChatGPT or Gemini key — Draft only or Auto reply, per-item FAQs, spending limits, activity log. Free; you pay your provider. ## 2026-10-24 — Support tickets - [Support tickets API](https://sellmycode.net/api-docs/support-tickets.md): scopes `tickets:read`, `tickets:reply`, `tickets:note`; list, read, reply, close / reopen, internal notes. - Webhook events `ticket.created` and `ticket.replied`. - Guide: [AI support assistant](https://sellmycode.net/api-docs/ai-support.md). ## 2026-10-24 - **Uploads straight to storage.** `transfer=direct` on [uploads](https://sellmycode.net/api-docs/upload.md): each part is PUT to a signed storage URL, much faster from far away. Relay stays the default. - [`GET /api/uploads`](https://sellmycode.net/api-docs/upload.md#list-and-cancel-uploads) lists your unfinished uploads; `DELETE /api/items/{id}/uploads/{upload}` cancels one. - Upload limits: 10 GB per author per 24 hours, 2 open uploads, and a one-day pause after 5 failed or abandoned uploads. - Updates left unreviewed for 30 days are rejected automatically. - [Author API policy](https://sellmycode.net/api-docs/policy.md) published; tokens with write permissions require accepting it. ## 2026-10-24 — Author write API - New scopes `items:write`, `items:price`, `items:upload`. The legacy single API key can never write. - [`PATCH /api/items/{id}`](https://sellmycode.net/api-docs/update-item.md), [`POST /api/items/{id}/changelogs`](https://sellmycode.net/api-docs/add-changelog.md), [`GET /api/items/{id}/versions`](https://sellmycode.net/api-docs/review-state.md). - Price moves over 30% wait for the author's email confirmation. ## 2026-10-16 - Licence slots: deactivate pauses a site and keeps its slot; only the author frees slots. Answers carry `slot_bound` and `slot_released`. ## 2026-10-09 - Licence answers are Ed25519-signed envelopes with a required `nonce`; `activate` returns an `activation_token` that `deactivate` requires. ## 2026-07-18 - [Public catalog](https://sellmycode.net/api-docs/catalog.md), [My purchases](https://sellmycode.net/api-docs/purchases.md), [Balance](https://sellmycode.net/api-docs/balance.md) and [sale webhooks](https://sellmycode.net/api-docs/webhooks.md). Rate limits are counted per token. --- Source: https://sellmycode.net/api-docs/changelog