Skip to content

Read the current user session

POST
/v1/id/get-session
curl --request POST \
--url https://your-tenant-host/v1/id/get-session \
--header 'Content-Type: application/json' \
--header 'x-edgekit-site-id: site_example' \
--cookie ek.session_token=<ek.session_token> \
--data '{ "castleRequestToken": "example" }'

POST only: there is no GET. Never cached. Mounted in all three idModes — the authority differs, not the surface, which is what lets an organization move external_only to dual without shipping an SDK release. No credential answers 200 with a null user and a null session, never 401. In dual it also performs the exchange on first sight and reports it as session.exchanged, which makes this a write — still safe to retry. Where Castle is required for the site and a castleRequestToken is sent, an EdgeKit session Castle denies or challenges is revoked, and the answer is the same 200 with two nulls.

x-edgekit-site-id
required

The site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.

string
>= 1 characters <= 128 characters

Example

site_example

The site this request is for, within this tenant. Every official EdgeKit SDK sets it from the client you configured; set it yourself only when calling this API directly.

Media typeapplication/json
object
castleRequestToken

A fresh Castle request token from castle.js on the page. Each token is good for one request. While Castle is required for the site, an EdgeKit session is checked with it, and one Castle denies or challenges is revoked. Without one, the session is returned unchecked.

string

Example generated

{
"castleRequestToken": "example"
}

The user and their session, or two nulls.

Media typeapplication/json
object
user
required
object
id
required
string format: uuid
email
required
string
emailVerified
required
boolean
name
required
string | null
firstName
required
string | null
lastName
required
string | null
image
required
string | null
session
required

Discriminated on kind, which is open: known edgekit, external. A client must accept a session of another kind.

One of:
object
id
required
string format: uuid
kind
required
string
Allowed values: edgekit
expiresAt
required
string format: date-time
exchanged
boolean

Example

{
"user": {
"id": "01926f3a-8b4c-7d2e-9f10-2a3b4c5d6e7f",
"email": "user@example.com",
"emailVerified": true,
"name": "Ada Lovelace",
"firstName": "Ada",
"lastName": "Lovelace",
"image": null
},
"session": {
"id": "01926f3a-8b4d-7a11-8c22-3d4e5f6a7b8c",
"kind": "edgekit",
"expiresAt": "2026-08-30T09:00:00.000Z",
"exchanged": true
}
}

Invalid request.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Not allowed.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Resource not found.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Request validation failed.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

Unexpected error.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details

Example

{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key."
}
}

edgekit.ai