跳转到内容

Threads

此内容尚不支持你的语言。

GET /v1/accounts/{a}/threads

List the chats, newest activity first.

Scope: read

ParameterInTypeDescription
a (required)pathstringAccount ID or alias.
cursorquerystring, nullableThe nextCursor of the previous page, up to 8192 characters. Send it with the same query.
kindquerystring, nullableOnly list chats of this kind: direct, group or system.
limitqueryinteger, nullableItems per page, from 1 to 200.
relationquerystring, nullableContact lists only: friend (default), non_contact, unknown, or all cached people.
searchquerystring, nullableText to search for, up to 256 characters. The name query is accepted too.

Response: NativeThreadPage

GET /v1/accounts/{a}/threads/{id}

Show one chat.

Scope: read

ParameterInTypeDescription
a (required)pathstringAccount ID or alias.
id (required)pathstringChat ID.

Response: NativeThread

PUT /v1/accounts/{a}/threads/{id}/notifications

Mute or unmute notifications for a chat.

Scope: admin

ParameterInTypeDescription
a (required)pathstringAccount ID or alias.
id (required)pathstringChat ID.
Idempotency-Key (required)headerstringRepeating a request with the same key returns the original result instead of repeating the work.

Request body: NativeThreadNotificationsRequest

Response: NativeOperation

PUT /v1/accounts/{a}/threads/{id}/pin

Pin or unpin a chat.

Scope: admin

ParameterInTypeDescription
a (required)pathstringAccount ID or alias.
id (required)pathstringChat ID.
Idempotency-Key (required)headerstringRepeating a request with the same key returns the original result instead of repeating the work.

Request body: NativeThreadPinRequest

Response: NativeOperation

POST /v1/accounts/{a}/threads/{thread}/read-state

Mark a chat as read when its read-state version still matches the one in the body.

Scope: read-state

ParameterInTypeDescription
a (required)pathstringAccount ID or alias.
thread (required)pathstringChat ID.

Request body: NativeReadRequest

Types

CallMedia

Media type of a stored VoIP call record.

ValueDescription
”video”Video call record.
”voice”Voice-only call record.
”unknown”Call record whose media type could not be established.

CallOutcome

Outcome recorded on a stored VoIP call record.

ValueDescription
”connected”Call connected and recorded a duration.
”not_connected”Call did not connect.
”canceled”Caller canceled before pickup.
”canceled_by_peer”Other user canceled before pickup.
”declined”Call was declined locally.
”declined_by_peer”Call was declined by the other user.
”busy”Local line was busy.
”busy_peer”Other user’s line was busy.
”not_answered”Call was not answered locally.
”not_answered_by_peer”Other user did not answer.
”answered_elsewhere”Call was already answered on another device.
”declined_elsewhere”Call was declined on another device.
”ended”Call ended or disconnected.
”unsupported_by_peer”Other user’s client cannot accept calls.
”unknown”Outcome could not be determined from stored metadata.

ChannelsLiveStatus

Live-stream status carried on a Channels Live share card.

ValueDescription
”live”Stream was reported live when the card was stored.
”ended”Stream was reported ended when the card was stored.
”unknown”Live status was absent or unrecognized.

ContactCardKind

Category of a shared WeChat contact card.

ValueDescription
”personal”Ordinary personal WeChat contact card.
”official_account”Official Account or Service Account card.
”wecom”WeCom (OpenIM) business contact card.
”customer_support”WeCom Customer Support contact card.
”photo_account”Photo Account contact card.

MessageSummary

Structured read-only summary for a rich message type.

ValueDescription
objectShared contact card (personal, Official Account, WeCom, Customer Support or Photo Account).
objectStored voice or video call record (type 50).
objectShared WeChat favorite note (type 49, subtype 24).
objectShared Mini Program card or Mini Program profile card (type 49, subtypes 33 and 36).
objectShared WeChat Channels live stream card (type 49, subtype 63).
objectRead-only WeChat Transfer record (type 49, subtype 2000).
objectRead-only WeChat Red Packet record (type 49, subtype 2001 with non-split-bill scene).
objectRead-only group split-bill request (type 49, subtype 2001 with scene 1001).
objectPassive live-location sharing notice (type 49, subtype 17).
objectPassive file-upload placeholder notice (type 49, subtype 74).
objectPlain-text group announcement notice (type 49, subtype 87).

NativeOperation

A background operation such as signing in or out, refreshing contacts or changing a group. Poll it by ID until it finishes.

