> For the complete documentation index, see [llms.txt](https://docs.licensespring.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.licensespring.com/license-api/license-activation-and-deactivation/deactivate-license-offline-method.md).

# Deactivate License (Offline Method)

{% hint style="info" %}
Currently we support trial, perpetual and consumption license types for offline deactivation purposes
{% endhint %}

### Endpoint

* Method: `POST`
* Path: `/api/v4/deactivate_offline`
* Description: Deactivates a license using the offline flow (base64 payload).

### 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`

### Request

#### Body

The request body is a **base64-encoded, stringified JSON object** (see schema below).

{% hint style="danger" %}
If using `multipart/form-data`, the `file` form parameter is mandatory.
{% endhint %}

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

```bash
curl --location --request POST '/api/v4/deactivate_offline' \
--header 'Accept: application/json' \
--header 'Date: string' \
--header 'Authorization: string' \
--data-raw '_BASE64_PAYLOAD_HERE_'
```

{% endtab %}

{% tab title="nodejs" %}

```javascript
var request = require('request');
var options = {
   'method': 'POST',
   'url': '/api/v4/deactivate_offline',
   'headers': {
      'Accept': 'application/json',
      'Date': 'string',
      'Authorization': 'string'
   },
   body: Buffer.from(JSON.stringify(offline_payload)).toString('base64')
};

request(options, function (error, response) {
   if (error) throw new Error(error);
   console.log(response.body);
});
```

{% endtab %}

{% tab title="javascript" %}

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

var requestOptions = {
   method: 'POST',
   headers: myHeaders,
   body: btoa(JSON.stringify(offline_payload)),
   redirect: 'follow'
};

fetch("/api/v4/deactivate_offline", 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_offline"

payload = "{\"Payload\":\"Object\"}"
headers = {
   'Accept': 'application/json',
   'Date': 'string',
   'Authorization': 'string'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}

{% tab title="ruby" %}

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

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

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Date"] = "string"
request["Authorization"] = "string"
request.body = "{\"Payload\":\"Object\"}"

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

{% endtab %}
{% endtabs %}

***

### Schema

#### Request Body

The request body is a string representing a base64-encoded JSON object containing all the required activation data.

{% hint style="danger" %}
If using "multipart/form-data" for the request, the "file" form parameter is mandatory
{% endhint %}

<details>

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

**TypeScript**

```typescript
type LicenseOfflineActivationObject = ({

  // for key-based licenses:
  license_key: string

} | {

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

}) & {

  // required properties:
  hardware_id: string
  product: string
  request_id: string
  signature: string
  date: string
  request: "deactivation"
  
} & ({
  api_key: string // for API key authorization
} | {
  client_id: string // for OAuth authorization
}) & {

  // optional properties:
  bundle_code?: string | undefined
  license_id?: number | undefined
  is_vm?: boolean | undefined
  vm_info?: string | undefined
  os_ver?: string | undefined
  hostname?: string | undefined
  os_hostname?: string | undefined
  ip?: string | undefined
  ip_local?: string | undefined
  app_ver?: string | undefined
  sdk_ver?: string | undefined
  mac_address?: string | undefined
  consumptions?: number | undefined
  product_features?: {
    feature: string,
    consumptions: number,
  }[]
}
```

**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": {
        "api_key": { "type": "string" },
        "client_id": { "type": "string" },
        "request": { "type": "string" },
        "request_id": { "type": "string" },
        "date": { "type": "string" },
        "signature": { "type": "string" },
        "hardware_id": { "type": "string" },
        "product": { "type": "string" },
        "bundle_code": { "type": "string" },
        "license_id": { "type": "number" },
        "is_vm": { "type": "boolean" },
        "vm_info": { "type": "string" },
        "os_ver": { "type": "string" },
        "hostname": { "type": "string" },
        "os_hostname": { "type": "string" },
        "ip": { "type": "string" },
        "ip_local": { "type": "string" },
        "app_ver": { "type": "string" },
        "sdk_ver": { "type": "string" },
        "mac_address": { "type": "string" },
        "consumptions": { "type": "number" }, 
        "product_features": {
          "type": "object",
          "properties": {
            "feature": { "type": "string" },
            "consumptions": { "type": "number" }
          }
        }
      },
     "allOf": [
        { "anyOf": [{ "required": ["api_key"] }, { "required": ["client_id"] }] },
        { "anyOf": [{ "required": ["license_key"] }, { "required": ["username"] }] }
      ],
      "required": ["hardware_id", "product", "date", "signature"],
      "additionalProperties": false
    }
  ]
}
```

</details>

***

### Signature

The signature value is constructed from a specific signing string and then encrypted using HMAC-SHA256 with the company shared key (or client secret for OAuth). Use the following steps to build the signing string:

{% stepper %}
{% step %}

### Step

Concatenate the string "licenseSpring" plus a newline.
{% endstep %}

{% step %}

### Step

Add the string "date: " plus the "date" value from the license payload object, plus a newline.
{% endstep %}

{% step %}

### Step

Add either the "license\_key" or "username" value from the request payload (whichever is present), plus a newline.
{% endstep %}

{% step %}

### Step

Add the "hardware\_id" value from the request payload, plus a newline.
{% endstep %}

{% step %}

### Step

Add the "api\_key" value from the request payload.
{% endstep %}
{% endstepper %}

Encrypt the complete string with HMAC-SHA256 using the signing key (Shared Key for API key authorization; Client Secret for OAuth). Example in Node.js:

```javascript
import crypto from 'node:crypto';

