Sessions
A session authenticates one tenant in the embedded component for one application.
POST /applications/{application_id}/sessions
The session object
| Field | Type | Description |
|---|---|---|
id | string | |
object | string | Always session. |
application_id | string | |
mode | enum | One of embedded, redirect. |
client_secret | string | Secret used to mount the embedded component. |
url | uri | The hosted page for redirect mode. |
expires_at | date-time |
Create a session
POST/applications/{application_id}/sessions
Creates a session for an application. Sessions expire after 60 minutes. Creating a session invalidates the application's earlier sessions.
Request body
| Field | Type | Description |
|---|---|---|
mode | enum | embedded: for the JavaScript component. redirect: the tenant is sent to url. Default embedded. |
locale | enum | Overrides the application's locale for this session. One of en, zh-CN. |
return_url | uri | Where the tenant is sent when they finish or leave. Required for redirect. We append application_id and session_status (completed or exited). |
Example request
curl https://api.thestudentguarantor.com/v1/applications/app_3Nf7QwR1tY8uLk5H/sessions \
-X POST \
-H "Authorization: Bearer $TSG_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "embedded",
"locale": "zh-CN",
"return_url": "https://www.example-platform.com/bookings/BK-2026-223515/guarantee"
}'
Returns
Returns the session object. Returns an error if no requirement can be completed in a session.
Example response
{
"id": "sess_9Tg4HbN6mJ2kLp8Q",
"object": "session",
"application_id": "app_3Nf7QwR1tY8uLk5H",
"mode": "embedded",
"client_secret": "sess_9Tg4HbN6mJ2kLp8Q_secret_x7Vq2ZcR5tYw8Ub1",
"url": "https://app.thestudentguarantor.com/embed/session#sess_9Tg4HbN6mJ2kLp8Q_secret_x7Vq2ZcR5tYw8Ub1",
"expires_at": "2026-11-19T10:17:10Z"
}