Overview
Agent Lab ships native authentication endpoints for email/password sign-up and sign-in, Google sign-in, session lookup, and logout. Successful authentication sets a session cookie that stays valid for one year. Sign-up, login, and Google sign-in responses also return the session token in the response body. Clients can send it as aBearer token in the Authorization header when cookies are unavailable.
Every new account gets its own personal workspace. Agent Lab creates the workspace automatically and assigns the user the owner role in it. This happens on sign-up, on first Google sign-in, and on first email login (see First-login auto-provisioning).
Endpoints
Sign up
POST /api/auth/signup creates a new account, provisions a personal workspace, and starts a session.
Request body:
email(required): a valid email address.password(required): at least 6 characters.name(optional): display name. Defaults to the part of the email before the@.
200 with the new user and sets the session cookie:
400if the email is missing or invalid.400if the password is shorter than 6 characters.400if an account with that email already exists. Sign in instead.
Log in
POST /api/auth/login signs in with email and password and starts a session.
Request body:
email(required)password(required)
200 with the same user shape as sign-up. Missing fields return 400.
First-login auto-provisioning
Logging in with an email that has no account does not fail. Instead of returning an “account not found” error, Agent Lab auto-provisions the account on the spot:- Creates a new user record with the
emaillogin method. - Creates a personal workspace named after the user (for example, “Ada’s Workspace”).
- Assigns the user the
ownerrole in that workspace. - Starts a session and returns the new user in the response.
Agent Lab derives the display name for an auto-provisioned account from the
email address. For example,
ada.lovelace@example.com becomes “Ada Lovelace”. Users
can pass an explicit name through sign-up instead if they want
full control over it.Google sign-in
POST /api/auth/google signs in with a Google account. If no account exists for the email, Agent Lab provisions one the same way as first-login auto-provisioning, with the google login method.
Request body:
email(required): the Google account email.name(optional): display name. Defaults to the part of the email before the@.
200 with the same token and user shape as sign-up and sets the session cookie.
Get the current user
GET /api/auth/me returns the user for the active session. Use it to restore the signed-in state on page load.
200:
- With a valid session, the response contains the
userobject. - Without a session, or with an invalid or expired token, the response is
{ "user": null }.
Log out
POST /api/auth/logout clears the session cookie and ends the session.
200 with { "success": true }.
Sessions
- Sessions last one year from sign-up or sign-in.
- Agent Lab delivers the session token as an HTTP cookie and also accepts it as a
Bearertoken in theAuthorizationheader. - Signing in again refreshes the user’s last-signed-in timestamp.
Session cookie behavior
Agent Lab adapts the session cookie to the connection:- Over HTTPS, Agent Lab sets the cookie with
SecureandSameSite=None, so cross-site embeds keep working. - Over plain HTTP, such as
localhostduring local development, Agent Lab setsSameSite=LaxwithoutSecure. Browsers rejectSecurecookies on insecure connections, so this fallback keeps sessions working locally.
HttpOnly and scoped to the whole site.
Bearer token fallback
Sign-up, login, and Google sign-in responses include the session token as a top-leveltoken field. Store it and send it in the Authorization header when cookies are unavailable, for example in embedded webviews or scripted API calls:

