SearchClient
Client for interacting with Twist search endpoints.
Extends
BaseClient
Constructors
Constructor
new SearchClient(config: ClientConfig): SearchClient;
Parameters
| Parameter | Type |
|---|---|
config | ClientConfig |
Returns
SearchClient
Inherited from
BaseClient.constructor
Properties
| Property | Modifier | Type |
|---|---|---|
apiToken | readonly | string |
baseUrl? | readonly | string |
customFetch? | readonly | CustomFetch |
defaultVersion | readonly | ApiVersion |
Methods
getBaseUri()
protected getBaseUri(version?: ApiVersion): string;
Gets the base URI for API requests with proper trailing slash handling. This method fixes the trailing slash bug that occurred when using custom baseUrl.
Parameters
| Parameter | Type | Description |
|---|---|---|
version? | ApiVersion | Optional API version override. Defaults to the configured version or 'v3' |
Returns
string
Base URI with guaranteed trailing slash for proper URL resolution
Inherited from
BaseClient.getBaseUri
search()
Call Signature
search(args: SearchArgs, options: {
batch: true;
}): BatchRequestDescriptor<SearchResponse>;
Searches across all threads and conversations in a workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | SearchArgs | The arguments for searching. |
options | { batch: true; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch | true | - |
Returns
BatchRequestDescriptor<SearchResponse>
Search results with pagination.
Example
const results = await api.search.search({
query: 'important meeting',
import { BaseClient, type ClientConfig } from './base-client'
workspaceId: 123
})
Call Signature
search(args: SearchArgs, options?: {
batch?: false;
}): Promise<SearchResponse>;
Searches across all threads and conversations in a workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | SearchArgs | The 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',
import { BaseClient, type ClientConfig } from './base-client'
workspaceId: 123
})
searchConversation()
Call Signature
searchConversation(args: SearchConversationArgs, options: {
batch: true;
}): BatchRequestDescriptor<SearchConversationResponse>;
Searches within messages of a specific conversation.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | SearchConversationArgs | The arguments for searching within a conversation. |
options | { batch: true; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch | true | - |
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
| Parameter | Type | Description |
|---|---|---|
args | SearchConversationArgs | The 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
| Parameter | Type | Description |
|---|---|---|
args | SearchThreadArgs | The arguments for searching within a thread. |
options | { batch: true; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch | true | - |
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
| Parameter | Type | Description |
|---|---|---|
args | SearchThreadArgs | The 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
})