const activationPayload = {
  // ...payload content...
};

// api_key or client_id depending on authorization type used:
const key = (activationPayload.api_key || activationPayload.client_id);

// if using API key authorization: the signing key is the Shared Key
// if using OAuth: the signing key is the Client Secret
const signingKey = '...';

const signingString =
  'licenseSpring\n' +
  'date: ' + activationPayload.date + '\n' +
  (activationPayload.license_key || activationPayload.username) + '\n' +
  activationPayload.hardware_id + '\n' +
  key;

const signature = crypto
  .createHmac('sha256', signingKey)
  .update(signingString)
  .digest('base64');
```

***

#### Finalized payload

This object is then stringified and encoded to base64.

{% tabs %}
{% tab title="JS Browser" %}

```javascript
const activationPayload = {
  // ...payload content...
};
const requestBody = btoa(JSON.stringify(activationPayload));
```

{% endtab %}

{% tab title="nodeJS" %}

```javascript
const activationPayload = {
  // ...payload content with "signature" property...
};
const requestBody = Buffer.from(JSON.stringify(activationPayload)).toString('base64');
```

{% endtab %}
{% endtabs %}

***

#### Response Body

If the request succeeds, the endpoint responds with HTTP 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

* Client provides property license\_key in the request body.
* The license response object will contain license\_key.
* product\_details.authorization\_method will be "license\_key".

#### User-based product licenses

* Product uses a license user instead of a license key.
* Access methods include:
  * Providing username and password
  * Providing id\_token and customer\_account\_code (Implicit grant SSO)
  * Providing code and customer\_account\_code (Authorization code grant SSO)

In responses, product\_details.authorization\_method will be "user" and the response will contain the user object with information on the license user.

***

### Errors

If an error occurs, the response will have HTTP status code >= 400 and the body will contain an error description:

```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

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

* when missing authorization or date headers

> missing\_parameters (400): some parameters are missing in the request

* when no request body at all or no file found in request body

> authorization\_missing\_params (400): some parameters are missing in authorization

* when the request body is not properly base64 encoded
* when file is missing in request body
* when license\_key or hardware\_id body parameters are missing
* when data body parameter is missing
* when api\_key parameter is missing

***

### Guide on using Offline Licenses

If any aspect of the offline licensing model remains unclear, see [Offline License Activation](/license-entitlements/license-activation-types/offline-license-activation.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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-offline-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.
