> 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/sdks/go-sdk/v2/samples/offline-license.md).

# Offline License

The LicenseSpring SDK supports full offline license activation, refresh, and deactivation. This is useful in environments where no direct internet access is available on the client machine. This guide walks you through the entire offline flow using the SDK.

### Overview

Offline licensing is a multi-step process involving manual steps with the LicenseSpring portal. Each of these steps has a corresponding function in the SDK.

{% stepper %}
{% step %}

### Generate an Offline Activation Request

This function creates an activation request file and stores it in a specified or default path (Desktop). You can upload this request on the LicenseSpring portal to get a license activation file.

See the detailed section below for example usage.
{% endstep %}

{% step %}

### Activate License Using Activation File

After receiving the activation file from the LicenseSpring portal, use the SDK method to activate the license locally. The file is verified (signature, hardware ID, etc.) before updating the local license state.

See the detailed section below for example usage.
{% endstep %}

{% step %}

### Apply Updates via a Refresh File

If the license is updated on the portal (e.g., extended expiration, additional features), you can download a refresh file and update your local license using the SDK. Option to reset local consumption counts is available.

See the detailed section below for example usage.
{% endstep %}

{% step %}

### Generate Offline Deactivation Request

This function creates a deactivation request file that includes local license state (e.g., updated consumptions). Upload this file to the LicenseSpring portal to complete the deactivation. After calling this function, the license should be marked as inactive locally.

See the detailed section below for example usage.
{% endstep %}
{% endstepper %}

***

### Generate Offline Activation Request

This function creates an activation request file and stores it in a specified or default path (Desktop). You can upload this request on the LicenseSpring portal to get a license activation file.

```go
// Provide a path where the request file should be stored.
// If an empty string is given, the file will be saved to the default desktop path.
offlineActivationData, path, err := lh.CreateOfflineActivationFile("")
if err != nil {
	return err
}

fmt.Printf("Offline Activation Request Data: %s\n Stored in path: %s\n", offlineActivationData, path)
```

By uploading this request file to the LicenseSpring's offline portal, you can activate the license and receive a license activation file.

### Activate License Using Activation File

After receiving the activation file from the LicenseSpring portal, use this method to activate the license locally. The file is verified (signature, hardware ID, etc.) before updating the local license state.

```go
// Provide the path to the license activation file obtained from the portal.
// The SDK verifies the file (signature, hardware ID, etc.) and stores the license locally.
ld, err := lh.ActivateLicenseOffline(path)
if err != nil {
	return err
}
```

### Update License Using Refresh File

If the license is updated on the portal (e.g., extended expiration, additional features), you can download a refresh file and update your local license using this function. The second argument specifies whether to reset local consumption counts. If set to false, the number of local consumptions remain unchanged, otherwise, this value will be set to zero.

```go
ld, err := lh.OfflineUpdate(path, true)
if err != nil {
	return err
}
```

### Generate Offline Deactivation Request

This function creates a deactivation request file that includes local license state (e.g., updated consumptions). Upload this file to the LicenseSpring portal to complete the deactivation. After calling this function, the license should be marked as inactive locally. License Offline Deactivation updates the LicenseSpring server with the latest state of the license before being deactivated.

```go
ld, deactivationReq, path, err := lh.DeactivateOffline("")
if err != nil {
	return err
}
```

### Notes

* These offline flows are meant for environments where no internet access is available.
* Offline deactivation is currently the only way to sync local changes (such as consumption updates) back to the cloud in offline mode.


---

# 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/sdks/go-sdk/v2/samples/offline-license.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.
