# Personal access tokens

> Personal access tokens let scripts, CI jobs and other services call the NOVA Cloud API as you, without an interactive login. Learn how to create, use and revoke a token, and what a token can and cannot do.

A personal access token belongs to you and acts as you: every request made with it carries your
role and your access to instances. It is meant for scripts and services, which do not require a
browser login.

A token looks like this:

```
nvcp_01K2ABCDEFGHJKMNPQRSTVWXYZ
```

> **Treat a token like a password:** A token has the same access rights as you do in NOVA Cloud's public API. Store it
> as a secret in the target system, never commit it to a repository, and revoke it as soon as
> you no longer need it.

## Create a token

Every user with a role can create tokens for their own account.
You can have as many as you need, e.g., one per script or pipeline.

### Step 1: Open the token page

Open the account menu in the header and select `Personal access tokens`.\
→ The `Personal Access Tokens` page opens and lists your tokens, newest first.

### Step 2: Name the token

Enter a `Name` of up to 60 characters that defines by what service it is used, e.g., `CI pipeline`.
The name identifies the token in the list. Names do not have to be unique.

### Step 3: Create and copy the token

1. Click `Create token`.\
   → The page displays the token once.
   A token you create in the web app has no expiry date: it stays valid until you revoke it.
2. Copy it with the copy button.

> **The token is shown once:** NOVA Cloud stores only a hash of the token. Once you leave the page, the token cannot be shown
> again. If you lose it, revoke the entry and create a new token.

## Use a token

1. Send the token as a bearer token in the `Authorization` header of a request to the public API
   under `/api/v0`:

```bash
curl https://<your-nova-cloud-host>/api/v0/instances \
  -H "Authorization: Bearer nvcp_01K2ABCDEFGHJKMNPQRSTVWXYZ"
```

The [API reference](/nova-cloud/api-reference) documents the endpoints, their parameters and
their responses.

2. To ensure the token's functionality, call `GET /api/v0/whoami`.\
   → For a personal access token, the response names the token under `credential` with the
   kind `personal_access_token`, together with the user it acts as.

### Limitations

- A token cannot call endpoints that need your full NOVA login. Endpoints that act on
  your behalf against other Wandelbots services, e.g., the ones for virtual instances,
  reject the token with `403` and the error code `token_not_permitted`.
- The token cannot act as anyone else. For an identity that is not a person, see
  [Callers that are not users](/nova-cloud/roles-and-permissions#callers-that-are-not-users).
- Besides the API, a token can authenticate a NATS connection to the instances you have access to.

## Revoke a token

Revoke a token when a script is retired, its creator no longer uses it, or when
you suspect it leaked.

1. Open the account menu and select `Personal access tokens`.
2. Click `Revoke` next to the token and confirm.\
   → The entry stays in the list and is marked `Revoked`, with its creation date.

The API rejects the token from that moment on, and revoking cannot be undone. NATS connections
that the token already opened keep their access, including the right to publish, for up to five
minutes, until they have to authenticate again.

Revoked and expired tokens stay in the list, so you can see what existed. Only you see your own
tokens, and only you can revoke them.

## Rotate a token

To replace a token without downtime:

1. Create a second token with the same name. Names do not have to be unique.
2. Switch the target system over to the new token.
3. Revoke the old one.
