> For the complete documentation index, see [llms.txt](https://docs.e6data.com/query-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.e6data.com/query-engine/developers/management-api/authentication.md).

# Authentication

Choose and send the right credential for automating e6data - service tokens with least-privilege permissions.

Every request carries a **token** in the `Authorization` header. Pick the credential that fits the caller.

| Credential                                         | Best for                                                       | How to get it                                                   |
| -------------------------------------------------- | -------------------------------------------------------------- | --------------------------------------------------------------- |
| **Service Tokens** *(recommended for apps and CI)* | Unattended apps and pipelines with their own identity and role | Create a service tokens from control plane under Access Control |

**How to send it** - it work as a Bearer token, and are also accepted via `X-API-Key`. A Bearer token always takes precedence over a browser session cookie.

```bash
# service token usage:
curl -H "Authorization: Bearer e6sa_…" https://<HOST>/api/v1/queryservices
```

```mermaid
sequenceDiagram
    autonumber
    participant U as You / admin
    participant E as e6data
    participant S as Secret manager
    participant A as Your automation
    U->>E: Create a key (Console or API)
    E-->>U: Raw token - shown once
    U->>S: Store the token
    A->>S: Read token at runtime
    A->>E: Request with Authorization: Bearer token
    E-->>A: Verify token + check permission → allow or 403
```

## Permissions

Access is governed by role-based permissions on each resource. A `403` response names the permission the call needs, so you can grant least privilege.

| Resource                                       | Actions                                                                |
| ---------------------------------------------- | ---------------------------------------------------------------------- |
| Clusters (`query_engine.clusters`)             | `read`, `create`, `update` (covers suspend / resume / scale), `delete` |
| Catalogs (`query_engine.catalog`)              | `read`, `create`, `update`, `delete`, `refresh`                        |
| Query history (`query_engine.history`)         | `read`                                                                 |
| System catalog (`query_engine.system_catalog`) | `read`, `execute`                                                      |

The built-in roles - **Admin**, **Manager**, and **Viewer** - cover common cases; create custom roles for tighter scoping. Grant a service token the **minimum** it needs.

## Security

* A raw token is **shown exactly once** - store it in a secret manager at creation.
* Use **one credential per consumer**; set an expiry and rotate before it lapses.
* Never log the secret (log the token ID instead) and never commit it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.e6data.com/query-engine/developers/management-api/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
