Interface: DirectApi
Direct messages: the inbox, a thread's messages, and sending.
Methods
addUsers()
addUsers(threadId, userIds): Promise<void>;Adds people to a group thread.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
userIds | readonly string[] |
Returns
Promise<void>
approve()
approve(threadId): Promise<void>;Accepts a message request, moving it to the inbox.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
Promise<void>
createGroup()
createGroup(userIds, title?): Promise<string>;Creates a group thread and returns its id.
Parameters
| Parameter | Type |
|---|---|
userIds | readonly string[] |
title? | string |
Returns
Promise<string>
deleteMessage()
deleteMessage(threadId, itemId): Promise<void>;Deletes one of the account's own messages for everyone in the thread.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
itemId | string |
Returns
Promise<void>
findThread()
findThread(userIds): Promise<
| {
[key: string]: unknown;
is_group?: boolean;
items?: object[];
last_activity_at?: string;
last_permanent_item?: {
[key: string]: unknown;
item_id?: string;
item_type?: string;
text?: string;
timestamp?: string;
user_id?: string;
};
thread_id?: string;
thread_title?: string;
users?: object[];
}
| undefined>;The existing thread with exactly these people, if there is one.
Parameters
| Parameter | Type |
|---|---|
userIds | readonly string[] |
Returns
Promise< | { [key: string]: unknown; is_group?: boolean; items?: object[]; last_activity_at?: string; last_permanent_item?: { [key: string]: unknown; item_id?: string; item_type?: string; text?: string; timestamp?: string; user_id?: string; }; thread_id?: string; thread_title?: string; users?: object[]; } | undefined>
hide()
hide(threadId, options?): Promise<void>;Declines a message request.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
options? | HideThreadOptions |
Returns
Promise<void>
inbox()
inbox(options?): Promise<Page<{
[key: string]: unknown;
is_group?: boolean;
items?: object[];
last_activity_at?: string;
last_permanent_item?: {
[key: string]: unknown;
item_id?: string;
item_type?: string;
text?: string;
timestamp?: string;
user_id?: string;
};
thread_id?: string;
thread_title?: string;
users?: object[];
}>>;One page of the inbox threads.
Parameters
| Parameter | Type |
|---|---|
options? | CursorOptions |
Returns
Promise<Page<{ [key: string]: unknown; is_group?: boolean; items?: object[]; last_activity_at?: string; last_permanent_item?: { [key: string]: unknown; item_id?: string; item_type?: string; text?: string; timestamp?: string; user_id?: string; }; thread_id?: string; thread_title?: string; users?: object[]; }>>
markSeen()
markSeen(threadId, itemId): Promise<void>;Marks a thread as seen up to a message.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
itemId | string |
Returns
Promise<void>
mute()
mute(threadId): Promise<void>;Mutes the notifications of a thread.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
Promise<void>
paginateInbox()
paginateInbox(): AsyncGenerator<{
[key: string]: unknown;
is_group?: boolean;
items?: object[];
last_activity_at?: string;
last_permanent_item?: {
[key: string]: unknown;
item_id?: string;
item_type?: string;
text?: string;
timestamp?: string;
user_id?: string;
};
thread_id?: string;
thread_title?: string;
users?: object[];
}>;Walks the inbox threads, one at a time across pages.
Returns
AsyncGenerator<{ [key: string]: unknown; is_group?: boolean; items?: object[]; last_activity_at?: string; last_permanent_item?: { [key: string]: unknown; item_id?: string; item_type?: string; text?: string; timestamp?: string; user_id?: string; }; thread_id?: string; thread_title?: string; users?: object[]; }>
paginatePending()
paginatePending(): AsyncGenerator<{
[key: string]: unknown;
is_group?: boolean;
items?: object[];
last_activity_at?: string;
last_permanent_item?: {
[key: string]: unknown;
item_id?: string;
item_type?: string;
text?: string;
timestamp?: string;
user_id?: string;
};
thread_id?: string;
thread_title?: string;
users?: object[];
}>;Walks the message requests.
Returns
AsyncGenerator<{ [key: string]: unknown; is_group?: boolean; items?: object[]; last_activity_at?: string; last_permanent_item?: { [key: string]: unknown; item_id?: string; item_type?: string; text?: string; timestamp?: string; user_id?: string; }; thread_id?: string; thread_title?: string; users?: object[]; }>
paginateSpam()
paginateSpam(): AsyncGenerator<{
[key: string]: unknown;
is_group?: boolean;
items?: object[];
last_activity_at?: string;
last_permanent_item?: {
[key: string]: unknown;
item_id?: string;
item_type?: string;
text?: string;
timestamp?: string;
user_id?: string;
};
thread_id?: string;
thread_title?: string;
users?: object[];
}>;Walks the hidden requests.
Returns
AsyncGenerator<{ [key: string]: unknown; is_group?: boolean; items?: object[]; last_activity_at?: string; last_permanent_item?: { [key: string]: unknown; item_id?: string; item_type?: string; text?: string; timestamp?: string; user_id?: string; }; thread_id?: string; thread_title?: string; users?: object[]; }>
paginateThread()
paginateThread(threadId): AsyncGenerator<{
[key: string]: unknown;
item_id?: string;
item_type?: string;
text?: string;
timestamp?: string;
user_id?: string;
}>;Walks a thread's messages, newest first.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
AsyncGenerator<{ [key: string]: unknown; item_id?: string; item_type?: string; text?: string; timestamp?: string; user_id?: string; }>
pending()
pending(options?): Promise<Page<{
[key: string]: unknown;
is_group?: boolean;
items?: object[];
last_activity_at?: string;
last_permanent_item?: {
[key: string]: unknown;
item_id?: string;
item_type?: string;
text?: string;
timestamp?: string;
user_id?: string;
};
thread_id?: string;
thread_title?: string;
users?: object[];
}>>;One page of the message requests.
Parameters
| Parameter | Type |
|---|---|
options? | CursorOptions |
Returns
Promise<Page<{ [key: string]: unknown; is_group?: boolean; items?: object[]; last_activity_at?: string; last_permanent_item?: { [key: string]: unknown; item_id?: string; item_type?: string; text?: string; timestamp?: string; user_id?: string; }; thread_id?: string; thread_title?: string; users?: object[]; }>>
react()
react(
threadId,
itemId,
options?
): Promise<void>;Reacts to a message with an emoji, or removes the reaction.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
itemId | string |
options? | ReactionOptions |
Returns
Promise<void>
searchRecipients()
searchRecipients(query, mode?): Promise<object[]>;The people the account can message who match a query, ranked.
Parameters
| Parameter | Type |
|---|---|
query | string |
mode? | RecipientSearchMode |
Returns
Promise<object[]>
sendLink()
sendLink(text, target): Promise<{
[key: string]: unknown;
item_id?: string;
thread_id?: string;
timestamp?: string;
}>;Sends a message with a link, which the app shows with a preview.
Parameters
| Parameter | Type |
|---|---|
text | string |
target | SendTarget |
Returns
Promise<{ [key: string]: unknown; item_id?: string; thread_id?: string; timestamp?: string; }>
sendPhoto()
sendPhoto(jpeg, target): Promise<{
[key: string]: unknown;
item_id?: string;
thread_id?: string;
timestamp?: string;
}>;Sends a JPEG photo in a thread or to users.
Parameters
| Parameter | Type |
|---|---|
jpeg | Uint8Array |
target | SendTarget |
Returns
Promise<{ [key: string]: unknown; item_id?: string; thread_id?: string; timestamp?: string; }>
sendText()
sendText(text, target): Promise<{
[key: string]: unknown;
item_id?: string;
thread_id?: string;
timestamp?: string;
}>;Sends a text message to a thread or to users.
Parameters
| Parameter | Type |
|---|---|
text | string |
target | SendTarget |
Returns
Promise<{ [key: string]: unknown; item_id?: string; thread_id?: string; timestamp?: string; }>
sendVideo()
sendVideo(mp4, target): Promise<{
[key: string]: unknown;
item_id?: string;
thread_id?: string;
timestamp?: string;
}>;Sends an MP4 video (H.264 + AAC) into a thread or the thread with the given users.
Parameters
| Parameter | Type |
|---|---|
mp4 | Uint8Array |
target | SendTarget |
Returns
Promise<{ [key: string]: unknown; item_id?: string; thread_id?: string; timestamp?: string; }>
sendVoice()
sendVoice(
m4a,
target,
options?
): Promise<{
[key: string]: unknown;
item_id?: string;
thread_id?: string;
timestamp?: string;
}>;Sends a voice message: an AAC clip in an MP4 container (.m4a).
Parameters
| Parameter | Type |
|---|---|
m4a | Uint8Array |
target | SendTarget |
options? | VoiceOptions |
Returns
Promise<{ [key: string]: unknown; item_id?: string; thread_id?: string; timestamp?: string; }>
setTitle()
setTitle(threadId, title): Promise<void>;Renames a group thread.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
title | string |
Returns
Promise<void>
shareMedia()
shareMedia(
mediaId,
target,
options?
): Promise<{
[key: string]: unknown;
item_id?: string;
thread_id?: string;
timestamp?: string;
}>;Shares a post in a thread or with users.
Parameters
| Parameter | Type |
|---|---|
mediaId | string |
target | SendTarget |
options? | ShareMediaOptions |
Returns
Promise<{ [key: string]: unknown; item_id?: string; thread_id?: string; timestamp?: string; }>
shareProfile()
shareProfile(userId, target): Promise<{
[key: string]: unknown;
item_id?: string;
thread_id?: string;
timestamp?: string;
}>;Shares a user's profile in a thread or with users.
Parameters
| Parameter | Type |
|---|---|
userId | string |
target | SendTarget |
Returns
Promise<{ [key: string]: unknown; item_id?: string; thread_id?: string; timestamp?: string; }>
shareStory()
shareStory(storyId, target): Promise<{
[key: string]: unknown;
item_id?: string;
thread_id?: string;
timestamp?: string;
}>;Shares a story, by its full id (pk_ownerPk), into a thread or to users.
Parameters
| Parameter | Type |
|---|---|
storyId | string |
target | SendTarget |
Returns
Promise<{ [key: string]: unknown; item_id?: string; thread_id?: string; timestamp?: string; }>
spam()
spam(options?): Promise<Page<{
[key: string]: unknown;
is_group?: boolean;
items?: object[];
last_activity_at?: string;
last_permanent_item?: {
[key: string]: unknown;
item_id?: string;
item_type?: string;
text?: string;
timestamp?: string;
user_id?: string;
};
thread_id?: string;
thread_title?: string;
users?: object[];
}>>;One page of the hidden requests.
Parameters
| Parameter | Type |
|---|---|
options? | CursorOptions |
Returns
Promise<Page<{ [key: string]: unknown; is_group?: boolean; items?: object[]; last_activity_at?: string; last_permanent_item?: { [key: string]: unknown; item_id?: string; item_type?: string; text?: string; timestamp?: string; user_id?: string; }; thread_id?: string; thread_title?: string; users?: object[]; }>>
thread()
thread(threadId, options?): Promise<Page<{
[key: string]: unknown;
item_id?: string;
item_type?: string;
text?: string;
timestamp?: string;
user_id?: string;
}>>;One page of a thread's messages, newest first.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
options? | CursorOptions |
Returns
Promise<Page<{ [key: string]: unknown; item_id?: string; item_type?: string; text?: string; timestamp?: string; user_id?: string; }>>
unmute()
unmute(threadId): Promise<void>;Turns the notifications of a thread back on.
Parameters
| Parameter | Type |
|---|---|
threadId | string |
Returns
Promise<void>