> ## Documentation Index
> Fetch the complete documentation index at: https://docs.komodor.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Worker tokens

> Issue, store, expire, rotate and revoke the token a self-hosted agent authenticates with, and know how fast each change takes effect.

A worker token is the credential a self-hosted agent uses to talk to the Komodor Agentic Operation
Platform (KAOP). Each self-hosted agent has one, and it works only for that agent in your account.
Its pods send it on every call, from heartbeats to claiming runs and reporting results.

For an agent that Komodor hosts, KAOP creates the token and delivers it to the agent, so there is
nothing for you to handle. For an agent on a [management cluster](https://docs.komodor.com/manage-your-agents/build/koperator/overview),
koperator fetches and stores the token for you, as described under each step below.

## What a token is

* A token starts with `wt_`. The rest is random.
* KAOP shows the value **once**, when it issues or rotates the token, and cannot show it again. If
  you lose it, rotate the token.
* A worker token cannot issue, rotate or revoke tokens. Only a person or an
  [API key](https://docs.komodor.com/security-and-governance/identity-and-access/api-keys.md) with the right permission can.

| Step | In the console | In the API | Permission |
| - | - | - | - |
| Issue | The Add agent wizard, or **Generate** | `POST /api/v1/agents/worker-token` | `agent.create` |
| Check | **Settings → Agents → Worker tokens**, or the agent's **Worker token** card | `GET /api/v1/agents/{agent}/token` | `agent.read` |
| Rotate | **Rotate** | `POST /api/v1/agents/worker-token` again, for the same agent | `agent.create` |
| Revoke | **Revoke** | `DELETE /api/v1/agents/{agent}/token` | `agent.revoke_token` |
| Expire | Not set from the console | `ttlSeconds` on issue or rotate | Automatic |

`{agent}` is the agent's Agent ID or its `agt_…` id.

## Issue a token

The Add agent wizard issues the token when you deploy a self-hosted agent and puts it in the Helm
values it gives you. To issue one from the API:

```bash theme={null}
curl -s -X POST "$AGENTOPS_URL/api/v1/agents/worker-token" \
  -H "Authorization: Bearer $AGENTOPS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agentId": "payments-triage"}'
```

The response carries the token (`token`), a short hint to recognize it later (`workerTokenHint`),
the agent (`agentId`) and its expiry (`expiresAt`, `null` when it does not expire). When no agent
has that Agent ID yet, KAOP creates the agent, and it reads **Not installed** until its first worker
connects.

## Where the token lives in the pod

The agent's Helm chart reads the token from a Kubernetes Secret and passes it to the worker as
`AGENTOPS_WORKER_TOKEN`. You choose where that Secret comes from:

```yaml theme={null}
controlplane:
  url: https://<your-account-host>
  workerToken:
    value: ""            # the chart writes this into a Secret it creates
    existingSecret: ""   # or name a Secret you manage yourself
    key: token           # the key inside that Secret
```

* With `value`, the chart creates the Secret, and the token is also in your Helm release values.
  Keep those values out of Git.
* With `existingSecret`, you create and manage the Secret yourself, for example with External
  Secrets or Sealed Secrets, and the token never appears in the Helm values. Use this in production.
* When the chart's KEDA autoscaling is on, the KEDA scaler reads the same Secret.

On a management cluster, koperator fetches the token from KAOP and writes it into a Secret it owns,
named `<agent id>-agentops-bootstrap`. Each fetch is recorded in the audit log.

## Expiry

A token does not expire unless you ask it to. To give one a lifetime, send `ttlSeconds` when you
issue or rotate it:

```json theme={null}
{"agentId": "payments-triage", "ttlSeconds": 3600}
```

* `ttlSeconds` is a whole number from 1 to 86400 (24 hours). A value outside that range is refused.
* Once a token expires it no longer authenticates. Its status reads **Expired**, and the agent's
  page asks you to rotate it.
* An expiry belongs to one issue or rotation and is not carried to the next. **Rotate** in the
  console sends no `ttlSeconds`, so a token rotated there does not expire. To keep an expiry, rotate
  from the API and send `ttlSeconds` each time.

Because the longest lifetime is 24 hours, `ttlSeconds` suits tests and short-lived deployments. For
a long-running agent, use a token with no expiry and rotate it on your own schedule.

## Rotate a token

Rotating issues a new value for the same agent. The old value stops working, as described in
[How fast a change takes effect](#how-fast-a-change-takes-effect). The agent keeps its id, its run
history and its configuration.

**1. Rotate the token**

In the console, choose **Rotate** on the agent's **Worker token** card or in **Settings → Agents
→ Worker tokens**, and copy the new value from the dialog. From the API, send the same
`POST /api/v1/agents/worker-token` call again for the agent.

**2. Put the new value where the pods read it**

Update the Secret you manage, or set `controlplane.workerToken.value` in a `helm upgrade`.

**3. Restart the agent's pods**

The worker reads `AGENTOPS_WORKER_TOKEN` when it starts, so a running pod keeps the old value
until it restarts. For example: `kubectl rollout restart deployment/<release> -n <namespace>`.

Between the first step and the last, the agent's pods cannot authenticate, so rotate when a short
gap is acceptable. The old and new values never work side by side.

On a management cluster, koperator does the second and third steps for you: it sees the new token,
writes it into its Secret and rolls the pods.

Rotating an archived agent's token also takes the agent out of the archive.

### Rotate on a schedule

KAOP has no built-in rotation schedule. To rotate regularly, run the steps above from your own
scheduler, such as a CI job that calls the API, writes the new value into your secret store, and
restarts the deployment.

## Revoke a token

Revoking deletes the agent's token. Its pods can no longer authenticate, so the agent goes offline
and takes no new runs. The agent stays, with its history and configuration. Revoking does not stop
the worker process itself.

* In the console, choose **Revoke** on the agent's **Worker token** card or in **Settings → Agents
  → Worker tokens**, and confirm.
* From the API, the call answers `204` and is safe to repeat:

  ```bash theme={null}
  curl -s -X DELETE "$AGENTOPS_URL/api/v1/agents/payments-triage/token" \
    -H "Authorization: Bearer $AGENTOPS_API_KEY"
  ```

A revoked token cannot be restored. To bring the agent back, issue a new token with **Generate** or
the API, and deploy it.

How other agent actions affect the token:

* **Delete** an agent and its token is revoked.
* **Archive** and **Stop** leave the token unchanged.
* The general credentials API refuses to change or delete a worker token. Use the agent endpoints
  above.

## How fast a change takes effect

KAOP refuses a revoked, rotated-out or expired token as soon as it checks the token against its
records. To keep up with the volume of agent calls, some KAOP services hold a short in-memory copy of
credentials used in the last 30 seconds, so on those services an old token can keep working for up
to **30 seconds**.

Plan on a revoke or rotation taking full effect within 30 seconds. After that, every call with the
old token gets `401`. The same window applies to API keys and to changes in a person's roles.

## Check a token's status

Status shows metadata, never the token value.

* **Settings → Agents → Worker tokens** lists every worker token in the account, including those of
  agents that have not connected yet, with **Agent status**, **Token**, **Created** and **Expires**.
  Filter by **Active** or **Expired**.
* The agent's **Worker token** card shows **Created**, **Last rotated** and **Expires**, which reads
  **Never** for a token with no expiry.
* From the API:

  ```bash theme={null}
  curl -s "$AGENTOPS_URL/api/v1/agents/payments-triage/token" \
    -H "Authorization: Bearer $AGENTOPS_API_KEY"
  ```

  ```json theme={null}
  {
    "agentId": "payments-triage",
    "exists": true,
    "createdAt": "2026-11-01T09:12:44+00:00",
    "lastRotatedAt": "2026-11-15T08:00:02+00:00",
    "expiresAt": null,
    "expired": false
  }
  ```

  `GET /api/v1/agents/worker-tokens` returns the same fields for every token in the account.

## Audit

Every change to a token is recorded in the [audit log](https://docs.komodor.com/security-and-governance/controls/audit-log.md)
with the person or API key that made it.

| Action | Audit event |
| - | - |
| Issue a token | `agent.token_create` |
| Rotate a token | `agent.token_create` |
| Revoke a token | `agent.token_revoke` |
| Koperator fetches a token for a management cluster | `agent.bootstrap_secrets_fetch` |

A rotation and a first issue write the same event. An `agent.token_create` for an agent that already
had a token is a rotation, and **Last rotated** shows when the latest one happened.

## Next steps

> [card] [Agent identity](https://docs.komodor.com/security-and-governance/identity-and-access/agent-identity.md)
>
> How a self-hosted worker authenticates as its agent.

> [card] [Deploy a self-hosted agent](https://docs.komodor.com/manage-your-agents/build/deploy-a-self-hosted-agent.md)
>
> The Helm install that carries the token.


## Related topics

- [Agent identity](https://docs.komodor.com/security-and-governance/identity-and-access/agent-identity.md)
- [Troubleshooting](https://docs.komodor.com/reference/troubleshooting.md)
- [Agent isolation & tenancy](https://docs.komodor.com/security-and-governance/architecture-considerations/agent-isolation-tenancy.md)
- [Secrets & credential handling](https://docs.komodor.com/security-and-governance/architecture-considerations/secrets-credential-handling.md)
- [Deploy a self-hosted agent](https://docs.komodor.com/manage-your-agents/build/deploy-a-self-hosted-agent.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.