---
title: POST /api/v1/auth/service-token
description: Mint Service Token
locale: en
version: 0.2.0
canonical: https://enterium-developer-docs.pages.dev/developers/api/auth/post-auth-service-token/
---

> Documentation index: https://enterium-developer-docs.pages.dev/developers/llms.txt — every page of this portal has a Markdown twin at <route>.md; the frozen API contract is at https://enterium-developer-docs.pages.dev/developers/api/openapi.json.

:::note
Generated from the OpenAPI contract — do not edit by hand. Interactive explorer with full schemas: [https://entherium.duckdns.org:8443/reference](https://entherium.duckdns.org:8443/reference); frozen spec for this build: [openapi.json](/developers/api/openapi.json). Group: [auth](../).
:::

Mint Service Token

Mint (or rotate) a long-lived READ-ONLY access token for an external agent.

Superuser-only. The endpoint can only create/serve users with
read-only agent scope — it is structurally unable to hand out
full-access tokens. Re-minting reactivates a previously revoked user.

**Auth:** `Authorization: Bearer <token>` required

## Request

```sh
curl -sS -X POST "https://entherium.duckdns.org:8443/api/v1/auth/service-token" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"email":"<email>","expires_days":"<expires_days>","full_name":"<full_name>","revoke_prior":"<revoke_prior>"}'
```

## Response `200`

```json
{
  "access_token": "eyJhbGciOiJIUzI1NiJ9.<payload>.<signature>",
  "api_scope": "agent",
  "email": "agent@entherium.dev",
  "expires_in": 7776000,
  "token_type": "bearer",
  "user_guid": 5
}
```

## Returns

`ServiceTokenResponse` — Successful Response

| Field | Type | Description |
| --- | --- | --- |
| `access_token` | `string` |  |
| `api_scope` | `string` |  |
| `email` | `string` |  |
| `expires_in` | `integer` |  |
| `token_type` | `string` (opt.) |  |
| `user_guid` | `integer` |  |

## Parameters

| Parameter | In | Required | Type | Default | Constraints | Description |
| --- | --- | --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | no | `string` | — | uuid | Optional. |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | `string` | no |  |
| `expires_days` | `integer` | no |  |
| `full_name` | `string \| null` | no |  |
| `revoke_prior` | `boolean` | no |  |

## Errors

| Code | Meaning | Body |
| --- | --- | --- |
| `401` | Missing or invalid authentication credentials | `ErrorResponse` |
| `409` | The e-mail belongs to an existing non-read-only user; refusing to convert | `ErrorResponse` |
| `422` | Validation Error | `HTTPValidationError` |

Every error body is `{detail, code?, request_id, doc_url}` — `request_id` is the value to quote, `doc_url` points at the [Errors reference](../../../reference/errors/).
