> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/integrations/rest-apis/sl-public-api/authorization.md). Agents can also search and read this documentation through its [MCP server](https://docs.sealights.io/knowledgebase/~gitbook/mcp).

# Authorization

API Token vs Agent Token — what each is for, where to get it, and how to pass it in requests.

## How authentication works

Every request to the SeaLights Public API must include a Bearer token in the `Authorization` header:

```http
Authorization: Bearer <your-token>
```

There is no session management or cookie-based auth. Each request is authenticated independently.

## Two token types

The API uses two distinct token types. Each endpoint in the [API reference](https://docs.sealights.io/knowledgebase/setup-and-configuration/integrations/rest-apis/sl-public-api/api-reference.md) states which one it requires.

### API Token

Used by the **vast majority of endpoints** — anything that reads or writes data in the SeaLights platform from an external system or script.

**When to use:** Querying builds, coverage data, reports, TIA recommendations, app settings, audit logs.

**How to get one:**

1. In the SeaLights UI, click the gear icon → **Settings**
2. Left sidebar: **Integration → API Tokens**
3. Click **Create token**, give it a descriptive name
4. Copy the token — it is shown only once

**In requests:**

```http
GET /sl-api/v1/apps HTTP/1.1
Authorization: Bearer <api-token>
```

***

### Agent Token

Used by a **small number of endpoints** that are called directly by SeaLights agents running in your CI/CD pipeline — for example, opening a test session, registering an integration build, or retrieving exclude-tests lists.

**When to use:** Integration build endpoints, test session endpoints, getting the agent default version.

{% hint style="info" %}
If you are calling an API from a script or external tool (not from a SeaLights agent), you almost certainly need an **API Token**, not an Agent Token.
{% endhint %}

**How to get one:**

1. In the SeaLights UI, click the gear icon → **Settings**
2. Left sidebar: **Cockpit & Onboarding → Agent Tokens**
3. Click **Create token**, give it a descriptive name
4. Copy the token — it is shown only once

**In requests:**

```http
POST /sl-api/v1/test-sessions HTTP/1.1
Authorization: Bearer <agent-token>
```

***

## Which token does each endpoint use?

The [API reference](https://docs.sealights.io/knowledgebase/setup-and-configuration/integrations/rest-apis/sl-public-api/api-reference.md) marks each endpoint. As a general guide:

| Endpoint group                                | Token type  |
| --------------------------------------------- | ----------- |
| Apps, branches, builds, coverage, reports     | API Token   |
| Audit logs, live labs, settings, code domains | API Token   |
| TIA recommendations (read)                    | API Token   |
| Agent default version                         | Agent Token |
| Integration builds                            | Agent Token |
| Test sessions (open, close, exclude-tests)    | Agent Token |

***

## Security recommendations

{% hint style="warning" %}
**Never commit tokens to source control.** Store them as CI/CD secrets or in a secrets manager (e.g. GitHub Actions secrets, HashiCorp Vault, AWS Secrets Manager).
{% endhint %}

* Use separate tokens for separate systems — one per CI pipeline, one per script, not one shared across everything
* Rotate tokens periodically via Settings → Tokens
* If a token is compromised, delete it immediately in the SeaLights UI and create a replacement


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/integrations/rest-apis/sl-public-api/authorization.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
