Skip to main content

SearchClient

Client for interacting with Twist search endpoints.

Constructors

Constructor

new SearchClient(apiToken: string, baseUrl?: string): SearchClient;

Parameters

ParameterType
apiTokenstring
baseUrl?string

Returns

SearchClient

Methods

Call Signature

search(args: SearchArgs, options: {
batch: true;
}): BatchRequestDescriptor<SearchResponse>;

Searches across all threads and conversations in a workspace.

Parameters
ParameterTypeDescription
argsSearchArgsThe arguments for searching.
options{ batch: true; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batchtrue-
Returns

BatchRequestDescriptor<SearchResponse>

Search results with pagination.

Example
const results = await api.search.search({
query: 'important meeting',
workspaceId: 123
})

Call Signature

search(args: SearchArgs, options?: {
batch?: false;
}): Promise<SearchResponse>;

Searches across all threads and conversations in a workspace.

Parameters
ParameterTypeDescription
argsSearchArgsThe arguments for searching.
options?{ batch?: false; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batch?false-
Returns

Promise<SearchResponse>

Search results with pagination.

Example
const results = await api.search.search({
query: 'important meeting',
workspaceId: 123
})

searchConversation()

Call Signature

searchConversation(args: SearchConversationArgs, options: {
batch: true;
}): BatchRequestDescriptor<SearchConversationResponse>;

Searches within messages of a specific conversation.

Parameters
ParameterTypeDescription
argsSearchConversationArgsThe arguments for searching within a conversation.
options{ batch: true; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batchtrue-
Returns

BatchRequestDescriptor<SearchConversationResponse>

Message IDs that match the search query.

Example
const results = await api.search.searchConversation({
query: 'budget',
conversationId: 456
})

Call Signature

searchConversation(args: SearchConversationArgs, options?: {
batch?: false;
}): Promise<SearchConversationResponse>;

Searches within messages of a specific conversation.

Parameters
ParameterTypeDescription
argsSearchConversationArgsThe arguments for searching within a conversation.
options?{ batch?: false; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batch?false-
Returns

Promise<SearchConversationResponse>

Message IDs that match the search query.

Example
const results = await api.search.searchConversation({
query: 'budget',
conversationId: 456
})

searchThread()

Call Signature

searchThread(args: SearchThreadArgs, options: {
batch: true;
}): BatchRequestDescriptor<SearchThreadResponse>;

Searches within comments of a specific thread.

Parameters
ParameterTypeDescription
argsSearchThreadArgsThe arguments for searching within a thread.
options{ batch: true; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batchtrue-
Returns

BatchRequestDescriptor<SearchThreadResponse>

Comment IDs that match the search query.

Example
const results = await api.search.searchThread({
query: 'deadline',
threadId: 789
})

Call Signature

searchThread(args: SearchThreadArgs, options?: {
batch?: false;
}): Promise<SearchThreadResponse>;

Searches within comments of a specific thread.

Parameters
ParameterTypeDescription
argsSearchThreadArgsThe arguments for searching within a thread.
options?{ batch?: false; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batch?false-
Returns

Promise<SearchThreadResponse>

Comment IDs that match the search query.

Example
const results = await api.search.searchThread({
query: 'deadline',
threadId: 789
})