# API tokens

> A key for the CLI, CI and scripts — who creates it, what it can do and what it can't.

Source: https://livops.dev/en/docs/api-tokens

An API token is a key for programs: the [CLI](https://livops.dev/en/docs/cli), GitHub Actions or your own scripts use it to call the Livops API.

## Create a token

1. In the cabinet, open the team's **Settings → API tokens** (`/<team>/settings/tokens`).
2. Name the token (for example `github-actions`) and click **Create**.
3. The token is shown **only once**. Save it right away in your CI secrets or a password manager.

Rules:

- Only the **team owner** can create tokens.
- **One token, one team.** A token only sees that team's projects; a request for another team's project returns `404`.
- Tokens start with `lvp_`. Livops stores only their hash.
- Tokens don't expire — they work until revoked. Up to 20 active tokens per account.
- The last-used time is shown in the list. Revoke unused or leaked tokens immediately.
- If the token's owner leaves the team, the token stops working.

## Usage

Send the token in the `Authorization` header:

```bash
curl https://livops.uz/api/projects \
  -H 'Authorization: Bearer lvp_xxx'
```

Never put a token in code or in a repository — keep it in an environment variable (`LIVOPS_TOKEN`).

## What a token can do

- **Read** almost everything: projects, deploys, logs, the list of databases, domains.
- **Write** only within `projects`, `deploys` and `stacks`: deploy, set variables, add services and environments, promote.

## What a token can't do

The following are open only to a person in the cabinet (with a browser session) — a token gets `403`:

- **deleting anything** (`DELETE` requests);
- creating, viewing or revoking tokens — a token can't issue another token;
- password, sessions, two-factor authentication and account settings;
- team, members, billing and payments;
- changing an environment's shared variables;
- transferring a project and changing project members;
- database connection details (password) and backups;
- managing deploy hooks, webhooks, log forwarding and SSH keys.

The full list is marked next to each endpoint in the [API reference](https://livops.dev/en/docs/api).

## Not from a browser

If a request carries `Cookie`, `Origin` or `Sec-Fetch-*` headers (that is, it looks like it came from a browser), the `Authorization` header is ignored. Use tokens in server-side code or in a terminal.
