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_templatesderived
get_activederived
searchderived

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

FieldTypeRequiredDescription
idstringnoUnique identifier
workspaceidstringyesUnique workspace identifier (UUID v4)
workspaceIDstringnoUnique workspace identifier (UUID v4)
namestringyesName of the resource
descriptionstringnoDetailed description of purpose and capabilities
functionNamestringnoName of the function executed by the hook
availableLibrariesstringnoList of libraries available to the hook
customExecutionInstructionsstringnoCustom instructions for hook execution
customExecutionCodestringnoCustom Python code executed by the hook
customExecutionSecretsstringnoJSON-encoded secrets used by the hook
staticDocsstringnoJSON-encoded static documents available to the hook
staticArtifactsstringnoJSON-encoded static artifacts available to the hook
allowExternalAPIbooleannoWhether the hook can make external API calls
hardcodedScriptbooleannoWhether the hook uses a hardcoded script
isTemplatebooleannoWhether this hook is a reusable template
isGlobalbooleannoWhether this function is available across all agents
customCodeExecutionEnvironmentVersionstringnoVersion of the code execution environment
customCodeExecutionEnvironmentTypestringnoType of the code execution environment
createdBystringnoID of the user who created this resource
updatedBystringnoID of the user who last updated this resource

The Python SDK accepts snake_case keyword arguments and converts them to the camelCase wire fields shown above.

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

FieldTypeRequiredDescription
idstringyesUnique identifier
workspaceidstringnoUnique workspace identifier (UUID v4)
workspaceIDstringnoUnique workspace identifier (UUID v4)
namestringnoName of the resource
descriptionstringnoDetailed description of purpose and capabilities
functionNamestringnoName of the function executed by the hook
availableLibrariesstringnoList of libraries available to the hook
customExecutionInstructionsstringnoCustom instructions for hook execution
customExecutionCodestringnoCustom Python code executed by the hook
customExecutionSecretsstringnoJSON-encoded secrets used by the hook
staticDocsstringnoJSON-encoded static documents available to the hook
staticArtifactsstringnoJSON-encoded static artifacts available to the hook
allowExternalAPIbooleannoWhether the hook can make external API calls
hardcodedScriptbooleannoWhether the hook uses a hardcoded script
isTemplatebooleannoWhether this hook is a reusable template
isGlobalbooleannoWhether this function is available across all agents
customCodeExecutionEnvironmentVersionstringnoVersion of the code execution environment
customCodeExecutionEnvironmentTypestringnoType of the code execution environment
createdBystringnoID of the user who created this resource
updatedBystringnoID of the user who last updated this resource

The Python SDK accepts snake_case keyword arguments and converts them to the camelCase wire 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 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="…")