Authentication API
The Authentication API signs users in and issues the access tokens that every other PlayTelly API accepts. It also manages the user's sessions, activates invited accounts, resets forgotten passwords and publishes the keys that verify tokens.
Resources¶
| Resource | What it is |
|---|---|
| Access token | A short-lived signed JWT (RS256) you send as Authorization: Bearer on every API request. |
| Refresh token | A single-use token you exchange for a new access token and a new refresh token. |
| Session | One signed-in device or browser. It keeps the same ID across refreshes until it is revoked or expires. |
| Invitation link | A one-time link e-mailed to a user an organization admin invited. Redeeming it activates the account and signs the user in. The routes call it a magic link (/auth/magic-link/…). |
| Password-reset link | A one-time link e-mailed when a user forgets their password. |
| Company code | A short code (lowercase letters and digits) that names an organization, chosen when the organization is created. Users get it from their organization admin. Web sign-in needs it; the public lookup says where the organization is hosted. |
| Identity provider | An external sign-in such as Google ("social sign-in"). |
Authentication and permissions¶
The routes on this page don't use named permissions. A route is either public or needs a valid access token, and a signed-in user can only act on their own account and sessions. How to get and send the token is in Authentication.
| Action | Requirement |
|---|---|
| Sign in, refresh, redeem an invitation link, reset a password, social sign-in, look up a company code, check a token, read the signing keys | Public: no token needed |
| Sign out, sign out everywhere, change your password | Valid access token |
| List your sessions, revoke a session, revoke all other sessions, stream session events | Valid access token |
Send the access token as Authorization: Bearer <ACCESS_TOKEN>. Browser clients signed in with
PlayTelly-Platform: web can rely on the access_token cookie instead.
Inviting users, creating organizations and approving organization sign-ups are done through the Tenancy API, which needs organization or platform permissions.
Request headers¶
| Header | Used on | Values |
|---|---|---|
PlayTelly-Platform |
Sign-in, invitation redeem | web (default): tokens are set as HttpOnly cookies. mobile: tokens are returned in the body. Use mobile for apps, scripts and servers. |
PlayTelly-SessionDetail |
Sign-in, invitation redeem (mobile) | Base64 of a JSON object with osName, osVersion, modelName, appVersion. Shown in the session list. Optional. |
PlayTelly-AppVersion |
Sign-in, invitation redeem | Your app's version, shown in the session list. Optional. |
Browser calls from your own domain also need your origin on PlayTelly's allowed list (CORS). Ask PlayTelly
support to add it. If your app isn't served from a PlayTelly domain, the browser may not send PlayTelly's cookies
with your requests: use PlayTelly-Platform: mobile and send the access token in the Authorization header.
There is no service-account or client-credentials flow: a server signs in as a PlayTelly user, with
PlayTelly-Platform: mobile, and keeps the session alive with refresh.
Sign in and refresh¶
To call another PlayTelly API, send the access token as a bearer token to <API_HOST>. For example, to read the signed-in
user and the workspace IDs you can use (see the Quickstart):
Sign in (company_code is optional with mobile; without it the user signs in to their own organization):
curl -s -X POST "https://<AUTH_HOST>/api/v1/login" \
-H "Content-Type: application/json" \
-H "PlayTelly-Platform: mobile" \
-d '{"username": "<USERNAME>", "password": "<PASSWORD>", "company_code": "<COMPANY_CODE>"}'
| Field | Type | Required | Description |
|---|---|---|---|
username |
string | Yes | The user's login name or e-mail address. |
password |
string | Yes | The user's password. |
company_code |
string | Web: yes. Mobile: no | The organization to sign in to. |
You get a sign-in response with access_token and refresh_token. Before expires_in
seconds pass, refresh:
curl -s -X POST "https://<AUTH_HOST>/api/v1/refresh" \
-H "Content-Type: application/json" \
-d '{"client_type": "mobile", "refresh_token": "<REFRESH_TOKEN>"}'
| Field | Type | Required | Description |
|---|---|---|---|
client_type |
string | Yes | mobile: the refresh token is in the body. web: it is read from the refresh_token cookie. |
refresh_token |
string | Mobile only | The refresh token from sign-in or from the previous refresh. |
You get a new access_token and refresh_token (same shape, without user). The refresh token works once. When to refresh and how to handle concurrent refreshes are in
Authentication.
Base path¶
Served by AuthAPI on <AUTH_HOST>. The host for each environment is in API conventions.
Other PlayTelly APIs are on a different host, <API_HOST>.
Two groups of routes sit at the root instead: https://<AUTH_HOST>/.well-known/… (signing keys and discovery)
and https://<AUTH_HOST>/health. No route takes a workspace or organization ID: every route acts on the caller or
on the token or link you send.
Capabilities¶
- Password sign-in for web (cookies) and non-web clients (tokens in the body)
- Token refresh with rotation; role changes take effect at the next refresh
- Sign out of one session, of every session, or of every other session
- Session list with device details, and a server-sent event stream that reports revocation
- Invitation links: check and redeem
- Forgotten-password reset by e-mail, and password change for a signed-in user
- Social sign-in with an identity provider (Google, where enabled), including first-use account linking
- Company-code lookup for cloud and self-hosted organizations
- Token introspection and public signing keys (JWKS)
- Update or delete your own profile (planned)
- Accept an invitation into another organization (planned)
Object model¶
Sign-in response¶
Returned by POST /api/v1/login, POST /api/v1/auth/magic-link/redeem and, without the token fields,
POST /api/v1/auth/idp/link/confirm.
| Field | Type | Required | Description |
|---|---|---|---|
access_token |
string | Mobile only | RS256 JWT. Send as Authorization: Bearer. Read-only. |
refresh_token |
string | Mobile only | Exchange at POST /api/v1/refresh. Works once. Read-only. |
expires_in |
integer | Mobile only | Access token lifetime in seconds. Default 900. |
token_type |
string | Mobile only | Always Bearer. |
user |
object | Yes | The signed-in user. See User. |
org |
object | Yes | The organization of this session and the user's role in it. See Organization claim. |
Web clients get only user and org in the body. The tokens are set as cookies: access_token (path /) and
refresh_token (path /api/v1), both HttpOnly and SameSite=Lax.
POST /api/v1/refresh returns the same token fields and org, without user. For web clients it returns only
org and replaces both cookies.
{
"access_token": "<ACCESS_TOKEN>",
"refresh_token": "<REFRESH_TOKEN>",
"expires_in": 900,
"token_type": "Bearer",
"user": {
"id": "6f1c2a9e-4b7d-4c1e-9a52-1d3e8b7f0c44",
"username": "alice",
"email": "alice@example.com",
"org_id": "9b2e4d71-0c3a-4f8e-b6d2-5a1c7e9f3b20",
"password_change_required": false
},
"org": {
"org_id": "9b2e4d71-0c3a-4f8e-b6d2-5a1c7e9f3b20",
"org_slug": "acme",
"role": "ORG_ADMIN"
}
}
User¶
| Field | Type | Required | Description |
|---|---|---|---|
id |
string (UUID) | Yes | User ID. The same ID is used by every other PlayTelly API. Read-only. |
username |
string | Yes | Display name, or the login name when there is none. Read-only here. |
email |
string | Yes | The user's e-mail address. Read-only here. |
org_id |
string (UUID) | Yes | The user's organization. Read-only. |
password_change_required |
boolean | Yes | When true, ask the user to choose a new password (PUT /api/v1/protected/users/me/password) before anything else. |
Organization claim¶
| Field | Type | Required | Description |
|---|---|---|---|
org_id |
string (UUID) | Yes | The organization this session is for. One session is for one organization. |
org_slug |
string | Yes | Short, URL-friendly name of the organization, for example acme. |
role |
string | Yes | The user's organization role: a system role (ORG_OWNER, ORG_ADMIN, ORG_MANAGER, ORG_OPERATOR or ORG_MEMBER), or the ID of a role the organization created. Roles are described in the Tenancy API. |
ORG_OWNER is the highest organization role: it can't be given by invitation (ownership moves by transfer), and with ORG_ADMIN it passes the permission check on every workspace of the organization.
Access token claims¶
The access token is a JWT signed with RS256. Verify it with the keys from /.well-known/jwks.json (match the
kid in the token header), or call POST /api/v1/token/introspect.
| Claim | Type | Description |
|---|---|---|
sub |
string (UUID) | User ID. |
uid |
string (UUID) | User ID (same as sub). |
sid |
string (UUID) | Session ID. Matches id in the session list. |
org |
object | Organization claim. |
iss |
string | Issuer. |
iat, exp |
integer | Issued at and expiry, Unix seconds. |
jti |
string | Token ID. |
Tokens can carry other claims. Don't rely on any claim not listed here: to read a user's roles and permissions, call the Identity API.
Session¶
Returned by GET /api/v1/sessions as {"sessions": [ … ]}: not paginated, all active sessions of the user, newest
first (created_at descending). A session whose refresh token has expired is not listed.
| Field | Type | Required | Description |
|---|---|---|---|
id |
string (UUID) | Yes | Session ID. Stays the same across refreshes. Read-only. |
platform |
string | Yes | web or mobile. |
os, os_version |
string | Yes | Operating system, from User-Agent (web) or PlayTelly-SessionDetail (mobile). Can be empty. |
browser, browser_version |
string | Yes | Web only; empty for mobile. |
device_model |
string | Yes | Device model. Can be empty. |
app_version |
string | Yes | From PlayTelly-AppVersion or PlayTelly-SessionDetail. Can be empty. |
current |
boolean | Yes | true for the session of the access token you sent. |
created_at |
string (ISO 8601 UTC) | Yes | When the session started. |
last_used_at |
string (ISO 8601 UTC) | Yes | Last sign-in or refresh. |
expires_at |
string (ISO 8601 UTC) | Yes | When the current refresh token expires. |
{
"id": "5c8e1f2a-7b3d-4e9a-a1c6-0f2d4b6e8a10",
"platform": "web",
"os": "macOS",
"os_version": "15.1",
"browser": "Chrome",
"browser_version": "131.0.0.0",
"device_model": "",
"app_version": "",
"current": true,
"created_at": "2026-11-16T08:12:40Z",
"last_used_at": "2026-11-16T09:02:11Z",
"expires_at": "2026-11-23T09:02:11Z"
}
List response:
{
"sessions": [
{
"id": "5c8e1f2a-7b3d-4e9a-a1c6-0f2d4b6e8a10",
"platform": "web",
"os": "macOS",
"os_version": "15.1",
"browser": "Chrome",
"browser_version": "131.0.0.0",
"device_model": "",
"app_version": "",
"current": true,
"created_at": "2026-11-16T08:12:40Z",
"last_used_at": "2026-11-16T09:02:11Z",
"expires_at": "2026-11-23T09:02:11Z"
},
{
"id": "0b7d3a9c-6e21-4f58-8c14-9a2e5d7b1f33",
"platform": "mobile",
"os": "iOS",
"os_version": "18.1",
"browser": "",
"browser_version": "",
"device_model": "iPhone15,2",
"app_version": "2.4.0",
"current": false,
"created_at": "2026-11-10T06:30:02Z",
"last_used_at": "2026-11-15T21:44:50Z",
"expires_at": "2026-11-22T21:44:50Z"
}
]
}
Session event¶
Sent on GET /api/v1/sessions/stream (server-sent events). The SSE event: name equals type.
| Field | Type | Description |
|---|---|---|
type |
string | connected when the stream opens; session_revoked when the session is ended elsewhere. |
session_id |
string (UUID) | The session the event is about. Can be absent on session_revoked sent to all of a user's sessions. |
reason |
string | session_revoked only: logout, logout_all, revoked_by_user, revoked_other_devices or account_deleted. |
message |
string | Human-readable text. |
timestamp |
string (ISO 8601 UTC) | When the event was sent. |
The stream also sends a : ping comment every 25 seconds. When you receive session_revoked, sign the user out
locally.
Company code lookup¶
Returned by GET /api/v1/company-code/{code}.
| Field | Type | Required | Description |
|---|---|---|---|
hosting_type |
string | Yes | cloud (hosted by PlayTelly) or on_prem (self-hosted). |
api_url |
string (URL) | No | Self-hosted only, when known. Use it instead of <API_HOST>. |
auth_url |
string (URL) | No | Self-hosted only, when known. Use it instead of <AUTH_HOST>. |
Token lifetimes¶
| Item | Default lifetime | Notes |
|---|---|---|
| Access token | 15 minutes (expires_in: 900) |
Stays valid until it expires, even after its session is revoked. |
| Refresh token | 7 days | Single use: each refresh returns a new one. |
| Invitation link | 10 minutes | Ask the organization admin to send it again if it expires. |
| Password-reset link | 1 hour | A new request replaces the previous link. |
| Social sign-in round trip and link token | 10 minutes | Start the sign-in again if it expires. |
Lifetimes are server settings and can differ on a self-hosted instance (an organization that runs PlayTelly on
its own servers under a license; hosting_type on_prem). Read expires_in instead of assuming 900.
States¶
A user can sign in only when both their account and their organization are active.
| Account state | Meaning | Sign-in result |
|---|---|---|
active |
Normal account | Allowed |
invited |
Invited by an admin, not activated yet | 403 ACCOUNT_INVITED. Activate with the invitation link (POST /api/v1/auth/magic-link/redeem). |
pending |
Awaiting approval | 403 ACCOUNT_PENDING |
disabled |
Disabled by an admin | 403 ACCOUNT_DISABLED. Refresh also fails (401). |
| Organization state | Meaning | Sign-in result |
|---|---|---|
active |
Normal | Allowed |
pending |
Sign-up awaiting PlayTelly approval | 403 ORG_PENDING for every member. Refresh fails (401). |
disabled |
Disabled by PlayTelly | 403 ORG_DISABLED for every member. Refresh fails (401). |
Errors¶
Status codes follow API conventions. The body depends on the route:
| Routes | Error body |
|---|---|
| Sign-in, invitation links, password reset, social sign-in | {"error": {"code": "INVALID_CREDENTIALS", "message": "…"}}. Branch on code. |
| Sessions, sign-out, token check, password change, company-code lookup, most refresh errors | {"error": "<text>"}. Branch on the status code. |
Refresh without a token or with a bad client_type |
{"code": "no_refresh_token", "message": "…"}, or for web {"error": "no_refresh_token", "message": "…"} |
| Unknown route or method | {"error": "not_found", "message": "…"} |
Error codes¶
| Status | Code | When it happens | What to do |
|---|---|---|---|
| 400 | INVALID_REQUEST |
The body isn't JSON or a required field is missing (for example company_code on web sign-in) |
Fix the request. |
| 400 | WEAK_PASSWORD |
The new password doesn't meet the password rules | Ask the user for a stronger password. |
| 400 | REDIRECT_NOT_ALLOWED |
redirect_uri on social sign-in isn't on an allowed origin |
Use an allowed address, or ask PlayTelly support to allow your origin. |
| 400 | invalid_client_type |
Refresh client_type isn't web or mobile |
Send web or mobile. |
| 401 | INVALID_CREDENTIALS |
Wrong user name or password, or the user isn't a member of the organization for that company code | Ask the user to check their details. Don't say which part was wrong. |
| 401 | no_refresh_token |
Refresh without a refresh token (no cookie on web, no refresh_token on mobile) |
Sign in again. |
| 401 | (no code) | Refresh token unknown, expired or already used, or the account or organization is no longer active | Sign in again. |
| 401 | (no code) | Access token missing, expired or invalid on a route that needs one | Refresh the token, then retry once. |
| 403 | ACCOUNT_INVITED |
The account hasn't been activated | Use the invitation link. |
| 403 | ACCOUNT_PENDING |
The account is awaiting approval | Wait for approval. |
| 403 | ACCOUNT_DISABLED |
The account is disabled | Contact the organization admin. |
| 403 | ORG_PENDING |
The organization's sign-up is awaiting approval | Wait for approval. |
| 403 | ORG_DISABLED |
The organization is disabled | Contact PlayTelly support. |
| 403 | MAGIC_LINK_INVALID |
The invitation link is unknown or already used | Ask the organization admin to send the invitation again. |
| 403 | MAGIC_LINK_EXPIRED |
The invitation link has expired | Ask the organization admin to send the invitation again. |
| 403 | PASSWORD_RESET_INVALID |
The reset link is unknown or already used | Request a new reset e-mail. |
| 403 | PASSWORD_RESET_EXPIRED |
The reset link has expired | Request a new reset e-mail. |
| 403 | LINK_INVALID |
The social sign-in link token has expired | Start the social sign-in again. |
| 404 | ORG_NOT_FOUND |
The company code doesn't match an organization | Ask the user to check the company code. |
| 404 | PROVIDER_NOT_FOUND |
The identity provider isn't enabled | Show only providers from GET /api/v1/auth/idp/providers. |
| 500 | SERVER_ERROR |
Something failed on the server | Retry once. If it persists, contact PlayTelly support. |
| 502 | SERVER_ERROR |
Social sign-in couldn't be started with the provider | Retry. |
| 503 | LICENSE_EXPIRED |
The license of this self-hosted instance has expired | Contact the instance's operator. |
Example bodies:
{ "error": { "code": "INVALID_REQUEST", "message": "username and password are required" } }
{ "error": { "code": "INVALID_CREDENTIALS", "message": "Invalid email or password." } }
{ "error": "missing or malformed authorization header" }
{ "error": { "code": "ACCOUNT_DISABLED", "message": "Your account has been disabled. Please contact your administrator." } }
{ "error": { "code": "ORG_NOT_FOUND", "message": "Organization not found." } }
There is no 409: these routes don't return it.
Social sign-in result codes¶
Social sign-in ends in a browser redirect, not a JSON body. On failure the browser lands on the PlayTelly sign-in
page with ?idp_error=<code>. The sign-up flow (flow=signup, used when a new organization signs up with Google)
returns to your redirect_uri with the same parameter instead.
| Code | Meaning |
|---|---|
no_account |
No PlayTelly account has the provider's e-mail address. The user must be invited first. |
email_unverified |
The provider didn't verify the e-mail address. |
account_exists |
Sign-up flow: the e-mail already has an account. Sign in instead. |
provider_failed |
The user cancelled, or the provider reported a failure. |
state_invalid |
The sign-in took longer than 10 minutes, or finished in a different browser. |
account_pending, account_disabled, account_invited |
Account state, as in States. |
org_pending, org_disabled, org_not_found |
Organization state, as in States. |
license_expired |
The self-hosted instance's license has expired. |
server_error |
Anything else. Retry. |
Endpoints¶
Related¶
- Authentication: how tokens, refresh and sessions fit together
- Sign users in with Google
- Identity API: the signed-in user's roles and permissions
- Tenancy API: invite users, create organizations, organization sign-up
- API conventions
- Changelog