Skip to main content

Triggers

Triggers​

toothfairyai@latest…

Manager for event-driven agent triggers.

Triggers invoke an agent when a configured event source fires (native ToothFairyAI events or external provider events such as Google Drive, Slack, GitHub, etc.).

Example:

>>> client = ToothFairyClient(api_key="...", workspace_id="...")
>>> trigger = client.triggers.create(
... name="Slack mention",
... agent_id="agent-123",
... event_source_type="EXTERNAL",
... event_config={"provider": "slack", "acquisitionMode": "WEBHOOK"},
... )

Accessed via client.triggers.

Methods​

MethodHTTPEndpoint
createPOSTPOST /trigger/create
updatePOSTPOST /trigger/update
getGETGET /trigger/get/{trigger_id}
deleteDELETEDELETE /trigger/delete/{trigger_id}
listGETGET /trigger/list
pause—derived
resume—derived
get_by_agent—derived
get_active—derived
search—derived

create​

Create a new trigger.

def create(
name: str,
agent_id: str,
event_source_type: Any,
custom_prompt_id: Optional[str] = None,
description: Optional[str] = None,
forced_prompt: Optional[str] = None,
event_config: Optional[Union[TriggerExternalConfig, Dict[str, Any]]] = None,
is_active: bool = True,
status: Optional[TriggerStatusRequest] = None,
execution_config: Optional[Union[CronExecutionConfig, Dict[str, Any]]] = None,
notification_config: Optional[Union[CronNotificationConfig, Dict[str, Any]]] = None,
retry_config: Optional[Union[CronRetryConfig, Dict[str, Any]]] = None,
metadata: Optional[Dict[str, Any]] = None
) -> Trigger

Endpoint: POST /trigger/create · API service

Request fields​

Python kwargWire fieldTypeRequiredDescription
ididstringnoOptional trigger ID (UUID). Omit to let the API generate one.
workspace_idworkspaceidstringyesWorkspace ID (UUID). Must match the workspace the API key belongs to.
namenamestringyesHuman-readable name for the trigger.
descriptiondescriptionstringnoOptional description of what the trigger does.
forced_promptforcedPromptstringnoFree-text prompt sent to the agent when the trigger fires. Provide either forcedPrompt or customPromptID, not both.
agent_idagentIDstringyesID of the agent that runs when the trigger fires. Voice-mode agents are not supported.
custom_prompt_idcustomPromptIDstringnoID of a saved prompt (assigned to the selected agent) to send. Provide either forcedPrompt or customPromptID, not both.
event_source_typeeventSourceTypestringyesNATIVE fires on ToothFairyAI's own platform events (document lifecycle, agent, planner). EXTERNAL fires on third-party provider events acquired by polling.

Allowed: NATIVE, EXTERNAL | | event_config | eventConfig | string | no | Event configuration as a JSON string (AWSJSON). The shape depends on eventSourceType.

NATIVE — filters on the event payload (dataFilter rows all must match; operators: equals, not equals, includes, greater than, less than, exists): {"eventType":"document.created","eventCategory":"documents","dataFilter":[{"field":"topics","op":"includes","value":"<topicID>"}]}

EXTERNAL — provider + provider event (valid pairs are served by the trigger catalog endpoint GET /triggers/catalog, which lists every provider, its events, partner event names and sample payloads): {"provider":"googleDrive","providerEvent":"drive.file.created","pollIntervalMins":5} | | is_active | isActive | boolean | no | true arms the trigger (status ARMED); false pauses it. | | status | status | string | no | Lifecycle status. Use ARMED with isActive: true for an active trigger.

