# Check out a license file

Returns a signed license file that your application can check without a network.

`POST /v1/licenses/check-out`

## When to check out

Check out a new license file after each successful validation. The stored file is then always new. A device that goes offline can use the file for its full lifetime. See [Offline validation](../../../guides/offline-use/offline-validation/).

The policy of the license must allow offline validation. See [Policies](../../../concepts/policies/#offline-validation).

## Device

If the policy binds devices, the license file is valid on one device only. The device must claim the license first. A check-out does not claim the license. If the heartbeat lease of the device has ended, the check-out fails with `not_claimed`.

If the policy does not bind devices, the file is valid on any device. Seatify ignores the device in the request. So your application can send the device in every check-out. See [Binding](../../../concepts/seats-and-devices/#binding).

## Validity

Seatify issues a file only for a license that is valid. An expired license is still valid if the policy uses Keep access or Perpetual fallback. The file then has the status `expired`, and your application applies the After expiry rule from the file. See [Check the license](../../../guides/offline-use/offline-validation/#check-the-license).

## Signing key

Seatify signs the license file with the key that `Seatify-Signing-Key` names. Without the header, Seatify signs with the active key. The answer is signed with the same key.

Always name the key that your application embeds. Your application can only verify a file that one of its embedded keys signed. See [Key selection](../../../concepts/signing-keys/#key-selection).

## Effects

- A check-out does not bind a device, and it does not take a seat.
- A check-out does not start the heartbeat lease again. Only a [heartbeat](../heartbeat/) does that.
- A check-out does not change the time of the last validation. Only a [validation](../validate/) does that.
- A check-out does not activate the license. Only a claim does that. See [Activation](../../../concepts/licenses/#activation).
- Seatify records each check-out in the activity of the license, a refused one too. See [Activity](../../../concepts/activity/).
- Seatify cannot take back a file. The file works until it expires, also after you suspend the license or release the device. A shorter license file lifetime makes this time shorter.

## Authentication

Send the publishable key of the product. See [Authentication](../../authentication/).

## Request

| Header | Required | Description |
| --- | --- | --- |
| `Seatify-Publishable-Key` | Yes | The publishable key of the product. |
| `Content-Type` | Yes | Always `application/json`. |
| `Seatify-Nonce` | No | A new random value that the signature includes. See [Signed responses](../../#signed-responses). |
| `Seatify-Signing-Key` | No | The key ID of the signing key in your application. Seatify signs the answer and the license file with this key. See [Signing key](#signing-key). |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `key` | string | Yes | The license key. |
| `device` | object | No | The device. If the policy binds devices and the request has no device, the check-out fails with the reason `device_required`. |

The `device` object has these fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `fingerprint` | string | Yes | The fingerprint that the device sent in its claim. The fingerprint is case-sensitive. See [Devices](../../../concepts/seats-and-devices/#devices). |
| `hostname` | string | No | The name of the device. A check-out does not use the name. So your application can send the same `device` object as in the claim. |

A `device` object with no values counts as a missing device.

## Response

The answer is not a license check object. It has only these fields:

| Field | Type | Description |
| --- | --- | --- |
| `valid` | boolean | `true` if Seatify issued a license file. |
| `reason` | string | The cause when `valid` is `false`. It is null when `valid` is `true`. See [Reasons](#reasons). |
| `certificate` | string | The license file. |
| `issued` | string | The time when Seatify issued the file. |
| `expires_at` | string | The time when the file expires. This is not the expiry date of the license. |
| `ttl` | integer | The lifetime of the file in seconds. It is the license file lifetime of the policy. The default is 30 days. |

Every field is always in the answer. When `valid` is `false`, `certificate`, `issued`, `expires_at` and `ttl` are null.

The file is text. It starts with the line `-----BEGIN SEATIFY LICENSE FILE-----` and ends with the line `-----END SEATIFY LICENSE FILE-----`. The file also holds `issued`, `expires_at` and `ttl`, in `meta`. The answer repeats them, so your application knows when to check out again without opening the file.

Store the file on the device, next to the license key. Replace the stored file after each successful check-out. To verify the file and read it, see [Verify the file](../../../guides/offline-use/offline-validation/#verify-the-file) and [License file contents](../../../guides/offline-use/offline-validation/#license-file-contents).

## Reasons

A refused check-out answers with the status 200, `valid` set to `false` and a reason. Seatify issues no file.

| Reason | Description |
| --- | --- |
| `license_not_found` | No license has this key. Ask the user to check the key. |
| `product_mismatch` | The license belongs to another product. Ask the user to check the key. |
| `offline_validation_not_enabled` | The policy does not allow offline validation. Turn on offline validation in the policy. |
| `suspended` | The license is suspended. Remove the stored file, and tell the user. |
| `expired` | The license has expired, and the policy uses Expire. Remove the stored file, and tell the user. |
| `device_required` | The policy binds devices. Send the device. |
| `not_claimed` | The device has no binding on this license, or its heartbeat lease has ended. Claim the license again. Then check out the file again. |

Seatify checks the policy before the status of the license. So a suspended license under a policy without offline validation answers `offline_validation_not_enabled`.

See [Reasons](../#reasons).

## Errors

| Status | Reason | Description |
| --- | --- | --- |
| 400 | `The request body could not be read.` | The body is not valid JSON. |
| 400 | `The submitted details are not valid.` | A field is not valid. The `errors` field names it. See the table below. |
| 400 | `The signing key is not known.` | Your organization has no signing key with the ID in `Seatify-Signing-Key`. |
| 400 | `The nonce must be at most 255 characters.` | The value of `Seatify-Nonce` is too long. |
| 401 | `A publishable key is required.` | The request has no `Seatify-Publishable-Key` header, or the header is empty. |
| 401 | `The publishable key is not valid.` | No product has this key. |
| 429 | `There are too many requests. Try again later.` | See [Rate limits](../../#rate-limits). |

These fields can be in `errors`:

| Field | Description |
| --- | --- |
| `key` | The license key is missing or too long. |
| `device.fingerprint` | The `device` object has no fingerprint, or the fingerprint is too long. |
| `device.hostname` | The hostname is too long. |

See [Errors](../../#errors).

## Example

{{< 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 >}}

```json
{
  "valid": true,
  "reason": null,
  "certificate": "-----BEGIN SEATIFY LICENSE FILE-----\neyJlbmMiOiJleUp0WlhSaElqcDdJbWx6YzNWbFpDSTZJakl3TWpZdE1Ea3RNalpVTVRNNk1EVTZORFJh\n…\n-----END SEATIFY LICENSE FILE-----",
  "issued": "2026-09-26T13:05:44Z",
  "expires_at": "2026-10-26T13:05:44Z",
  "ttl": 2592000
}
```

