# Authentication

Every path of the Distribution API names the product. A request sends a license key in the `Seatify-License-Key` header. A product with the `open` distribution setting does not require a license key.

## Products

Every path starts with `/v1/products/{product}`. `{product}` is the ID of the product. The Distribution API does not use a publishable key.

An unknown product ID answers with the status 404.

## License keys

| Header | Required | Description |
| --- | --- | --- |
| `Seatify-License-Key` | For a `licensed` product | The license key of the customer. |

The [distribution](../../concepts/products/#distribution) setting of the product decides when the key is required:

| Distribution | Without a license key | With a license key |
| --- | --- | --- |
| `licensed` | The answer has the status 401. | Seatify checks the license. |
| `open` | Anyone can list and download the releases. | Seatify checks the license. |

The Distribution API reads the license key only from the header. Do not put the key in the URL.

A browser sends no header when it follows a link. For a download page of a `licensed` product, see [Licensed products](../../guides/releases/updates-and-download-links/#licensed-products).

## License checks

A known license key does not always get the releases. The Distribution API refuses the license in these cases:

| Reason | Description |
| --- | --- |
| `product_mismatch` | The license belongs to another product. This applies to an `open` product too. |
| `suspended` | The license is [suspended](../../concepts/licenses/#suspension). |
| `expired` | The license expired, and its policy uses the Expire rule. |
| `release_not_covered` | The license expired under Perpetual fallback, and the release was published after its expiry date. |

With Keep access, an expired license gets every release. See [After expiry](../../concepts/policies/#after-expiry).

A request does not claim the license. It does not use a seat or a device.

The status of a refusal depends on the endpoint:

| Endpoint | Refusal |
| --- | --- |
| [List releases](../list-releases/), [Get a release](../get-a-release/) and [Check for an update](../check-for-an-update/) | The status 200, with `valid` set to `false` and the reason. |
| [Download an artifact](../download-an-artifact/), the [stable download link](../stable-download-link/) and the updater feeds | The status 403, with `valid` set to `false` and the reason. |

[Get a product](../get-a-product/) does not check the license. It answers for every known key.

## Errors

| Status | Message | Description |
| --- | --- | --- |
| 401 | `A license key is required.` | The product is `licensed`, and the request has no `Seatify-License-Key` header, or the header is empty. |
| 401 | `The license key is not valid.` | No license in your account has this key. This applies to an `open` product too. |
| 404 | `The product was not found.` | No product has this ID. |

## Unsigned answers

A 401 answer has no signature. It never grants access. Your application trusts only a 200 answer with a valid signature. See [Verify signed responses](../../guides/signatures/verify-signed-responses/).

## Example

Check that a license key is known with [Get a product](../get-a-product/).

{{< tabs >}}
{{< tab name="curl" >}}
```bash
curl https://dist.seatify.dev/v1/products/$PRODUCT_ID \
  -H "Seatify-License-Key: $LICENSE_KEY"
```
{{< /tab >}}
{{< tab name="Swift" >}}
```swift
var request = URLRequest(url: URL(string: "https://dist.seatify.dev/v1/products/\(productID)")!)
request.setValue(licenseKey, forHTTPHeaderField: "Seatify-License-Key")

let (data, response) = try await URLSession.shared.data(for: request)
```
{{< /tab >}}
{{< tab name="C#" >}}
```csharp
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Seatify-License-Key", licenseKey);

using var response = await client.GetAsync($"https://dist.seatify.dev/v1/products/{productId}");
var body = await response.Content.ReadAsStringAsync();
```
{{< /tab >}}
{{< tab name="Go" >}}
```go
req, err := http.NewRequest("GET", "https://dist.seatify.dev/v1/products/"+productID, nil)
if err != nil {
	return err
}
req.Header.Set("Seatify-License-Key", licenseKey)

res, err := http.DefaultClient.Do(req)
if err != nil {
	return err
}
defer res.Body.Close()
```
{{< /tab >}}
{{< tab name="JavaScript" >}}
```javascript
const response = await fetch(`https://dist.seatify.dev/v1/products/${productId}`, {
  headers: { "Seatify-License-Key": licenseKey },
});
const body = await response.json();
```
{{< /tab >}}
{{< /tabs >}}

A known key answers with the status 200:

```json
{
  "id": "<product id>",
  "name": "Beacon Studio",
  "code": "BEACON",
  "distribution": "licensed"
}
```

A request without the header answers with the status 401:

```json
{
  "message": "A license key is required."
}
```

