getSession
GET
/get-session
const url = 'http://localhost:4000/api/auth/get-session';const options = { method: 'GET', headers: {cookie: 'better-auth.session_token=<better-auth.session_token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url http://localhost:4000/api/auth/get-session \ --cookie better-auth.session_token=<better-auth.session_token>Get the current session
The signed-in user and session, or null.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”disableCookieCache
Disable cookie cache and fetch session from database
boolean
disableRefresh
Disable session refresh. Useful for checking session status, without updating the session
boolean
Responses
Section titled “Responses”Success
Media typeapplication/json
object
session
required
object
id
required
string
expiresAt
required
string format: date-time
token
required
string
createdAt
required
string format: date-time
updatedAt
required
string format: date-time
ipAddress
string
userAgent
string
userId
required
string
activeOrganizationId
string
impersonatedBy
string
oauthOrgId
string
user
required
object
id
required
string
name
required
string
email
required
string
emailVerified
required
boolean
image
string
createdAt
required
string format: date-time
updatedAt
required
string format: date-time
twoFactorEnabled
boolean
role
string
banned
boolean
banReason
string
banExpires
string format: date-time
tokensRevokedAt
string format: date-time
Example
{ "user": { "emailVerified": false, "twoFactorEnabled": false, "banned": false }}Bad Request. Usually due to missing parameters, or invalid parameters.
Media typeapplication/json
object
message
required
string
Example generated
{ "message": "example"}Unauthorized. Due to missing or invalid authentication.
Media typeapplication/json
object
message
required
string
Example generated
{ "message": "example"}Forbidden. You do not have permission to access this resource or to perform this action.
Media typeapplication/json
object
message
string
Example generated
{ "message": "example"}Not Found. The requested resource was not found.
Media typeapplication/json
object
message
string
Example generated
{ "message": "example"}Too Many Requests. You have exceeded the rate limit. Try again later.
Media typeapplication/json
object
message
string
Example generated
{ "message": "example"}Internal Server Error. This is a problem with the server that you cannot fix.
Media typeapplication/json
object
message
string
Example generated
{ "message": "example"}