---
url: https://docs.sunlicense.com/api/management.md
---
# Management API

Used by the dashboard, authenticated with a **session token** from `POST /api/v1/auth/login` or a [personal access token](/api/overview#personal-access-tokens) (`slp_…`). Each route needs a [permission](/guide/team-and-roles); the gateway rejects anything your role (and a token's scopes) does not allow.

## Auth

| Method | Path | Body |
|---|---|---|
| GET | `/api/v1/auth/config` | No auth. `{ signupMode, turnstileSiteKey }`: `approval` while new organizations wait on the sign-up whitelist |
| POST | `/api/v1/auth/signup` | `{ companyName, email, password, turnstileToken? }` |
| POST | `/api/v1/auth/login` | `{ email, password, turnstileToken? }` → `{ token, user }` |
| GET | `/api/v1/auth/me` | Current user, role, permissions, plan and `tenantStatus` |
| PUT | `/api/v1/auth/me/avatar` | `{ style: "open-peeps", seed, options? }`: your profile picture, drawn with [DiceBear](https://www.dicebear.com/styles/open-peeps/) from these values. `options` takes Open Peeps' option names with lists of plain values (`{"head":["afro"]}`) or 0–100 probabilities. Not with a personal access token |
| DELETE | `/api/v1/auth/me/avatar` | Back to the default picture, drawn from your member id |
| POST | `/api/v1/auth/password` | `{ currentPassword, newPassword }` |
| POST | `/api/v1/auth/resend-verification` | Sends the "confirm your email" link again (at most once a minute) |
| GET | `/api/v1/auth/tokens` | Your [personal access tokens](/api/overview#personal-access-tokens) (never the token itself) |
| POST | `/api/v1/auth/tokens` | `{ name, scopes: ["licenses.read", …], expiresInDays? }` (1–366, or `null` for no expiry) → includes `token`, once. Scopes must be permissions your role has; at most 20 active tokens each |
| DELETE | `/api/v1/auth/tokens/{id}` | Revokes one of your tokens |

The three `/auth/tokens` routes need a session token: a personal access token can't create, list or revoke tokens.

Public (no session; the token from the emailed link is the credential):

| Method | Path | Body |
|---|---|---|
| POST | `/api/v1/auth/password-reset` | `{ email }` → always `202`, whether or not the address has an account |
| POST | `/api/v1/auth/password-reset/confirm` | `{ token, newPassword }` → `204`; `400` invalid or used, `410` expired |
| POST | `/api/v1/auth/verify-email` | `{ token }` → `204` |
| GET | `/api/v1/auth/invitations/{token}` | → `{ organization, email, name, role, expiresAt, existingAccount }` |
| POST | `/api/v1/auth/invitations/{token}/accept` | No account yet: `{ name?, password }` → `{ token, user }` (signed in); `409` with `code: "account_exists"` if the address already has one |
| POST | `/api/v1/auth/invitations/{token}/join` | Existing account: `{ password, turnstileToken? }` → `{ token, user }` signed in to the new organization; wrong passwords count toward the sign-in lockout |

While an organization waits on the sign-up whitelist (`tenantStatus: PENDING`), its members can sign in and call `GET /auth/me`, `POST /auth/password`, `POST /auth/resend-verification` and the account routes below except leaving; every other route answers `403` with `code: "pending_approval"` (or `"signup_rejected"` once it was turned down). Sign-up, and sign-in after three failed attempts for an account, need a [Cloudflare Turnstile](https://developers.cloudflare.com/turnstile/) answer when the server has one configured; without it they answer `400` with `code: "captcha_required"`.

Sign-up also refuses: an address whose inbox already has an account under another spelling (`409`, same as an exact match: lower case, without a `+tag`, and for Gmail without dots), an address at a throwaway-inbox service (`400`, `code: "disposable_email"`), an organization name with a web or email address in it (`400`, `code: "organization_name_link"`, also on `PATCH /org`), and more than three sign-ups a day from one network (`429`, `code: "signup_limited"`, with `Retry-After`). When sign-ups don't need approval, a new organization's `GET /auth/me` has `emailConfirmationRequired: true` until its Owner opens the confirmation link: it can read everything and use `/auth/*`, `/account/*` and billing, but every other write answers `403` with `code: "email_unverified"`.

## Your account across organizations

One login (email and password) can be a member of several organizations. A session token belongs to one of them; switching issues a new token for another. Any signed-in member can call these with a session token (personal access tokens can't: a token acts in one organization); they only ever act on the caller's own account.

| Method | Path | Body / answer |
|---|---|---|
| GET | `/api/v1/account/organizations` | → `[{ tenantId, name, role, owner, active, tenantStatus, current, joinedAt }]` |
| POST | `/api/v1/account/switch` | `{ tenantId }` → `{ token, user }` for that organization; `404` if you aren't an active member there. Sign-in lands in the organization used last |
| DELETE | `/api/v1/account/organizations/{tenantId}` | Leave it → `204`; `409` for its last active Owner or your only organization |
| POST | `/api/v1/account/invitations/{token}/join` | Accept an invitation sent to this session's email → `{ token, user }` in the new organization; `403` if it was sent to another address |

## Products and policies

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/products` | `products.read` |
| POST | `/api/v1/products` `{ name, code?, description? }` | `products.write` |
| GET | `/api/v1/products/{id}` | `products.read` |
| GET | `/api/v1/products/{id}/setup` → `{ productId, parts: [{ id, selected, available, feature, status, since }], done, total, lastReportAt }`, the product's **Setup**: `status` is `DONE`, `WAITING` (selected, the setup prompt finished, your app hasn't shown it working yet) or `NOT_STARTED` | `products.read` |
| PUT | `/api/v1/products/{id}/setup` `{ parts: ["license", "analytics", …] }`: the parts switched on, sent whole. `license` is always on; a part whose requirement is off goes off too (`tamper` needs `unlock`, `charts` needs `analytics`) | `products.write` |
| POST | `/api/v1/products/{id}/setup/report` `{ done: ["notice", "portal-link"] }`: the parts only your code knows about (what `sunlicense setup report` sends); the others tick by themselves | `products.write` |
| GET | `/api/v1/policies?productId=` | `products.read` |
| POST | `/api/v1/policies` `{ productId, name, type, maxMachines?, durationDays?, code?, maxIps?, ipReleaseDays? }` | `products.write` |
| PATCH | `/api/v1/policies/{id}` `{ name?, type?, maxMachines?, durationDays?, code?, maxIps?, ipReleaseDays? }` (`maxIps: 0` removes the IP limit) | `products.write` |
| GET | `/api/v1/products/{id}/deletion` · `/api/v1/policies/{id}/deletion` → `{ policies, licenses, activeLicenses }`, what deleting it takes along | `products.read` |
| DELETE | `/api/v1/products/{id}` · `/api/v1/policies/{id}` → the [trash](#trash) entry. A product takes its policies and licenses, a policy its licenses | `products.write` |

A policy's `code` (up to 12 letters and digits, stored upper-case; `""` removes it) is what `{POLICY}` shows in [license key designs](/guide/key-designs).

## License key designs

What new license keys look like ([guide](/guide/key-designs)).

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/key-designs` | `products.read` |
| POST | `/api/v1/key-designs/preview` `{ template, productId?, policyId? }` → `{ template, examples, randomCharacters, maxLength }` | `products.read` |
| POST | `/api/v1/key-designs` `{ name, template, makeDefault? }` | `products.write` |
| PATCH | `/api/v1/key-designs/{id}` `{ name?, template? }` | `products.write` |
| DELETE | `/api/v1/key-designs/{id}` | `products.write` |
| POST | `/api/v1/key-designs/{id}/default` | `products.write` |
| DELETE | `/api/v1/key-designs/default` | `products.write` |

A template that breaks a rule is `400` with the reason. Creating, editing and choosing a default need a plan with **Custom license key designs** (`403` with `code: plan_limit` otherwise); previews and deletes work on every plan.

## Licenses

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/licenses?productId=&status=` | `licenses.read` |
| POST | `/api/v1/licenses` `{ policyId, customerEmail, customerName? }` or `{ policyId, customerId }` | `licenses.write` |
| GET | `/api/v1/licenses/{id}` | `licenses.read` |
| POST | `/api/v1/licenses/{id}/suspend` · `/reinstate` · `/revoke` | `licenses.write` |
| POST | `/api/v1/licenses/{id}/rotate` → the license with its new key, masked. Same license and machines; the old key is refused from then on and the customer is emailed the new one | `licenses.write` |
| GET | `/api/v1/licenses/{id}/file` (offline license) | `licenses.read` |
| GET | `/api/v1/signing-key` | `licenses.read` |
| GET | `/api/v1/activations?licenseId=` | `licenses.read` |
| POST | `/api/v1/activations/{id}/deactivate` | `licenses.write` |
| GET | `/api/v1/activations/ips?licenseId=` (the license's IP limit, addresses in use and freed) | `licenses.read` |
| POST | `/api/v1/activations/ips/{id}/release`, `/api/v1/activations/ips/release?licenseId=` (one, all) | `licenses.write` |
| GET | `/api/v1/activations/addresses?licenseId=` (every address the license passed a check from in the last 90 days, with counts for 24 hours, 7 days and 90 days; any policy) | `licenses.read` |
| GET | `/api/v1/licenses/{id}/deletion` → `{ policies, licenses, activeLicenses }` | `licenses.read` |
| DELETE | `/api/v1/licenses/{id}` → the [trash](#trash) entry | `licenses.write` |

Every license has a `customerId`; `customerEmail`/`customerName` are what it was issued to.

## Customers

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/customers?q=&status=ACTIVE\|BLOCKED&page=&size=` → `{ items, total, page, size }`. `q` matches email or name, or exactly a Discord id, a marketplace buyer id or the start of a key | `licenses.read` |
| POST | `/api/v1/customers` `{ email?, name?, notes? }` | `licenses.write` |
| GET | `/api/v1/customers/{id}` → `{ customer, licenses, purchases }` | `licenses.read` |
| PATCH | `/api/v1/customers/{id}` `{ email?, name?, notes?, discordUserId? }` (`""` clears a field) | `licenses.write` |
| POST | `/api/v1/customers/{id}/block` · `/unblock` | `licenses.write` |
| POST | `/api/v1/customers/{id}/merge` `{ customerId }` (that customer is merged into this one and deleted) | `licenses.write` |
| GET | `/api/v1/customers/{id}/deletion` → `{ policies, licenses, activeLicenses }` | `licenses.read` |
| DELETE | `/api/v1/customers/{id}` → the [trash](#trash) entry; their licenses go with them | `licenses.write` |

## Trash

Deleting a product, policy, license or customer moves it to the trash with everything that hangs off it, as one deletion
named by the item you deleted. Its licenses stop working at once (validation answers `NOT_FOUND`, as for a key that
doesn't exist) and nobody is emailed. A deletion can be restored for 30 days; then it is deleted for good. Lists, counts
and plan limits leave trashed items out; a trashed license's key is never given to a new license.

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/trash` → `[{ type, id, name, detail, productId, contains: { products, policies, licenses, customers }, deletedAt, deletedBy, purgeAfter }]`, newest first; only the types you may read | any member |
| POST | `/api/v1/trash/{type}/{id}/restore` (`type`: `products`, `policies`, `licenses` or `customers`) → the entry | `products.write` for products and policies, `licenses.write` for licenses and customers |
| DELETE | `/api/v1/trash/{type}/{id}` → `{ products, policies, licenses, customers }` deleted for good | `org.manage` |

Only the item you deleted can be restored, with what went with it. Restoring answers `409` while something it belongs to
is still in the trash (restore the product before its license), when another product took its code, another policy its
name or another customer its email in the meantime, or when your plan's limits have no room for it.

## API keys

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/api-keys` | `api_keys.read` |
| POST | `/api/v1/api-keys` `{ name }` → includes the key, once | `api_keys.write` |
| DELETE | `/api/v1/api-keys/{id}` | `api_keys.write` |

## Organization and team

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/org` (plan, limits, usage) | any member |
| PATCH | `/api/v1/org` `{ name }` | `org.manage` |
| GET | `/api/v1/org/members` | `staff.read` |
| PATCH | `/api/v1/org/members/{id}` `{ roleId?, status? }` | `staff.write` |
| POST | `/api/v1/org/members/{id}/sign-out` (ends the member's sessions; they sign in again) | `staff.write` |
| GET | `/api/v1/org/invitations` (pending and expired) | `staff.read` |
| POST | `/api/v1/org/invitations` `{ email, name?, roleId }` → includes the invite `link`, once | `staff.write` |
| POST | `/api/v1/org/invitations/{id}/resend` → new `link` | `staff.write` |
| DELETE | `/api/v1/org/invitations/{id}` | `staff.write` |
| GET | `/api/v1/org/roles` | `staff.read` |
| POST · PUT · DELETE | `/api/v1/org/roles[/{id}]` `{ name, description?, permissions[] }` | `staff.write` |

## Marketplace integrations

See [Marketplace integrations](/integrations/) for what each store does.

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/integrations/providers` (the catalog: fields, product ID label, patterns) | `integrations.read` |
| GET | `/api/v1/integrations` · `/api/v1/integrations/{id}` | `integrations.read` |
| POST | `/api/v1/integrations` `{ provider, name, settings?, secrets?, mappings: [{ externalProductId, policyId }], issueMode? }` (`issueMode`: `AUTO`, the default, or `AUTOMATIONS` to [let automations decide](/integrations/#let-automations-decide), which makes `mappings` optional) | `integrations.write` |
| PATCH | `/api/v1/integrations/{id}` `{ name?, enabled?, settings?, secrets?, mappings?, issueMode? }` (secrets merge; mappings replace) | `integrations.write` |
| DELETE | `/api/v1/integrations/{id}` (issued licenses stay) | `integrations.write` |
| GET | `/api/v1/integrations/{id}/secrets` | `integrations.write` |
| POST | `/api/v1/integrations/{id}/rotate-token` (new hook/redeem URL) | `integrations.write` |
| GET | `/api/v1/integrations/{id}/events?limit=50` | `integrations.read` |

`externalProductId` `*` (or empty) matches every product. The view's `hookPath` and `redeemPath` are
the public URLs (`hookPath` on the API host, `redeemPath` on the dashboard host).

Public, no credentials (the token in the path names the integration; each marketplace request is checked
against its own signature or secret):

| Method | Path | Called by |
|---|---|---|
| POST | `/api/v1/integrations/hooks/{token}` | The marketplace (webhooks, placeholders) |
| GET | `/api/v1/integrations/redeem/{token}` | Redeem page: store name, products, what to enter |
| POST | `/api/v1/integrations/redeem/{token}` `{ proof, email? }` → `{ status, licenses: [{ key, status, expiresAt, product, policy }] }` | Redeem page |

## Access rules

Blacklists and exclusions ([guide](/guide/access-rules)). `kind` is `BLACKLIST` or `EXCLUSION`; `type` is `IP` (an address or CIDR range, IPv4 or IPv6), `HWID` (a machine id as your app sends it), `COUNTRY` (ISO code, blacklists only) or `CUSTOMER` (a customer id, blacklists only); `scope` is `ORG` (default), `PRODUCT` or `LICENSE` with `scopeId`.

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/access-rules?kind=&type=&scopeId=` | `licenses.read` |
| GET | `/api/v1/access-rules/{id}` | `licenses.read` |
| POST | `/api/v1/access-rules` `{ kind, type, value, scope?, scopeId?, note?, ignoreStatus?, expiresAt? }` | `licenses.write` |
| PATCH | `/api/v1/access-rules/{id}` `{ note?, ignoreStatus?, expiresAt?, clearExpiry? }` | `licenses.write` |
| DELETE | `/api/v1/access-rules/{id}` | `licenses.write` |
| POST | `/api/v1/access-rules/import` `{ rules: [ … ] }` (up to 1,000; every row or none, existing rules skipped) → `{ created, skipped, rules }`, or 400 `{ errors: [{ row, message }] }` | `licenses.write` |
| GET | `/api/v1/access-rules/my-ip` → `{ ip }` (your address as validation sees it, for "Exclude my current IP") | `licenses.read` |
| GET | `/api/v1/access-rule-hits` → `[{ ruleId, hits, lastHitAt }]` | `licenses.read` |

`ignoreStatus` (exclusions only) lets suspended and expired licenses through for that rule; revoked ones stay revoked. A duplicate rule is `409`; a product, license or customer that isn't yours is `404`. Rules count against your plan's **access rules** limit and country rules need a plan with **Country blacklist** (`403` with `code: plan_limit` otherwise); enforcement never depends on the plan.

## Analytics

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/stats/validation/report?range=24h\|7d\|30d&productId=` | `analytics.read` |
| GET | `/api/v1/stats/licensing/report?range=24h\|7d\|30d` | `analytics.read` |
| GET | `/api/v1/stats/validation/geo?hours=24` | `analytics.read` |

`productId` (optional) narrows the check report to one product's licenses. Free keeps the last 7 days: the licensing
report answers `403` with `code: plan_limit` and `limit: analytics_report_days` for `range=30d`.

## Tasks and obfuscation

[Code obfuscation](/guide/obfuscation) runs as a server-side task. Read the engines and your profiles, then start a run and drive it through the generic task endpoints.

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/obfuscation/engines` → `{ languages, engines: [{ id, language, displayName, options: [{ key, label, type, defaultValue, help }] }] }` | `tasks.read` |
| POST | `/api/v1/obfuscation/engines/preview` `{ engine, options }` → `{ config }` (the raw config those options generate) | `tasks.read` |
| GET | `/api/v1/obfuscation/usage` → `{ used, limit, allowed }` (this month against your plan) | `tasks.read` |
| GET | `/api/v1/obfuscation/profiles`, `GET /api/v1/obfuscation/profiles/{id}` | `tasks.read` |
| POST | `/api/v1/obfuscation/profiles` `{ name, engine, mode, productId?, options?, rawConfig? }`; `PUT`/`DELETE /api/v1/obfuscation/profiles/{id}` | `tasks.write` |
| POST | `/api/v1/obfuscation/runs` `{ title?, profileId? }` or `{ title?, engine, mode, options?, rawConfig? }` → a draft task | `tasks.write` |

A run returns a draft `obfuscate.*` task; `profileId` copies the profile's settings into it, so later edits never change a past run. Then, with the [tasks API](#tasks):

1. `POST /api/v1/tasks/{id}/files` `{ slot: "input", name, size, contentType }` → a presigned upload; `PUT` the bytes to it, then `POST /api/v1/tasks/{id}/files/{fileId}/complete`.
2. `POST /api/v1/tasks/{id}/submit`.
3. Follow it: `GET /api/v1/tasks/{id}/events` (server-sent `status`, `log` and `end`), or poll `GET /api/v1/tasks/{id}` and `GET /api/v1/tasks/{id}/logs?after=`.
4. On success, download each output (the obfuscated file, `mapping.txt`, `report.txt`): `GET /api/v1/tasks/{id}/files/{fileId}/download` → a presigned link.

Obfuscation needs the **obfuscation** feature (every plan: 3 runs a month on Free, 20 on Lite, 100 on Standard) and counts against the monthly obfuscation limit (`403` with `code: plan_limit` otherwise).

### Tasks

| Method | Path | Permission |
|---|---|---|
| GET | `/api/v1/tasks?open=&page=&size=`, `GET /api/v1/tasks/{id}`, `GET /api/v1/tasks/types`, `GET /api/v1/tasks/usage` | `tasks.read` |
| GET | `/api/v1/tasks/{id}/events` (SSE), `GET /api/v1/tasks/{id}/logs?after=` | `tasks.read` |
| POST | `/api/v1/tasks` `{ type, title?, inputs }`, `/api/v1/tasks/{id}/submit`, `/api/v1/tasks/{id}/cancel` | `tasks.write` |
| POST | `/api/v1/tasks/{id}/files` `{ slot, name, size, contentType }`, `/api/v1/tasks/{id}/files/{fileId}/complete`; `DELETE` the file | `tasks.write` |
| GET | `/api/v1/tasks/{id}/files/{fileId}/download` → a presigned link | `tasks.read` |
