Skip to main content

updateSession()

Warning

This feature requires a paid plan for production use, but all features are free to use in development mode so that you can try out what works for you. See the pricing page for more information.

Changes when the given session expires. The new expiry applies to this session only and can exceed the instance's session lifetime. Only active and pending sessions can be updated.

Take the session ID from the sid claim of a verified session token, never from an unverified client request.

Returns the updated Session.

function updateSession(sessionId: string, params: { expireAt: Date }): Promise<Session>
  • Name
    sessionId
    Type
    string
    Description

    The ID of the session to update.

  • Name
    params
    Type
    { expireAt: Date; }
    Description

    The parameters to update the session with.

  • Name
    params.expireAt
    Type
    Date
    Description

    When the session should expire. Must be at least 5 minutes and at most 10 years from now.

Note

Using clerkClient varies based on the SDK you're using. Refer to the overview for usage details, including guidance on how to access the userId and other properties.

const sessionId = 'sess_123'
const expireAt = new Date(Date.now() + 60 * 60 * 1000)

const response = await clerkClient.sessions.updateSession(sessionId, { expireAt })

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint PATCH/sessions/{session_id}. See the BAPI reference for more information.

Feedback

What did you think of this content?

Last updated on