Amarsia
API Reference

Trigger API

Create and read one-shot triggers that prime assistant conversations.

Overview

Triggers store the first-message content and optional variables for a deployment. Create is authenticated. Get by id is public so chat UIs can load a trigger from a tid URL param.

Base path: /v1/runner/{deployment_id}


Create trigger

Creates a trigger for a published deployment.

POST /v1/runner/{deployment_id}/trigger

Auth: x-api-key (or dashboard session Bearer token).

Body

FieldTypeDescription
contentMessageContent[]First-message content (same shape as runner)
variablesobjectOptional arbitrary variables
ui_surfacestringOptional surface hint (chat, assessment, …)
ttl_hoursinteger | nullHours until expiry. Default 24. Pass null for no expiry

Response

FieldTypeDescription
idstring8-character public trigger id (tid in chat URLs)
deployment_idUUIDDeployment
workflow_idintegerParent workflow
ui_surfacestring | nullSurface hint
contentarrayStored content
variablesobject | nullStored variables
conversation_idUUID | nullSet after first successful use
workflow_log_idinteger | nullLinked log when available
created_atdatetimeCreated time
expires_atdatetime | nullExpiry time
expiredbooleanComputed: expires_at is in the past
import { amarsia } from "@amarsia/sdk";

const client = amarsia.init({
  apiKey: process.env.AMARSIA_API_KEY!,
  deploymentId: "YOUR_DEPLOYMENT_ID",
});

const trigger = await client.trigger.create({
  content: [{ type: "text", text: "Let us begin. Student: Riya." }],
  variables: { studentName: "Riya" },
  uiSurface: "chat",
  ttlHours: 24,
});

const url = `https://chat.amarsia.com/chat/${trigger.deployment_id}?tid=${trigger.id}`;

Get trigger

Public read. Safe to call repeatedly. Does not mutate the trigger.

GET /v1/runner/{deployment_id}/trigger/{trigger_id}

Auth: none.

Use conversation_id and expired to decide UI state:

ConditionUI / client action
expiredShow expired; do not start or continue
conversation_id nullFire: start conversation with stored content + trigger_id
conversation_id setResume that conversation
const trigger = await client.trigger.get({ triggerId: "TRIGGER_UUID" });

List triggers

Paginated history for the dashboard (authenticated).

GET /v1/runner/{deployment_id}/triggers?page=1&page_size=20

Runner integration

Pass optional trigger_id on v1/v2 one-shot and conversation requests. For conversations, only on the first message (no conversation_id yet).

If the workflow has trigger_required: true and the request omits trigger_id, the runner returns 400.

Workflow setting endpoint (dashboard):

POST /v1/workflow/{workflow_id}/trigger-settings

Body: { "trigger_required": true }

Public widget-meta includes trigger_required so chat UIs can block early.