# How-to-remove-specific-license-key-for-SaaS-UCMDB_688996303
## Background & Design

Previously when removing UD licenses, it can only remove all the license keys for the whole SaaS UCMDB instance, we don't have the way to remove specific license key. This brings problem for managing SaaS UD licenses, like when a license is expired, SaaS Ops cannot remove the expired license key only.

Since UCMDB 24.4.1 release, we provide a new capability to remove specific license key for SaaS UCMDB. There are 2 methods in total:

- Remove specific license key, which has one required param: license key.

![](attachments/688996303/688996301.png)

- 200pxRemove allocated license capacity from specific license key for a customer, which has two params: customer id (required), license key (optional)

![](attachments/688996303/688996302.png)

Note

When removing the allocated license capacity, there is no check for license consumption. SaaS Ops need to double check customer's license usage before removing allocated capacity.

And there are 2 ways: JMX & Rest API, please find details as below for each.

---

## JMX

Please refer to the online help directly [OpenText Documentation Portal](https://staging.docs.microfocus.com/doc/UCMDB_Containerized/Main/MCLicenseMgmt)

## Rest API

Considering all the license related Rest APIs are private APIs (hidden for customers), we don't have the official document for them, so please refer to below for the guidance.

### Authentication

- **XSRF Token**: Every request requires an `xsrftoken` header for security purposes.
- **Authentication**: Ensure that you are authenticated via a valid session before making requests. The `xsrftoken` can typically be obtained after logging into the system.

### API Endpoints

#### 1\. Delete specific license by inputting licenseKey

- **Description**: This endpoint deletes a specific license from the UCMDB server using the provided license key.
- **HTTP Method**: `DELETE`
- **URL**:
	https://{server}:{port}/ucmdb-server/rest-api/uiserver/license/key
- **Request Headers**:
	- `accept: */*`
		- `Content-Type: text/plain`
		- `xsrftoken: {xsrftoken}` - Replace `{xsrftoken}` with a valid token.
- **Request Body**:

`{licensekey}`

Replace `{licensekey}` with the actual license key you want to delete.

- **Example Request**:
	curl -X 'DELETE' \\  
	'https://{server}:{port}/ucmdb-server/rest-api/uiserver/license/key' \\  
	\-H 'accept: \*/\*' \\  
	\-H 'Content-Type: text/plain' \\  
	\-H 'xsrftoken: 94e22c20-2c16-44b0-b753-e55921ac25d3' \\  
	\-d '{licensekey}'
- **Response**:
	- **Success**: `200 OK`
		- **Error**: Appropriate HTTP error code with a message (e.g., `404 Not Found`, `500 Internal Server Error`).

#### 2\. Delete allocated license capacity from specific license key for a customer

- **Description**: This endpoint deletes the allocated license capacity from specific license key for a specific customer identified by the customer ID.
- **HTTP Method**: `DELETE`
- **URL**:
	https://{server}:{port}/ucmdb-server/rest-api/uiserver/license/customers/{customerId}/capacity
	Replace `{customerId}` with the ID of the customer whose license capacity you want to delete. Note that customerId is required.
- **Request Headers**:
	- `accept: */*`
		- `Content-Type: text/plain`
		- `xsrftoken: {xsrftoken}` - Replace `{xsrftoken}` with a valid token.
- **Request Body**:
	{licensekey}
	Replace `{licensekey}` with the actual license key you want to delete for the specified customer.
- **Example Request**:
	curl -X 'DELETE' \\  
	'https://{server}:{port}/ucmdb-server/rest-api/uiserver/license/customers/1/capacity' \\  
	\-H 'accept: \*/\*' \\  
	\-H 'Content-Type: text/plain' \\  
	\-H 'xsrftoken: 94e22c20-2c16-44b0-b753-e55921ac25d3' \\  
	\-d '{licensekey}'
- **Response**:
	- **Success**: `200 OK`
		- **Error**: Appropriate HTTP error code with a message (e.g., `404 Not Found`, `500 Internal Server Error`).

### Response Codes

- **200 OK**: The request was successful, and the license or capacity was deleted.
- **400 Bad Request**: The request was malformed (e.g., missing required parameters or invalid data).
- **401 Unauthorized**: Authentication failed or the `xsrftoken` is invalid.
- **403 Forbidden**: You do not have the required permissions to perform this action.
- **404 Not Found**: The specified license key or customer ID was not found.
- **500 Internal Server Error**: The server encountered an error processing the request.

### Example Scenarios

1. **Deleting a License by Key**: To delete a license with the key `ABC-123-XYZ`, you can use the following command:
	curl -X 'DELETE' \\  
	' [https://ucmdb.example.com:8443/ucmdb-server/rest-api/uiserver/license/key](https://ucmdb.example.com:8443/ucmdb-server/rest-api/uiserver/license/key) ' \\  
	\-H 'accept: \*/\*' \\  
	\-H 'Content-Type: text/plain' \\  
	\-H 'xsrftoken: 94e22c20-2c16-44b0-b753-e55921ac25d3' \\  
	\-d 'ABC-123-XYZ'
2. **Deleting a Customer’s License Capacity**: To delete the license capacity for customer with ID `1`, using license key `ABC-123-XYZ`:
	curl -X 'DELETE' \\  
	' [https://ucmdb.example.com:8443/ucmdb-server/rest-api/uiserver/license/customers/1/capacity](https://ucmdb.example.com:8443/ucmdb-server/rest-api/uiserver/license/customers/1/capacity) ' \\  
	\-H 'accept: \*/\*' \\  
	\-H 'Content-Type: text/plain' \\  
	\-H 'xsrftoken: 94e22c20-2c16-44b0-b753-e55921ac25d3' \\  
	\-d 'ABC-123-XYZ'

### Notes

- Make sure to replace `{server}`, `{port}`, `{licensekey}`, `{customerId}`, and `{xsrftoken}` with actual values when using the API.
- Always ensure you are using secure connections (e.g., HTTPS) when interacting with the UCMDB API.
