---
title: "Exchange a signed assertion for a short-lived service key"
method: POST
path: "/auth/service-token"
tags: ["API Keys", "Auth"]
---

# Exchange a signed assertion for a short-lived service key

`POST /auth/service-token`

## Request

- Base URL: `https://api.medianfi.com/api/v1`
- URL: `https://api.medianfi.com/api/v1/auth/service-token`
- Auth: none required

No session: the credential is an ES256 JWS signed by a registered service signing key (header kid = its thumbprint). Claims: iss and sub = the service principal user id, aud = the exact SERVICE_TOKEN_AUDIENCE URL when configured (otherwise this endpoint's absolute URL derived from API_BASE_URL and API_VERSION), iat, exp (exp - iat at most 300 seconds), and a single-use jti (16 to 128 characters). Returns an hour-long service key for the X-API-Key header, bound to the same principal, home company and accountant:* scope as a minted service key. Every refusal is the same 401. Rate limited per client IP. Answers 503 until an audience and the service principal are configured; that check runs before body validation, so an empty-body probe tells a misconfigured deployment (503) from a working one (422).

## Request body

- ServiceTokenExchangeInput
  - `assertion` string, required: Compact ES256 JWS

## Response `200`

Short-lived service key; the plaintext is returned once and never stored

- ServiceTokenExchangeResponse
  - `success` true, required
  - `data` object, required
    - `serviceKey` string, required: mdn_svc_v1_ key for the X-API-Key header; returned once
    - `keyId` string, uuid, required
    - `expiresAt` string, date-time, required
    - `kid` string, required

## Other responses

- `401`: Authentication required
- `422`: Validation error
- `429`: Too many exchanges from this client
- `503`: The exchange is not configured (neither SERVICE_TOKEN_AUDIENCE nor the API_BASE_URL fallback, or the service principal)

## Changes

- **2026-10-21** `28f719a747c2`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/medianfi/apis/median-api/changes/auth/service-token/post.md)

---

[API](https://skmtc.dev/medianfi/apis/median-api.md) - [All operations](https://skmtc.dev/medianfi/apis/median-api/llms.txt) - [OpenAPI document](https://skmtc.dev/medianfi/apis/median-api/revisions/4f4c2d34276b?raw)
