# updateSession()

> This feature requires a [paid plan](https://clerk.com/pricing) 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](https://clerk.com/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`](https://clerk.com/docs/reference/backend/types/backend-session.md).

```typescript
function updateSession(sessionId: string, params: { expireAt: Date }): Promise<Session>
```

## Parameters

| Parameter         | Type                             | Description                                                                               |
| ----------------- | -------------------------------- | ----------------------------------------------------------------------------------------- |
| `sessionId`       | `string`                         | The ID of the session to update.                                                          |
| `params`          | `{ expireAt: Date; }` | The parameters to update the session with.                                                |
| `params.expireAt` | `Date`                           | When the session should expire. Must be at least 5 minutes and at most 10 years from now. |

## Usage

> Using `clerkClient` varies based on the SDK you're using. Refer to the [overview](https://clerk.com/docs/reference/backend/overview.md) for usage details, including guidance on [how to access the `userId` and other properties](https://clerk.com/docs/reference/backend/overview.md#example-get-the-userid-and-other-properties).

```tsx
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](https://clerk.com/docs/reference/backend-api/tag/sessions/PATCH/sessions/%7Bsession_id%7D) for more information.

---

## Sitemap

[Overview of all docs pages](https://clerk.com/docs/llms.txt)
