Skip to main content

Hooks API

Hooks API

import { CodeBoltClient } from '@codebolt/clientsdk';

const client = new CodeBoltClient();

Quick Reference

MethodDescription
createCreates a new hook.
deleteDeletes a hook.
disableDisables a hook without deleting it.
enableEnables a previously disabled hook.
getRetrieves a specific hook by its ID.
initializeInitializes the hooks subsystem.
listLists all registered hooks.
updateUpdates an existing hook's configuration.

Methods


create

client.hooks.create(data: CreateHookRequest): Promise<Hook>

Creates a new hook.

Registers a hook that will fire when the specified event occurs. The hook is enabled by default upon creation.

ParameterTypeRequiredDescription
dataCreateHookRequestYesHook creation payload including event type and action

Returns: Promise<Hook> — A promise that resolves to the newly created

Full reference →


delete

client.hooks.delete(id: string): Promise<unknown>

Deletes a hook.

Permanently removes a hook registration. The hook will no longer fire for any events after deletion.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the hook to delete

Returns: Promise<unknown> — A promise that resolves when deletion is complete

Full reference →


disable

client.hooks.disable(id: string): Promise<unknown>

Disables a hook without deleting it.

Prevents the hook from firing while preserving its configuration. The hook can be re-enabled later with .

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the hook to disable

Returns: Promise<unknown> — A promise that resolves when the hook has been disabled

Full reference →


enable

client.hooks.enable(id: string): Promise<unknown>

Enables a previously disabled hook.

Re-activates the hook so it will fire again when its event occurs. Has no effect if the hook is already enabled.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the hook to enable

Returns: Promise<unknown> — A promise that resolves when the hook has been enabled

Full reference →


get

client.hooks.get(id: string): Promise<Hook>

Retrieves a specific hook by its ID.

Returns the full configuration and state of a single hook.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the hook

Returns: Promise<Hook> — A promise that resolves to the

Full reference →


initialize

client.hooks.initialize(data?: InitializeHooksRequest): Promise<unknown>

Initializes the hooks subsystem.

Sets up the hooks infrastructure, loading any persisted hooks and preparing event listeners. Should be called once during application bootstrap before registering or triggering hooks.

ParameterTypeRequiredDescription
dataInitializeHooksRequestNoOptional initialization configuration

Returns: Promise<unknown> — A promise that resolves when initialization is complete

Full reference →


list

client.hooks.list(params?: Record<string, unknown>): Promise<Hook[]>

Lists all registered hooks.

Returns every hook in the system, including both enabled and disabled hooks. Use optional parameters to filter or paginate the results.

ParameterTypeRequiredDescription
paramsRecord<string, unknown>NoOptional query parameters for filtering or pagination

Returns: Promise<Hook[]> — A promise that resolves to an array of objects

Full reference →


update

client.hooks.update(id: string, data: UpdateHookRequest): Promise<Hook>

Updates an existing hook's configuration.

Modifies hook properties such as its name, event trigger, or action. Only the fields provided in the request body are updated.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the hook to update
dataUpdateHookRequestYesThe fields to update

Returns: Promise<Hook> — A promise that resolves to the updated

Full reference →