Skip to main content

Agent Functions

Agent Functions

toothfairyai@latest…

Manager for agent functions operations.

This manager provides methods to create, update, and manage agent functions.

Example:

>>> client = ToothFairyClient(api_key="...", workspace_id="...")
>>> agent_function = client.agent_functions.create(...)

Accessed via client.agentFunctions.

Methods

MethodHTTPEndpoint
createPOSTPOST /function/create
updatePOSTPOST /function/update
deleteDELETEDELETE /function/delete/{agent_function_id}
getGETGET /function/get/{agent_function_id}
listGETGET /function/list
searchderived

create

Create a new agent function.

def create(
name: str,
description: str,
url: Optional[str] = None,
request_type: Optional[FunctionRequestType] = None,
authorisation_type: FunctionAuthorisationTypeRequest = 'none',
authorisation_key: Optional[str] = None,
authorisation_id: Optional[str] = None,
parameters: Optional[Dict[str, Any]] = None,
model: Optional[str] = None,
depends_on_before_execution: Optional[List[str]] = None,
depends_on_after_execution: Optional[List[str]] = None,
params_as_path: Optional[bool] = None,
scope: Optional[FunctionScope] = None,
json_path_extractor: Optional[str] = None,
headers: Optional[Dict[str, Any]] = None,
static_args: Optional[Dict[str, Any]] = None,
custom_execution_code: Optional[str] = None,
is_mcp_server: Optional[bool] = None,
is_callback_fn: Optional[bool] = None,
is_database_script: Optional[bool] = None,
is_html_fn: Optional[bool] = None,
is_chat_fn: Optional[bool] = None,
is_hand_off_fn: Optional[bool] = None,
is_code_template: Optional[bool] = None,
is_agent_skill: Optional[bool] = None,
code_execution_environment_id: Optional[str] = None,
on_fn_call: Optional[Dict[str, Any]] = None,
hand_off_agent: Optional[str] = None,
hand_off_to_original_agent_on_completion: Optional[bool] = None,
hand_off_to_original_agent_on_failure: Optional[bool] = None,
hand_off_agent_on_completion: Optional[str] = None,
hand_off_agent_on_failure: Optional[str] = None,
agent_skill_script: Optional[str] = None,
chat_script: Optional[str] = None,
chat_action: Optional[AgentFunctionChatActionRequest] = None,
html_url: Optional[str] = None,
html_script: Optional[str] = None,
is_html_redirect_fn: Optional[bool] = None,
html_form_on_successful_submit_message: Optional[str] = None,
html_form_on_failed_submit_message: Optional[str] = None,
db_schema_metadata: Optional[Dict[str, Any]] = None,
pre_execution_script: Optional[str] = None,
post_execution_script: Optional[str] = None,
db_script: Optional[str] = None,
db_connection_id: Optional[str] = None,
pre_execution_fn_id: Optional[str] = None,
pre_execution_mapping: Optional[Dict[str, Any]] = None,
oauth_connection_id: Optional[str] = None,
handed_off_to_human_on_call: Optional[bool] = None,
graphql_query: Optional[str] = None,
graphql_mutation: Optional[str] = None,
graphql_operation_name: Optional[str] = None,
users_to_hand_off_to: Optional[List[str]] = None,
is_global: Optional[bool] = None
) -> AgentFunction

Endpoint: POST /function/create · API service

Request fields

