Skip to content

Chain Triggers

A Chain is an executable workflow: its Bit-DAG is the action. A chain trigger declares when that workflow runs. One chain may have many triggers (e.g. a daily cron and an event trigger). Triggers replace the removed legacy automation rules free-text form — you connect existing Agents/Twins/Chains as Bit nodes instead of typing prompts.

Every trigger fires through the loop-guarded run path, so cron, event, and chain→chain firings are wallet-reserved and protected against runaway recursion.

Trigger types

trigger_typeFires whentriggerConfig
manualA user calls POST /chains/:id/trigger-run
cronA 5-field cron expression matches (minute granularity){ "cron": "0 9 * * 1" }
eventA subscribed domain event is emitted{ "eventType": "chain.streak_broken" }

Specialized legacy event types (bit_overdue, chain_streak_broken, period_completed, …) all map to event + the corresponding eventType.

Endpoints

MethodPathDescriptionAuthRate Limit
POST/chains/:chainId/triggersCreate a triggerJWT30/min
GET/chains/:chainId/triggersList a chain's triggersJWT60/min
PATCH/chains/:chainId/triggers/:triggerIdUpdate a trigger (re-runs loop validation)JWT30/min
POST/chains/:chainId/triggers/:triggerId/deactivateDeactivate a triggerJWT30/min

Create a trigger

Request

http
POST /chains/{chainId}/triggers
Authorization: Bearer $TOKEN
Content-Type: application/json
json
{
  "trigger_type": "cron",
  "triggerConfig": { "cron": "0 9 * * 1" },
  "conditions": [
    { "field": "bit.priority", "operator": "gte", "value": 3 }
  ],
  "cooldownMinutes": 60,
  "maxRunsPerDay": 5,
  "scheduleId": null,
  "isActive": true
}

Tenant fields (account/chainer/workspace) are derived from the owning chain and must not be sent. conditions use the structured {field, operator, value} shape (operators: eq, neq, gt, gte, lt, lte, contains, exists); all conditions must pass (AND). There is no free-text actions/prompt field — the chain's Bit-DAG is the action.

Validation

  • cron triggers require triggerConfig.cron; event triggers require triggerConfig.eventType (400 otherwise).
  • An event trigger that listens on the chain or bit entity family (which a chain run inevitably affects) is rejected as a self-loop with 422 and code automation_rule_cycle.
  • Event triggers get pacing defaults applied: cooldownMinutes >= 1 and a maxRunsPerDay default so a hot event cannot fan out unbounded.

Response

json
{
  "data": {
    "id": "…",
    "chainId": "…",
    "triggerType": "cron",
    "triggerConfig": { "cron": "0 9 * * 1" },
    "conditions": [],
    "isActive": true,
    "cooldownMinutes": 60,
    "maxRunsPerDay": 5,
    "scheduleId": null,
    "runCount": "0",
    "lastTriggeredAt": null,
    "lastStatus": null,
    "createdAt": "…",
    "updatedAt": "…"
  }
}

See also

Built with purpose.