# Deactivate a license

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

Public: the license key is the credential. No API key.

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

## 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/deactivate \
  -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/deactivate", {
  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/deactivate",
    json={
      "key": "PXF-7Q2M-K8WD-4H9R-2LTN",
      "device_id": "a3f9c2e17b8d4e05",
      "name": "Studio Mac",
      "platform": "macOS"
    },
)
answer = response.json()
```

Answer (200):

```json
{
  "ok": true,
  "license": {
    "id": "lic_01m3rv2f8k1q7w3e5r9t0y4u6i",
    "status": "active",
    "livemode": true,
    "product": {
      "id": "prod_01m3rr5kmbeb2s18x1kpntjxqb",
      "name": "Lumen Studio Pro"
    },
    "expires_at": null,
    "updates_until": "2027-10-02T14:21:07.000Z",
    "devices": {
      "used": 1,
      "limit": 2
    },
    "activation": {
      "activated_at": "2026-10-02T14:21:07.000Z",
      "name": "Studio Mac"
    }
  }
}
```

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.