Python kwargWire fieldTypeRequiredDescription
ididstringnoUnique identifier
workspace_idworkspaceidstringyesUnique workspace identifier (UUID v4)
namenamestringyesName of the resource
descriptiondescriptionstringyesDetailed description of purpose and capabilities
modelmodelstringnoModel identifier for the function's LLM
is_callback_fnisCallbackFnbooleannoWhether this is a callback function
is_database_scriptisDatabaseScriptbooleannoWhether this function executes a database script
is_html_fnisHtmlFnbooleannoWhether this function renders an HTML form/page
is_chat_fnisChatFnbooleannoWhether this is a chat action function
is_mcp_serverisMCPServerbooleannoWhether this function connects to an MCP (Model Context Protocol) server
is_code_templateisCodeTemplatebooleannoWhether this is a code template function
is_hand_off_fnisHandOffFnbooleannoWhether this function hands off to another agent or human
is_agent_skillisAgentSkillbooleannoWhether this function is an agent skill
agent_skill_scriptagentSkillScriptstringnoScript for the agent skill function
hand_off_agenthandOffAgentstringnoAgent ID to hand off to
hand_off_to_original_agent_on_completionhandOffToOriginalAgentOnCompletionbooleannoWhether to return to the original agent on completion
hand_off_to_original_agent_on_failurehandOffToOriginalAgentOnFailurebooleannoWhether to return to the original agent on failure
hand_off_agent_on_completionhandOffAgentOnCompletionstringnoAgent ID to hand off to on completion
hand_off_agent_on_failurehandOffAgentOnFailurestringnoAgent ID to hand off to on failure
handed_off_to_human_on_callhandedOffToHumanOnCallbooleannoWhether the function hands off to a human operator
users_to_hand_off_tousersToHandOffTostringnoList of user IDs who can receive hand-offs
on_fn_callonFnCallstringnoJSON-encoded configuration for actions on function call
graphql_querygraphqlQuerystringnoGraphQL query string (for graphql_query request type)
graphql_mutationgraphqlMutationstringnoGraphQL mutation string (for graphql_mutation request type)
graphql_operation_namegraphqlOperationNamestringnoName of the GraphQL operation
is_globalisGlobalbooleannoWhether this function is available across all agents
created_bycreatedBystringnoID of the user who created this resource
updated_byupdatedBystringnoID of the user who last updated this resource
depends_on_before_executiondependsOnBeforeExecutionstringnoList of function IDs that must execute before this one
depends_on_after_executiondependsOnAfterExecutionstringnoList of function IDs that execute after this one
pre_execution_scriptpreExecutionScriptstringnoScript executed before this function runs
post_execution_scriptpostExecutionScriptstringnoScript executed after this function runs
pre_execution_fn_idpreExecutionFnIDstringnoID of a function to execute before this one
pre_execution_mappingpreExecutionMappingstringnoJSON-encoded mapping for pre-execution data
oauth_connection_idOAuthConnectionIDstringnoID of the OAuth connection used by this function
function_versionfunctionVersionstringnoVersion identifier for the function
function_typefunctionTypestringnoType classification for the function
request_typerequestTypestringnoHTTP request type for API call functions: get, post, put, delete, patch, custom, graphql_query, or graphql_mutation

Allowed: get, post, put, delete, patch, custom, graphql_query, graphql_mutation, `` | | authorisation_type | authorisationType | string | no | Authorisation type for the function: none, apikey, bearer, or oauth

Allowed: none, apikey, bearer, oauth, `` | | url | url | string | no | Public URL of the website to crawl/index | | parameters | parameters | string | no | JSON-encoded input parameters for the function | | authorisation_key | authorisationKey | string | no | Authorisation key/header name for the function | | authorisation_id | authorisationID | string | no | ID of the authorisation configuration to use | | params_as_path | paramsAsPath | boolean | no | Whether parameters are passed as path segments instead of body/query | | scope | scope | string | no | OAuth scope

