Hooks
Hooks
@toothfairyai/sdk@latest…Hook Management Module Handles hook CRUD operations for custom code execution.
Accessed via client.hooks.
Methods
| Method | HTTP | Endpoint |
|---|---|---|
create | POST | POST /hook/create |
update | POST | POST /hook/update |
delete | DELETE | DELETE /hook/delete/{id} |
get | GET | GET /hook/get/{id} |
list | GET | GET /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
| Field | Type | Required | Description |
|---|---|---|---|
id | string | no | Unique identifier |
workspaceid | string | yes | Unique workspace identifier (UUID v4) |
workspaceID | string | no | Unique workspace identifier (UUID v4) |
name | string | yes | Name of the resource |
description | string | no | Detailed description of purpose and capabilities |
functionName | string | no | Name of the function executed by the hook |
availableLibraries | string | no | List of libraries available to the hook |
customExecutionInstructions | string | no | Custom instructions for hook execution |
customExecutionCode | string | no | Custom Python code executed by the hook |
customExecutionSecrets | string | no | JSON-encoded secrets used by the hook |
staticDocs | string | no | JSON-encoded static documents available to the hook |
staticArtifacts | string | no | JSON-encoded static artifacts available to the hook |
allowExternalAPI | boolean | no | Whether the hook can make external API calls |
hardcodedScript | boolean | no | Whether the hook uses a hardcoded script |
isTemplate | boolean | no | Whether this hook is a reusable template |
isGlobal | boolean | no | Whether this function is available across all agents |
customCodeExecutionEnvironmentVersion | string | no | Version of the code execution environment |
customCodeExecutionEnvironmentType | string | no | Type of the code execution environment |
createdBy | string | no | ID of the user who created this resource |
updatedBy | string | no | ID of the user who last updated this resource |
Response fields
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the hook |
name | string | Name of the resource |
description | string | Hook description |
functionName | string | Function name to execute |
availableLibraries | string | Available libraries for execution |
customExecutionInstructions | string | Instructions for code execution |
customExecutionCode | string | Custom code to execute |
customExecutionSecrets | object | JSON-encoded secrets used by the hook |
staticDocs | object | JSON-encoded static documents available to the hook |
staticArtifacts | object | JSON-encoded static artifacts available to the hook |
allowExternalAPI | boolean | Whether external API calls are allowed |
hardcodedScript | boolean | Whether the script is hardcoded |
isTemplate | boolean | Whether this is a template |
workspaceID | string | Unique workspace identifier (UUID v4) |
createdBy | string | ID of the user who created this resource |
updatedBy | string | ID of the user who last updated this resource |
customCodeExecutionEnvironmentVersion | string | Version of the code execution environment |
customCodeExecutionEnvironmentType | string | Type of the code execution environment |
createdAt | string | Timestamp when this resource was created |
updatedAt | string | Timestamp 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
| Field | Type | Required | Description |
|---|---|---|---|
id | string | yes | Unique identifier |
workspaceid | string | no | Unique workspace identifier (UUID v4) |
workspaceID | string | no | Unique workspace identifier (UUID v4) |
name | string | no | Name of the resource |
description | string | no | Detailed description of purpose and capabilities |
functionName | string | no | Name of the function executed by the hook |
availableLibraries | string | no | List of libraries available to the hook |
customExecutionInstructions | string | no | Custom instructions for hook execution |
customExecutionCode | string | no | Custom Python code executed by the hook |
customExecutionSecrets | string | no | JSON-encoded secrets used by the hook |
staticDocs | string | no | JSON-encoded static documents available to the hook |
staticArtifacts | string | no | JSON-encoded static artifacts available to the hook |
allowExternalAPI | boolean | no | Whether the hook can make external API calls |
hardcodedScript | boolean | no | Whether the hook uses a hardcoded script |
isTemplate | boolean | no | Whether this hook is a reusable template |
isGlobal | boolean | no | Whether this function is available across all agents |
customCodeExecutionEnvironmentVersion | string | no | Version of the code execution environment |
customCodeExecutionEnvironmentType | string | no | Type of the code execution environment |
createdBy | string | no | ID of the user who created this resource |
updatedBy | string | no | ID 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();