Send messages
Send messages from the CLI or the HTTP API. Files, images, video and voice notes are on the attachments page, and stickers are on the stickers page.
Send text
wx messages send CHAT_ID --text "On my way"The command waits up to 30 seconds for WeChat to accept the message. Add --detach to return right away. If the wait ends first, it exits with code 7 and the send keeps going; check it with wx messages sends get SEND_ID. See exit codes.
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -H "Idempotency-Key: order-1234-confirmation" \ -d '{"threadId": "filehelper", "text": "Order 1234 confirmed"}' \ "$WX/accounts/$ACCOUNT/sends"Every send needs an Idempotency-Key. Reusing a key returns the original send instead of sending twice. Check progress with GET /sends/{id}.
Quote a message
-
Copy the
idandserverIdof the message you’re replying to:Terminal window wx messages list CHAT_ID --json -
Send the reply with both quote flags:
Terminal window wx messages send CHAT_ID --text "Agreed" \--quote-message-id MESSAGE_ID --quote-server-id SERVER_ID --detach
Copy id and serverId from GET /threads/{id}/messages, then send them in a quote object:
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -H "Idempotency-Key: agreed-001" \ -d '{"threadId": "filehelper", "text": "Agreed", "quote": {"messageId": "MESSAGE_ID", "serverId": "SERVER_ID"}}' \ "$WX/accounts/$ACCOUNT/sends"The token needs read and send scope.
The original has to be saved in the same chat. Missing, recalled or mismatched originals are rejected. These kinds can be quoted:
| Original | Can be quoted |
|---|---|
| Text, image, voice, video, file, sticker or shared link | Yes |
| Shared contact or static location | Yes, in the saved forms that can be checked |
| Existing quoted reply | Yes, its own comment is quoted |
| Forwarded chat history | Yes, its summary only |
| System messages, upload notices and other cards | No |
Mention group members
In a group, add --mention MEMBER_ID or --mention-all to a text message or a quoted reply. Over HTTP, use mentions with userIds or all. Member IDs and the permissions that apply are on the groups page.
wx messages send GROUP_ID --text "Meeting moved to 3pm" --mention MEMBER_IDShare a link
wx messages send CHAT_ID --share https://example.com/post --title "Worth a read"Add --description for the text under the title, and --thumbnail-url for a preview image.
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -H "Idempotency-Key: post-share-001" \ -d '{"kind": "share", "threadId": "CHAT_ID", "url": "https://example.com/post", "title": "Worth a read"}' \ "$WX/accounts/$ACCOUNT/sends"The card shows the title you give. Nothing is fetched from the linked page.
Share a contact card
Send your own card (self), a contact (wxid_...) or an Official Account (gh_...) as a WeChat contact card.
wx messages send CHAT_ID --contact-card selfwx messages send CHAT_ID --contact-card CONTACT_IDcurl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -H "Idempotency-Key: contact-card-001" \ -d '{"kind": "contact_card", "threadId": "CHAT_ID", "contactId": "self"}' \ "$WX/accounts/$ACCOUNT/sends"The token needs send scope. Use GET /messages/{id}/card-avatar (with media scope) to fetch a card’s avatar image.
Recall a message
Recall a message you sent. You need its full id and serverId, which you can get from wx messages list CHAT_ID --json.
wx messages recall MESSAGE_ID --server-id SERVER_IDcurl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -H "Idempotency-Key: recall-001" -d '{"serverId": "SERVER_ID"}' \ "$WX/accounts/$ACCOUNT/messages/MESSAGE_ID/recall"The token needs send scope. The request returns 202 with an operation to poll.