Allowed: none, customerAuthentication, customer, caseAuthentication, case | | json_path_extractor | jsonPathExtractor | string | no | JSONPath expression to extract specific data from the response | | headers | headers | string | no | JSON-encoded HTTP headers for the function request | | static_args | staticArgs | string | no | JSON-encoded static arguments for the authorisation | | custom_execution_code | customExecutionCode | string | no | Custom Python code executed by the hook | | db_script | dbScript | string | yes | Database script to execute (database_script type) | | db_connection_id | dbConnectionID | string | no | ID of the database connection to use | | db_schema_metadata | dbSchemaMetadata | string | no | JSON-encoded database schema metadata | | html_url | htmlUrl | string | yes | URL for the HTML form/page (html_fn type) | | html_script | htmlScript | string | no | Script for the HTML function | | is_html_redirect_fn | isHtmlRedirectFn | boolean | no | Whether the HTML function redirects | | html_form_on_successful_submit_message | htmlFormOnSuccessfulSubmitMessage | string | no | Message shown on successful form submission | | html_form_on_failed_submit_message | htmlFormOnFailedSubmitMessage | string | no | Message shown on failed form submission | | chat_script | chatScript | string | yes | Script for the chat action function (chat_fn type) | | chat_action | chatAction | string | yes | Chat action type: suggestion, nextQuestion, or script

Allowed: suggestion, nextQuestion, script | | code_execution_environment_id | codeExecutionEnvironmentID | string | no | ID of the code execution environment (code_template type) |

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 agent function
namestringHuman-readable name of the function
descriptionstringDetailed description of function purpose
parametersobjectFunction parameters schema (JSON Schema format)
modelstringAI model used for processing function calls
urlstringEndpoint URL for the function
requestTypestringHTTP method for the function call

Allowed: get, post, put, delete, patch, custom, graphql_query, graphql_mutation | | authorisationType | string | Authentication method required

Allowed: bearer, apikey, oauth, password, env, generic, none, username_and_password, basic | | dependsOnBeforeExecution | array<string> | List of function IDs that must execute before this function | | dependsOnAfterExecution | array<string> | List of function IDs that must execute after this function | | authorisationKey | string | Authentication key or token | | authorisationID | string | ID of the authorisation configuration to use | | paramsAsPath | boolean | Whether parameters should be passed as URL path segments | | scope | string | Function scope for access control

Allowed: customerAuthentication, customer, caseAuthentication, case | | jsonPathExtractor | string | JSONPath expression to extract data from response | | headers | object | Required HTTP headers (JSON object) | | staticArgs | object | Static arguments passed to function (JSON object) | | customExecutionCode | string | Custom code for function execution | | isMCPServer | boolean | Whether this function connects to an MCP server | | isCallbackFn | boolean | Whether this is a callback function | | isDatabaseScript | boolean | Whether this function executes database scripts | | isHtmlFn | boolean | Whether this function renders HTML content | | isChatFn | boolean | Whether this function handles chat actions | | isHandOffFn | boolean | Whether this function handles hand-off to another agent or human | | isCodeTemplate | boolean | Whether this function executes code templates | | isAgentSkill | boolean | Whether this function is an agent skill (prompt-based function) | | codeExecutionEnvironmentID | string | ID of the custom execution environment for code templates | | onFnCall | object | Script or handler executed when function is called (JSON object) | | handOffAgent | string | Agent ID to hand off to | | handOffToOriginalAgentOnCompletion | boolean | Whether to return to original agent after completion | | handOffToOriginalAgentOnFailure | boolean | Whether to return to original agent on failure | | handOffAgentOnCompletion | string | Agent ID to hand off to on completion | | handOffAgentOnFailure | string | Agent ID to hand off to on failure | | agentSkillScript | string | Script or prompt for agent skill execution | | chatScript | string | Script for chat function execution | | chatAction | string | Action type for chat function

