Triggers¶
trigger.type decides when an agent runs.
| Type | Runs when | Extra fields |
|---|---|---|
collection_event |
an item is created, updated, deleted, published or unpublished | event_trigger.collection, event_trigger.events |
webhook |
POST /agents/webhook/{id} with the right token |
webhook_token |
cron |
on a schedule | cron |
manual |
never on its own (definition only) |
Collection events¶
"trigger": {
"type": "collection_event",
"event_trigger": { "collection": "articles", "events": ["item:created", "item:updated"] }
}
Events: item:created, item:updated, item:deleted, and for
draft-and-publish collections
item:published and item:unpublished (when an item becomes visible to readers, or stops
being visible). They are emitted for REST and GraphQL writes that change something: a save
that changes nothing emits no event. Writes an agent makes while it runs do not emit
events, with gohead standalone too, so agents cannot trigger each other in loops; an
approved proposal does, except to the agent that proposed it. The agent's
first message contains the event type, the collection, the item ID and the item data.
Webhook¶
This section is about webhooks that start an agent. To send content events to another service without an agent, use outbound webhooks.
Call it with the agent's numeric ID (shown when you create or list agents):
curl -X POST $GOHEAD/agents/webhook/2 \
-H "Content-Type: application/json" \
-H "Webhook-Token: a-long-random-string" \
-d '{"event":"order.paid","order_id":123}'
| Response | Meaning |
|---|---|
202 {"data":{"status":"Job accepted for processing"}} |
queued |
401 |
wrong or missing token, or the agent is not a webhook agent |
404 |
no agent with this ID |
500 |
the job could not be queued (is Redis up?) |
The JSON body is passed to the agent in its first message. Tokens are compared in constant
time; generate them with openssl rand -hex 32.
Cron¶
Standard five-field cron expressions, evaluated in UTC. The scheduler re-reads cron agents every minute, so new or changed schedules apply without a restart. Run exactly one scheduler, or each tick runs once per scheduler.
Manual¶
manual agents are stored but never started automatically. Use them to keep a definition
around, or switch their trigger later with PUT /admin/agents/{name}.