feat(api): implement REST API routes for licensing system #341
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The licensing data models exist in
models/licenses/(5 files: license_key.go, license_key_usage.go, license_package.go, master_key.go, update_stream_config.go) but no API routes expose them.moko-platform now has a
licenseCLI tool (cli/license_manage.php) that expects these endpoints.Required API Endpoints
Package Management
GET /api/v1/orgs/{org}/license-packages— List packagesPOST /api/v1/orgs/{org}/license-packages— Create packagePATCH /api/v1/orgs/{org}/license-packages/{id}— Update packageDELETE /api/v1/orgs/{org}/license-packages/{id}— Delete packageKey Management
GET /api/v1/orgs/{org}/license-keys— List all keys for orgGET /api/v1/orgs/{org}/license-packages/{id}/keys— List keys for packagePOST /api/v1/orgs/{org}/license-keys— Issue new keyPATCH /api/v1/orgs/{org}/license-keys/{id}— Update key (activate/revoke)POST /api/v1/orgs/{org}/license-keys/{id}/renew— Renew key expirationPOST /api/v1/orgs/{org}/license-keys/master— Ensure master keyValidation
POST /api/v1/license-keys/validate— Validate raw key + domainUsage Analytics
GET /api/v1/orgs/{org}/license-keys/{id}/usage— View usage logsAuth
All org endpoints require org admin or owner token. The validate endpoint should be public or require only the license key itself.
Models Reference
models/licenses/license_key.go— Key generation (MOKO-XXXX format), SHA-256 hashing, domain restriction, heartbeatmodels/licenses/license_package.go— Subscription tiers with duration, max sites, repo scopemodels/licenses/license_key_usage.go— Update check activity trackingmodels/licenses/master_key.go— Internal unlimited key per orgmodels/licenses/update_stream_config.go— Stream config with licensing toggleRelated
cli/license_manage.php— CLI consumer of these endpointsCovered by #387 (API renew), #388 (API package CRUD), and #349 (settings API). All REST API routes are now implemented.
?? Generated with Claude Code