User tokens
A user token, ut_test_… or ut_live_…, is what a browser sends for whoever is signed in to your project, however they signed in. It lasts 15 minutes by default and an hour at most. Services treat it like that principal’s session.
Paths are from https://api.agentpost.tools, and every route follows the API basics. The examples send the first credential the route takes; Credentials explains each one.
Mint a user token
POST /v1/user-tokens
Mints a user token. Your server, with its secret key, mints one for someone your own sign-in names. A principal signed in through the project’s IdentityHound exchanges its session for one, which never outlives the session.
- Who may call: Your server, with a secret key or a principal signed in to your project, with its IdentityHound session token.
- Access: A secret key sends
externalId. A session sends neitherexternalIdnordisplayName. A publishable key, an API key, a delegated token, and another user token are refused. - Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>.
Body
The body is optional.
| Name | Type | Required | Description |
|---|---|---|---|
externalId |
string |
No | With a secret key: your own ID for whoever signed in, such as u_42, with no spaces; 1–200 characters. |
displayName |
string |
No | With a secret key: the name to show; up to 200 characters. |
expiresIn |
string |
No | How long it lasts, as a number and a unit, s, m, h, or d: 1m to 1h; default "15m". |
Response
201 Created, with:
| Name | Type | Present | Description |
|---|---|---|---|
token |
string |
Always | The token itself. Shown once. |
userToken |
UserToken |
Always |
Errors
forbidden(403)
Any operation can also answer with the codes Conventions lists.
Get the current user token
GET /v1/user-tokens/current
Who a user token is for, so a page can show who is signed in.
- Who may call: A user token.
- Credential: the examples send a user token,
ut_test_…, asAuthorization: Bearer <token>.
Response
200 OK, with:
| Name | Type | Present | Description |
|---|---|---|---|
userToken |
UserToken |
Always |
Errors
forbidden(403)
Any operation can also answer with the codes Conventions lists.
The UserToken object
A short-lived token for one signed-in principal, without the token.
| Name | Type | Present | Description |
|---|---|---|---|
id |
string |
Always | A user token ID, utk_…. |
projectId |
string |
Always | |
environment |
"dev" or "prd" |
Always | dev for development and tests, prd for production. |
principalRef |
string |
Always | Who it is for: an IdentityHound principal ID, or external:<id> for someone your own sign-in names. |
displayName |
string |
When set | |
createdAt |
string |
Always | An ISO 8601 date and time. |
expiresAt |
string |
Always | An ISO 8601 date and time. |