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

# Authentication & API keys

Every surface — REST, CLI, MCP — authenticates with a long-lived **API key**.

## Creating a key

Keys are created in the TestVibe app under **Settings → CLI & API keys**. A key looks like:

```
tvb_9hK2mPqRsT4uVwXyZ1aB3cD5eF7gH8jL0nQ6rS2tU4v
```

* The `tvb_` prefix plus 43 base62 characters.
* The full key is shown **exactly once**, at creation. Only a hash is stored server-side; if you lose the key, revoke it and create a new one.
* The Settings panel shows each key's display prefix (`tvb_XXXXXXXX`), creation date, and last-used time.

## Using a key

Send it as a bearer token on every request:

```bash
curl -H "Authorization: Bearer $TESTVIBE_API_KEY" \
  "$TESTVIBE_SERVER/api/v1/ops/projects"
```

The CLI and MCP server read it from `testvibe login`, the `TESTVIBE_API_KEY` environment variable, or per-repo config — see [The testvibe CLI](/testvibe-api/cli/cli.md).

## What a key can do

A key **acts as the user who created it, inside the workspace it was created in**:

* It can see and operate on every project of that workspace (subject to the creator's access).
* It stops working immediately if it is **revoked**, or if the creating user **leaves the workspace**.

## Failure mode

Requests without a valid key get `401`:

```json
{
  "error": "unauthorized",
  "message": "A valid API key is required (Authorization: Bearer tvb_…)."
}
```

{% hint style="warning" %}
**Key hygiene.** Put keys in environment variables or secret stores, never in committed files. Create one key per machine or integration so you can revoke them independently.
{% endhint %}


---

# 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:

```
GET https://docs.testvibe.com/testvibe-api/getting-started/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
