# Deactivate License (Online Method)

### Endpoint

* Method: `POST`
* Path: `/api/v4/deactivate_license`
* Description: Deactivates a license for a device and returns `license_deactivated` on success.

### Authentication

See [License API Authorization](/license-api/license-api-authorization.md).

#### Required headers

* `Date` (string) — RFC7231 GMT date string
* `Authorization` (string) — signature or bearer token

#### Recommended headers

* `Accept: application/json`
* `Content-Type: application/json`

### Request

#### Body parameters

Required:

* `hardware_id` (string)
* `product` (string)

One of:

* `license_key` (string)
* `username` (+ `password` when applicable)
* `id_token` (use access\_token value) + `customer_account_code`
* `code` + `customer_account_code`

Optional:

* `license_id` (number)
* `sdk_ver` (string)
* `consumptions` (number)

### Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl --location --request POST '/api/v4/deactivate_license' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Date: string' \
--header 'Authorization: string' \
--data-raw '{
  "hardware_id": "some-unique-id",
  "product": "XY",
  "license_key": "AAAA-BBBB-CCCC-DDDD"
}'
```

{% endtab %}

{% tab title="nodejs" %}

```javascript
var request = require('request');
var options = {
  method: 'POST',
  url: '/api/v4/deactivate_license',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Date': 'string',
    'Authorization': 'string'
  },
  body: JSON.stringify({
    hardware_id: 'some-unique-id',
    product: 'XY',
    license_key: 'AAAA-BBBB-CCCC-DDDD'
  })
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

{% endtab %}

