Sessions

A session authenticates one tenant in the embedded component for one application.

POST   /applications/{application_id}/sessions

The session object

FieldTypeDescription
idstring
objectstringAlways session.
application_idstring
modeenumOne of embedded, redirect.
client_secretstringSecret used to mount the embedded component.
urluriThe hosted page for redirect mode.
expires_atdate-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

FieldTypeDescription
modeenumembedded: for the JavaScript component. redirect: the tenant is sent to url. Default embedded.
localeenumOverrides the application's locale for this session. One of en, zh-CN.
return_urluriWhere 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"
}