Agent Functions
Agent Functions
@toothfairyai/sdk@latest…Agent Function Management Module Handles agent function CRUD operations for API integrations.
Accessed via client.agentFunctions.
Methods
| Method | HTTP | Endpoint |
|---|---|---|
create | POST | POST /function/create |
update | POST | POST /function/update |
delete | DELETE | DELETE /function/delete/{id} |
get | GET | GET /function/get/{id} |
list | GET | GET /function/list |
search | — | derived |
create
Create a new agent function
async create(
name: string,
options: {
description: string;
url?: string;
requestType?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
authorisationType?: string;
authorisationKey?: string;
parameters?: FunctionParameter[];
headers?: FunctionHeader[];
staticArgs?: StaticArg[];
}
)
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) |
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
const result = await client.agentFunctions.create('…', '…');
update
Update an existing agent function
async update(
agentFunctionId: string,
options: {
name?: string;
description?: string;
url?: string;
requestType?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
authorisationType?: string;
authorisationKey?: string;
parameters?: FunctionParameter[];
headers?: FunctionHeader[];
staticArgs?: StaticArg[];
} = {}
)
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) |
Response
Returns the AgentFunction object — fields documented in the create section above.
Example
const result = await client.agentFunctions.update('agent-id');
delete
Delete an agent function
async delete(agentFunctionId: string): Promise<
Endpoint: DELETE /function/delete/{id} · API service
Response fields
| Field | Type | Description |
|---|---|---|
success | boolean | Operation success status |
data | object | Response data |
message | string | Optional success message |
Example
const result = await client.agentFunctions.delete('agent-id');
get
Get an agent function by ID
async get(agentFunctionId: string)
Endpoint: GET /function/get/{id} · API service
Response
Returns the AgentFunction object — fields documented in the create section above.
Example
const result = await client.agentFunctions.get('agent-id');
list
List all agent functions in the workspace
async list(limit?: number, offset?: number)
Endpoint: GET /function/list · API service
Example
const result = await client.agentFunctions.list();
search
Search agent functions by name
async search(searchTerm: string)
Derived method — delegates to another SDK call and performs no direct HTTP request.
Example
const result = await client.agentFunctions.search('…');