Allowed: ARMED, PAUSED, PENDING, RUNNING, FAILED, COMPLETED, DISABLED | | execution_config | executionConfig | string | no | Execution options as a JSON string, e.g. {"timeout":30,"maxDuration":300,"priority":"normal"}. | | notification_config | notificationConfig | string | no | Notification options as a JSON string, e.g. {"onSuccess":true,"onFailure":true,"emailRecipients":[]}. | | retry_config | retryConfig | string | no | Retry options as a JSON string, e.g. {"maxRetries":3,"retryInterval":60}. | | metadata | metadata | string | no | Free-form metadata as a JSON string. | | last_triggered_at | lastTriggeredAt | string | no | (Read-only) Timestamp of the last fire. | | last_event_id | lastEventID | string | no | (Read-only) ID of the last matched event, used by the dispatcher for idempotency. | | trigger_count | triggerCount | integer | no | (Read-only) Number of times the trigger has fired. | | created_by | createdBy | string | no | (Read-only) User who created the trigger. | | updated_by | updatedBy | string | no | (Read-only) User who last updated the trigger. | | created_at | createdAt | string | no | (Read-only) Creation timestamp. | | updated_at | updatedAt | string | no | (Read-only) Last update timestamp. |

Always pass snake_case keyword arguments — the Python kwarg column shows the exact name to use for each wire field (as a named parameter where it appears in the method signature, otherwise via **kwargs). The SDK converts it deterministically to the camelCase wire key the API expects. Passing camelCase directly is deprecated: it emits a warning and converts to the same wire key.

Response fields​

FieldTypeDescription
idstringUnique identifier
namestringName of the resource
descriptionstringDetailed description of purpose and capabilities
agentIDstringID of the agent associated with this resource
customPromptIDstringID of a custom prompt to use
forcedPromptstringForced prompt text to use for the job (max 1024 chars)
eventSourceTypestringEvent source type: NATIVE (internal events) or EXTERNAL (third-party provider events)

Allowed: NATIVE, EXTERNAL | | eventConfig | object | JSON-encoded event configuration. NATIVE requires eventType + optional dataFilter. EXTERNAL requires provider, providerEvent, acquisitionMode (POLLING/WEBHOOK), and pollConfig.intervalSeconds (60/120/300/600/1800) | | isActive | boolean | Whether the job is currently active | | status | string | Current status of the resource

Allowed: ARMED, PAUSED, DISABLED, FIRING, COMPLETED, FAILED, PENDING | | lastTriggeredAt | string | Timestamp when the trigger last fired | | lastEventID | string | ID of the last event that triggered this trigger | | triggerCount | integer | Number of times this trigger has fired | | executionConfig | object | JSON-encoded execution configuration | | notificationConfig | object | JSON-encoded notification configuration | | retryConfig | object | JSON-encoded retry policy configuration | | workspaceID | string | Unique workspace identifier (UUID v4) | | createdBy | string | ID of the user who created this resource | | updatedBy | string | ID of the user who last updated this resource | | createdAt | string | Timestamp when this resource was created | | updatedAt | string | Timestamp when this resource was last updated | | metadata | object | Arbitrary metadata key-value pairs (JSON) |

Example​

client.triggers.create(name="…", agent_id="agent-id", event_source_type=…)

update​

Update a trigger.

def update(trigger_id: str) -> Trigger

Endpoint: POST /trigger/update · API service

Request fields​

Python kwargWire fieldTypeRequiredDescription
ididstringyesID of the trigger to update (from /trigger/create or /trigger/list).
workspace_idworkspaceidstringnoWorkspace ID (UUID). Must match the workspace the API key belongs to.
namenamestringnoHuman-readable name for the trigger.
descriptiondescriptionstringnoOptional description of what the trigger does.
forced_promptforcedPromptstringnoFree-text prompt sent to the agent when the trigger fires. Provide either forcedPrompt or customPromptID, not both.
agent_idagentIDstringnoID of the agent that runs when the trigger fires. Voice-mode agents are not supported.
custom_prompt_idcustomPromptIDstringnoID of a saved prompt (assigned to the selected agent) to send. Provide either forcedPrompt or customPromptID, not both.
event_source_typeeventSourceTypestringnoNATIVE fires on ToothFairyAI's own platform events. EXTERNAL fires on third-party provider events acquired by polling.

