2020-10-28 15:08:49 +00:00
---
2021-04-23 15:09:37 +00:00
stage: Growth
group: Activation
2020-11-26 06:09:20 +00: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 15:08:49 +00:00
---
2019-07-08 08:50:38 +00:00
# Managed Licenses API **(ULTIMATE)**
2019-05-18 21:27:41 +00:00
## List managed licenses
Get all managed licenses for a given project.
2020-02-27 09:09:01 +00:00
```plaintext
2019-05-18 21:27:41 +00:00
GET /projects/:id/managed_licenses
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) |
2020-01-30 15:09:15 +00:00
```shell
2020-05-28 00:08:37 +00:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/managed_licenses"
2019-05-18 21:27:41 +00:00
```
Example response:
```json
[
{
"id": 1,
"name": "MIT",
"approval_status": "approved"
},
{
"id": 3,
"name": "ISC",
"approval_status": "blacklisted"
}
]
```
## Show an existing managed license
Shows an existing managed license.
2020-02-27 09:09:01 +00:00
```plaintext
2019-05-18 21:27:41 +00:00
GET /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
2020-01-30 15:09:15 +00:00
```shell
2019-05-18 21:27:41 +00: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",
"approval_status": "blacklisted"
}
```
## Create a new managed license
Creates a new managed license for the given project with the given name and approval status.
2020-02-27 09:09:01 +00:00
```plaintext
2019-05-18 21:27:41 +00:00
POST /projects/:id/managed_licenses
```
| Attribute | Type | Required | Description |
| ------------- | ------- | -------- | ---------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `name` | string | yes | The name of the managed license |
| `approval_status` | string | yes | The approval status. "approved" or "blacklisted" |
2020-01-30 15:09:15 +00:00
```shell
2019-05-18 21:27:41 +00:00
curl --data "name=MIT& approval_status=blacklisted" --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/managed_licenses"
```
Example response:
```json
{
"id": 1,
"name": "MIT",
"approval_status": "approved"
}
```
## Delete a managed license
2020-05-07 06:09:38 +00:00
Deletes a managed license with a given ID.
2019-05-18 21:27:41 +00:00
2020-02-27 09:09:01 +00:00
```plaintext
2019-05-18 21:27:41 +00:00
DELETE /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------- | ------- | -------- | --------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
2020-01-30 15:09:15 +00:00
```shell
2019-05-18 21:27:41 +00:00
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/managed_licenses/4"
```
2019-07-09 03:28:41 +00:00
When successful, it replies with an HTTP 204 response.
2019-05-18 21:27:41 +00:00
## Edit an existing managed license
Updates an existing managed license with a new approval status.
2020-02-27 09:09:01 +00:00
```plaintext
2019-05-18 21:27:41 +00:00
PATCH /projects/:id/managed_licenses/:managed_license_id
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](README.md#namespaced-path-encoding ) owned by the authenticated user |
| `managed_license_id` | integer/string | yes | The ID or URL-encoded name of the license belonging to the project |
| `approval_status` | string | yes | The approval status. "approved" or "blacklisted" |
2020-01-30 15:09:15 +00:00
```shell
2021-06-02 15:09:59 +00:00
curl --request PATCH --data "approval_status=blacklisted" \
--header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6"
2019-05-18 21:27:41 +00:00
```
Example response:
```json
{
"id": 1,
"name": "MIT",
"approval_status": "blacklisted"
}
```