Skip to main content
POST
Start a session

Authorizations

Authorization
string
header
required

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.

Body

application/json

Body for POST /api/v1/sessions. The whole body must be 32KB or smaller.

type
string
required

Free-form discriminator for the session, e.g. chat.agent. Not validated against an enum.

Required string length: 1 - 64
Example:

"chat.agent"

taskIdentifier
string
required

The task this session triggers runs against.

Required string length: 1 - 128
Example:

"my-chat"

triggerConfig
object
required

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.

externalId
string

Your stable identity for the session, unique per environment. Cannot start with the reserved session_ prefix. Reusing an externalId makes create idempotent; reusing one whose session is closed or expired returns 409.

Required string length: 1 - 256
Example:

"chat_1234"

tags
string[]

Up to 10 tags on the session row, for dashboard filtering.

Maximum array length: 10
Maximum string length: 128
metadata
object

Arbitrary JSON metadata.

expiresAt
string<date-time>

Absolute expiry timestamp for retention.

Response

An open session already existed for this externalId. The existing session is returned with isCached: true.

A session row.

id
string
required

The session's friendly ID, prefixed with session_.

Example:

"session_abc123"

type
string
required

The session type discriminator.

Example:

"chat.agent"

taskIdentifier
string
required

The task this session triggers runs against.

Example:

"my-chat"

tags
string[]
required

Tags on the session row.

Example:
createdAt
string<date-time>
required
updatedAt
string<date-time>
required
runId
string
required

Friendly ID of the first run triggered alongside the session.

Example:

"run_def456"

publicAccessToken
string
required

Session-scoped public access token carrying read:sessions:{key} and write:sessions:{key}. Default TTL is 1 hour. Safe to pass to frontend clients.

isCached
boolean
required

true if an open session already existed for this externalId (idempotent upsert), false if newly created.

externalId
string | null

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

Example:

"chat_1234"

triggerConfig
object

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 | null

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

Example:

"run_def456"

metadata
object | null

Arbitrary JSON metadata, or null if unset.

closedAt
string<date-time> | null

When the session was closed, or null if open.

closedReason
string | null

The optional reason recorded when the session was closed.

expiresAt
string<date-time> | null

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