# Publishing a plugin

**The plugin API is experimental**, except for the
[v1 data source contract](/documentation/plugins/data-sources): for capabilities outside that
contract, say so in your README and pin the version of `recit` your plugin peers on
([Stability](/documentation/reference/stability#experimental)).

## Name and keyword

- The package is `recit-plugin-<name>` or `@scope/recit-plugin-<name>`.
- `package.json` carries the `recit-plugin` keyword, and peers on `recit` and `zod`.
- Its README says what it brings, and, for an AI plugin, where your content goes.

## Without showing the source

- **Publish `dist/` alone.** The `files` field of `package.json` lists the built code, the README
  and the license. No `src/`, no tests, no fixtures.
- **Minify, without sourcemaps.** A sourcemap often holds the whole source (`sourcesContent`). Turn
  them off for the release.
- **Obfuscation is possible, but it is not a protection.** It slows reading down, it does not stop
  it. Récit does not provide it.
- **A private registry or tarballs.** A private package on npm, GitHub Packages, a registry of your
  own, or a `.tgz` archive sent to the customer.
- **A proprietary license.** `"license": "SEE LICENSE IN LICENSE.md"` (or `UNLICENSED`), and your
  text in `LICENSE.md`.
- **For a real secret, a thin client.** Everything that runs on the user's machine can be read, and
  every component sent to the browser is public. Keep the prompts, the logic and the data on your
  server: the plugin is only a client of your API (`serverProvider` and `createAiServer` of
  `@recit/ai`), with a license key.

## Selling a plugin

Récit records who holds a licence for your plugin; you keep serving the plugin itself. The plugin's
archive stays in your private registry or with your tarballs, and your server asks Récit's API
whether the customer's account holds the licence before it serves anything.

1. **The customer creates a personal token** on their account page, with the `licenses:read` scope,
   and gives it to your registry (an `.npmrc` entry, or the header of their download).
2. **Your server asks for the licence** with that token, for your product and your plugin:

   ```http
   GET /v1/licenses/<productId>/<pluginId>
   Authorization: Bearer rct_…
   ```

   `GET /v1/licenses/<productId>` asks for a licence of the whole product instead.

3. **`200` serves the archive.** The answer is
   `{ license: { productId, resourceId, plan, organizationId, endsAt } }`, never cached
   (`Cache-Control: no-store`); `endsAt` is `null` for a licence without an end.
4. **`404` refuses it.** The account holds no such licence, or the product does not exist: the
   answer never says which. `401` means the token is missing, revoked, expired or lacks
   `licenses:read`.

Rules that hold whatever you sell:

- **A build never depends on this check.** Ask at download time, never from the plugin's code at
  build or render time: an installed plugin keeps working offline and when Récit's API is out of
  reach.
- **The plugin never imports a package of the platform.** It talks to the API over HTTP only
  (`pnpm check` refuses a plugin that depends on one).
- **The token is the customer's.** Never store it beyond the request, never log it.

The route belongs to the [account API](/documentation/reference/account) (licences, **available**).
