---
title: "Update a session"
method: PATCH
path: "/api/v1/sessions/{session}"
tags: ["sessions"]
---

# Update a session

`PATCH /api/v1/sessions/{session}`

## Request

- Base URL: `https://api.trigger.dev`
- URL: `https://api.trigger.dev/api/v1/sessions/{session}`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/triggerdotdev/apis/trigger-dev-v3-rest-api/docs/api/v1/sessions/:session/patch.ts> (a function with typed inputs; its response is checked against the schema)

Update a session's `tags` or `metadata`. Pass `metadata: null` to clear it.

Requires a secret key — a session public token cannot update a session. `externalId` is read-only after create: it cannot be changed or cleared. Sending a value different from the current one (including `null` when one is set) returns `422`; sending the same value is accepted as a no-op.

## Request body

- UpdateSessionRequestBody: Body for `PATCH /api/v1/sessions/{session}`. The whole body must be 32KB or smaller. Every field is optional; omitted fields are left unchanged.
  - `tags` string[]: Replaces the tags on the session row.
  - `metadata` object, nullable: Replaces the metadata. Pass `null` to clear it.
  - `externalId` string, nullable: Read-only after create: cannot be changed or cleared. Sending a value different from the current one (including `null` when one is set) returns `422`; sending the same value is idempotent.

## Response `200`

Session updated successfully

- SessionObject: A session row.
  - `id` string, required: The session's friendly ID, prefixed with `session_`.
  - `externalId` string, nullable: Your stable identity for the session, if one was set.
  - `type` string, required: The session type discriminator.
  - `taskIdentifier` string, required: The task this session triggers runs against.
  - `triggerConfig` SessionTriggerConfig: Trigger options applied to every run a session schedules. `basePayload` is the wire payload merged into each run; the remaining fields map onto the standard trigger options.
    - `basePayload` object, required: Base payload passed to every run this session triggers. For `chat.agent` this carries `{ chatId, ...clientData }`.
    - `machine` string: Machine preset for each run, e.g. `small-1x`.
    - `queue` string: Queue to schedule runs on.
    - `tags` string[]: Tags applied to every run this session triggers.
    - `maxAttempts` integer: Maximum retry attempts per run.
    - `maxDuration` integer: Per-run wall-clock cap in seconds.
    - `lockToVersion` string: Pin every run to a specific worker version.
    - `region` string: Region to schedule runs in.
    - `idleTimeoutInSeconds` integer: Idle timeout surfaced to `chat.agent` via the wire payload.
  - `currentRunId` string, nullable: Friendly ID of the live run for this session, if any. Prefixed with `run_`. Omitted on list rows.
  - `tags` string[], required: Tags on the session row.
  - `metadata` object, nullable: Arbitrary JSON metadata, or `null` if unset.
  - `closedAt` string, date-time, nullable: When the session was closed, or `null` if open.
  - `closedReason` string, nullable: The optional reason recorded when the session was closed.
  - `expiresAt` string, date-time, nullable: The session's retention deadline, or `null` if none.
  - `createdAt` string, date-time, required
  - `updatedAt` string, date-time, required

## Other responses

- `401`: Unauthorized request
- `404`: Session not found
- `422`: Validation failed — for example an attempt to change `externalId` to a different value, or a body exceeding 32KB.

## Changes

- **2026-06-14** `6e21987d1377`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/triggerdotdev/apis/trigger-dev-v3-rest-api/changes/api/v1/sessions/:session/patch.md)

---

[API](https://skmtc.dev/triggerdotdev/apis/trigger-dev-v3-rest-api.md) - [All operations](https://skmtc.dev/triggerdotdev/apis/trigger-dev-v3-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/triggerdotdev/apis/trigger-dev-v3-rest-api/revisions/441161111493?raw)
