Sessions

This object represents an active session for a user. Sessions are created when a user successfully goes through the sign in or sign up flows.

Available requests

  • GET/v1/sessions/:id

  • GET/v1/sessions

  • POST/v1/sessions/:id/revoke

  • POST/v1/sessions/:id/verify

Example session schema

{
"object": "session",
"id": "sess_1q8uCbeJSMgTJnTQMgpAK1Ff0ER",
"client_id": "client_1q8sn8pLHjqTU2g1UheJwJ7YWU6",
"user_id": "user_1n5BS00ns3t21GWIXiPJ0KcSe02",
"status": "active",
"last_active_at": 1616473411,
"expire_at": 1617078211,
"abandon_at": 1619065411
}

get
Retrieve a session

https://api.clerk.dev/v1/sessions/:id
Retrieve the details of a session.
Request
Response
Request
Headers
Authorization
required
string
Bearer [YOUR_API_KEY]
Response
200: OK
// see example schema
{
"object": "session",
"id": "sess_1q8uCbeJSMgTJnTQMgpAK1Ff0ER",
...
}

get
List all sessions

https://api.clerk.dev/v1/sessions
List all sessions.
Request
Response
Request
Headers
Authorization
required
string
Bearer [YOUR_API_KEY]
Response
200: OK
// see example schema
[
{
"object": "session",
"id": "sess_1q8uCbeJSMgTJnTQMgpAK1Ff0ER",
...
},
{
"object": "session",
"id": "sess_1q8uCbeJSMgTJnTQMgpAK1Ff0ER",
...
}
]

post
Revoke a session

https://api.clerk.dev/v1/sessions/:id/revoke
Sets the status of a session as "revoked". Which is an unauthenticated state. In multi-session mode, a revoked session will still return along with it's client object, however the user will need to sign into it again.
Request
Response
Request
Headers
Authorization
required
string
Bearer [YOUR_API_KEY]
Response
200: OK
// see example schema
{
"object": "session",
"id": "sess_1q8uCbeJSMgTJnTQMgpAK1Ff0ER",
...
}

post
Verify a session

https://api.clerk.dev/v1/sessions/:id/verify
Returns the session if it is authenticated, otherwise returns a 404 resource_not_found error.
Request
Response
Request
Headers
Authorization
required
string
Bearer [YOUR_API_KEY]
Form Data Parameters
token
required
string
The JWT that is sent via the `__session` cookie from your frontend. Note: this JWT must be associated with the supplied session ID
Response
200: OK
// see example schema
{
"object": "session",
"id": "sess_1q8uCbeJSMgTJnTQMgpAK1Ff0ER",
...
}
404: Not Found
The supplied session_id was either not valid, or was not related to the supplied token.
{
"errors": [
{
"message": "Session not found",
"long_message": "No session was found with id session_id",
"code": "resource_not_found"
}
]
}