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
---
2021-01-28 01:08:59 -05:00
# License **(FREE SELF)**
2019-05-18 17:27:41 -04:00
2020-10-02 17:08:18 -04:00
To interact with license endpoints, you need to authenticate yourself as an
2020-11-23 13:09:14 -05:00
administrator.
2019-05-18 17:27:41 -04:00
## Retrieve information about the current license
2020-02-27 04:09:01 -05:00
```plaintext
2019-05-18 17:27:41 -04:00
GET /license
```
```json
{
"id": 2,
"plan": "gold",
"created_at": "2018-02-27T23:21:58.674Z",
"starts_at": "2018-01-27",
"expires_at": "2022-01-27",
"historical_max": 300,
2019-11-08 07:06:32 -05:00
"maximum_user_count": 300,
2019-05-18 17:27:41 -04:00
"expired": false,
"overage": 200,
"user_limit": 100,
"active_users": 300,
"licensee": {
"Name": "John Doe1"
},
"add_ons": {
"GitLab_FileLocks": 1,
"GitLab_Auditor_User": 1
}
}
```
## Retrieve information about all licenses
2020-02-27 04:09:01 -05:00
```plaintext
2019-05-18 17:27:41 -04:00
GET /licenses
```
```json
[
{
"id": 1,
"plan": "silver",
"created_at": "2018-02-27T23:21:58.674Z",
"starts_at": "2018-01-27",
"expires_at": "2022-01-27",
"historical_max": 300,
2019-11-08 07:06:32 -05:00
"maximum_user_count": 300,
2019-05-18 17:27:41 -04:00
"expired": false,
"overage": 200,
"user_limit": 100,
"licensee": {
"Name": "John Doe1"
},
"add_ons": {
"GitLab_FileLocks": 1,
"GitLab_Auditor_User": 1
}
},
{
"id": 2,
"plan": "gold",
"created_at": "2018-02-27T23:21:58.674Z",
"starts_at": "2018-01-27",
"expires_at": "2022-01-27",
"historical_max": 300,
2019-11-08 07:06:32 -05:00
"maximum_user_count": 300,
2019-05-18 17:27:41 -04:00
"expired": false,
"overage": 200,
"user_limit": 100,
"licensee": {
"Name": "Doe John"
},
"add_ons": {
2021-04-29 08:09:58 -04:00
"GitLab_FileLocks": 1
2019-05-18 17:27:41 -04:00
}
}
]
```
2020-11-23 13:09:14 -05:00
Overage is the difference between the number of billable users and the licensed number of users.
2019-05-18 17:27:41 -04:00
This is calculated differently depending on whether the license has expired or not.
2020-11-23 13:09:14 -05:00
- If the license has expired, it uses the historical maximum billable user count (`historical_max`).
- If the license has not expired, it uses the current billable users count.
2019-05-18 17:27:41 -04:00
Returns:
2020-11-19 16:09:07 -05:00
- `200 OK` with response containing the licenses in JSON format. This is an empty JSON array if there are no licenses.
2019-05-18 17:27:41 -04:00
- `403 Forbidden` if the current user in not permitted to read the licenses.
## Add a new license
2020-02-27 04:09:01 -05:00
```plaintext
2019-05-18 17:27:41 -04:00
POST /license
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `license` | string | yes | The license string |
2020-01-30 10:09:15 -05:00
```shell
2019-05-18 17:27:41 -04:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/license?license=eyJkYXRhIjoiMHM5Q...S01Udz09XG4ifQ=="
```
Example response:
```json
{
"id": 1,
"plan": "gold",
"created_at": "2018-02-27T23:21:58.674Z",
"starts_at": "2018-01-27",
"expires_at": "2022-01-27",
"historical_max": 300,
2019-11-08 07:06:32 -05:00
"maximum_user_count": 300,
2019-05-18 17:27:41 -04:00
"expired": false,
"overage": 200,
"user_limit": 100,
"active_users": 300,
"licensee": {
"Name": "John Doe1"
},
"add_ons": {
"GitLab_FileLocks": 1,
"GitLab_Auditor_User": 1
}
}
```
Returns:
- `201 Created` if the license is successfully added.
- `400 Bad Request` if the license couldn't be added, with an error message explaining the reason.
## Delete a license
2020-02-27 04:09:01 -05:00
```plaintext
2019-05-18 17:27:41 -04:00
DELETE /license/:id
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | ID of the GitLab license. |
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/license/:id"
```
Example response:
```json
{
"id": 2,
"plan": "gold",
"created_at": "2018-02-27T23:21:58.674Z",
"starts_at": "2018-01-27",
"expires_at": "2022-01-27",
"historical_max": 300,
2019-11-08 07:06:32 -05:00
"maximum_user_count": 300,
2019-05-18 17:27:41 -04:00
"expired": false,
"overage": 200,
"user_limit": 100,
"licensee": {
"Name": "John Doe"
},
"add_ons": {
"GitLab_FileLocks": 1,
"GitLab_Auditor_User": 1
}
}
```
Returns:
- `204 No Content` if the license is successfully deleted.
- `403 Forbidden` if the current user in not permitted to delete the license.
- `404 Not Found` if the license to delete could not be found.