Add Custom License

Xray REST APIs

Products
JFrog Xray
Content Type
REST API

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.

UsagePOST xray/api/v1/licenses/assign

Consumes:   application/json

Produces:  application/json

Request body:

Name

Type

Required/Optional

Description

component

object

required

Component information

license

object

required

License information

Component fields:

Name

Type

Required/Optional

Description

package_id

string

required

Package identifier (e.g., npm://lodash, build://my-build)

component_name

string

required

Component name

pkg_type

string

required

Package type (e.g., npm, maven, pypi)

version

string

optional

Component version

distribution

string

optional

Distribution identifier for remote repositories

build_repo

string

optional

Build repository name (required for build:// components)

License fields:

Name

Type

Required/Optional

Description

full_name

string

optional

Full license name

name

string

required

License identifier (must be a known license)

references

array

optional

Array of reference URLs

aliases

array

optional

Array of license aliases

Response body:

Name

Type

Description

info

string

Success message (present on successful operations)

error

string

Error message (present on failed operations)

warn

string

Warning message (present when warnings occur)

errors

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'"
}