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

# Authentication

> Authenticate server-side requests with a Legnext API key.

Legnext uses an API key in the `x-api-key` request header.

```bash theme={null}
curl "https://api.legnext.ai/api/account/balance" \
  -H "x-api-key: $LEGNEXT_API_KEY"
```

Create and manage keys in the
[Legnext dashboard](https://legnext.ai/dashboard), then store the key in your
application's server-side secret or environment configuration.

<Warning>
  Never expose a Legnext API key in browser or mobile client code, public logs,
  agent conversations, or committed `.env` files. Send requests through a trusted
  server boundary.
</Warning>

## Request base URL

Use this base URL for the API:

```text theme={null}
https://api.legnext.ai/api
```

Endpoint paths in the API Reference are appended to that base. For example,
`POST /v1/diffusion` becomes:

```text theme={null}
https://api.legnext.ai/api/v1/diffusion
```

## Get Task is the exception

`GET /v1/job/{job_id}` does not require an API key. The UUID in that URL is a
capability token: anyone who has it can read the public task result.

Keep each `job_id` server-side. Do not expose it in browser URLs, client logs,
analytics events, screenshots, or support messages sent through public
channels.

## Authentication failures

An absent, invalid, revoked, or wrong-environment key returns `401`. A disabled
account returns `403`. Do not retry either response unchanged; correct the key or
account state first.

See [Errors & Handling](/api-reference/errors) for the client action associated
with each failure class.
