Skip to main content

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​

MethodHTTPEndpoint
createPOSTPOST /hook/create
updatePOSTPOST /hook/update
deleteDELETEDELETE /hook/delete/{hook_id}
getGETGET /hook/get/{hook_id}
listGETGET /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 kwargWire fieldTypeRequiredDescription
ididstringnoUnique identifier
workspace_idworkspaceidstringyesUnique workspace identifier (UUID v4)
workspace_idworkspaceIDstringnoUnique workspace identifier (UUID v4)
namenamestringyesName of the resource
descriptiondescriptionstringnoDetailed description of purpose and capabilities
function_namefunctionNamestringnoName of the function executed by the hook
available_librariesavailableLibrariesstringnoList of libraries available to the hook
custom_execution_instructionscustomExecutionInstructionsstringnoCustom instructions for hook execution
custom_execution_codecustomExecutionCodestringnoCustom Python code executed by the hook
custom_execution_secretscustomExecutionSecretsstringnoJSON-encoded secrets used by the hook
static_docsstaticDocsstringnoJSON-encoded static documents available to the hook
static_artifactsstaticArtifactsstringnoJSON-encoded static artifacts available to the hook
allow_external_apiallowExternalAPIbooleannoWhether the hook can make external API calls
hardcoded_scripthardcodedScriptbooleannoWhether the hook uses a hardcoded script
is_templateisTemplatebooleannoWhether this hook is a reusable template
is_globalisGlobalbooleannoWhether this function is available across all agents
custom_code_execution_environment_versioncustomCodeExecutionEnvironmentVersionstringnoVersion of the code execution environment
custom_code_execution_environment_typecustomCodeExecutionEnvironmentTypestringnoType of the code execution environment
created_bycreatedBystringnoID of the user who created this resource
updated_byupdatedBystringnoID of the user who last updated this resource

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 for the hook
namestringName of the resource
descriptionstringHook description
functionNamestringFunction name to execute
availableLibrariesstringAvailable libraries for execution
customExecutionInstructionsstringInstructions for code execution
customExecutionCodestringCustom code to execute
customExecutionSecretsobjectJSON-encoded secrets used by the hook
staticDocsobjectJSON-encoded static documents available to the hook
staticArtifactsobjectJSON-encoded static artifacts available to the hook
allowExternalAPIbooleanWhether external API calls are allowed
hardcodedScriptbooleanWhether the script is hardcoded
isTemplatebooleanWhether this is a template
workspaceIDstringUnique workspace identifier (UUID v4)
createdBystringID of the user who created this resource
updatedBystringID of the user who last updated this resource
customCodeExecutionEnvironmentVersionstringVersion of the code execution environment
customCodeExecutionEnvironmentTypestringType of the code execution environment
createdAtstringTimestamp when this resource was created
updatedAtstringTimestamp 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 kwargWire fieldTypeRequiredDescription
ididstringyesUnique identifier
workspace_idworkspaceidstringnoUnique workspace identifier (UUID v4)
workspace_idworkspaceIDstringnoUnique workspace identifier (UUID v4)
namenamestringnoName of the resource
descriptiondescriptionstringnoDetailed description of purpose and capabilities
function_namefunctionNamestringnoName of the function executed by the hook
available_librariesavailableLibrariesstringnoList of libraries available to the hook
custom_execution_instructionscustomExecutionInstructionsstringnoCustom instructions for hook execution
custom_execution_codecustomExecutionCodestringnoCustom Python code executed by the hook
custom_execution_secretscustomExecutionSecretsstringnoJSON-encoded secrets used by the hook
static_docsstaticDocsstringnoJSON-encoded static documents available to the hook
static_artifactsstaticArtifactsstringnoJSON-encoded static artifacts available to the hook
allow_external_apiallowExternalAPIbooleannoWhether the hook can make external API calls
hardcoded_scripthardcodedScriptbooleannoWhether the hook uses a hardcoded script
is_templateisTemplatebooleannoWhether this hook is a reusable template
is_globalisGlobalbooleannoWhether this function is available across all agents
custom_code_execution_environment_versioncustomCodeExecutionEnvironmentVersionstringnoVersion of the code execution environment
custom_code_execution_environment_typecustomCodeExecutionEnvironmentTypestringnoType of the code execution environment
created_bycreatedBystringnoID of the user who created this resource
updated_byupdatedBystringnoID of the user who last updated this resource

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 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 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="…")