Allowed: suggestion, nextQuestion, humanSupport, redirection, script | | htmlUrl | string | URL for HTML content | | htmlScript | string | HTML script content | | isHtmlRedirectFn | boolean | Whether this function redirects to another URL | | htmlFormOnSuccessfulSubmitMessage | string | Message to show on successful form submission | | htmlFormOnFailedSubmitMessage | string | Message to show on failed form submission | | dbSchemaMetadata | object | Database schema metadata (JSON object) | | preExecutionScript | string | Script to run before function execution | | postExecutionScript | string | Script to run after function execution | | dbScript | string | Database script to execute | | dbConnectionID | string | Database connection ID to use | | preExecutionFnID | string | Function ID to execute before this function | | preExecutionMapping | object | Mapping for pre-execution output (JSON object) | | OAuthConnectionID | string | OAuth connection ID to use | | handedOffToHumanOnCall | boolean | Whether call is handed off to human | | graphqlQuery | string | GraphQL query string | | graphqlMutation | string | GraphQL mutation string | | graphqlOperationName | string | GraphQL operation name | | usersToHandOffTo | array<string> | List of user IDs to hand off to | | workspaceID | string | Unique workspace identifier (UUID v4) | | createdBy | string | User ID who created the function | | updatedBy | string | User ID who last updated the function | | isGlobal | boolean | Whether this function is available globally | | functionVersion | string | Version identifier for the function | | functionType | string | Type classification for the function | | createdAt | string | Timestamp when this resource was created | | updatedAt | string | Timestamp when this resource was last updated |

Example

client.agentFunctions.create(name="…", description="…")

update

Update a agent_function.

def update(agent_function_id: str) -> AgentFunction

Endpoint: POST /function/update · API service

Request fields

Python kwargWire fieldTypeRequiredDescription
ididstringyesUnique identifier
workspace_idworkspaceidstringnoUnique workspace identifier (UUID v4)
namenamestringnoName of the resource
descriptiondescriptionstringnoDetailed description of purpose and capabilities
modelmodelstringnoModel identifier for the function's LLM
is_callback_fnisCallbackFnbooleannoWhether this is a callback function
is_database_scriptisDatabaseScriptbooleannoWhether this function executes a database script
is_html_fnisHtmlFnbooleannoWhether this function renders an HTML form/page
is_chat_fnisChatFnbooleannoWhether this is a chat action function
is_mcp_serverisMCPServerbooleannoWhether this function connects to an MCP (Model Context Protocol) server
is_code_templateisCodeTemplatebooleannoWhether this is a code template function
is_hand_off_fnisHandOffFnbooleannoWhether this function hands off to another agent or human
is_agent_skillisAgentSkillbooleannoWhether this function is an agent skill
agent_skill_scriptagentSkillScriptstringnoScript for the agent skill function
hand_off_agenthandOffAgentstringnoAgent ID to hand off to
hand_off_to_original_agent_on_completionhandOffToOriginalAgentOnCompletionbooleannoWhether to return to the original agent on completion
hand_off_to_original_agent_on_failurehandOffToOriginalAgentOnFailurebooleannoWhether to return to the original agent on failure
hand_off_agent_on_completionhandOffAgentOnCompletionstringnoAgent ID to hand off to on completion
hand_off_agent_on_failurehandOffAgentOnFailurestringnoAgent ID to hand off to on failure
handed_off_to_human_on_callhandedOffToHumanOnCallbooleannoWhether the function hands off to a human operator
users_to_hand_off_tousersToHandOffTostringnoList of user IDs who can receive hand-offs
on_fn_callonFnCallstringnoJSON-encoded configuration for actions on function call
graphql_querygraphqlQuerystringnoGraphQL query string (for graphql_query request type)
graphql_mutationgraphqlMutationstringnoGraphQL mutation string (for graphql_mutation request type)
graphql_operation_namegraphqlOperationNamestringnoName of the GraphQL operation
is_globalisGlobalbooleannoWhether this function is available across all agents
created_bycreatedBystringnoID of the user who created this resource
updated_byupdatedBystringnoID of the user who last updated this resource
depends_on_before_executiondependsOnBeforeExecutionstringnoList of function IDs that must execute before this one
depends_on_after_executiondependsOnAfterExecutionstringnoList of function IDs that execute after this one
pre_execution_scriptpreExecutionScriptstringnoScript executed before this function runs
post_execution_scriptpostExecutionScriptstringnoScript executed after this function runs
pre_execution_fn_idpreExecutionFnIDstringnoID of a function to execute before this one
pre_execution_mappingpreExecutionMappingstringnoJSON-encoded mapping for pre-execution data
oauth_connection_idOAuthConnectionIDstringnoID of the OAuth connection used by this function
function_versionfunctionVersionstringnoVersion identifier for the function
function_typefunctionTypestringnoType classification for the function
request_typerequestTypestringnoHTTP request type for API call functions: get, post, put, delete, patch, custom, graphql_query, or graphql_mutation

