Skip to main content

Agent Functions

Agent Functions

@toothfairyai/sdk@latest…

Agent Function Management Module Handles agent function CRUD operations for API integrations.

Accessed via client.agentFunctions.

Methods

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

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

FieldTypeRequiredDescription
idstringnoUnique identifier
workspaceidstringyesUnique workspace identifier (UUID v4)
namestringyesName of the resource
descriptionstringyesDetailed description of purpose and capabilities
modelstringnoModel identifier for the function's LLM
isCallbackFnbooleannoWhether this is a callback function
isDatabaseScriptbooleannoWhether this function executes a database script
isHtmlFnbooleannoWhether this function renders an HTML form/page
isChatFnbooleannoWhether this is a chat action function
isMCPServerbooleannoWhether this function connects to an MCP (Model Context Protocol) server
isCodeTemplatebooleannoWhether this is a code template function
isHandOffFnbooleannoWhether this function hands off to another agent or human
isAgentSkillbooleannoWhether this function is an agent skill
agentSkillScriptstringnoScript for the agent skill function
handOffAgentstringnoAgent ID to hand off to
handOffToOriginalAgentOnCompletionbooleannoWhether to return to the original agent on completion
handOffToOriginalAgentOnFailurebooleannoWhether to return to the original agent on failure
handOffAgentOnCompletionstringnoAgent ID to hand off to on completion
handOffAgentOnFailurestringnoAgent ID to hand off to on failure
handedOffToHumanOnCallbooleannoWhether the function hands off to a human operator
usersToHandOffTostringnoList of user IDs who can receive hand-offs
onFnCallstringnoJSON-encoded configuration for actions on function call
graphqlQuerystringnoGraphQL query string (for graphql_query request type)
graphqlMutationstringnoGraphQL mutation string (for graphql_mutation request type)
graphqlOperationNamestringnoName of the GraphQL operation
isGlobalbooleannoWhether this function is available across all agents
createdBystringnoID of the user who created this resource
updatedBystringnoID of the user who last updated this resource
dependsOnBeforeExecutionstringnoList of function IDs that must execute before this one
dependsOnAfterExecutionstringnoList of function IDs that execute after this one
preExecutionScriptstringnoScript executed before this function runs
postExecutionScriptstringnoScript executed after this function runs
preExecutionFnIDstringnoID of a function to execute before this one
preExecutionMappingstringnoJSON-encoded mapping for pre-execution data
OAuthConnectionIDstringnoID of the OAuth connection used by this function
functionVersionstringnoVersion identifier for the function
functionTypestringnoType classification for the function
requestTypestringnoHTTP 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

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

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

FieldTypeRequiredDescription
idstringyesUnique identifier
workspaceidstringnoUnique workspace identifier (UUID v4)
namestringnoName of the resource
descriptionstringnoDetailed description of purpose and capabilities
modelstringnoModel identifier for the function's LLM
isCallbackFnbooleannoWhether this is a callback function
isDatabaseScriptbooleannoWhether this function executes a database script
isHtmlFnbooleannoWhether this function renders an HTML form/page
isChatFnbooleannoWhether this is a chat action function
isMCPServerbooleannoWhether this function connects to an MCP (Model Context Protocol) server
isCodeTemplatebooleannoWhether this is a code template function
isHandOffFnbooleannoWhether this function hands off to another agent or human
isAgentSkillbooleannoWhether this function is an agent skill
agentSkillScriptstringnoScript for the agent skill function
handOffAgentstringnoAgent ID to hand off to
handOffToOriginalAgentOnCompletionbooleannoWhether to return to the original agent on completion
handOffToOriginalAgentOnFailurebooleannoWhether to return to the original agent on failure
handOffAgentOnCompletionstringnoAgent ID to hand off to on completion
handOffAgentOnFailurestringnoAgent ID to hand off to on failure
handedOffToHumanOnCallbooleannoWhether the function hands off to a human operator
usersToHandOffTostringnoList of user IDs who can receive hand-offs
onFnCallstringnoJSON-encoded configuration for actions on function call
graphqlQuerystringnoGraphQL query string (for graphql_query request type)
graphqlMutationstringnoGraphQL mutation string (for graphql_mutation request type)
graphqlOperationNamestringnoName of the GraphQL operation
isGlobalbooleannoWhether this function is available across all agents
createdBystringnoID of the user who created this resource
updatedBystringnoID of the user who last updated this resource
dependsOnBeforeExecutionstringnoList of function IDs that must execute before this one
dependsOnAfterExecutionstringnoList of function IDs that execute after this one
preExecutionScriptstringnoScript executed before this function runs
postExecutionScriptstringnoScript executed after this function runs
preExecutionFnIDstringnoID of a function to execute before this one
preExecutionMappingstringnoJSON-encoded mapping for pre-execution data
OAuthConnectionIDstringnoID of the OAuth connection used by this function
functionVersionstringnoVersion identifier for the function
functionTypestringnoType classification for the function
requestTypestringnoHTTP 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

FieldTypeDescription
successbooleanOperation success status
dataobjectResponse data
messagestringOptional 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 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('…');