---
title: "User tokens"
description: "Learn what a user token is, the two ways a project gets one for a signed-in principal, and how long it lasts."
url: "https://agentpost.tools/docs/platform/concepts/user-tokens"
kind: concept
---

# User tokens

A user token is a credential a browser or native app can send to a project’s services for its signed-in principal: `ut_test_…` in `dev` and `ut_live_…` in `prd`. It lasts 15 minutes by default. To choose a lifetime, send an `expiresIn` duration string from `"1m"` to `"1h"`. Each service’s reference says which user tokens it accepts.

`POST /v1/user-tokens` gives one in two ways:

-   **From a session token:** a principal signed in through a service exchanges its [session token](/docs/platform/concepts/credentials.md#session-tokens) for one, which never outlasts the session.
-   **From a secret key:** your server mints one with its [secret key](/docs/platform/concepts/secret-keys.md) for a principal your own sign-in names, with your ID for them in `externalId`.

A user token from a session stops working when that session ends. One from a secret key stops when that key is revoked; when a rotated key’s grace ends, the tokens it minted keep working until their own `expiresAt`.

A live stream a user token opened [stops within 30 seconds](/docs/platform/concepts/credentials.md#open-streams) after the token expires or stops working, or its project is deleted. Every token expires, so a client that keeps a stream open reconnects with a fresh token when the stream ends for its token’s expiry.

A user token is for Agentpost’s services, not for your own server. To learn who a user token is for, send it to [`GET /v1/user-tokens/current`](/docs/platform/reference/user-tokens.md#get-the-current-user-token).

## Where to act on it

-   The [user tokens reference](/docs/platform/reference/user-tokens.md) has both requests.
