Hooks
Hooks
toothfairyai@latest…Manager for hooks (CustomCodeExecutionEnvironment) operations.
This manager provides methods to create, update, and manage custom code execution environments.
Example:
>>> client = ToothFairyClient(api_key="...", workspace_id="...")
>>> hook = client.hooks.create(...)
Accessed via client.hooks.
Methods
| Method | HTTP | Endpoint |
|---|---|---|
create | POST | POST /hook/create |
update | POST | POST /hook/update |
delete | DELETE | DELETE /hook/delete/{hook_id} |
get | GET | GET /hook/get/{hook_id} |
list | GET | GET /hook/list |
get_templates | — | derived |
get_active | — | derived |
search | — | derived |
create
Create a new hook (custom code execution environment).
def create(
name: str,
description: str = '',
function_name: Optional[str] = None,
custom_execution_code: Optional[str] = None,
custom_execution_instructions: Optional[str] = None,
custom_execution_secrets: Optional[Dict[str, Any]] = None,
static_docs: Optional[Dict[str, Any]] = None,
available_libraries: Optional[str] = None,
allow_external_api: bool = False,
hardcoded_script: bool = False,
is_template: bool = False
) -> CustomCodeExecutionEnvironment
Endpoint: POST /hook/create · API service
Request fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | no | Unique identifier |
workspaceid | string | yes | Unique workspace identifier (UUID v4) |
workspaceID | string | no | Unique workspace identifier (UUID v4) |
name | string | yes | Name of the resource |
description | string | no | Detailed description of purpose and capabilities |
functionName | string | no | Name of the function executed by the hook |
availableLibraries | string | no | List of libraries available to the hook |
customExecutionInstructions | string | no | Custom instructions for hook execution |
customExecutionCode | string | no | Custom Python code executed by the hook |
customExecutionSecrets | string | no | JSON-encoded secrets used by the hook |
staticDocs | string | no | JSON-encoded static documents available to the hook |
staticArtifacts | string | no | JSON-encoded static artifacts available to the hook |
allowExternalAPI | boolean | no | Whether the hook can make external API calls |
hardcodedScript | boolean | no | Whether the hook uses a hardcoded script |
isTemplate | boolean | no | Whether this hook is a reusable template |
isGlobal | boolean | no | Whether this function is available across all agents |
customCodeExecutionEnvironmentVersion | string | no | Version of the code execution environment |
customCodeExecutionEnvironmentType | string | no | Type of the code execution environment |
createdBy | string | no | ID of the user who created this resource |
updatedBy | string | no | ID of the user who last updated this resource |
The Python SDK accepts
snake_casekeyword arguments and converts them to thecamelCasewire fields shown above.
Response fields
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the hook |
name | string | Name of the resource |
description | string | Hook description |
functionName | string | Function name to execute |
availableLibraries | string | Available libraries for execution |
customExecutionInstructions | string | Instructions for code execution |
customExecutionCode | string | Custom code to execute |
customExecutionSecrets | object | JSON-encoded secrets used by the hook |
staticDocs | object | JSON-encoded static documents available to the hook |
staticArtifacts | object | JSON-encoded static artifacts available to the hook |
allowExternalAPI | boolean | Whether external API calls are allowed |
hardcodedScript | boolean | Whether the script is hardcoded |
isTemplate | boolean | Whether this is a template |
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 |
customCodeExecutionEnvironmentVersion | string | Version of the code execution environment |
customCodeExecutionEnvironmentType | string | Type of the code execution environment |
createdAt | string | Timestamp when this resource was created |
updatedAt | string | Timestamp when this resource was last updated |
Example
client.hooks.create(name="…")
update
Update a hook.
def update(hook_id: str) -> Hook
Endpoint: POST /hook/update · API service
Request fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Unique identifier |
workspaceid | string | no | Unique workspace identifier (UUID v4) |
workspaceID | string | no | Unique workspace identifier (UUID v4) |
name | string | no | Name of the resource |
description | string | no | Detailed description of purpose and capabilities |
functionName | string | no | Name of the function executed by the hook |
availableLibraries | string | no | List of libraries available to the hook |
customExecutionInstructions | string | no | Custom instructions for hook execution |
customExecutionCode | string | no | Custom Python code executed by the hook |
customExecutionSecrets | string | no | JSON-encoded secrets used by the hook |
staticDocs | string | no | JSON-encoded static documents available to the hook |
staticArtifacts | string | no | JSON-encoded static artifacts available to the hook |
allowExternalAPI | boolean | no | Whether the hook can make external API calls |
hardcodedScript | boolean | no | Whether the hook uses a hardcoded script |
isTemplate | boolean | no | Whether this hook is a reusable template |
isGlobal | boolean | no | Whether this function is available across all agents |
customCodeExecutionEnvironmentVersion | string | no | Version of the code execution environment |
customCodeExecutionEnvironmentType | string | no | Type of the code execution environment |
createdBy | string | no | ID of the user who created this resource |
updatedBy | string | no | ID of the user who last updated this resource |
The Python SDK accepts
snake_casekeyword arguments and converts them to thecamelCasewire fields shown above.
Response
Returns the Hook object — fields documented in the create section above.
Example
client.hooks.update(hook_id="agent-id")
delete
Delete a hook.
def delete(hook_id: str) -> Dict[str, bool]
Endpoint: DELETE /hook/delete/{hook_id} · API service
Example
client.hooks.delete(hook_id="agent-id")
get
Get a hook by ID.
def get(hook_id: str) -> CustomCodeExecutionEnvironment
Endpoint: GET /hook/get/{hook_id} · API service
Response
Returns the Hook object — fields documented in the create section above.
Example
client.hooks.get(hook_id="agent-id")
list
List all hooks.
def list(
limit: Optional[int] = None,
offset: Optional[int] = None
) -> ListResponse
Endpoint: GET /hook/list · API service
Example
client.hooks.list()
get_templates
Get all template hooks.
def get_templates() -> List[CustomCodeExecutionEnvironment]
Derived method — delegates to another SDK call and performs no direct HTTP request.
Example
client.hooks.get_templates()
get_active
Get all non-template hooks.
def get_active() -> List[CustomCodeExecutionEnvironment]
Derived method — delegates to another SDK call and performs no direct HTTP request.
Example
client.hooks.get_active()
search
Search hooks by name.
def search(search_term: str) -> List[CustomCodeExecutionEnvironment]
Derived method — delegates to another SDK call and performs no direct HTTP request.
Example
client.hooks.search(search_term="…")