# Offline validation

This guide adds offline validation to your application. At the end, your application checks out a signed license file while it is online. When there is no network, your application verifies the file and checks the license from the file.

## Before you start

- Your application claims and validates licenses. See [Add your application](../../licensing/add-your-application/).
- The policy of the license allows offline validation. Set the license file lifetime, and choose whether to encrypt license files. See [Offline validation](../../../concepts/policies/#offline-validation) on the Policies page.
- You have a [signing key](../../../concepts/signing-keys/). Copy its key ID and its public key in Base64 from the dashboard.

The examples call `https://license.seatify.dev`. In curl, the keys and the fingerprint are the variables `$SEATIFY_PUBLISHABLE_KEY`, `$SEATIFY_SIGNING_KEY_ID`, `$LICENSE_KEY` and `$DEVICE_FINGERPRINT`. In the other languages, they are variables of your application.

## Steps

{{% steps %}}

### Embed the public key

Put the key ID and the public key in your application as constants. Your application checks every license file with this key. Never download the key at run time.

You can embed more than one key. Each file names the key ID of the key that signed it. After you rotate keys, a new build embeds the new key, and older builds keep the old key. See [Rotate signing keys](../../signatures/rotate-signing-keys/).

Your application also knows the algorithm of its license files. The algorithm is `aes-256-gcm+ed25519` if the policy encrypts license files. It is `base64+ed25519` if the policy does not encrypt them.

### Claim the license

If the policy binds devices, claim the license on the device first. Check-out does not claim the license. A check-out from a device that has not claimed the license fails with `not_claimed`. See [Claim the license](../../licensing/add-your-application/#claim-the-license).

If the policy does not bind devices, skip this step.

### Check out the license file

Check out a license file after each successful validation. Send the stored license key and the fingerprint. Name the embedded key in the `Seatify-Signing-Key` header. Seatify then signs the file with that key.

{{< tabs >}}
{{< tab name="curl" >}}
```bash
curl https://license.seatify.dev/v1/licenses/check-out \
  -H "Seatify-Publishable-Key: $SEATIFY_PUBLISHABLE_KEY" \
  -H "Seatify-Signing-Key: $SEATIFY_SIGNING_KEY_ID" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "key": "$LICENSE_KEY",
  "device": { "fingerprint": "$DEVICE_FINGERPRINT" }
}
EOF
```
{{< /tab >}}
{{< tab name="Swift" >}}
```swift
import Foundation

struct CheckOut: Decodable {
    let valid: Bool
    let reason: String?
    let certificate: String?
    let expiresAt: String?
}

let body: [String: Any] = [
    "key": licenseKey,
    "device": ["fingerprint": fingerprint],
]

var request = URLRequest(url: URL(string: "https://license.seatify.dev/v1/licenses/check-out")!)
request.httpMethod = "POST"
request.setValue(publishableKey, forHTTPHeaderField: "Seatify-Publishable-Key")
request.setValue(signingKeyID, forHTTPHeaderField: "Seatify-Signing-Key")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try JSONSerialization.data(withJSONObject: body)

let (data, _) = try await URLSession.shared.data(for: request)
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
let checkOut = try decoder.decode(CheckOut.self, from: data)
```
{{< /tab >}}
{{< tab name="C#" >}}
```csharp
using System.Net.Http.Json;
using System.Text.Json;

var jsonOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower };

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Seatify-Publishable-Key", publishableKey);
client.DefaultRequestHeaders.Add("Seatify-Signing-Key", signingKeyId);

var response = await client.PostAsJsonAsync("https://license.seatify.dev/v1/licenses/check-out", new
{
    key = licenseKey,
    device = new { fingerprint },
});
var checkOut = await response.Content.ReadFromJsonAsync<CheckOut>(jsonOptions);

record CheckOut(bool Valid, string? Reason, string? Certificate, DateTimeOffset? ExpiresAt);
```
{{< /tab >}}
{{< tab name="Go" >}}
```go
body, err := json.Marshal(map[string]any{
	"key":    licenseKey,
	"device": map[string]string{"fingerprint": fingerprint},
})
if err != nil {
	return err
}

req, err := http.NewRequest("POST", "https://license.seatify.dev/v1/licenses/check-out", bytes.NewReader(body))
if err != nil {
	return err
}
req.Header.Set("Seatify-Publishable-Key", publishableKey)
req.Header.Set("Seatify-Signing-Key", signingKeyID)
req.Header.Set("Content-Type", "application/json")

res, err := http.DefaultClient.Do(req)
if err != nil {
	return err
}
defer res.Body.Close()

var checkOut struct {
	Valid       bool       `json:"valid"`
	Reason      *string    `json:"reason"`
	Certificate *string    `json:"certificate"`
	ExpiresAt   *time.Time `json:"expires_at"`
}
err = json.NewDecoder(res.Body).Decode(&checkOut)
```
{{< /tab >}}
{{< tab name="JavaScript" >}}
```javascript
const response = await fetch("https://license.seatify.dev/v1/licenses/check-out", {
  method: "POST",
  headers: {
    "Seatify-Publishable-Key": publishableKey,
    "Seatify-Signing-Key": signingKeyId,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    key: licenseKey,
    device: { fingerprint },
  }),
});
const checkOut = await response.json();
```
{{< /tab >}}
{{< /tabs >}}

A successful check-out answers with `valid` set to `true`:

```json
{
  "valid": true,
  "reason": null,
  "certificate": "-----BEGIN SEATIFY LICENSE FILE-----\neyJlbmMiOiI4aWV4NnlLMTNCVHN5U2JzR0dEMVJ5enAySjlNbjdURkNqSEVYVmZKRUFBNk9UcVBpemFn\n…\n-----END SEATIFY LICENSE FILE-----",
  "issued": "2026-09-25T16:16:41Z",
  "expires_at": "2026-10-25T16:16:41Z",
  "ttl": 2592000
}
```

The `certificate` field is the license file. The file is valid until `expires_at`. The `ttl` field is the lifetime of the file in seconds.

If `valid` is `false`, the `reason` field names the cause, and the other fields are `null`. See [Check-out refusals](#check-out-refusals).

The answer is signed like every other License API answer. See [Verify signed responses](../../signatures/verify-signed-responses/).

### Store the license file

Store the certificate and its `expires_at` on the device, next to the license key. Replace the stored file after each successful check-out.

Your application checks out a new file after each online validation. The stored file is then always new. A device that goes offline can use the file for its full lifetime.

### Verify the file

When your application cannot reach the License API, it verifies the stored file. If any check fails, your application must not use the file.

1. Remove the `BEGIN` and `END` lines. Join the other lines, and decode them from Base64. The result is a JSON object with the fields `enc`, `sig`, `alg` and `kid`.
2. Check that `alg` is the algorithm that your application expects. Never let the file choose the algorithm.
3. Find the embedded public key that has the key ID in `kid`. If no embedded key has this ID, the file is not valid.
4. Verify the Ed25519 signature in `sig`. The signature covers the text `license/`, followed by the value of `enc`.
5. Read the contents. For `base64+ed25519`, decode `enc` from Base64. For `aes-256-gcm+ed25519`, decrypt `enc`. See [Encrypted files](#encrypted-files).

All Base64 in the file is standard Base64 with padding.

{{< tabs >}}
{{< tab name="curl" >}}
This step runs inside your application. Choose a language tab to see the code.
{{< /tab >}}
{{< tab name="Swift" >}}
```swift
import CryptoKit
import Foundation

struct InvalidLicenseFile: Error {}

struct Envelope: Decodable {
    let enc: String
    let sig: String
    let alg: String
    let kid: String
}

let publicKeys = ["<key id>": "<public key in Base64>"]
let expectedAlgorithm = "aes-256-gcm+ed25519"

func sha256Hex(_ value: String) -> String {
    SHA256.hash(data: Data(value.utf8)).map { String(format: "%02x", $0) }.joined()
}

func openLicenseFile(_ certificate: String, licenseKey: String, fingerprint: String?) throws -> Data {
    let body = certificate
        .split(separator: "\n")
        .filter { !$0.hasPrefix("-----") }
        .joined()
    guard let raw = Data(base64Encoded: body) else { throw InvalidLicenseFile() }
    let envelope = try JSONDecoder().decode(Envelope.self, from: raw)

    guard envelope.alg == expectedAlgorithm,
          let encodedKey = publicKeys[envelope.kid],
          let keyData = Data(base64Encoded: encodedKey),
          let signature = Data(base64Encoded: envelope.sig)
    else { throw InvalidLicenseFile() }

    let publicKey = try Curve25519.Signing.PublicKey(rawRepresentation: keyData)
    guard publicKey.isValidSignature(signature, for: Data(("license/" + envelope.enc).utf8)) else {
        throw InvalidLicenseFile()
    }

    if envelope.alg == "base64+ed25519" {
        guard let contents = Data(base64Encoded: envelope.enc) else { throw InvalidLicenseFile() }
        return contents
    }

    let parts = envelope.enc.split(separator: ".").compactMap { Data(base64Encoded: String($0)) }
    guard parts.count == 3 else { throw InvalidLicenseFile() }

    let material = licenseKey + (fingerprint.map(sha256Hex) ?? "")
    let key = SymmetricKey(data: SHA256.hash(data: Data(material.utf8)))
    let box = try AES.GCM.SealedBox(nonce: AES.GCM.Nonce(data: parts[1]), ciphertext: parts[0], tag: parts[2])

    return try AES.GCM.open(box, using: key)
}
```
{{< /tab >}}
{{< tab name="C#" >}}
```csharp
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
// .NET has no Ed25519, so the signature check uses the NSec.Cryptography package.
using NSec.Cryptography;

var publicKeys = new Dictionary<string, string> { ["<key id>"] = "<public key in Base64>" };
const string expectedAlgorithm = "aes-256-gcm+ed25519";

string Sha256Hex(string value) =>
    Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(value))).ToLowerInvariant();

byte[] OpenLicenseFile(string certificate, string licenseKey, string? fingerprint)
{
    var body = string.Concat(certificate.Split('\n').Where(line => !line.StartsWith("-----")));
    var envelope = JsonSerializer.Deserialize<Envelope>(Convert.FromBase64String(body), jsonOptions)
        ?? throw new InvalidDataException("The license file is not valid.");

    if (envelope.Alg != expectedAlgorithm || !publicKeys.TryGetValue(envelope.Kid, out var encodedKey))
        throw new InvalidDataException("The license file is not valid.");

    var publicKey = PublicKey.Import(SignatureAlgorithm.Ed25519, Convert.FromBase64String(encodedKey), KeyBlobFormat.RawPublicKey);
    var signed = Encoding.UTF8.GetBytes("license/" + envelope.Enc);
    if (!SignatureAlgorithm.Ed25519.Verify(publicKey, signed, Convert.FromBase64String(envelope.Sig)))
        throw new InvalidDataException("The license file is not valid.");

    if (envelope.Alg == "base64+ed25519")
        return Convert.FromBase64String(envelope.Enc);

    var parts = envelope.Enc.Split('.').Select(Convert.FromBase64String).ToArray();
    var material = fingerprint is null ? licenseKey : licenseKey + Sha256Hex(fingerprint);
    var key = SHA256.HashData(Encoding.UTF8.GetBytes(material));

    var contents = new byte[parts[0].Length];
    using var aes = new AesGcm(key, tagSizeInBytes: 16);
    aes.Decrypt(parts[1], parts[0], parts[2], contents);

    return contents;
}

record Envelope(string Enc, string Sig, string Alg, string Kid);
```
{{< /tab >}}
{{< tab name="Go" >}}
```go
var errInvalidLicenseFile = errors.New("the license file is not valid")

var publicKeys = map[string]string{"<key id>": "<public key in Base64>"}

const expectedAlgorithm = "aes-256-gcm+ed25519"

func openLicenseFile(certificate, licenseKey, fingerprint string) ([]byte, error) {
	var body strings.Builder
	for _, line := range strings.Split(certificate, "\n") {
		if !strings.HasPrefix(line, "-----") {
			body.WriteString(strings.TrimSpace(line))
		}
	}

	raw, err := base64.StdEncoding.DecodeString(body.String())
	if err != nil {
		return nil, errInvalidLicenseFile
	}

	var envelope struct {
		Enc string `json:"enc"`
		Sig string `json:"sig"`
		Alg string `json:"alg"`
		Kid string `json:"kid"`
	}
	if err := json.Unmarshal(raw, &envelope); err != nil {
		return nil, errInvalidLicenseFile
	}

	encodedKey, found := publicKeys[envelope.Kid]
	if envelope.Alg != expectedAlgorithm || !found {
		return nil, errInvalidLicenseFile
	}

	publicKey, err := base64.StdEncoding.DecodeString(encodedKey)
	if err != nil {
		return nil, errInvalidLicenseFile
	}
	signature, err := base64.StdEncoding.DecodeString(envelope.Sig)
	if err != nil {
		return nil, errInvalidLicenseFile
	}
	if !ed25519.Verify(publicKey, []byte("license/"+envelope.Enc), signature) {
		return nil, errInvalidLicenseFile
	}

	if envelope.Alg == "base64+ed25519" {
		return base64.StdEncoding.DecodeString(envelope.Enc)
	}

	parts := strings.Split(envelope.Enc, ".")
	if len(parts) != 3 {
		return nil, errInvalidLicenseFile
	}
	ciphertext, err1 := base64.StdEncoding.DecodeString(parts[0])
	iv, err2 := base64.StdEncoding.DecodeString(parts[1])
	tag, err3 := base64.StdEncoding.DecodeString(parts[2])
	if err1 != nil || err2 != nil || err3 != nil {
		return nil, errInvalidLicenseFile
	}

	material := licenseKey
	if fingerprint != "" {
		fingerprintHash := sha256.Sum256([]byte(fingerprint))
		material += hex.EncodeToString(fingerprintHash[:])
	}
	key := sha256.Sum256([]byte(material))

	block, err := aes.NewCipher(key[:])
	if err != nil {
		return nil, err
	}
	gcm, err := cipher.NewGCM(block)
	if err != nil {
		return nil, err
	}

	contents, err := gcm.Open(nil, iv, append(ciphertext, tag...), nil)
	if err != nil {
		return nil, errInvalidLicenseFile
	}

	return contents, nil
}
```
{{< /tab >}}
{{< tab name="JavaScript" >}}
```javascript
const publicKeys = { "<key id>": "<public key in Base64>" };
const expectedAlgorithm = "aes-256-gcm+ed25519";

const encoder = new TextEncoder();
const fromBase64 = (value) => Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
const sha256Hex = async (value) =>
  Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", encoder.encode(value))))
    .map((byte) => byte.toString(16).padStart(2, "0"))
    .join("");

async function openLicenseFile(certificate, licenseKey, fingerprint) {
  const body = certificate
    .split("\n")
    .filter((line) => !line.startsWith("-----"))
    .join("");
  const envelope = JSON.parse(atob(body));

  const encodedKey = publicKeys[envelope.kid];
  if (envelope.alg !== expectedAlgorithm || !encodedKey) {
    throw new Error("The license file is not valid.");
  }

  const publicKey = await crypto.subtle.importKey("raw", fromBase64(encodedKey), { name: "Ed25519" }, false, ["verify"]);
  const verified = await crypto.subtle.verify(
    { name: "Ed25519" },
    publicKey,
    fromBase64(envelope.sig),
    encoder.encode("license/" + envelope.enc),
  );
  if (!verified) {
    throw new Error("The license file is not valid.");
  }

  if (envelope.alg === "base64+ed25519") {
    return JSON.parse(new TextDecoder().decode(fromBase64(envelope.enc)));
  }

  const [ciphertext, iv, tag] = envelope.enc.split(".").map(fromBase64);
  const material = fingerprint ? licenseKey + (await sha256Hex(fingerprint)) : licenseKey;
  const keyBytes = await crypto.subtle.digest("SHA-256", encoder.encode(material));
  const key = await crypto.subtle.importKey("raw", keyBytes, { name: "AES-GCM" }, false, ["decrypt"]);
  const contents = await crypto.subtle.decrypt({ name: "AES-GCM", iv }, key, new Uint8Array([...ciphertext, ...tag]));

  return JSON.parse(new TextDecoder().decode(contents));
}
```
{{< /tab >}}
{{< /tabs >}}

#### Encrypted files

The value of `enc` has three parts, separated by dots: the ciphertext, the IV and the tag. Each part is Base64. Decrypt the ciphertext with AES-256-GCM.

The AES key is the SHA-256 of a text that your application builds:

| File | Text to hash |
| --- | --- |
| For one device | The license key, followed by the SHA-256 of the fingerprint in lower-case hex. |
| For the whole license | The license key. |

Use the license key in upper case, as your application stored it. A file is for one device when the policy binds devices. A file for another device does not decrypt.

### Check the contents

After the signature, check that the file is for this license and this device. Also check that the file has not expired.

1. The time now is between `meta.issued` and `meta.expiry`. When the file has expired, your application must go online again.
2. `license.key_hash` is the SHA-256 of the stored license key, in lower-case hex.
3. If `meta.scope` is not `null`, `meta.scope.fingerprint_hash` is the SHA-256 of the fingerprint of this device, in lower-case hex.

Store the latest time that your application has seen. If the clock of the device shows an earlier time, do not trust the file. A clock that is set back must not make an old file valid again.

{{< tabs >}}
{{< tab name="curl" >}}
This step runs inside your application. Choose a language tab to see the code.
{{< /tab >}}
{{< tab name="Swift" >}}
```swift
struct LicenseFile: Decodable {
    struct Meta: Decodable {
        struct Scope: Decodable {
            let fingerprintHash: String
        }

        let issued: Date
        let expiry: Date
        let scope: Scope?
    }

    struct License: Decodable {
        let keyHash: String
        let expiresAt: Date?
    }

    struct Expiration: Decodable {
        let strategy: String
        let gracePeriodSeconds: Int?
    }

    let meta: Meta
    let license: License
    let expiration: Expiration
}

func checkLicenseFile(_ contents: Data, licenseKey: String, fingerprint: String?, now: Date = Date()) throws -> LicenseFile {
    let decoder = JSONDecoder()
    decoder.keyDecodingStrategy = .convertFromSnakeCase
    decoder.dateDecodingStrategy = .iso8601
    let file = try decoder.decode(LicenseFile.self, from: contents)

    guard file.meta.issued <= now, now <= file.meta.expiry else { throw InvalidLicenseFile() }
    guard file.license.keyHash == sha256Hex(licenseKey) else { throw InvalidLicenseFile() }
    if let scope = file.meta.scope {
        guard let fingerprint, scope.fingerprintHash == sha256Hex(fingerprint) else { throw InvalidLicenseFile() }
    }

    return file
}
```
{{< /tab >}}
{{< tab name="C#" >}}
```csharp
LicenseFile CheckLicenseFile(byte[] contents, string licenseKey, string? fingerprint, DateTimeOffset now)
{
    var file = JsonSerializer.Deserialize<LicenseFile>(contents, jsonOptions)
        ?? throw new InvalidDataException("The license file is not valid.");

    if (now < file.Meta.Issued || now > file.Meta.Expiry)
        throw new InvalidDataException("The license file is not valid.");

    if (file.License.KeyHash != Sha256Hex(licenseKey))
        throw new InvalidDataException("The license file is not valid.");

    if (file.Meta.Scope is not null && (fingerprint is null || file.Meta.Scope.FingerprintHash != Sha256Hex(fingerprint)))
        throw new InvalidDataException("The license file is not valid.");

    return file;
}

record LicenseFile(LicenseFileMeta Meta, LicenseFileLicense License, LicenseFileExpiration Expiration);
record LicenseFileMeta(DateTimeOffset Issued, DateTimeOffset Expiry, LicenseFileScope? Scope);
record LicenseFileScope(string FingerprintHash);
record LicenseFileLicense(string KeyHash, DateTimeOffset? ExpiresAt);
record LicenseFileExpiration(string Strategy, long? GracePeriodSeconds);
```
{{< /tab >}}
{{< tab name="Go" >}}
```go
type licenseFile struct {
	Meta struct {
		Issued time.Time `json:"issued"`
		Expiry time.Time `json:"expiry"`
		Scope  *struct {
			FingerprintHash string `json:"fingerprint_hash"`
		} `json:"scope"`
	} `json:"meta"`
	License struct {
		KeyHash   string     `json:"key_hash"`
		ExpiresAt *time.Time `json:"expires_at"`
	} `json:"license"`
	Expiration struct {
		Strategy           string `json:"strategy"`
		GracePeriodSeconds *int64 `json:"grace_period_seconds"`
	} `json:"expiration"`
}

func checkLicenseFile(contents []byte, licenseKey, fingerprint string, now time.Time) (licenseFile, error) {
	var file licenseFile
	if err := json.Unmarshal(contents, &file); err != nil {
		return file, errInvalidLicenseFile
	}

	if now.Before(file.Meta.Issued) || now.After(file.Meta.Expiry) {
		return file, errInvalidLicenseFile
	}

	keyHash := sha256.Sum256([]byte(licenseKey))
	if file.License.KeyHash != hex.EncodeToString(keyHash[:]) {
		return file, errInvalidLicenseFile
	}

	if file.Meta.Scope != nil {
		fingerprintHash := sha256.Sum256([]byte(fingerprint))
		if file.Meta.Scope.FingerprintHash != hex.EncodeToString(fingerprintHash[:]) {
			return file, errInvalidLicenseFile
		}
	}

	return file, nil
}
```
{{< /tab >}}
{{< tab name="JavaScript" >}}
```javascript
async function checkLicenseFile(file, licenseKey, fingerprint, now = new Date()) {
  if (now < new Date(file.meta.issued) || now > new Date(file.meta.expiry)) {
    throw new Error("The license file is not valid.");
  }
  if (file.license.key_hash !== (await sha256Hex(licenseKey))) {
    throw new Error("The license file is not valid.");
  }
  if (file.meta.scope && file.meta.scope.fingerprint_hash !== (await sha256Hex(fingerprint))) {
    throw new Error("The license file is not valid.");
  }

  return file;
}
```
{{< /tab >}}
{{< /tabs >}}

### Check the license

The file holds the license as it was at check-out. Work out the status of the license again from the file. Use the expiry date of the license, the grace period and the After expiry rule:

| Time now | Status | Valid |
| --- | --- | --- |
| The license has no `expires_at`. | `active` | Yes |
| Before `license.expires_at` | `active` | Yes |
| Before `license.expires_at` plus `expiration.grace_period_seconds` | `grace` | Yes |
| Later | `expired` | Only if `expiration.strategy` is `keep_access` or `perpetual_fallback` |

If `grace_period_seconds` is `null`, the policy has no grace period. Then use the entitlements and the limits in the file, as your application uses them from a validation. See [Statuses](../../../concepts/licenses/#statuses).

{{% /steps %}}

## License file contents

The contents of a license file are JSON. The field names are the same as in a validation answer.

| Field | Description |
| --- | --- |
| `meta` | The file itself: `issued`, `expiry`, `ttl` in seconds and `scope`. The `scope` is `null` for a file for the whole license. For a file for one device, the `scope` holds `fingerprint_hash`. |
| `license` | `id`, `name`, `key_hash`, `expires_at` and `activated_at`. `status` and `expired` are the values at check-out. |
| `limits` | `max_devices`, `max_seats` and `max_processes`. `null` means that there is no limit. |
| `entitlements` | The entitlements of the license. Each one has a `code` and a `name`. |
| `heartbeat` | Whether the policy requires heartbeats, with the interval and the grace in seconds. |
| `expiration` | The After expiry rule in `strategy`, and the grace period in `grace_period_seconds`. |

The file holds no license key and no fingerprint. It holds only their SHA-256 hashes.

This file is for one device:

```json
{
  "meta": {
    "issued": "2026-09-25T16:16:41Z",
    "expiry": "2026-10-25T16:16:41Z",
    "ttl": 2592000,
    "scope": {
      "fingerprint_hash": "<SHA-256 of the fingerprint>"
    }
  },
  "license": {
    "id": "<license id>",
    "name": "Studio team",
    "key_hash": "<SHA-256 of the license key>",
    "expires_at": "2026-10-22T23:00:00Z",
    "activated_at": "2026-01-29T01:41:17Z",
    "status": "active",
    "expired": false
  },
  "limits": {
    "max_devices": 6,
    "max_seats": null,
    "max_processes": 1
  },
  "entitlements": [
    {
      "code": "API_ACCESS",
      "name": "API Access"
    },
    {
      "code": "AUDIT_LOG",
      "name": "Audit Log"
    }
  ],
  "heartbeat": {
    "required": false,
    "interval_seconds": null,
    "grace_seconds": null
  },
  "expiration": {
    "strategy": "keep_access",
    "grace_period_seconds": null
  }
}
```

## When the file is not valid

| Situation | What your application does |
| --- | --- |
| The License API answers. | Use the online answer, because it is newer than the file. If the answer has `valid` set to `false`, remove the stored file. |
| There is no stored file. | Ask the user to connect to the internet. |
| The file has expired. | Ask the user to connect to the internet. The next check-out gives a new file. |
| A check fails. | Remove the stored file. Ask the user to connect to the internet. |

For a device that never connects to the internet, see [Devices with no internet](../devices-with-no-internet/).

## Check-out refusals

Check-out answers every licensing outcome with the status 200, a refusal too. The `reason` field names the cause.

| Reason | Cause | What your application does |
| --- | --- | --- |
| `offline_validation_not_enabled` | The policy does not allow offline validation. | Turn on offline validation in the policy. |
| `license_not_found` | The key is not known. | Ask the user to enter the key again. |
| `product_mismatch` | The key belongs to another product. | Ask the user for the right key. |
| `suspended` | The license is suspended. | Remove the stored file, and tell the user. |
| `expired` | The license has expired, and the After expiry rule is Expire. | Remove the stored file, and tell the user. |
| `device_required` | The policy binds devices, and the request has no device. | Send the fingerprint. |
| `not_claimed` | The device has not claimed the license, or its heartbeat lease has ended. | Claim the license again. Then check out the file again. |

Other statuses mean that the request itself is wrong:

| Status | Cause |
| --- | --- |
| 400 | The body is not valid, or `Seatify-Signing-Key` names a key that is not known. |
| 401 | The publishable key is missing or not valid. |
| 429 | Your application sent too many requests. Try again later. |

## Limits of offline files

- A file works until it expires. A suspended or deleted license keeps working offline until then. A shorter license file lifetime makes this time shorter.
- Check-out does not renew a heartbeat lease. If the policy requires heartbeats, the lease can end while the device is offline. Seatify then frees the device slot, but the file still works until it expires.
- Encryption stops a person from reading the file in a text editor. A person who has the license key can still decrypt the file. The signature protects the file from changes.
- A file that a deleted signing key signed still verifies until the file expires. Seatify signs no new files with a deleted key.

## Next steps

- [Verify signed responses](../../signatures/verify-signed-responses/)
- [Rotate signing keys](../../signatures/rotate-signing-keys/)
- [Devices with no internet](../devices-with-no-internet/)
- [Check out a license file](../../../license-api/licenses/check-out/)