{% tab title="javascript (fetch)" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Date", "string");
myHeaders.append("Authorization", "string");

var raw = JSON.stringify({
  hardware_id: "some-unique-id",
  product: "XY",
  license_key: "AAAA-BBBB-CCCC-DDDD"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("/api/v4/deactivate_license", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="python" %}

```python
import requests

url = "/api/v4/deactivate_license"

payload = {
  "hardware_id": "some-unique-id",
  "product": "XY",
  "license_key": "AAAA-BBBB-CCCC-DDDD"
}

headers = {
  "Accept": "application/json",
  "Content-Type": "application/json",
  "Date": "string",
  "Authorization": "string"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

{% endtab %}

{% tab title="ruby" %}

```ruby
require "uri"
require "net/http"
require "json"

url = URI("/api/v4/deactivate_license")

http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
request["Date"] = "string"
request["Authorization"] = "string"
request.body = JSON.dump({
  hardware_id: "some-unique-id",
  product: "XY",
  license_key: "AAAA-BBBB-CCCC-DDDD"
})

response = http.request(request)
puts response.read_body
```

{% endtab %}
{% endtabs %}

<details>

<summary><strong>Interactive API reference</strong></summary>

:::ApiMethodV2

```json
{
  "tab": "examples",
  "url": "/api/v4/deactivate_license",
  "name": "/api/v4/deactivate_license",
  "method": "POST",
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [
      {
        "kind": "required",
        "name": "Date",
        "type": "string",
        "children": [],
        "description": "In RFC7231 format (see \"License API Authorization\"), eg.: Thu, 17 Nov 2022 20:51:35 GMT"
      },
      {
        "kind": "required",
        "name": "Authorization",
        "type": "string",
        "children": [],
        "description": "See \"License API Authorization\" article"
      }
    ],
    "bodyDataParameters": [
      {
        "kind": "required",
        "name": "hardware_id",
        "type": "String",
        "children": [],
        "description": "Unique hardware ID generated for the client device"
      },
      {
        "kind": "required",
        "name": "product",
        "type": "string",
        "children": [],
        "description": "Product short code"
      },
      {
        "kind": "optional",
        "name": "license_key",
        "type": "string",
        "children": [],
        "description": "Required if product is key-based (see section below)"
      },
      {
        "kind": "optional",
        "name": "username",
        "type": "string",
        "children": [],
        "description": "Required if product is user based (see section below)"
      },
      {
        "kind": "optional",
        "name": "id_token",
        "type": "string",
        "children": [],
        "description": "Required if using SSO (see section below). This is the id_token received from the SSO if Implicit grant authorization method is being used."
      },
      {
        "kind": "optional",
        "name": "code",
        "type": "string",
        "children": [],
        "description": "Required if using SSO (see section below). This is the code received from the SSO if Authorization code grant method is being used."
      },
      {
        "kind": "optional",
        "name": "customer_account_code",
        "type": "string",
        "children": [],
        "description": "Required if using SSO (see section below). This is the customer_account_code to which SSO provider is configured. "
      },
      {
        "name": "license_id",
        "kind": "optional",
        "type": "Number",
        "description": "Ensures that the action affects only the license with the specified ID. This is useful if e.g. you have multiple licenses for the same product assigned to the same user. For obtaining a list of licenses assigned to a user, see \"User Licenses\"",
        "children": []
      },
      {
        "kind": "optional",
        "name": "sdk_ver",
        "type": "string",
        "description": "Version of the SDK used",
        "": "Version of the SDK used"
      },
      {
        "name": "consumptions",
        "kind": "optional",
        "type": "number",
        "description": "Increases/decreases total_consumptions",
        "": "Increases/decreases total_consumptions"
      }
    ],
    "formDataParameters": []
  },
  "results": {
    "languages": [
      {
        "id": "es8g1cuKJMbNPiIVt9VoF",
        "code": "license_deactivated",
        "language": "200",
        "customLabel": ""
      },
      {
        "id": "7eyIlKSv2QgJcowEsDZ-2",
        "code": "{\n    \"unknown_product\": \"Provided product was not found\",\n    \"license_not_found\": \"License with the provided license user not found\",\n    \"license_not_enabled\": \"The license is not enabled\",\n    \"vm_not_allowed\": \"Virtual machine not allowed\",\n    \"offline_floating_cloud_not_supported\": \" Floating cloud licenses cannot be activated offline.\",\n    \"license_start_date_error\": \"This license cannot be activated before start date: {date}\",\n    \"blacklisted\": \"This device is blacklisted\",\n    \"license_activated_max_times\": \"This license  has already been activated the maximum number of times\",\n    \"license_user_activated_max_times\": \"License user has activated this license max times\",\n    \"license_expired\": \"License validity period has expired.\",\n    \"license_transferred_max_times\": \"This license has already been transferred the maximum number of times\",\n    \"license_device_exists\": \"A device matching this hardware_id is already created on the license\"\n}",
        "language": "400",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "7eyIlKSv2QgJcowEsDZ-2"
  },
  "examples": {
    "languages": [
      {
        "id": "xgX5uw4vq7BJNbqvQ_ia0",
        "language": "curl",
        "code": "curl --location --request POST '/api/v4/deactivate_license' \\\n--header 'Accept: application/json' \\\n--header 'Date: string' \\\n--header 'Authorization: string' \\\n--data-raw '{\"hardware_id\":\"String\",\"product\":\"string\",\"license_key\":\"string\",\"username\":\"string\",\"password\":\"string\",\"id_token\":\"string\",\"code\":\"string\",\"customer_account_code\":\"string\",\"is_vm\":\"Boolean\",\"vm_info\":\"string\",\"os_ver\":\"string\",\"hostname\":\"string\",\"os_hostname\":\"string\",\"ip\":\"string\",\"ip_local\":\"string\",\"app_ver\":\"string\",\"sdk_ver\":\"string\",\"mac_address\":\"string\"}'",
        "customLabel": ""
      },
      {
        "id": "3Fz0Q_qaZA0RnhG5k5R_W",
        "language": "nodejs",
        "code": "var request = require('request');\nvar options = {\n   'method': 'POST',\n   'url': '/api/v4/deactivate_license',\n   'headers': {\n      'Accept': 'application/json',\n      'Date': 'string',\n      'Authorization': 'string'\n   },\n   body: '{\"hardware_id\":\"String\",\"product\":\"string\",\"license_key\":\"string\",\"username\":\"string\",\"password\":\"string\",\"id_token\":\"string\",\"code\":\"string\",\"customer_account_code\":\"string\",\"is_vm\":\"Boolean\",\"vm_info\":\"string\",\"os_ver\":\"string\",\"hostname\":\"string\",\"os_hostname\":\"string\",\"ip\":\"string\",\"ip_local\":\"string\",\"app_ver\":\"string\",\"sdk_ver\":\"string\",\"mac_address\":\"string\"}'\n\n};\nrequest(options, function (error, response) {\n   if (error) throw new Error(error);\n   console.log(response.body);\n});\n",
        "customLabel": ""
      },
      {
        "id": "uJvCS-wF1cAIBTUqKJTug",
        "language": "javascript",
        "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Accept\", \"application/json\");\nmyHeaders.append(\"Date\", \"string\");\nmyHeaders.append(\"Authorization\", \"string\");\n\nvar raw = \"{\\\"hardware_id\\\":\\\"String\\\",\\\"product\\\":\\\"string\\\",\\\"license_key\\\":\\\"string\\\",\\\"username\\\":\\\"string\\\",\\\"password\\\":\\\"string\\\",\\\"id_token\\\":\\\"string\\\",\\\"code\\\":\\\"string\\\",\\\"customer_account_code\\\":\\\"string\\\",\\\"is_vm\\\":\\\"Boolean\\\",\\\"vm_info\\\":\\\"string\\\",\\\"os_ver\\\":\\\"string\\\",\\\"hostname\\\":\\\"string\\\",\\\"os_hostname\\\":\\\"string\\\",\\\"ip\\\":\\\"string\\\",\\\"ip_local\\\":\\\"string\\\",\\\"app_ver\\\":\\\"string\\\",\\\"sdk_ver\\\":\\\"string\\\",\\\"mac_address\\\":\\\"string\\\"}\";\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"/api/v4/deactivate_license\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));",
        "customLabel": ""
      },
      {
        "id": "oHvG2_KC9rAafj9m1qUOF",
        "language": "python",
        "code": "import requests\n\nurl = \"/api/v4/deactivate_license\"\n\npayload = \"{\\\"hardware_id\\\":\\\"String\\\",\\\"product\\\":\\\"string\\\",\\\"license_key\\\":\\\"string\\\",\\\"username\\\":\\\"string\\\",\\\"password\\\":\\\"string\\\",\\\"id_token\\\":\\\"string\\\",\\\"code\\\":\\\"string\\\",\\\"customer_account_code\\\":\\\"string\\\",\\\"is_vm\\\":\\\"Boolean\\\",\\\"vm_info\\\":\\\"string\\\",\\\"os_ver\\\":\\\"string\\\",\\\"hostname\\\":\\\"string\\\",\\\"os_hostname\\\":\\\"string\\\",\\\"ip\\\":\\\"string\\\",\\\"ip_local\\\":\\\"string\\\",\\\"app_ver\\\":\\\"string\\\",\\\"sdk_ver\\\":\\\"string\\\",\\\"mac_address\\\":\\\"string\\\"}\"\nheaders = {\n   'Accept': 'application/json',\n   'Date': 'string',\n   'Authorization': 'string'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n",
        "customLabel": ""
      },
      {
        "id": "urxE_DgGNxfjEo27HuGSl",
        "language": "ruby",
        "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"/api/v4/deactivate_license\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"Accept\"] = \"application/json\"\nrequest[\"Date\"] = \"string\"\nrequest[\"Authorization\"] = \"string\"\nrequest.body = \"{\\\"hardware_id\\\":\\\"String\\\",\\\"product\\\":\\\"string\\\",\\\"license_key\\\":\\\"string\\\",\\\"username\\\":\\\"string\\\",\\\"password\\\":\\\"string\\\",\\\"id_token\\\":\\\"string\\\",\\\"code\\\":\\\"string\\\",\\\"customer_account_code\\\":\\\"string\\\",\\\"is_vm\\\":\\\"Boolean\\\",\\\"vm_info\\\":\\\"string\\\",\\\"os_ver\\\":\\\"string\\\",\\\"hostname\\\":\\\"string\\\",\\\"os_hostname\\\":\\\"string\\\",\\\"ip\\\":\\\"string\\\",\\\"ip_local\\\":\\\"string\\\",\\\"app_ver\\\":\\\"string\\\",\\\"sdk_ver\\\":\\\"string\\\",\\\"mac_address\\\":\\\"string\\\"}\"\n\nresponse = http.request(request)\nputs response.read_body\n",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "uJvCS-wF1cAIBTUqKJTug"
  },
  "description": "Dectivate a license for a product\n",
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  }
}
```

:::

</details>

### Schema

#### Request Body

<details>

<summary><strong>Request schema (TypeScript + JSON Schema)</strong></summary>

**TypeScript**

```typescript
type LicenseActivationRequestBody = ({

  // for key-based licenses:
  license_key: string

} | {

  // for user-based licenses:
  username: string
  password: string

} | {

  // for user-based licenses using single sign-on Implicit grant:
  id_token: string
  customer_account_code: string

} | {

  // for user-based licenses using single sign-on Authorization code grant:
  code: string
  customer_account_code: string

}) & {

  // required properties:
  hardware_id: string
  product: string

  // optional properties:
  bundle_code?: string | undefined
  license_id?: number | undefined
  sdk_ver?: string | undefined
}
```

**JSON Schema**

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "allOf": [
    {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "license_key": { "type": "string" }
          },
          "required": ["license_key"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "username": { "type": "string" },
            "password": { "type": "string" }
          },
          "required": ["username", "password"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id_token": { "type": "string" },
            "customer_account_code": { "type": "string" }
          },
          "required": ["id_token", "code", "customer_account_code"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "code": { "type": "string" },
            "customer_account_code": { "type": "string" }
          },
          "required": ["id_token", "code", "customer_account_code"],
          "additionalProperties": false
        }
      ]
    },
    {
      "type": "object",
      "properties": {
        "hardware_id": { "type": "string" },
        "product": { "type": "string" },
        "bundle_code": { "type": "string" },
        "license_id": { "type": "number" },
        "sdk_ver": { "type": "string" }
      },
      "required": ["hardware_id", "product"],
      "additionalProperties": false
    }
  ]
}
```

</details>

#### Response Body

If the request succeeds, the endpoint responds with the HTTP code 200 and the string `license_deactivated`.

### License Authorization Method

There are two types of product licenses based on how the client application authorizes itself to interact with a license:

#### Key-based product licenses

Each license assigned to the product requires the client to provide a license key in order to activate, check or deactivate the license (property `license_key` in the request body).

The license response object will contain the `license_key` property, and the property `product_details.authorization_method` will be the string `license_key`.

#### User-based product licenses

Each license assigned to the product has a corresponding "license user" instead of a license key. There are multiple ways a user-based product license can be accessed when making a request:

* By providing the values for `username` and `password` for the license user
* By providing the values for `id_token` (use access\_token value) and `customer_account_code` if using single sign-on authentication using Implicit grant
* By providing the values for `code` and `customer_account_code` if using single sign-on authentication using Authorization code grant

In the license response object, `product_details.authorization_method` will have the string value `user` and the response object will contain the `user` object with information on the license user.

### Errors

If an error occurs, the response will have an HTTP status code of 400 or higher, and the response body will contain an error description in the following format:

```typescript
{
  status: number,
  code: string,
  message: string
}
```

JSON Schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "status": { "type": "number" },
    "code": { "type": "string" },
    "message": { "type": "string" }
  },
  "required": [
    "status",
    "code",
    "message"
  ],
  "additionalProperties": false
}
```

#### List of Exceptions

> unknown\_product (400): Provided product was not found

> license\_not\_found (400): License with the provided license user not found

> license\_not\_active (400): The license is not active

> device\_not\_found (400): An active device matching the hardware\_id not found

> missing\_headers (400): Some headers are missing


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.licensespring.com/license-api/license-activation-and-deactivation/deactivate-license-online-method.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