FieldTypeDescription
accountId (required)stringID of the account the operation belongs to.
createdAt (required)stringWhen the operation was created, as an RFC 3339 time.
id (required)stringOperation ID.
kind (required)stringWhat the operation does, such as login, logout, sync, metadata, group_mutation, message_recall or media-writeback.
result (required)anyDetails of the outcome. Its fields depend on kind, and it is empty until the operation has something to report.
state (required)stringWhere the operation stands, such as queued, running, succeeded, failed or cancelled. Some kinds report more states, for example needs_review, or awaiting_scan and awaiting_approval during a login.
updatedAt (required)stringWhen the operation last changed, as an RFC 3339 time.

NativePageItemOfNativeThread

One entry on a page: the resource itself, or a tombstone when the resource has been removed since the list was first read.

ValueDescription
NativeThread
NativeTombstone

NativeReadRequest

Request to mark a chat as read.

FieldTypeDescription
expectedVersion (required)stringThe chat’s readStateVersion from when you read it. The request is refused if the chat has changed since.

NativeThread

A chat in the chat list: a direct chat, a group or a built-in chat such as File Transfer. Summaries come from saved history and are not refreshed from WeChat.

FieldTypeDescription
accountId (required)stringID of the account the chat belongs to.
avatarMembers (required)array of NativeThreadAvatarMember, nullableUp to four cached group members, for drawing the group’s picture. Empty for direct chats or when the member list is unavailable.
classificationPeerClassification or , nullable
displayName (required)string, nullableName shown for the chat: your remark if set, else the contact’s nickname or the group’s name, else the ID.
history (required)anyHow complete the saved history is. It currently always reports partial coverage and no local message count.
id (required)stringChat ID. For a direct chat it is the contact’s username, and for a group it ends with @chatroom.
kind (required)stringdirect for a one-to-one chat, group for a group, and system for a built-in chat such as File Transfer.
lastMessageNativeThreadMessage or , nullablePreview of the latest message. Omitted when local message data is unavailable, and null when the chat has no messages.
muted (required)boolean, nullableSaved notification preference: true when the chat is muted and false when it is not. Null means the profile cannot establish it.
peerId (required)stringID of the person or group on the other side of the chat. It is the same as id.
pinned (required)boolean, nullableSaved pin preference: true when the chat is pinned and false when it is not. Null means the profile cannot establish it.
readStateVersion (required)stringVersion of the chat’s read state. Send it as expectedVersion when marking the chat read; the request is refused if the chat changed since.
unreadCount (required)integer, nullableNumber of unread messages as saved in the profile. Null when the saved data does not say.

NativeThreadAvatarMember

A group member shown in the group’s picture.

FieldTypeDescription
displayName (required)stringName to show for the member.
id (required)stringMember ID.

NativeThreadMessage

Preview of the latest message in a chat.

FieldTypeDescription
createdAt (required)string, nullableWhen the message was created, as an RFC 3339 time. Null when unknown.
direction (required)string, nullableoutgoing when this account sent the message and incoming when someone else did. Null when it cannot be determined.
id (required)stringID of the message, the same as id on the full message.
senderId (required)string, nullableID of the sender. Null for system notices and when the sender is unknown.
senderName (required)string, nullableName of the sender, taken from the group’s cached members or your contacts. Null when the message has no sender or the name is unknown.
summaryMessageSummary or , nullableStructured read-only summary of the latest message when available. Omitted otherwise.
text (required)stringPlain-text preview of up to 160 characters. Media messages use labels such as Photo and Sticker, and a recalled message shows its recall notice.
type (required)integerWeChat’s numeric message type, with the same values as type on a message.

NativeThreadNotificationsRequest

Request to mute or unmute notifications for a chat.

FieldTypeDescription
muted (required)booleanTrue to mute the chat and false to turn its notifications back on.

NativeThreadPage

One page of a list. items holds the resources, nextCursor continues the list, and the other fields describe the saved data the list was read from.

FieldTypeDescription
asOfEventCursor (required)string, nullableEvent cursor that was current when the list was first read. Resume the event stream from it to catch changes made after the read.
coverage (required)anyWhich saved databases the read covered, as partial (true when some could not be read) and databases (each one with its state). It describes local data, not completeness on WeChat’s servers.
items (required)array of NativePageItemOfNativeThreadThe entries on this page, in list order.
nextCursor (required)string, nullablePass it as cursor with the same query to get the next page. Null on the last page.
sourceGeneration (required)stringFingerprint of the saved profile data the page was read from. It changes when the profile files change.

NativeThreadPinRequest

Request to pin or unpin a chat.

FieldTypeDescription
pinned (required)booleanTrue to pin the chat and false to unpin it.

