# Managed Licenses API > 原文:[https://docs.gitlab.com/ee/api/managed_licenses.html](https://docs.gitlab.com/ee/api/managed_licenses.html) * [List managed licenses](#list-managed-licenses) * [Show an existing managed license](#show-an-existing-managed-license) * [Create a new managed license](#create-a-new-managed-license) * [Delete a managed license](#delete-a-managed-license) * [Edit an existing managed license](#edit-an-existing-managed-license) # Managed Licenses API[](#managed-licenses-api-ultimate "Permalink") ## List managed licenses[](#list-managed-licenses "Permalink") 获取给定项目的所有托管许可证. ``` GET /projects/:id/managed_licenses ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/1/managed_licenses" ``` 响应示例: ``` [ { "id": 1, "name": "MIT", "approval_status": "approved" }, { "id": 3, "name": "ISC", "approval_status": "blacklisted" } ] ``` ## Show an existing managed license[](#show-an-existing-managed-license "Permalink") 显示现有的托管许可证. ``` GET /projects/:id/managed_licenses/:managed_license_id ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `managed_license_id` | integer/string | yes | 属于项目的许可证的 ID 或 URL 编码名称 | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6" ``` 响应示例: ``` { "id": 1, "name": "MIT", "approval_status": "blacklisted" } ``` ## Create a new managed license[](#create-a-new-managed-license "Permalink") 使用给定的名称和批准状态为给定的项目创建一个新的托管许可证. ``` POST /projects/:id/managed_licenses ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `name` | string | yes | 托管许可证的名称 | | `approval_status` | string | yes | 批准状态. "批准"或"列入黑名单" | ``` curl --data "name=MIT&approval_status=blacklisted" --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/1/managed_licenses" ``` 响应示例: ``` { "id": 1, "name": "MIT", "approval_status": "approved" } ``` ## Delete a managed license[](#delete-a-managed-license "Permalink") 删除具有给定 ID 的托管许可证. ``` DELETE /projects/:id/managed_licenses/:managed_license_id ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `managed_license_id` | integer/string | yes | 属于项目的许可证的 ID 或 URL 编码名称 | ``` curl --request DELETE --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/1/managed_licenses/4" ``` 成功后,它将以 HTTP 204 响应进行回复. ## Edit an existing managed license[](#edit-an-existing-managed-license "Permalink") 使用新的批准状态更新现有的托管许可证. ``` PATCH /projects/:id/managed_licenses/:managed_license_id ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `managed_license_id` | integer/string | yes | 属于项目的许可证的 ID 或 URL 编码名称 | | `approval_status` | string | yes | 批准状态. "批准"或"列入黑名单" | ``` curl --request PATCH --data "approval_status=blacklisted" --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/1/managed_licenses/6" ``` 响应示例: ``` { "id": 1, "name": "MIT", "approval_status": "blacklisted" } ```