Skip to main content

HooksClient

Client for /api/v1/hooks/. REST hooks require Todoist OAuth bearer tokens that include Comms audience; session tokens are rejected by the backend.

Extends

  • BaseClient

Constructors

Constructor

new HooksClient(config: ClientConfig): HooksClient;

Parameters

ParameterType
configClientConfig

Returns

HooksClient

Inherited from

BaseClient.constructor

Properties

PropertyModifierType
apiTokenreadonlystring
baseUrl?readonlystring
customFetch?readonlyCustomFetch
defaultVersionreadonly"v1"

Methods

getBaseUri()

protected getBaseUri(): string;

Returns the base URI for an API request, with a guaranteed trailing slash so relative paths resolve cleanly through URL.

Returns

string

Inherited from

BaseClient.getBaseUri

getLinkBaseUrl()

protected getLinkBaseUrl(): string | undefined;

Base URL for entity web links, or undefined to use getFullCommsURL's default web app. Trailing-slash normalization happens in getFullCommsURL, so the configured value is returned verbatim.

Returns

string | undefined

Inherited from

BaseClient.getLinkBaseUrl

subscribe()

subscribe(args:
| {
channelId?: string | null;
conversationId?: undefined;
event: | "workspace_added"
| "workspace_updated"
| "workspace_deleted"
| "workspace_user_added"
| "workspace_user_updated"
| "workspace_user_removed"
| "channel_added"
| "channel_updated"
| "channel_deleted"
| "channel_user_added"
| "channel_user_removed"
| "thread_added"
| "thread_updated"
| "thread_deleted"
| "comment_added"
| "comment_updated"
| "comment_deleted"
| "group_added"
| "group_updated"
| "group_deleted"
| "group_user_added"
| "group_user_removed";
targetUrl: string;
threadId?: string | null;
workspaceId?: number | null;
}
| {
channelId?: string | null;
conversationId?: string | null;
event: "message_added" | "message_updated";
targetUrl: string;
threadId?: string | null;
workspaceId?: number | null;
}): Promise<{
id: number;
status: "ok";
}>;

Subscribes the current OAuth app to a REST hook event.

Parameters

ParameterTypeDescription
args| { channelId?: string | null; conversationId?: undefined; event: | "workspace_added" | "workspace_updated" | "workspace_deleted" | "workspace_user_added" | "workspace_user_updated" | "workspace_user_removed" | "channel_added" | "channel_updated" | "channel_deleted" | "channel_user_added" | "channel_user_removed" | "thread_added" | "thread_updated" | "thread_deleted" | "comment_added" | "comment_updated" | "comment_deleted" | "group_added" | "group_updated" | "group_deleted" | "group_user_added" | "group_user_removed"; targetUrl: string; threadId?: string | null; workspaceId?: number | null; } | { channelId?: string | null; conversationId?: string | null; event: "message_added" | "message_updated"; targetUrl: string; threadId?: string | null; workspaceId?: number | null; }The hook subscription parameters.

Returns

Promise<{ id: number; status: "ok"; }>

The { status: 'ok', id } response for the subscription.


unsubscribe()

unsubscribe(args: {
targetUrl: string;
}): Promise<{
status: "ok";
}>;

Unsubscribes all hooks with the target URL for the current OAuth app.

Parameters

ParameterTypeDescription
args{ targetUrl: string; }The hook unsubscribe parameters.
args.targetUrlstringTarget URL to remove.

Returns

Promise<{ status: "ok"; }>