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
| Method | HTTP | Endpoint |
|---|---|---|
create | POST | POST /function/create |
update | POST | POST /function/update |
delete | DELETE | DELETE /function/delete/{agent_function_id} |
get | GET | GET /function/get/{agent_function_id} |
list | GET | GET /function/list |
search | — | derived |
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
| Field | Type | Required | Description |
|---|---|---|---|
id | string | no | Unique identifier |
workspaceid | string | yes | Unique workspace identifier (UUID v4) |
name | string | yes | Name of the resource |
description | string | yes | Detailed description of purpose and capabilities |
model | string | no | Model identifier for the function's LLM |
isCallbackFn | boolean | no | Whether this is a callback function |
isDatabaseScript | boolean | no | Whether this function executes a database script |
isHtmlFn | boolean | no | Whether this function renders an HTML form/page |
isChatFn | boolean | no | Whether this is a chat action function |
isMCPServer | boolean | no | Whether this function connects to an MCP (Model Context Protocol) server |
isCodeTemplate | boolean | no | Whether this is a code template function |
isHandOffFn | boolean | no | Whether this function hands off to another agent or human |
isAgentSkill | boolean | no | Whether this function is an agent skill |
agentSkillScript | string | no | Script for the agent skill function |
handOffAgent | string | no | Agent ID to hand off to |
handOffToOriginalAgentOnCompletion | boolean | no | Whether to return to the original agent on completion |
handOffToOriginalAgentOnFailure | boolean | no | Whether to return to the original agent on failure |
handOffAgentOnCompletion | string | no | Agent ID to hand off to on completion |
handOffAgentOnFailure | string | no | Agent ID to hand off to on failure |
handedOffToHumanOnCall | boolean | no | Whether the function hands off to a human operator |
usersToHandOffTo | string | no | List of user IDs who can receive hand-offs |
onFnCall | string | no | JSON-encoded configuration for actions on function call |
graphqlQuery | string | no | GraphQL query string (for graphql_query request type) |
graphqlMutation | string | no | GraphQL mutation string (for graphql_mutation request type) |
graphqlOperationName | string | no | Name of the GraphQL operation |
isGlobal | boolean | no | Whether this function is available across all agents |
createdBy | string | no | ID of the user who created this resource |
updatedBy | string | no | ID of the user who last updated this resource |
dependsOnBeforeExecution | string | no | List of function IDs that must execute before this one |
dependsOnAfterExecution | string | no | List of function IDs that execute after this one |
preExecutionScript | string | no | Script executed before this function runs |
postExecutionScript | string | no | Script executed after this function runs |
preExecutionFnID | string | no | ID of a function to execute before this one |
preExecutionMapping | string | no | JSON-encoded mapping for pre-execution data |
OAuthConnectionID | string | no | ID of the OAuth connection used by this function |
functionVersion | string | no | Version identifier for the function |
functionType | string | no | Type classification for the function |
requestType | string | no | HTTP 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, `` |
| authorisationType | string | no | Authorisation type for the function: none, apikey, bearer, or oauth
Allowed: none, apikey, bearer, oauth, `` |
| url | string | no | Public URL of the website to crawl/index |
| parameters | string | no | JSON-encoded input parameters for the function |
| authorisationKey | string | no | Authorisation key/header name for the function |
| authorisationID | string | no | ID of the authorisation configuration to use |
| paramsAsPath | boolean | no | Whether parameters are passed as path segments instead of body/query |
| scope | string | no | OAuth scope
Allowed: none, customerAuthentication, customer, caseAuthentication, case |
| jsonPathExtractor | string | no | JSONPath expression to extract specific data from the response |
| headers | string | no | JSON-encoded HTTP headers for the function request |
| staticArgs | string | no | JSON-encoded static arguments for the authorisation |
| customExecutionCode | string | no | Custom Python code executed by the hook |
| dbScript | string | yes | Database script to execute (database_script type) |
| dbConnectionID | string | no | ID of the database connection to use |
| dbSchemaMetadata | string | no | JSON-encoded database schema metadata |
| htmlUrl | string | yes | URL for the HTML form/page (html_fn type) |
| htmlScript | string | no | Script for the HTML function |
| isHtmlRedirectFn | boolean | no | Whether the HTML function redirects |
| htmlFormOnSuccessfulSubmitMessage | string | no | Message shown on successful form submission |
| htmlFormOnFailedSubmitMessage | string | no | Message shown on failed form submission |
| chatScript | string | yes | Script for the chat action function (chat_fn type) |
| chatAction | string | yes | Chat action type: suggestion, nextQuestion, or script
Allowed: suggestion, nextQuestion, script |
| codeExecutionEnvironmentID | string | no | ID of the code execution environment (code_template type) |
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 agent function |
name | string | Human-readable name of the function |
description | string | Detailed description of function purpose |
parameters | object | Function parameters schema (JSON Schema format) |
model | string | AI model used for processing function calls |
url | string | Endpoint URL for the function |
requestType | string | HTTP 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
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Unique identifier |
workspaceid | string | no | Unique workspace identifier (UUID v4) |
name | string | no | Name of the resource |
description | string | no | Detailed description of purpose and capabilities |
model | string | no | Model identifier for the function's LLM |
isCallbackFn | boolean | no | Whether this is a callback function |
isDatabaseScript | boolean | no | Whether this function executes a database script |
isHtmlFn | boolean | no | Whether this function renders an HTML form/page |
isChatFn | boolean | no | Whether this is a chat action function |
isMCPServer | boolean | no | Whether this function connects to an MCP (Model Context Protocol) server |
isCodeTemplate | boolean | no | Whether this is a code template function |
isHandOffFn | boolean | no | Whether this function hands off to another agent or human |
isAgentSkill | boolean | no | Whether this function is an agent skill |
agentSkillScript | string | no | Script for the agent skill function |
handOffAgent | string | no | Agent ID to hand off to |
handOffToOriginalAgentOnCompletion | boolean | no | Whether to return to the original agent on completion |
handOffToOriginalAgentOnFailure | boolean | no | Whether to return to the original agent on failure |
handOffAgentOnCompletion | string | no | Agent ID to hand off to on completion |
handOffAgentOnFailure | string | no | Agent ID to hand off to on failure |
handedOffToHumanOnCall | boolean | no | Whether the function hands off to a human operator |
usersToHandOffTo | string | no | List of user IDs who can receive hand-offs |
onFnCall | string | no | JSON-encoded configuration for actions on function call |
graphqlQuery | string | no | GraphQL query string (for graphql_query request type) |
graphqlMutation | string | no | GraphQL mutation string (for graphql_mutation request type) |
graphqlOperationName | string | no | Name of the GraphQL operation |
isGlobal | boolean | no | Whether this function is available across all agents |
createdBy | string | no | ID of the user who created this resource |
updatedBy | string | no | ID of the user who last updated this resource |
dependsOnBeforeExecution | string | no | List of function IDs that must execute before this one |
dependsOnAfterExecution | string | no | List of function IDs that execute after this one |
preExecutionScript | string | no | Script executed before this function runs |
postExecutionScript | string | no | Script executed after this function runs |
preExecutionFnID | string | no | ID of a function to execute before this one |
preExecutionMapping | string | no | JSON-encoded mapping for pre-execution data |
OAuthConnectionID | string | no | ID of the OAuth connection used by this function |
functionVersion | string | no | Version identifier for the function |
functionType | string | no | Type classification for the function |
requestType | string | no | HTTP 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, `` |
| authorisationType | string | no | Authorisation type for the function: none, apikey, bearer, or oauth
Allowed: none, apikey, bearer, oauth, `` |
| url | string | no | Public URL of the website to crawl/index |
| parameters | string | no | JSON-encoded input parameters for the function |
| authorisationKey | string | no | Authorisation key/header name for the function |
| authorisationID | string | no | ID of the authorisation configuration to use |
| paramsAsPath | boolean | no | Whether parameters are passed as path segments instead of body/query |
| scope | string | no | OAuth scope
Allowed: none, customerAuthentication, customer, caseAuthentication, case |
| jsonPathExtractor | string | no | JSONPath expression to extract specific data from the response |
| headers | string | no | JSON-encoded HTTP headers for the function request |
| staticArgs | string | no | JSON-encoded static arguments for the authorisation |
| customExecutionCode | string | no | Custom Python code executed by the hook |
| dbScript | string | no | Database script to execute (database_script type) |
| dbConnectionID | string | no | ID of the database connection to use |
| dbSchemaMetadata | string | no | JSON-encoded database schema metadata |
| htmlUrl | string | no | URL for the HTML form/page (html_fn type) |
| htmlScript | string | no | Script for the HTML function |
| isHtmlRedirectFn | boolean | no | Whether the HTML function redirects |
| htmlFormOnSuccessfulSubmitMessage | string | no | Message shown on successful form submission |
| htmlFormOnFailedSubmitMessage | string | no | Message shown on failed form submission |
| chatScript | string | no | Script for the chat action function (chat_fn type) |
| chatAction | string | no | Chat action type: suggestion, nextQuestion, or script
Allowed: suggestion, nextQuestion, script |
| codeExecutionEnvironmentID | string | no | ID of the code execution environment (code_template type) |
The Python SDK accepts
snake_casekeyword arguments and converts them to thecamelCasewire fields shown above.
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
| Field | Type | Description |
|---|---|---|
success | boolean | Operation success status |
data | object | Response data |
message | string | Optional 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
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="…")