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
| Python kwarg | Wire field | Type | Required | Description |
|---|---|---|---|---|
id | id | string | no | Unique identifier |
workspace_id | workspaceid | string | yes | Unique workspace identifier (UUID v4) |
workspace_id | workspaceID | string | no | Unique workspace identifier (UUID v4) |
name | name | string | yes | Name of the resource |
description | description | string | no | Detailed description of purpose and capabilities |
function_name | functionName | string | no | Name of the function executed by the hook |
available_libraries | availableLibraries | string | no | List of libraries available to the hook |
custom_execution_instructions | customExecutionInstructions | string | no | Custom instructions for hook execution |
custom_execution_code | customExecutionCode | string | no | Custom Python code executed by the hook |
custom_execution_secrets | customExecutionSecrets | string | no | JSON-encoded secrets used by the hook |
static_docs | staticDocs | string | no | JSON-encoded static documents available to the hook |
static_artifacts | staticArtifacts | string | no | JSON-encoded static artifacts available to the hook |
allow_external_api | allowExternalAPI | boolean | no | Whether the hook can make external API calls |
hardcoded_script | hardcodedScript | boolean | no | Whether the hook uses a hardcoded script |
is_template | isTemplate | boolean | no | Whether this hook is a reusable template |
is_global | isGlobal | boolean | no | Whether this function is available across all agents |
custom_code_execution_environment_version | customCodeExecutionEnvironmentVersion | string | no | Version of the code execution environment |
custom_code_execution_environment_type | customCodeExecutionEnvironmentType | string | no | Type of the code execution environment |
created_by | createdBy | string | no | ID of the user who created this resource |
updated_by | updatedBy | string | no | ID of the user who last updated this resource |
Always pass
snake_casekeyword 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 thecamelCasewire key the API expects. PassingcamelCasedirectly is deprecated: it emits a warning and converts to the same wire key.
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
| Python kwarg | Wire field | Type | Required | Description |
|---|---|---|---|---|
id | id | string | yes | Unique identifier |
workspace_id | workspaceid | string | no | Unique workspace identifier (UUID v4) |
workspace_id | workspaceID | string | no | Unique workspace identifier (UUID v4) |
name | name | string | no | Name of the resource |
description | description | string | no | Detailed description of purpose and capabilities |
function_name | functionName | string | no | Name of the function executed by the hook |
available_libraries | availableLibraries | string | no | List of libraries available to the hook |
custom_execution_instructions | customExecutionInstructions | string | no | Custom instructions for hook execution |
custom_execution_code | customExecutionCode | string | no | Custom Python code executed by the hook |
custom_execution_secrets | customExecutionSecrets | string | no | JSON-encoded secrets used by the hook |
static_docs | staticDocs | string | no | JSON-encoded static documents available to the hook |
static_artifacts | staticArtifacts | string | no | JSON-encoded static artifacts available to the hook |
allow_external_api | allowExternalAPI | boolean | no | Whether the hook can make external API calls |
hardcoded_script | hardcodedScript | boolean | no | Whether the hook uses a hardcoded script |
is_template | isTemplate | boolean | no | Whether this hook is a reusable template |
is_global | isGlobal | boolean | no | Whether this function is available across all agents |
custom_code_execution_environment_version | customCodeExecutionEnvironmentVersion | string | no | Version of the code execution environment |
custom_code_execution_environment_type | customCodeExecutionEnvironmentType | string | no | Type of the code execution environment |
created_by | createdBy | string | no | ID of the user who created this resource |
updated_by | updatedBy | string | no | ID of the user who last updated this resource |
Always pass
snake_casekeyword 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 thecamelCasewire key the API expects. PassingcamelCasedirectly is deprecated: it emits a warning and converts to the same wire key.
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="…")