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 for one, which never outlasts the session.
- From a secret key: your server mints one with its secret key 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 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.
Where to act on it
- The user tokens reference has both requests.