2020-10-28 11:08:49 -04:00
---
2022-05-23 11:08:42 -04:00
stage: Fulfillment
group: Utilization
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-10-28 11:08:49 -04:00
---
2019-07-08 04:50:38 -04:00
# Managed Licenses API **(ULTIMATE)**
2019-05-18 17:27:41 -04:00
2021-12-06 19:14:07 -05:00
WARNING:
2022-05-11 14:07:55 -04:00
"approval" and "blacklisted" approval statuses are changed to "allowed" and "denied" in GitLab 15.0.
2021-12-06 19:14:07 -05:00
2019-05-18 17:27:41 -04:00
## List managed licenses
Get all managed licenses for a given project.
2020-02-27 04:09:01 -05:00
```plaintext
2019-05-18 17:27:41 -04:00
GET /projects/:id/managed_licenses
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) |
2019-05-18 17:27:41 -04:00
2020-01-30 10:09:15 -05:00
```shell
2020-05-27 20:08:37 -04:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/managed_licenses"
2019-05-18 17:27:41 -04:00
```
Example response:
```json
[
{
"id": 1,
"name": "MIT",
2022-05-11 14:07:55 -04:00
"approval_status": "allowed"
2019-05-18 17:27:41 -04:00
},
{
"id": 3,
"name": "ISC",
2022-05-11 14:07:55 -04:00
"approval_status": "denied"
2019-05-18 17:27:41 -04:00
}
]
```
## Show an existing managed license
Shows an existing managed license.
2020-02-27 04:09:01 -05:00
```plaintext
2019-05-18 17:27:41 -04:00
GET /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2019-05-18 17:27:41 -04:00
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
2020-01-30 10:09:15 -05:00
```shell
2019-05-18 17:27:41 -04:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6"
```
Example response:
```json
{
"id": 1,
"name": "MIT",
2022-05-11 14:07:55 -04:00
"approval_status": "denied"
2019-05-18 17:27:41 -04:00
}
```
## Create a new managed license
Creates a new managed license for the given project with the given name and approval status.
2020-02-27 04:09:01 -05:00
```plaintext
2019-05-18 17:27:41 -04:00
POST /projects/:id/managed_licenses
```
| Attribute | Type | Required | Description |
| ------------- | ------- | -------- | ---------------------------- |
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2019-05-18 17:27:41 -04:00
| `name` | string | yes | The name of the managed license |
2022-05-11 14:07:55 -04:00
| `approval_status` | string | yes | The approval status of the license. "allowed" or "denied". |
2019-05-18 17:27:41 -04:00
2020-01-30 10:09:15 -05:00
```shell
2021-12-06 19:14:07 -05:00
curl --data "name=MIT& approval_status=denied" --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/managed_licenses"
2019-05-18 17:27:41 -04:00
```
Example response:
```json
{
"id": 1,
"name": "MIT",
2022-05-11 14:07:55 -04:00
"approval_status": "allowed"
2019-05-18 17:27:41 -04:00
}
```
## Delete a managed license
2020-05-07 02:09:38 -04:00
Deletes a managed license with a given ID.
2019-05-18 17:27:41 -04:00
2020-02-27 04:09:01 -05:00
```plaintext
2019-05-18 17:27:41 -04:00
DELETE /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2019-05-18 17:27:41 -04:00
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
2020-01-30 10:09:15 -05:00
```shell
2019-05-18 17:27:41 -04:00
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/managed_licenses/4"
```
2019-07-08 23:28:41 -04:00
When successful, it replies with an HTTP 204 response.
2019-05-18 17:27:41 -04:00
## Edit an existing managed license
Updates an existing managed license with a new approval status.
2020-02-27 04:09:01 -05:00
```plaintext
2019-05-18 17:27:41 -04:00
PATCH /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2019-05-18 17:27:41 -04:00
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
2022-05-11 14:07:55 -04:00
| `approval_status` | string | yes | The approval status of the license. "allowed" or "denied". |
2019-05-18 17:27:41 -04:00
2020-01-30 10:09:15 -05:00
```shell
2021-12-06 19:14:07 -05:00
curl --request PATCH --data "approval_status=denied" \
2021-06-02 11:09:59 -04:00
--header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6"
2019-05-18 17:27:41 -04:00
```
Example response:
```json
{
"id": 1,
"name": "MIT",
2022-05-11 14:07:55 -04:00
"approval_status": "denied"
2019-05-18 17:27:41 -04:00
}
```