Description: Allows users to add a custom license to a single component in Xray.
Since: Xray 3.0
Applicable Environment: JFrog SaaS, JFrog Self-Hosted
Security: Requires a valid user with MANAGE_DATA permission.
Usage: POST xray/api/v1/licenses/assign
Consumes: application/json
Produces: application/json
Request body:
Name | Type | Required/Optional | Description |
|---|---|---|---|
| object | required | Component information |
| object | required | License information |
Component fields:
Name | Type | Required/Optional | Description |
|---|---|---|---|
| string | required | Package identifier (e.g., |
| string | required | Component name |
| string | required | Package type (e.g., |
| string | optional | Component version |
| string | optional | Distribution identifier for remote repositories |
| string | optional | Build repository name (required for |
License fields:
Name | Type | Required/Optional | Description |
|---|---|---|---|
| string | optional | Full license name |
| string | required | License identifier (must be a known license) |
| array | optional | Array of reference URLs |
| array | optional | Array of license aliases |
Response body:
Name | Type | Description |
|---|---|---|
| string | Success message (present on successful operations) |
| string | Error message (present on failed operations) |
| string | Warning message (present when warnings occur) |
| array | Array of detailed error objects (present on validation errors) |
Response Codes:
Code | Description |
|---|---|
200 | OK - License successfully added |
400 | Bad request — required fields missing or malformed request |
403 | Permission denied |
415 | Unsupported media type — invalid license name or parsing error |
500 | Internal server error |
Sample Request:
POST /api/v1/licenses/assign Content-Type: application/json Accept: application/json
curl -u <user>:<password> \
-X POST "https://<xray-host>/api/v1/licenses/assign" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"component": {
"package_id": "npm://lodash",
"component_name": "lodash",
"pkg_type": "npm",
"version": "4.17.21"
},
"license": {
"name": "MIT",
"aliases": ["MIT License"]
}
}'Sample Response:
200 OK
{
"info": "license 'MIT' has been successfully added to component 'npm://lodash'"
}