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
| Method | HTTP | Endpoint |
|---|---|---|
create | POST | POST /trigger/create |
update | POST | POST /trigger/update |
get | GET | GET /trigger/get/{trigger_id} |
delete | DELETE | DELETE /trigger/delete/{trigger_id} |
list | GET | GET /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
| Field | Type | Required | Description |
|---|---|---|---|
id | string | no | Unique identifier |
workspaceid | string | yes | Your workspace ID (UUID v4). Auto-injected by the SDK client from your configuration; you do not need to set it manually. |
name | string | yes | Name of the resource |
description | string | no | Detailed description of purpose and capabilities |
forcedPrompt | string | no | Forced prompt text to use for the job (max 1024 chars) |
agentID | string | yes | ID of the agent associated with this resource |
customPromptID | string | no | ID of a custom prompt to use |
eventSourceType | string | yes | Event source type: NATIVE (internal events) or EXTERNAL (third-party provider events) |
Allowed: NATIVE, EXTERNAL |
| eventConfig | string | no | 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 | no | Whether the job is currently active |
| status | string | no | Current status of the resource
Allowed: ARMED, PAUSED, PENDING, RUNNING, FAILED, COMPLETED, DISABLED |
| executionConfig | string | no | JSON-encoded execution configuration |
| notificationConfig | string | no | JSON-encoded notification configuration |
| retryConfig | string | no | JSON-encoded retry policy configuration |
| metadata | string | no | Arbitrary metadata key-value pairs (JSON) |
| lastTriggeredAt | string | no | Timestamp when the trigger last fired |
| lastEventID | string | no | ID of the last event that triggered this trigger |
| triggerCount | integer | no | Number of times this trigger has fired |
| createdBy | string | no | ID of the user who created this resource |
| updatedBy | string | no | ID of the user who last updated this resource |
| createdAt | string | no | Timestamp when this resource was created |
| updatedAt | string | no | Timestamp when this resource was last updated |
The Python SDK accepts
snake_casekeyword arguments and converts them to thecamelCasewire fields shown above.
Response fields
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier |
name | string | Name of the resource |
description | string | Detailed description of purpose and capabilities |
agentID | string | ID of the agent associated with this resource |
customPromptID | string | ID of a custom prompt to use |
forcedPrompt | string | Forced prompt text to use for the job (max 1024 chars) |
eventSourceType | string | Event 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
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Unique identifier |
workspaceid | string | no | Your workspace ID (UUID v4). Auto-injected by the SDK client from your configuration; you do not need to set it manually. |
name | string | no | Name of the resource |
description | string | no | Detailed description of purpose and capabilities |
forcedPrompt | string | no | Forced prompt text to use for the job (max 1024 chars) |
agentID | string | no | ID of the agent associated with this resource |
customPromptID | string | no | ID of a custom prompt to use |
eventSourceType | string | no | Event source type: NATIVE (internal events) or EXTERNAL (third-party provider events) |
Allowed: NATIVE, EXTERNAL |
| eventConfig | string | no | 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 | no | Whether the job is currently active |
| status | string | no | Current status of the resource
Allowed: ARMED, PAUSED, PENDING, RUNNING, FAILED, COMPLETED, DISABLED |
| executionConfig | string | no | JSON-encoded execution configuration |
| notificationConfig | string | no | JSON-encoded notification configuration |
| retryConfig | string | no | JSON-encoded retry policy configuration |
| metadata | string | no | Arbitrary metadata key-value pairs (JSON) |
| lastTriggeredAt | string | no | Timestamp when the trigger last fired |
| lastEventID | string | no | ID of the last event that triggered this trigger |
| triggerCount | integer | no | Number of times this trigger has fired |
| createdBy | string | no | ID of the user who created this resource |
| updatedBy | string | no | ID of the user who last updated this resource |
| createdAt | string | no | Timestamp when this resource was created |
| updatedAt | string | no | Timestamp when this resource was last updated |
The Python SDK accepts
snake_casekeyword arguments and converts them to thecamelCasewire fields shown above.
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
| Field | Type | Description |
|---|---|---|
success | boolean | Operation success status |
data | object | Response data |
message | string | Optional 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
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="…")