---
title: "Sessions | IdentityHound"
description: "Learn what an IdentityHound session is, how a sign-in starts one, how long it lasts, what ends it, and how the user tokens and delegated tokens that come from it relate to it."
url: "https://agentpost.tools/docs/identityhound/concepts/sessions"
kind: concept
---

# Sessions

A session is a signed-in principal’s standing permission to act, from sign-in until it ends. Its token, `agp_st_…`, is shown only in the answer that starts the session, and the session record holds only its hash. Every request made with the token acts as the session’s [principal](/docs/identityhound/concepts/principals.md).

## How a session starts

Three sign-ins start a session, each from a browser or a native app with the publishable key, or from your server with the secret key:

-   **An emailed code.** `POST /auth/email-code` sends a 6-digit code, and `POST /auth/email-code/verify` takes it back with the `verificationId`. A code lasts `signIn.emailCode.codeTtl`, 10 minutes in a new project. If the last code for the address is unused and still within `signIn.emailCode.resendAfter`, 30 seconds in a new project, another request answers with the same `verificationId` and sends no code. A verification allows 5 guesses.
-   **An OAuth provider,** such as Twitch, from `POST /auth/oauth/:providerKey/start` to its callback. The same flow also links a provider login to a signed-in principal, or connects its account at the provider for later use.
-   **A guest,** with `POST /auth/guest`, when your config allows guests.

A first sign-in with a code or a provider creates the principal when the [sign-up mode](/docs/identityhound/concepts/principals.md#signing-up) allows it, and says so with `signedUp: true`. A guest that signs in with a new identity also gets `signedUp: true`. Requesting a code reveals nothing about whether the address already has an account. When the address has no account and the sign-up mode wouldn’t let it in, as in a `closed` project or for an address without an invitation in an `invite_only` one, no email goes out: the request answers as usual, and verifying its `verificationId` fails with [`code_invalid`](/docs/identityhound/errors.md#code_invalid), like a wrong code.

| Limit | Value |
| --- | --- |
| Code requests per address | 5 per 15 minutes |
| Code requests per IP address | 30 per 15 minutes |
| Code verification calls per IP | 50 per 15 minutes |
| OAuth starts per IP address | 30 per 15 minutes |

Past a limit, the request answers [`throttled`](/docs/identityhound/errors.md#throttled) with `details.retryAfter` in seconds. A browser’s own requests count against its IP address. When your server makes them, pass the visitor’s address as the [server helpers](/docs/identityhound/sdk/server.md#the-visitor) do.

## How long it lasts

In a new project, a session ends after 7 days without use (`sessions.idleTtl`), and 30 days after it started at the latest (`sessions.maxTtl`), whichever comes first. Use of the session token moves the idle limit forward at most once a minute. Your server [introspecting](/docs/identityhound/reference/auth.md#introspect-a-token) the token counts as use, so an app that only calls your server stays signed in while your server checks its token. Calls with a Platform user token leave it as it is. A guest’s session has the guests’ idle limit, `guests.idleTtl`, 30 days in a new project, and no `sessions.maxTtl` cap, since it is the guest’s only way back.

A session also ends when:

-   The principal signs out, or revokes it, or all its other sessions, from [the signed-in principal](/docs/identityhound/reference/me.md#list-sessions).
-   The principal is suspended or deleted.
-   A sign-in identity is removed, and the session uses the same authentication method. The session used to remove it stays active.
-   A guest [signs in with a new identity or merges into another principal](/docs/identityhound/concepts/principals.md#guests).
-   The principal’s account [merges into another account](/docs/identityhound/concepts/principals.md#merging-accounts). The survivor’s sessions stay active.

An ended session’s token answers [`unauthenticated`](/docs/identityhound/errors.md#unauthenticated).

## The tokens a session leads to

-   **User tokens.** A page can send a short-lived [Platform user token](/docs/platform/concepts/user-tokens.md) minted from the session instead of the session token.
-   **Delegated tokens.** A delegated token is a session of kind `delegated` that acts as the delegator for its delegate; [Delegations](/docs/identityhound/concepts/delegations.md#delegated-tokens) describes it.

A session records how it started (`authMethods`) and any client IP or user agent recorded for it (`client`), so a principal can tell its sessions apart.

## Where the session token is kept

The SDK’s [session strategies](/docs/identityhound/sdk/session-strategies.md) explain where a session token can be kept and when your page can read it.

## Checking a session on your server

Your server learns who a token acts for with the SDK’s [server helpers](/docs/identityhound/sdk/server.md#check-requests) or [Introspect a token](/docs/identityhound/reference/auth.md#introspect-a-token).

## Where to act on it

-   The [IdentityHound quickstart](/docs/identityhound/quickstart.md) signs a principal in, [Add email sign-in](/docs/identityhound/guides/email-sign-in.md) builds a sign-in screen, and [Keep the session on your server](/docs/identityhound/guides/server-session.md) keeps the token in a cookie.
-   [Sign-in](/docs/identityhound/reference/auth.md) starts, ends, and introspects sessions.
-   [The signed-in principal](/docs/identityhound/reference/me.md) lists and revokes a principal’s own sessions.
