# Get an offline license file

`POST https://api.anyshop.io/v1/licenses/offline`

Public: the license key is the credential. Verify the file with the store's Ed25519 public key (Developers page).

- Part of the [API reference](https://docs.anyshop.io/reference.md), [License checks](https://docs.anyshop.io/reference.md#license-checks).
- No API key: the license key is the credential.

## Body (application/json)

- `key` (string, required): The license key as the buyer typed or pasted it. Up to 200 characters.
- `device_id` (string): Your app's identifier of the device, the same on every launch; only its hash is kept. Needed to activate and deactivate; with validate, it also checks the license is active on this device. 1 to 200 characters.
- `name` (string): A name the seller sees, like Studio Mac. Up to 100 characters.
- `platform` (string): The device's system, for the seller. Up to 40 characters.

## Returns

An object with `ok` and `file`.

## Errors

| Status | When |
| --- | --- |
| 400 | `invalid_key`: not a license key; `device_required`: no device ID |
| 403 | `revoked` or `expired` |
| 404 | `not_found`: no license has this key; `not_activated`: it is not active on this device |
| 429 | `rate_limited`: too many requests; see Retry-After |

## Example

curl:

```bash
curl -X POST https://api.anyshop.io/v1/licenses/offline \
  -H "Content-Type: application/json" \
  -d '{
    "key": "PXF-7Q2M-K8WD-4H9R-2LTN",
    "device_id": "a3f9c2e17b8d4e05",
    "name": "Studio Mac",
    "platform": "macOS"
  }'
```

Node:

```js
const response = await fetch("https://api.anyshop.io/v1/licenses/offline", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "key": "PXF-7Q2M-K8WD-4H9R-2LTN",
    "device_id": "a3f9c2e17b8d4e05",
    "name": "Studio Mac",
    "platform": "macOS"
  }),
});
const answer = await response.json();
```

Python:

```python
import requests

response = requests.post(
    "https://api.anyshop.io/v1/licenses/offline",
    json={
      "key": "PXF-7Q2M-K8WD-4H9R-2LTN",
      "device_id": "a3f9c2e17b8d4e05",
      "name": "Studio Mac",
      "platform": "macOS"
    },
)
answer = response.json()
```

Answer (200):

```json
{
  "ok": true,
  "file": {
    "format": "anyshop-license",
    "version": 1,
    "alg": "Ed25519",
    "payload": "eyJsaWNlbnNlIjoibGljXzAxbTNydjJm...",
    "signature": "q8Zc0v2mK3a..."
  }
}
```

Answer (400):

```json
{
  "ok": false,
  "error": {
    "code": "device_limit",
    "message": "This license is active on as many devices as it allows"
  }
}
```

Answer (403):

```json
{
  "ok": false,
  "error": {
    "code": "device_limit",
    "message": "This license is active on as many devices as it allows"
  }
}
```

The IDs and keys in these examples are made up. Every schema is in the OpenAPI document, https://api.anyshop.io/v1/openapi.json.
