管理 API Key
當你希望自己的訂單系統自動簽發授權,或從伺服器讀取授權資料時,使用管理 API Key。它代表你的廠商工作區。
客戶端需要的是哪一種金鑰?
| 憑證 | 交給誰 | 用來做什么 |
|---|---|---|
lv_api_…管理 API Key | 你自己的伺服器 | 建立產品、策略和授權,查看裝置、用量和稽核記錄 |
lv_lic_…授權金鑰 | 客戶的軟體 | 啟用、驗證、傳送心跳和釋放當前裝置 |
| 產品公鑰 | 隨客戶端發布 | 檢查伺服器返回的授權簽章是否有效 |
如果你只串接客戶軟體的授權驗證,使用授權金鑰就夠了。管理 API Key 可以操作整個工作區,不能放進客戶軟體或公開網頁。
建立一個 Key
- 用工作區 Owner(所有者)帳號登入,打開 API Key,點擊“建立 API Key”。
- 名稱填它的用途,例如“訂單系統”。只查詢時選“只讀”;要建立或修改授權時選“讀寫”。有效期可設為 1–365 天。
- 儲存后立即複製完整 Key,它只顯示一次。把它放在你伺服器的私有設定或環境變量中。
傳送第一個管理請求
示例讀取產品清單。將 LICENTIVO_URL 設定為授權伺服器位址,將 LICENTIVO_API_KEY 設定為剛建立的完整 Key,再執行:
curl "$LICENTIVO_URL/api/v1/products?limit=25" \
-H "Authorization: Bearer $LICENTIVO_API_KEY"這是 Bash / macOS / Linux 的寫法。Windows PowerShell 請使用 curl.exe,環境變量用 $env:LICENTIVO_URL 和 $env:LICENTIVO_API_KEY。九種語言的完整請求程式碼也放在 SDK 頁的“服務端管理 API Key”選項中查看。
成功時返回 HTTP 200,正文包含 data.items。使用 Bearer Key 的管理請求不需要登入 Cookie 或 CSRF Token。
權限和失效處理
只讀 Key 能查看資源;讀寫 Key 還能建立和修改產品、策略、授權。管理 Key 不用于帳號、團隊、系統設定或收款操作,這些操作需要相應帳號登入。
Key 泄漏或不再使用時,在控制臺撤銷;需要更換時點擊“輪換”。舊 Key 會立即失效,隨后更新你伺服器上的設定。
方案中的 API 呼叫額度統計啟用、驗證、心跳和釋放。這里的管理請求不計入這項額度。
Common request and response conventions
| Item | Convention |
|---|---|
| Server origin | LICENTIVO_URL is the license server origin. API paths start with /api/v1 中查看。 |
| Authentication | Authorization: Bearer YOUR_MANAGEMENT_API_KEY. Read-only keys use scope=read; read/write keys use scope=write. A key accesses its own workspace. Writes also require its creator to be an active Owner. |
| JSON body | For requests with a body, send Content-Type: application/json. Bodies are limited to 64 KiB. Unknown fields, multiple JSON objects and invalid types are rejected. Operations marked {} require an empty JSON object. GET and DELETE have no body. |
| Updates | PATCH preserves omitted fields. Basic updates require at least one editable field. See conditional requirements, such as duration_days中查看。 |
| Success and failure | Successful JSON responses use {"data": ..., "request_id": "..."}; errors use {"error": {"code": "...", "message": "..."}, "request_id": "..."}. Creation usually returns 201, reads and updates 200, and queued tasks 202. |
| File responses | Successful CSV and ZIP responses contain file data without a data wrapper. Errors still use JSON. The X-Request-ID response header identifies the request. |
| Pagination | Paginated operations default to limit=25, offset=0; ranges are 1–100 and 0–100000. Most lists return items 和 total. Check each field table for echoed pagination parameters. Audit logs omit total. Increase offset for the next page and stop when fewer than limit items are returned. Do not rely on undocumented filters. |
| Dates and money | Date strings use UTC / RFC 3339. Offline requests use created_at in Unix seconds. Amounts ending in *_cents are hundredths of the currency unit;*_micros are millionths. Interpret amounts with currency 中查看。 |
Retries and idempotency
Ordinary creation, renewal and key rotation do not provide general Idempotency-Key deduplication. Do not blindly resend after a timeout; it can issue or renew twice. For reliable order processing, use POST /api/v1/licenses/batch: generate and store the body request_idper order, and keep the original ID and identical content for retries. Onboarding also deduplicates by its body request_id.
The top-level response request_id differs from the business idempotency ID: the server generates the former for each HTTP request, while you retain the latter per business operation. Poll task status after 202. On 429, wait according to Retry-After . A 5xx or lost connection can leave a write outcome uncertain; query first or recover using that operation’s idempotency rules.
Management errors and recovery
| HTTP / error.code | Cause and recovery |
|---|---|
400 INVALID_INPUT415 JSON_REQUIRED | Correct fields, conditional requirements or Content-Type before retrying. |
401 UNAUTHENTICATED | The key is malformed, expired or revoked, or its account/workspace is inactive. Check the complete key and account state. |
403 FORBIDDEN403 CSRF_INVALID | Check scope, Owner role and session requirements. CSRF tokens for cookie-authenticated writes must match the session. |
404 NOT_FOUND405 METHOD_NOT_ALLOWED | Check the resource ID, workspace, archive state and HTTP method. A 405 response lists allowed methods in Allow. |
409 PRODUCT_DISABLED409 RESOURCE_IN_USE | Enable the product first. Resolve dependent resources before archiving a product or policy. |
409 LICENSE_REVOKED409 PERPETUAL_LICENSE | Revoked licenses cannot be restored or renewed. Perpetual licenses have no usage expiry to extend. |
409 DEVICE_LIMIT_BELOW_ACTIVE409 ACTIVE_DEVICES_CONFLICT | Release excess devices/sessions before lowering limits or switching license models. |
409 POLICY_CHANGED409 PREVIEW_STALE | Reload the policy revision or preview the changes again before submitting; preserve concurrent updates. |
409 IDEMPOTENCY_CONFLICT | The business request_id was reused with different content. Retries retain the original ID and body; new operations need a new ID. |
409 KEY_LIMIT409 KEY_INACTIVE | At most 100 active keys are allowed; revoke unused keys. Rotation requires an active key whose creator remains an active Owner. |
409 PLAN_VERSION_CONFLICT409 INVOICE_STATE_CONFLICT409 JOB_STATE_CONFLICT | Reload pricing, invoice or task state before proceeding. Only failed billing tasks can be retried. |
409 DELIVERY_RUNNING409 WEBHOOK_DISABLED | Wait for the running delivery or enable the endpoint first. Receivers must deduplicate by event ID. |
413 EXPORT_TOO_LARGE429 RATE_LIMITED | Filter exports to at most 5000 rows or use pagination. Wait according to Retry-After when rate-limited. |
500 INTERNAL_ERROR503 DEFAULT_PLAN_DISABLED | Keep request_id for diagnosis; contact an administrator if the default allowance is disabled. Recover uncertain writes according to the operation’s idempotency rules. |
Offline operations may also return runtime licensing errors; see Troubleshooting and licensing errors中查看。
Technical terminology
| 期限 | 含義 |
|---|---|
authentication / authorization | Authentication / authorization: establish the credential’s identity, then check permission for the operation. |
scope | Scope: read grants read access and write grants read/write access; separate from the Owner / read_only account role. |
policy / plan / purchase | Licensing policy / billing plan / package purchase contract: software licensing rules, service prices and purchased entitlements respectively. |
license / license key | License / license key: the management record and the customer’s activation secret respectively; both differ from the management API Key. |
activation / seat / lease | Activation / seat / authorization lease: a device or session record, a concurrent-use slot, and time-bounded server-signed authorization respectively. |
revoke / suspend / archive / release | Revoke / suspend / archive / release: revocation is terminal, suspension is reversible, archiving removes normal visibility, and release frees a device or seat. |
rotate / idempotency / reservation | Rotation / idempotency / reservation: replacing a key, preventing additional effects from repeated execution of the same operation, and reserving feature uses before committing them. |
All management requests and responses
The reference covers every Bearer-key operation plus the Owner-session operations for creating, listing, rotating and revoking keys. Select an operation for calls, responses, fields and conditions. All example credentials are illustrative.
Loading API reference…
Management key permissions
Read-only keys can call operations marked “Read or write key”; write keys also support “Write key” operations. Key lifecycle, accounts, members, system settings, payments and refunds require an authorized session. Monthly billing queries and tasks use the permissions listed here. Customer runtime operations use customer credentials; see SDK 授權呼叫中查看。
Download the machine-readable OpenAPI JSON(目前語言)for import into tools such as Postman. Web field explanations follow the documentation language.