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

# Authentication

> Authenticate GENGEN API requests with a workspace API key.

GENGEN API requests use bearer-token authentication.

## Create a key

1. Sign in to the [GENGEN Dashboard](https://gengen.farm/dashboard).
2. Open **API Keys**.
3. Create a key and copy it immediately.

Keys begin with `gengen_live_`. The complete secret is shown only when the key is created.

## Send the key

Include the key in the `Authorization` header:

```bash theme={"dark"}
curl https://gengen.farm/api/gengen/v1/contents/generations/tasks \
  --header 'Authorization: Bearer gengen_live_xxxxxxxxxxxxxxxx'
```

<Warning>
  Treat API keys like passwords. Do not put them in browser code, mobile apps, public repositories, documentation examples, or client-side environment variables.
</Warning>

<Note>
  Retrieve a video task with the same API key that created it. A replacement key in the same workspace can list persisted tasks but cannot retrieve a task created by the previous key.
</Note>

## Server-side configuration

Keep the key in a server-side secret manager or environment variable:

<CodeGroup>
  ```bash Shell theme={"dark"}
  export GENGEN_API_KEY="gengen_live_xxxxxxxxxxxxxxxx"
  ```

  ```javascript Node.js theme={"dark"}
  const response = await fetch(
    "https://gengen.farm/api/gengen/v1/contents/generations/tasks",
    {
      headers: {
        Authorization: `Bearer ${process.env.GENGEN_API_KEY}`,
      },
    },
  );
  ```

  ```python Python theme={"dark"}
  import os
  import requests

  response = requests.get(
      "https://gengen.farm/api/gengen/v1/contents/generations/tasks",
      headers={"Authorization": f"Bearer {os.environ['GENGEN_API_KEY']}"},
  )
  ```
</CodeGroup>

## Authentication errors

| HTTP status | Error code               | Meaning                                  |
| ----------- | ------------------------ | ---------------------------------------- |
| `401`       | `gengen.auth_required`   | The bearer token is missing.             |
| `401`       | `gengen.invalid_bearer`  | The token is not a valid GENGEN API key. |
| `401`       | `gengen.api_key_invalid` | The key cannot be found or verified.     |
| `403`       | `gengen.api_key_revoked` | The key has been revoked or disabled.    |
| `403`       | `gengen.api_key_expired` | The key has expired.                     |

See [Errors](/help/errors) for the complete response shape.