Allowed: NATIVE, EXTERNAL | | event_config | eventConfig | string | no | Event configuration as a JSON string (AWSJSON). Same shape as create — see TriggerCreateInput.eventConfig. | | is_active | isActive | boolean | no | true arms the trigger (status ARMED); false pauses it. | | status | status | string | no | Lifecycle status.

Allowed: ARMED, PAUSED, PENDING, RUNNING, FAILED, COMPLETED, DISABLED | | execution_config | executionConfig | string | no | Execution options as a JSON string. | | notification_config | notificationConfig | string | no | Notification options as a JSON string. | | retry_config | retryConfig | string | no | Retry options as a JSON string. | | metadata | metadata | string | no | Free-form metadata as a JSON string. | | last_triggered_at | lastTriggeredAt | string | no | (Read-only) Timestamp of the last fire. | | last_event_id | lastEventID | string | no | (Read-only) ID of the last matched event. | | trigger_count | triggerCount | integer | no | (Read-only) Number of times the trigger has fired. | | created_by | createdBy | string | no | (Read-only) User who created the trigger. | | updated_by | updatedBy | string | no | (Read-only) User who last updated the trigger. | | created_at | createdAt | string | no | (Read-only) Creation timestamp. | | updated_at | updatedAt | string | no | (Read-only) Last update timestamp. |

Always pass snake_case keyword arguments — the Python kwarg column shows the exact name to use for each wire field (as a named parameter where it appears in the method signature, otherwise via **kwargs). The SDK converts it deterministically to the camelCase wire key the API expects. Passing camelCase directly is deprecated: it emits a warning and converts to the same wire key.

Response​

Returns the Trigger object — fields documented in the create section above.

Example​

client.triggers.update(trigger_id="agent-id")

get​

Get a trigger by ID.

def get(trigger_id: str) -> Trigger

Endpoint: GET /trigger/get/{trigger_id} · API service

Response​

Returns the Trigger object — fields documented in the create section above.

Example​

client.triggers.get(trigger_id="agent-id")

delete​

Delete a trigger.

def delete(trigger_id: str) -> Dict[str, bool]

Endpoint: DELETE /trigger/delete/{trigger_id} · API service

Response fields​

FieldTypeDescription
successbooleanOperation success status
dataobjectResponse data
messagestringOptional success message

Example​

client.triggers.delete(trigger_id="agent-id")

list​

List all triggers.

def list(
limit: Optional[int] = None,
offset: Optional[int] = None
) -> ListResponse

Endpoint: GET /trigger/list · API service

Response​

Returns the Trigger object — fields documented in the create section above.

Example​

client.triggers.list()

pause​

Pause (disarm) a trigger.

def pause(trigger_id: str) -> Trigger

Derived method — delegates to another SDK call and performs no direct HTTP request.

Example​

client.triggers.pause(trigger_id="agent-id")

resume​

Resume (arm) a paused trigger.

def resume(trigger_id: str) -> Trigger

Derived method — delegates to another SDK call and performs no direct HTTP request.

Example​

client.triggers.resume(trigger_id="agent-id")

get_by_agent​

Get triggers by agent ID.

def get_by_agent(agent_id: str) -> List[Trigger]

Derived method — delegates to another SDK call and performs no direct HTTP request.

Example​

client.triggers.get_by_agent(agent_id="agent-id")

get_active​

Get all active (armed) triggers.

def get_active() -> List[Trigger]

Derived method — delegates to another SDK call and performs no direct HTTP request.

Example​

client.triggers.get_active()

Search triggers by name.

def search(search_term: str) -> List[Trigger]

Derived method — delegates to another SDK call and performs no direct HTTP request.

Example​

client.triggers.search(search_term="…")