new_session mode, each run creates a new session; in reuse_session mode, the trigger reuses a platform-managed session that is automatically created and bound to the trigger on the first run, so you do not need to specify a session ID. You can also run a trigger manually at any time.
Platform-managed triggers (such as Dreams policies) cannot be modified through the endpoints on this page; see Dreams for how to manage them. This page covers triggers that you create yourself.
The examples below show both cURL and the kha CLI. You can create, view, and manage triggers in Console > Triggers, or run the same operations with the kha CLI.
Create a scheduled trigger
CallPOST /v1/triggers to create a trigger. For example, to generate a financial market morning brief every weekday at 9:00 AM:
name, agent_id, environment_id, and policy. policy.expression is a space-separated cron expression with five fields—minute, hour, day of month, month, and day of week—and a minimum granularity of 1 minute (0 9 * * 1-5 above means 9:00 AM on weekdays). Expressions with no matching fire time within the next 5 years are rejected on creation or update. timezone is the IANA time zone used to evaluate scheduled run times.
agent_id comes from id in the create-agent response. environment_id comes from id in the create-environment response and specifies the execution environment for triggered sessions; omitting it or passing an empty value is rejected (400 invalid_parameter_error). When agent_version is omitted, each run uses the agent’s latest version at fire time. On creation, the platform validates references to the agent, execution environment, vaults, and memory stores; nonexistent, cross-project, or archived references are rejected.
Creation returns 201 on success; save id from the response as TRIGGER_ID (trig_ prefix). Newly created triggers start in active status and fire automatically on schedule.
Optional fields:
session_mode:new_session(default) orreuse_session; the creation example above explicitly setsreuse_session.initial_events: Initial events delivered to the session on each run (such as task instructions), at most 16 entries; currently onlyuser.messageis supported.resources: Files, vaults, memory stores, or GitHub repositories mounted into the triggered session, at most 16 entries. Repositories use thegithub_repositorystructure; see GitHub Repositories.notification: Webhook configuration for run result notifications; see “Receive run notifications” below.
View triggers and scheduled run times
CallGET /v1/triggers to list triggers, ordered newest first. Archived triggers are excluded by default; filter by lifecycle status with status or by policy type with policy_type. The endpoint returns 50 items per page by default; if the response includes next_page_token, pass it as page_token on the next request until next_page_token is empty.
Call GET /v1/triggers/{id} to inspect a single trigger:
active status with a cron policy, the response includes upcoming_runs_at: up to the next 5 scheduled fire times in UTC, which you can use to verify that the schedule matches your expectations.
Run manually
For debugging or ad-hoc runs, callPOST /v1/triggers/{id}/run to trigger an immediate run without waiting for the next scheduled time. Paused triggers can also be run manually:
payload is optional text: when omitted, the trigger runs using only its existing configuration; when provided, it is delivered as a user message to the session for this run.
Manual runs are synchronous: the endpoint waits for the trigger run to finish and responds with 201 along with the terminal run record (completed, failed, or skipped). If another manual run is already in progress for the same trigger, the request returns 400 failed_precondition_error. In reuse_session mode, if a scheduled run or another run is currently using the managed session, the run is recorded as skipped with error.type set to overlap_in_flight.
Note what completed means: it indicates only that the session for this run was created and its initial events were accepted—not that the agent has finished the task. To check task execution and results, use session_id from the run record to query session status or subscribe to the event stream; see Create a Session and Event Stream.
View run history
CallGET /v1/triggers/{id}/runs to list run records, ordered newest first; pass has_error=true to list only failed runs. The endpoint returns 50 items per page by default; if the response includes next_page_token, pass it as page_token on the next request to fetch the next page:
status field can have the following values:
running: The run record has been created and the session is starting.completed: The session was created and initial events were accepted (does not indicate that the agent task itself succeeded).failed: The trigger run failed; seeerroron the record for the failure details.skipped: The trigger was not active at fire time, or the previous run inreuse_sessionmode had not yet finished.
context distinguishes how the run was initiated: schedule indicates a scheduled run (including scheduled_at), and manual indicates a manual run (including actor). session_id identifies the session used for the run, which you can query to track task progress.
Each trigger retains up to 500 of its most recent run records, and records older than 90 days are deleted.
Pause and resume
To temporarily disable scheduled runs, callPOST /v1/triggers/{id}/pause to pause the trigger:
204 and stops scheduled runs. Any session already running is unaffected, and manual runs remain available. Pausing an already paused trigger is a no-op. If an unrecoverable run error occurs, the platform also pauses the trigger automatically; inspecting the trigger in that state shows paused_reason.type set to error along with error details.
Call POST /v1/triggers/{id}/unpause to resume the trigger:
204 and recalculates the schedule from the current time forward; scheduled fire times missed while paused are not backfilled.
Update trigger configuration
CallPATCH /v1/triggers/{id} to update a trigger. This endpoint performs a partial update: only fields present in the request body are modified, while omitted fields remain unchanged. The example below moves the schedule to 8:30 AM on weekdays and clears bound resources (files, vaults, memory stores, or GitHub repositories) and initial events:
[] to clear resources or initial_events. Passing an empty string for agent_version selects the latest agent version at fire time. notification replaces the current configuration only if it appears in the request: pass an empty object {} to remove notifications, or omit the field to keep the existing configuration. Changing session_mode from reuse_session to new_session causes subsequent runs to create new sessions rather than reusing the previous session. While session_mode remains reuse_session, modifying agent_id, agent_version, environment_id, or resources returns 400 failed_precondition_error; to change any of those fields, switch to new_session first or create a new trigger. Pausing, resuming, and archiving cannot be done through the update endpoint—use their respective action endpoints instead.
Archive a trigger
Archive a trigger when you no longer need it:204. Once archived, a trigger never fires again, though existing run records are retained and remain queryable. Archiving is irreversible—confirm that you no longer need the schedule before archiving.
Receive run notifications
This section covers the trigger’s own
notification configuration. To subscribe to changes across multiple types of resources in your project, use Project Webhooks. Trigger run notifications use a webhook_secret stored in a vault, whereas Project Webhooks use the signing_secret returned when creating or rotating a Webhook configuration. Their subscription scopes, configuration, and signing secret management are independent.notification when creating or updating a trigger. On update, include only the fields you want to change:
url is the HTTPS endpoint that receives notifications. secret_vault points to a vault containing an environment_variable credential named webhook_secret, which is used to sign notifications; the credential value is read only at delivery time, so configuring notification validates only the vault reference, not whether the webhook_secret credential exists. url and secret_vault must be set together—providing only one is rejected (400 invalid_parameter_error). On update, pass an empty object {} to clear the notification configuration, or omit notification to retain the current configuration.
Once configured, the platform sends HTTPS POST notifications to that URL for each scheduled run (manual runs do not send notifications). There are four notification event types: trigger_run.started (run started), trigger_run.succeeded (run completed), trigger_run.failed (run failed), and trigger.paused (an unrecoverable run error caused the trigger to transition automatically from active to paused). A scheduled run typically delivers two run notifications: trigger_run.started at the beginning and trigger_run.succeeded or trigger_run.failed at the end. Skipped runs do not emit those run events, though trigger.paused may still be delivered if the trigger is paused automatically; see Pause and resume above. Notifications are delivered at least once; see the delivery policy and deduplication guidance below.
The notification body is a compact JSON envelope carrying only the event type and resource ID. For trigger_run.* events, data.id is the run ID (trun_ prefix); query the run history endpoint for details. For trigger.paused, data.id is the trigger ID (trig_ prefix); retrieve the trigger to inspect paused_reason:
id at the top level is the delivery ID (matching the Webhook-Id request header); retries resend the identical body byte for byte.
Every delivery includes the Webhook-Id, Webhook-Timestamp, and Webhook-Signature: v1,<base64> request headers. The signature is the Base64-encoded HMAC-SHA256 digest of "<Webhook-Id>.<Webhook-Timestamp>.<raw_request_body>" computed using the webhook_secret credential value as the key; receivers should compute and compare the signature in the same way to verify that the notification came from the platform.
The platform delivers notifications on an at-least-once basis, making at most 3 attempts per event (including the initial attempt). Any 2xx response is treated as successful delivery; once all attempts are exhausted, the notification is dropped. Receivers should deduplicate deliveries using Webhook-Id.
Next steps
Explore Dreams triggers
Learn how to configure platform-managed memory maintenance triggers (Dreams policies).
Configure multi-agent orchestration
Coordinate multiple agents to complete complex tasks.
Stream live session events
Subscribe to live events from triggered sessions to track task progress.