> ## Documentation Index
> Fetch the complete documentation index at: https://docs.myworklayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Authenticate Factory API requests with a Bearer API key scoped to your factory.

Every request to the Factory API requires a Bearer API key. Each key is bound to a single factory, so you never pass a factory ID in your requests.

## Create an API key

Generate keys in the Worklayer web app under **Develop** → **API**. See [Get an API key](https://docs.myworklayer.com/quickstart.md#get-an-api-key) for the exact steps.

Keys start with `wrk-`, followed by 43 characters:

```text theme={null}
wrk-Xq7Lm2Pv9Rt4Kc8Hs1Yd6Ab3Wn5Ge0Jf2Uz7Oi4Me9T
```

> [!WARNING]
>
> The key above is an example. Treat real API keys like production credentials: store them on your server and never commit them to source control or expose them in browser code.

## Send your key

Pass the key in a single `Authorization: Bearer <key>` header:

```bash cURL theme={null}
curl "https://api.myworklayer.com/v1/rooms"   -H "Authorization: Bearer $WORKLAYER_API_KEY"
```

```javascript fetch theme={null}
const response = await fetch('https://api.myworklayer.com/v1/rooms', {
  headers: { Authorization: `Bearer ${process.env.WORKLAYER_API_KEY}` },
});
```

The API returns `401 Unauthorized` with a `WWW-Authenticate: Bearer` header when:

* The `Authorization` header is missing, or more than one `Authorization` header is sent.
* The header is not formatted as `Bearer <key>`, or the key format is invalid.
* The key has been revoked.
* The key's factory is no longer available (for example, it was deleted).

## Revoke a key

Revoke any key from **Develop** → **API** in the Worklayer web app. Revocation takes effect immediately—subsequent requests using that key return `401 Unauthorized`.

## Permissions and scope

An API key has access to:

* Your factory's [main Room](https://docs.myworklayer.com/rooms.md#the-main-room) (`web`) and all Rooms created through the API.
* Your factory's [Subscriptions](https://docs.myworklayer.com/subscriptions.md).
* Any [Workers](https://docs.myworklayer.com/workers.md) and [Reviews](https://docs.myworklayer.com/review.md) visible in those Rooms.

When you send a message to a Worker using an API key, that Worker executes with the factory owner's permissions. Only the factory owner can create or revoke API keys. See [Who can use a factory](https://docs.myworklayer.com/factory.md#who-can-use-a-factory).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.