Skip to main content

Hooks

Hooks

@toothfairyai/sdk@latest…

Hook Management Module Handles hook CRUD operations for custom code execution.

Accessed via client.hooks.

Methods

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

create

Create a new hook

async create(
name: string,
functionName: string,
options: {
customExecutionCode?: string;
customExecutionInstructions?: string;
availableLibraries?: string;
allowExternalApi?: boolean;
hardcodedScript?: boolean;
} = {}
)

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

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

const result = await client.hooks.create('…', '…');

update

Update an existing hook

async update(
hookId: string,
options: {
name?: string;
functionName?: string;
customExecutionCode?: string;
customExecutionInstructions?: string;
availableLibraries?: string;
allowExternalApi?: boolean;
hardcodedScript?: boolean;
} = {}
)

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

Response

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

Example

const result = await client.hooks.update('agent-id');

delete

Delete a hook

async delete(hookId: string): Promise<

Endpoint: DELETE /hook/delete/{id} · API service

Example

const result = await client.hooks.delete('agent-id');

get

Get a hook by ID

async get(hookId: string)

Endpoint: GET /hook/get/{id} · API service

Response

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

Example

const result = await client.hooks.get('agent-id');

list

List all hooks in the workspace

async list(limit?: number, offset?: number)

Endpoint: GET /hook/list · API service

Example

const result = await client.hooks.list();