Allowed: get, post, put, delete, patch, custom, graphql_query, graphql_mutation, `` | | authorisation_type | authorisationType | string | no | Authorisation type for the function: none, apikey, bearer, or oauth

Allowed: none, apikey, bearer, oauth, `` | | url | url | string | no | Public URL of the website to crawl/index | | parameters | parameters | string | no | JSON-encoded input parameters for the function | | authorisation_key | authorisationKey | string | no | Authorisation key/header name for the function | | authorisation_id | authorisationID | string | no | ID of the authorisation configuration to use | | params_as_path | paramsAsPath | boolean | no | Whether parameters are passed as path segments instead of body/query | | scope | scope | string | no | OAuth scope

Allowed: none, customerAuthentication, customer, caseAuthentication, case | | json_path_extractor | jsonPathExtractor | string | no | JSONPath expression to extract specific data from the response | | headers | headers | string | no | JSON-encoded HTTP headers for the function request | | static_args | staticArgs | string | no | JSON-encoded static arguments for the authorisation | | custom_execution_code | customExecutionCode | string | no | Custom Python code executed by the hook | | db_script | dbScript | string | no | Database script to execute (database_script type) | | db_connection_id | dbConnectionID | string | no | ID of the database connection to use | | db_schema_metadata | dbSchemaMetadata | string | no | JSON-encoded database schema metadata | | html_url | htmlUrl | string | no | URL for the HTML form/page (html_fn type) | | html_script | htmlScript | string | no | Script for the HTML function | | is_html_redirect_fn | isHtmlRedirectFn | boolean | no | Whether the HTML function redirects | | html_form_on_successful_submit_message | htmlFormOnSuccessfulSubmitMessage | string | no | Message shown on successful form submission | | html_form_on_failed_submit_message | htmlFormOnFailedSubmitMessage | string | no | Message shown on failed form submission | | chat_script | chatScript | string | no | Script for the chat action function (chat_fn type) | | chat_action | chatAction | string | no | Chat action type: suggestion, nextQuestion, or script

Allowed: suggestion, nextQuestion, script | | code_execution_environment_id | codeExecutionEnvironmentID | string | no | ID of the code execution environment (code_template type) |

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 AgentFunction object — fields documented in the create section above.

Example

client.agentFunctions.update(agent_function_id="agent-id")

delete

Delete a agent_function.

def delete(agent_function_id: str) -> Dict[str, bool]

Endpoint: DELETE /function/delete/{agent_function_id} · API service

Response fields

FieldTypeDescription
successbooleanOperation success status
dataobjectResponse data
messagestringOptional success message

Example

client.agentFunctions.delete(agent_function_id="agent-id")

get

Get a agent_function by ID.

def get(agent_function_id: str) -> AgentFunction

Endpoint: GET /function/get/{agent_function_id} · API service

Response

Returns the AgentFunction object — fields documented in the create section above.

Example

client.agentFunctions.get(agent_function_id="agent-id")

list

List all agent functions.

def list(
limit: Optional[int] = None,
offset: Optional[int] = None
) -> ListResponse

Endpoint: GET /function/list · API service

Example

client.agentFunctions.list()

Search agent functions by name.

def search(search_term: str) -> List[AgentFunction]

Derived method — delegates to another SDK call and performs no direct HTTP request.

Example

client.agentFunctions.search(search_term="…")