---
title: "Mint an agent-bound worker token"
method: POST
path: "/api/agents/{id}/token"
tags: ["Sessions"]
---

# Mint an agent-bound worker token

`POST /api/agents/{id}/token`

## Request

- Base URL: `http://localhost:3013`
- URL: `http://localhost:3013/api/agents/{id}/token`
- Auth: HTTP bearer

Returns the token once. A worker runs on it in place of the swarm API key and acts only as this agent. Creates the agent when it does not exist and `name` is given. Fails with 409 when the agent already holds an active token.

## Path parameters

- `id` string, required

## Request body

- object
  - `name` string
  - `ttlMs` integer: Token lifetime in ms. Omit for the default (no expiry).

## Response `200`

Minted worker token

- object
  - `agentId` string, required
  - `tokenId` string, required
  - `plaintext` string, required
  - `expiresAt` string, nullable, required: null when the token does not expire
  - `agentCreated` boolean, required

## Other responses

- `403`: Operator or user credentials required
- `404`: Agent not found and no name given
- `409`: Agent already holds an active token

## Changes

- **2026-10-20** `9628ff490c6a`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/desplega-ai/apis/agent-swarm-api/changes/api/agents/:id/token/post.md)

---

[API](https://skmtc.dev/desplega-ai/apis/agent-swarm-api.md) - [All operations](https://skmtc.dev/desplega-ai/apis/agent-swarm-api/llms.txt) - [OpenAPI document](https://skmtc.dev/desplega-ai/apis/agent-swarm-api/revisions/7e4c7198192a?raw)
