Skip to Content

Update session

Required accessSessions: adminadmin:sessionsAny key with this access, from API keys
PATCH
/api/v1/sessions/{session}

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.

Authorization

secretKey
headerAuthorizationBearer <token>

Use a named environment API key. It starts with tr_dev_sk_, tr_prod_sk_, tr_stg_sk_, etc.

Create a named API key in the API Keys section of your Trigger.dev project dashboard. Choose the narrowest access preset that supports your integration.

Our TypeScript SDK will default to using the value of the TRIGGER_SECRET_KEY environment variable if it is set. If you are using the SDK in a different environment, you can set the key using the configure function.

import { configure } from "@trigger.dev/sdk";configure({ accessToken: "tr_dev_sk_1234" });

Path Parameters

session*string

The session's friendly ID (session_…) or your externalId. The server disambiguates by the session_ prefix.

Request Body

application/json
  1. body

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?array<>

Replaces the tags on the session row.

Itemsitems <= 10
metadata?

Replaces the metadata. Pass null to clear it.

externalId?string

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.

Length1 <= length <= 256

Response Body

Session updated successfully

application/json
  1. response

A session row.

id*string

The session's friendly ID, prefixed with session_.

externalId?string

Your stable identity for the session, if one was set.

type*string

The session type discriminator.

taskIdentifier*string

The task this session triggers runs against.

triggerConfig?

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.

currentRunId?string

Friendly ID of the live run for this session, if any. Prefixed with run_. Omitted on list rows.

tags*array<string>

Tags on the session row.

metadata?

Arbitrary JSON metadata, or null if unset.

closedAt?string

When the session was closed, or null if open.

Formatdate-time
closedReason?string

The optional reason recorded when the session was closed.

expiresAt?string

The session's retention deadline, or null if none.

Formatdate-time
createdAt*string
Formatdate-time
updatedAt*string
Formatdate-time
Example Request
import { sessions } from "@trigger.dev/sdk";const session = await sessions.update(chatId, {  tags: ["priority"],  metadata: { lastSeenBy: "support" },});
Example Response
{  "id": "session_abc123",  "externalId": "chat_1234",  "type": "chat.agent",  "taskIdentifier": "my-chat",  "triggerConfig": {    "basePayload": {},    "machine": "small-1x",    "queue": "string",    "tags": [      "string"    ],    "maxAttempts": 1,    "maxDuration": 1,    "lockToVersion": "20240523.1",    "region": "string",    "idleTimeoutInSeconds": 1  },  "currentRunId": "run_def456",  "tags": [    "chat:1234"  ],  "metadata": {},  "closedAt": "2019-08-24T14:15:22Z",  "closedReason": "string",  "expiresAt": "2019-08-24T14:15:22Z",  "createdAt": "2019-08-24T14:15:22Z",  "updatedAt": "2019-08-24T14:15:22Z"}

Was this page helpful?

Last updated

Edit on GitHub