sessions
Create a session
Changed onCreate a Session and trigger its first run in one atomic call. A Session is the durable identity for a bi-directional stream of records (the .in and .out channels) that survives across the runs processing it.
Idempotent on externalId within an environment. Calling create again with an externalId that already maps to an open session returns the existing session with isCached: true and 201 becomes 200. Reusing an externalId whose session is already closed or expired returns 409.
Authorize with a secret key, or a public token carrying write:sessions for the session you are creating.
post/api/v1/sessions
Request
- Base URLhttps://api.trigger.dev
- Auth
- HTTP bearer
- or HTTP bearer
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
Example request
{
"type": "chat.agent",
"taskIdentifier": "my-chat",
"triggerConfig": {
"machine": "small-1x",
"lockToVersion": "20240523.1"
},
"externalId": "chat_1234"
}Response
An open session already existed for this externalId. The existing session is returned with isCached: true.
Example response
{
"id": "session_abc123",
"externalId": "chat_1234",
"type": "chat.agent",
"taskIdentifier": "my-chat",
"triggerConfig": {
"machine": "small-1x",
"lockToVersion": "20240523.1"
},
"currentRunId": "run_def456",
"tags": [
"chat:1234"
],
"runId": "run_def456"
}Changes
- info
endpoint added
- info