# 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
