InboxClient
Client for interacting with Twist inbox endpoints.
Constructors
Constructor
new InboxClient(apiToken: string, baseUrl?: string): InboxClient;
Parameters
Parameter | Type |
---|---|
apiToken | string |
baseUrl? | string |
Returns
InboxClient
Methods
archiveAll()
Call Signature
archiveAll(args: ArchiveAllArgs, options: {
batch: true;
}): BatchRequestDescriptor<void>;
Archives all inbox items in a workspace.
Parameters
Parameter | Type | Description |
---|---|---|
args | ArchiveAllArgs | The arguments for archiving all. |
options | { batch : true ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch | true | - |
Returns
BatchRequestDescriptor
<void
>
Example
await api.inbox.archiveAll({
workspaceId: 123,
since: new Date('2024-01-01')
})
Call Signature
archiveAll(args: ArchiveAllArgs, options?: {
batch?: false;
}): Promise<void>;
Archives all inbox items in a workspace.
Parameters
Parameter | Type | Description |
---|---|---|
args | ArchiveAllArgs | The arguments for archiving all. |
options? | { batch? : false ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch? | false | - |
Returns
Promise
<void
>
Example
await api.inbox.archiveAll({
workspaceId: 123,
since: new Date('2024-01-01')
})
archiveThread()
Call Signature
archiveThread(id: number, options: {
batch: true;
}): BatchRequestDescriptor<void>;
Archives a thread in the inbox.
Parameters
Parameter | Type | Description |
---|---|---|
id | number | The thread ID. |
options | { batch : true ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch | true | - |
Returns
BatchRequestDescriptor
<void
>
Example
await api.inbox.archiveThread(456)
Call Signature
archiveThread(id: number, options?: {
batch?: false;
}): Promise<void>;
Archives a thread in the inbox.
Parameters
Parameter | Type | Description |
---|---|---|
id | number | The thread ID. |
options? | { batch? : false ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch? | false | - |
Returns
Promise
<void
>
Example
await api.inbox.archiveThread(456)
getCount()
Call Signature
getCount(workspaceId: number, options: {
batch: true;
}): BatchRequestDescriptor<number>;
Gets unread count for inbox.
Parameters
Parameter | Type | Description |
---|---|---|
workspaceId | number | The workspace ID. |
options | { batch : true ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch | true | - |
Returns
BatchRequestDescriptor
<number
>
The unread count.
Example
const count = await api.inbox.getCount(123)
console.log(`Unread items: ${count}`)
Call Signature
getCount(workspaceId: number, options?: {
batch?: false;
}): Promise<number>;
Gets unread count for inbox.
Parameters
Parameter | Type | Description |
---|---|---|
workspaceId | number | The workspace ID. |
options? | { batch? : false ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch? | false | - |
Returns
Promise
<number
>
The unread count.
Example
const count = await api.inbox.getCount(123)
console.log(`Unread items: ${count}`)
getInbox()
Call Signature
getInbox(args: GetInboxArgs, options: {
batch: true;
}): BatchRequestDescriptor<{
actions?: unknown[] | null;
attachments?: unknown[] | null;
channelId: number;
closed: boolean;
commentCount: number;
content: string;
creator: number;
creatorName?: string | null;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
groups?: number[] | null;
id: number;
inInbox: boolean;
isArchived: boolean;
isSaved?: boolean | null;
lastComment?: | {
actions?: unknown[] | null;
attachments?: unknown[] | null;
channelId?: number | null;
content: string;
conversationId?: number | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
groups?: number[] | null;
id: number;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: number;
toEmails?: string[] | null;
version?: number | null;
workspaceId?: number | null;
}
| null;
lastEdited?: Date | null;
lastObjIndex?: number | null;
lastUpdated: Date;
mutedUntil?: Date | null;
participants?: number[] | null;
pinned: boolean;
pinnedDate?: Date | null;
posted: Date;
reactions?: Record<string, number[]> | null;
recipients?: number[] | null;
responders?: number[] | null;
snippet: string;
snippetCreator: number;
snippetMaskAvatarUrl?: string | null;
snippetMaskPoster?: number | null;
starred: boolean;
systemMessage?: unknown;
title: string;
toEmails?: string[] | null;
version?: number | null;
workspaceId: number;
}[]>;
Gets inbox items (threads).
Parameters
Parameter | Type | Description |
---|---|---|
args | GetInboxArgs | The arguments for getting inbox. |
options | { batch : true ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch | true | - |
Returns
BatchRequestDescriptor
<{
actions?
: unknown
[] | null
;
attachments?
: unknown
[] | null
;
channelId
: number
;
closed
: boolean
;
commentCount
: number
;
content
: string
;
creator
: number
;
creatorName?
: string
| null
;
directGroupMentions?
: number
[] | null
;
directMentions?
: number
[] | null
;
groups?
: number
[] | null
;
id
: number
;
inInbox
: boolean
;
isArchived
: boolean
;
isSaved?
: boolean
| null
;
lastComment?
: | {
actions?
: unknown
[] | null
;
attachments?
: unknown
[] | null
;
channelId?
: number
| null
;
content
: string
;
conversationId?
: number
| null
;
creator
: number
;
creatorName?
: string
| null
;
deleted?
: boolean
| null
;
deletedBy?
: number
| null
;
directGroupMentions?
: number
[] | null
;
directMentions?
: number
[] | null
;
groups?
: number
[] | null
;
id
: number
;
lastEdited?
: Date
| null
;
objIndex?
: number
| null
;
posted
: Date
;
reactions?
: Record
<string
, unknown
> | null
;
recipients?
: number
[] | null
;
systemMessage?
: unknown
;
threadId
: number
;
toEmails?
: string
[] | null
;
version?
: number
| null
;
workspaceId?
: number
| null
;
}
| null
;
lastEdited?
: Date
| null
;
lastObjIndex?
: number
| null
;
lastUpdated
: Date
;
mutedUntil?
: Date
| null
;
participants?
: number
[] | null
;
pinned
: boolean
;
pinnedDate?
: Date
| null
;
posted
: Date
;
reactions?
: Record
<string
, number
[]> | null
;
recipients?
: number
[] | null
;
responders?
: number
[] | null
;
snippet
: string
;
snippetCreator
: number
;
snippetMaskAvatarUrl?
: string
| null
;
snippetMaskPoster?
: number
| null
;
starred
: boolean
;
systemMessage?
: unknown
;
title
: string
;
toEmails?
: string
[] | null
;
version?
: number
| null
;
workspaceId
: number
;
}[]>
Inbox threads.
Example
const inbox = await api.inbox.getInbox({
workspaceId: 123,
since: new Date('2024-01-01')
})
Call Signature
getInbox(args: GetInboxArgs, options?: {
batch?: false;
}): Promise<{
actions?: unknown[] | null;
attachments?: unknown[] | null;
channelId: number;
closed: boolean;
commentCount: number;
content: string;
creator: number;
creatorName?: string | null;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
groups?: number[] | null;
id: number;
inInbox: boolean;
isArchived: boolean;
isSaved?: boolean | null;
lastComment?: | {
actions?: unknown[] | null;
attachments?: unknown[] | null;
channelId?: number | null;
content: string;
conversationId?: number | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
groups?: number[] | null;
id: number;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: number;
toEmails?: string[] | null;
version?: number | null;
workspaceId?: number | null;
}
| null;
lastEdited?: Date | null;
lastObjIndex?: number | null;
lastUpdated: Date;
mutedUntil?: Date | null;
participants?: number[] | null;
pinned: boolean;
pinnedDate?: Date | null;
posted: Date;
reactions?: Record<string, number[]> | null;
recipients?: number[] | null;
responders?: number[] | null;
snippet: string;
snippetCreator: number;
snippetMaskAvatarUrl?: string | null;
snippetMaskPoster?: number | null;
starred: boolean;
systemMessage?: unknown;
title: string;
toEmails?: string[] | null;
version?: number | null;
workspaceId: number;
}[]>;
Gets inbox items (threads).
Parameters
Parameter | Type | Description |
---|---|---|
args | GetInboxArgs | The arguments for getting inbox. |
options? | { batch? : false ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch? | false | - |
Returns
Promise
<{
actions?
: unknown
[] | null
;
attachments?
: unknown
[] | null
;
channelId
: number
;
closed
: boolean
;
commentCount
: number
;
content
: string
;
creator
: number
;
creatorName?
: string
| null
;
directGroupMentions?
: number
[] | null
;
directMentions?
: number
[] | null
;
groups?
: number
[] | null
;
id
: number
;
inInbox
: boolean
;
isArchived
: boolean
;
isSaved?
: boolean
| null
;
lastComment?
: | {
actions?
: unknown
[] | null
;
attachments?
: unknown
[] | null
;
channelId?
: number
| null
;
content
: string
;
conversationId?
: number
| null
;
creator
: number
;
creatorName?
: string
| null
;
deleted?
: boolean
| null
;
deletedBy?
: number
| null
;
directGroupMentions?
: number
[] | null
;
directMentions?
: number
[] | null
;
groups?
: number
[] | null
;
id
: number
;
lastEdited?
: Date
| null
;
objIndex?
: number
| null
;
posted
: Date
;
reactions?
: Record
<string
, unknown
> | null
;
recipients?
: number
[] | null
;
systemMessage?
: unknown
;
threadId
: number
;
toEmails?
: string
[] | null
;
version?
: number
| null
;
workspaceId?
: number
| null
;
}
| null
;
lastEdited?
: Date
| null
;
lastObjIndex?
: number
| null
;
lastUpdated
: Date
;
mutedUntil?
: Date
| null
;
participants?
: number
[] | null
;
pinned
: boolean
;
pinnedDate?
: Date
| null
;
posted
: Date
;
reactions?
: Record
<string
, number
[]> | null
;
recipients?
: number
[] | null
;
responders?
: number
[] | null
;
snippet
: string
;
snippetCreator
: number
;
snippetMaskAvatarUrl?
: string
| null
;
snippetMaskPoster?
: number
| null
;
starred
: boolean
;
systemMessage?
: unknown
;
title
: string
;
toEmails?
: string
[] | null
;
version?
: number
| null
;
workspaceId
: number
;
}[]>
Inbox threads.
Example
const inbox = await api.inbox.getInbox({
workspaceId: 123,
since: new Date('2024-01-01')
})
markAllRead()
Call Signature
markAllRead(workspaceId: number, options: {
batch: true;
}): BatchRequestDescriptor<void>;
Marks all inbox items as read in a workspace.
Parameters
Parameter | Type | Description |
---|---|---|
workspaceId | number | The workspace ID. |
options | { batch : true ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch | true | - |
Returns
BatchRequestDescriptor
<void
>
Example
await api.inbox.markAllRead(123)
Call Signature
markAllRead(workspaceId: number, options?: {
batch?: false;
}): Promise<void>;
Marks all inbox items as read in a workspace.
Parameters
Parameter | Type | Description |
---|---|---|
workspaceId | number | The workspace ID. |
options? | { batch? : false ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch? | false | - |
Returns
Promise
<void
>
Example
await api.inbox.markAllRead(123)
unarchiveThread()
Call Signature
unarchiveThread(id: number, options: {
batch: true;
}): BatchRequestDescriptor<void>;
Unarchives a thread in the inbox.
Parameters
Parameter | Type | Description |
---|---|---|
id | number | The thread ID. |
options | { batch : true ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch | true | - |
Returns
BatchRequestDescriptor
<void
>
Example
await api.inbox.unarchiveThread(456)
Call Signature
unarchiveThread(id: number, options?: {
batch?: false;
}): Promise<void>;
Unarchives a thread in the inbox.
Parameters
Parameter | Type | Description |
---|---|---|
id | number | The thread ID. |
options? | { batch? : false ; } | Optional configuration. Set batch: true to return a descriptor for batch requests. |
options.batch? | false | - |
Returns
Promise
<void
>
Example
await api.inbox.unarchiveThread(456)