NativeTombstone

Stands in for a resource that was in the list when it was first read but is no longer in the saved profile. It keeps the resource’s place in the list.

FieldTypeDescription
deleted (required)booleanAlways true, marking the resource as removed.
id (required)stringID of the removed resource.
version (required)stringFingerprint of the saved profile data in which the resource is missing, the same value as sourceGeneration on the page.

PeerApplication

Reference to an account type for one language, from the saved WeCom application data. The label of the account type is not included.

FieldTypeDescription
accountTypeCached (required)booleanTrue when the profile also holds the label for this account type and language. The label itself is not returned.
accountTypeId (required)string, nullableID of the account type for this language. Null when none is saved.
languageId (required)integerThe language this entry applies to, as the number WeChat stores.

PeerBusinessKind

Kind of business account, worked out from the numeric businessType.

ValueDescription
”official_account”An official account (business type 0).
“service_account”A service account (business type 1).
“enterprise”An enterprise account (business type 2).
“enterprise_child”An enterprise child account (business type 3).
“photo_account”A photo account (business type 5).

PeerCategory

What kind of peer this is. It is separate from the chat type and from whether the peer is in your contacts.

ValueDescription
”unknown”No category is established. Do not assume a personal account or a friend.
”system”A built-in peer such as File Transfer.
”group”A group chat.
”business”An official or business account.
”openim”A WeCom contact.
”openim_customer_service”A WeCom customer-service identity.

PeerClassification

What kind of peer this is, worked out from the saved profile each time it is read. Missing details do not mean the peer is an ordinary person or that you are not subscribed to it.

FieldTypeDescription
businessKind (required)PeerBusinessKind or , nullable
businessType (required)integer, nullableNumeric service type saved for a business account: 0 official account, 1 service account, 2 enterprise, 3 enterprise child, 5 photo account. Null for other peers and when the saved values conflict.
category (required)PeerCategory
namespace (required)PeerNamespace
openIm (required)PeerOpenIm or , nullableSaved WeCom details, present for openim and openim_customer_service peers when the profile has them. Null otherwise.

PeerNamespace

The family of IDs a peer’s ID belongs to, worked out from the ID itself. It does not grant any extra actions.

ValueDescription
”wechat”An ordinary WeChat ID, including groups ending with @chatroom.
”openim”An ID containing @openim, a WeCom contact.
”openim_customer_service”An ID containing @kefu.openim, a WeCom customer-service identity.
”im_chatroom”A group ID containing @im.chatroom.
”qy”An ID ending with @qy_u (a person) or @qy_g (a group).
“weclaw”An ID containing @weclaw.
”other”Any other ID containing @ that matches no known family.

PeerOpenIm

Saved WeCom (OpenIM) details for a peer.

FieldTypeDescription
appId (required)string, nullableID of the WeCom application the peer belongs to. Null when none is saved.
applications (required)array of PeerApplicationAccount type references, one per language.
wordingId (required)string, nullableID of the set of labels in wordings. Null when none is saved.
wordings (required)array of PeerWordingLocalized labels for the peer, one per language.

PeerWording

A label in one language.

FieldTypeDescription
languageId (required)integerThe language of the text, as the number WeChat stores. Choose the language to show in your app.
text (required)stringThe label text.

RedPacketScene

Red-packet scene category carried on subtype 2001 messages.

ValueDescription
”ordinary”Ordinary direct or group red packet.
”enterprise”Enterprise or OpenIM red packet.
”other”Other red-packet scene.

RedPacketStatus

Claim status of a red packet when known from canonical evidence.

ValueDescription
”unopened”Red packet is unopened.
”opened”Red packet has been opened.
”all_opened”All shares of the red packet have been claimed.
”expired”Red packet expired before being claimed.
”unknown”Status is not established from the stored message row alone.

SplitBillInvolvement

Whether this account created or owes payment on a group split-bill request.

ValueDescription
”creator”This account created the split-bill request.
”payer”This account is listed as a payer.
”not_involved”This account does not need to pay.
”unknown”Involvement could not be determined from the stored message.

TransferStatus

Status carried inside a WeChat Transfer message row.

ValueDescription
”pending”Transfer is awaiting recipient confirmation.
”pending_delayed”Delayed-arrival transfer is awaiting recipient confirmation.
”accepted”Transfer was accepted and settled.
”accepted_delayed”Delayed-arrival transfer was accepted and awaits deposit.
”rejected”Transfer was rejected or refunded.
”expired”Transfer expired before acceptance.
”unknown”Transfer status was absent or unrecognized.