# Message (In design...)

# Message Archiving Status

GET ***/api/v1/message/configStatus?token=***

This API is used to check whether the current Message Archiving configuration is valid, if not, a non-zero code will be returned with a specific error message.

# Request parameters:

name type required description
token string yes token for authentication

# Response:

{
  errcode: 0,
  errmsg: 'ok',
}

# Response description:

name type required description
errcode number yes return code
errmsg string yes error message

# Error Code

code description
-1 system error
-2 no message archiving config exists
-3 invalid secret
-4 empty data, might be caused by wrong RSA keys

# Get Media Url

GET ***/api/v1/message/getMediaUrl?token=***

# Request parameters:

name type required description
token string yes token for authentication
seq string yes message seq

# Response:

{
  errcode: 0,
  errmsg: 'ok',
  mediaUrl: 'https://xxx.xxxx.com/xx',
}

# Response description:

name type required description
errcode number yes return code
errmsg string yes error message
mediaUrl string yes media url for the message

# Error Code

code description
-1 there no media url in the message
-2 the media url is not downloaded yet, please retry
-3 no message found for the given seq

# Get Message

POST ***/api/v1/message/get?token=***

This API is used for actively fetch the message data from given seq. If no seq is provided, this will return back the earliest message data from the time that Message Archiving is enabled.

# Request body:

name type required description
token string yes token for authentication
pageSize number yes page size for message data
seq string no Will pull messages after this seq
date string no string in YYYY-MM-DD format, example: '2020-11-20'

TIP

  1. Max pageSize is 500.

# Response:

{
  {
  errcode: 0,
  errmsg: 'ok',
  seq: 1,
  data: [{
    wxMessageId: '8999998875080674547_1597906666',
    action: 1,
    fromId: 'string',
    roomId: 'wraHgNCAAA9sssUo6C3K_FEuiIA4FUdd',
    toList: ['wxUserId','externalContactId'],
    timestamp: 1597903969925,
    messageType: 1,
    message: object
  }]
}

# Response description:

name type required description
errcode number yes return code
errmsg string yes error message
seq string no the latest seq number for this message batch
data.wxMessageId string yes message id
data.seq string yes seq number for this message
data.action number yes 1 send message 2 revoke message
data.fromId string yes sender id, if the user is in the corp, then this will be userId, if not, this will be external_userId, if the message is from a bot, this will also be external_userId
data.roomId number no group chat id, will be undefined if the message is in a private chat
data.toList array no message receiver list, if the user is in the corp, then this will be userId, if not, this will be external_userId
data.timestamp number yes message timestamp in millisecond, utc
data.messageType number yes message type
data.message object no message content object, data type as below

# Error Code

code description
-2 no message archiving config exist

# Text

# Sample data:

{
  messageType: 1,
  action: 1,
  message: {
    content: '这是一条引用/回复消息:\n'nick\n666'\n------\n@nick777'
  }
}

# description:

name type required description
messageType number yes fixed as 1
action number yes fixed as 1
message.content string yes the message content

# Image

# Sample data:

{
  messageType: 2,
  action: 1,
  message: {
    md5sum: '50de8e5ae8ffe4f1df7a93841f71993a',
    filesize: 70961,
    sdkfileid: 'CtYBMzA2OTAyMDEwMjA0NjIzMDYwMDIwMTAwMDIwNGI3ZmU0MDZlMDIwMzBmNTliMTAyMDQ1YzliNTQ3NzAyMDQ1YzM3M2NiYzA0MjQ2NjM0MzgzNTM0NjEzNTY1MmQzNDYxMzQzODJkMzQzMTYxNjEyZDM5NjEzOTM2MmQ2MTM2NjQ2NDY0NjUzMDY2NjE2NjM1MzcwMjAxMDAwMjAzMDExNTQwMDQxMDUwZGU4ZTVhZThmZmU0ZjFkZjdhOTM4NDFmNzE5OTNhMDIwMTAyMDIwMTAwMDQwMBI4TkRkZk1UWTRPRGcxTVRBek1ETXlORFF6TWw4eE9UUTVOamN6TkRZMlh6RTFORGN4TWpNNU1ERT0aIGEwNGQwYWUyM2JlYzQ3NzQ5MjZhNWZjMjk0ZTEyNTkz',
    mediaUrl: 'https://juzi-work-message-media.s3.cn-northwest-1.amazonaws.com.cn/message/xxx/yyy/image.png'
  }
}

# Description:

name type required description
messageType number yes fixed to 2
action number yes fixed to 1
message.md5sum string yes md5 for the image
message.filesize number yes image file size
message.sdkfileid string yes image file id
message.mediaUrl string yes image file url, permanent available

# Revoke

# Sample data:

{
  messageType: 3,
  action: 2,
  message: {
    pre_msgid: '14822339130656386894_1603875600'
  }
}

# Description:

name type required description
messageType number yes fixed to 3
action number yes fixed to 2
message.pre_msgid string yes the id of revoked message

# Agree Message Archiving

# Sample data:

{
  messageType: 4,
  action: 1,
  message: {
    userid: 'wmGAgeDQAAvQeaTqWwkMTxGMkvI7OOuQ',
    agree_time: 1603875826656
  }
}

# Description:

name type required description
messageType number yes fixed to 4
action number yes fixed to 1
message.userid string yes the user id that agreed to Message Archiving, will be external_userid for contact that is not in the corp
message.agree_time number yes agree timestamp in millisecond, utc

# Disagree Message Archiving

# Sample data:

{
  messageType: 5,
  action: 1,
  message: {
    userid: 'wmGAgeDQAAvQeaTqWwkMTxGMkvI7OOuQ',
    agree_time: 1603875826656
  }
}

# Description:

name type required description
messageType number yes fixed to 5
action number yes fixed to 1
message.userid string yes the user id that disagreed to Message Archiving, will be external_userid for contact that is not in the corp
message.agree_time number yes disagree timestamp in millisecond, utc

# Voice

# Sample data:

{
  messageType: 6,
  action: 1,
  message: {
    md5sum: '9db09c7fa627c9e53f17736c786a74d5',
    voice_size: 6810,
    play_length: 10,
    sdkfileid: 'kcyZjZqOXhETGYxajB2Zkp5Rk8zYzh4RVF3ZzZGdXlXNWRjMUoxVGZxbzFTTDJnQ2YxL0NraVcxUUJNK3VUamhEVGxtNklCbjZmMEEwSGRwN0h2cU1GQTU1MDRSMWdTSmN3b25ZMkFOeG5hMS90Y3hTQ0VXRlVxYkR0Ymt5c3JmV2VVcGt6UlNXR1ZuTFRWVGtudXVldDRjQ3hscDBrMmNhMFFXVnAwT3Y5NGVqVGpOcWNQV2wrbUJwV01TRm9xWmNDRVVrcFY5Nk9OUS9GbXIvSmZvOVVZZjYxUXBkWnMvUENkVFQxTHc2N0drb2pJT0FLZnhVekRKZ1FSNDU3ZnZtdmYvTzZDOG9DRXl2SUNIOHc9PRI0TkRkZk56ZzRNVE13TVRjMk5qQTRNak0yTmw4ek5qRTVOalExTjE4eE5qQXpPRGMxTmpBNRogNzM3MDY2NmM2YTc5Njg3NDdhNzU3NDY0NzY3NTY4NjY=',
    mediaUrl: 'https://juzi-work-message-media.s3.cn-northwest-1.amazonaws.com.cn/message/ww5ecc1acd5dce6e9d/345f1eb267bd34c9cb85007278553f24/voice.amr'
  }
}

# Description:

name type required description
messageType number yes fixed to 6
action number yes fixed to 1
message.md5sum string yes md5 for the voice file
message.voice_size number yes size of the voice file
message.play_length number yes length of the voice message
message.sdkfileid string yes voice file id
message.mediaUrl string yes url for the voice file, permanent available

# Video

# Sample data:

{
  messageType: 7,
  action: 1,
  message: {
    md5sum: 'd06fc80c01d6fbffcca3b229ba41eac6',
    filesize: 15169724,
    play_length: 108,
    sdkfileid: 'MzAzMjYxMzAzNTYzMzgzMjMyMzQwMjAxMDAwMjA0MDBlNzc4YzAwNDEwZDA2ZmM4MGMwMWQ2ZmJmZmNjYTNiMjI5YmE0MWVhYzYwMjAxMDQwMjAxMDAwNDAwEjhORGRmTVRZNE9EZzFNREEyTlRjM056QXpORjgxTWpZeE9USTBOek5mTVRZd016ZzNOVFl5Tnc9PRogNTIzNGQ1NTQ5N2RhNDM1ZDhlZTU5ODk4NDQ4NzRhNDk=',
    mediaUrl: 'https://juzi-work-message-media.s3.cn-northwest-1.amazonaws.com.cn/message/ww5ecc1acd5dce6e9d/c11a6f90611a58a35b6dd46ac514fc58/video.mp4'
  }
}

# Description:

name type required description
messageType number yes fixed to 7
action number yes fixed to 1
message.md5sum string yes md5 for the video
message.filesize number yes size of the video file
message.play_length number yes length of the video message
message.sdkfileid string yes video file id
message.mediaUrl string yes video file url, permanent available

# Contact Card

# Sample data:

{
  messageType: 8,
  action: 1,
  message: {
    corpname: '微信联系人',
    userid: 'wmGAgeDQAAGjFmfnP7A3j2JxQDdLNhSw'
  }
}

# Description:

name type required description
messageType number yes fixed to 8
action number yes fixed to 1
message.corpname string yes the corp name for the contact
message.userid string yes the contact id of the contact card, will be userid for contact in the corp, external_userid for contact outside the corp

# Location

# Sample data:

{
  messageType: 9,
  action: 1,
  message: {
    longitude: 116.586285899,
    latitude: 39.911125799,
    address: '北京市xxx区xxx路xxx大厦x座',
    title: 'xxx管理中心',
    zoom: 15
  }
}

# Description:

name type required description
messageType number yes fixed to 9
action number yes fixed to 1
message.longitude number yes longitude
message.latitude number yes latitude
message.address string yes address
message.title string yes the title of the location
message.zoom number yes zoom scale

# Emoji

# Sample data:

{
  messageType: 10,
  action: 1,
  message: {
    type: 1,
    width: 290,
    height: 290,
    imagesize: 962604,
    md5sum: '94c2b0bba52cc456cb8221b248096612',
    sdkfileid: '4eE1ESTVNalE1TnprMFh6RTJNRE00TnpVMk1UST0aIDc0NzI2NjY1NzE3NTc0Nzg2ZDZlNzg2YTY5NjY2MTYx',
    mediaUrl: 'https://juzi-work-message-media.s3.cn-northwest-1.amazonaws.com.cn/message/ww5ecc1acd5dce6e9d/3fcc0e33feb95536bc362ab8caeeec68/emotion.gif'
  }
}

# Description:

name type required description
messageType number yes fixed to10
action number yes fixed to 1
message.type number yes emoji type, 1 for gif, 2 for png
message.width number yes the width of the emoji
message.height string yes the height of the emoji
message.imagesize string yes the size of the emoji file
message.md5sum string yes the md5 for the emoji
message.sdkfileid string yes emoji file id
message.mediaUrl string yes emoji file url, permanent available

# File

# Sample data:

{
  messageType: 11,
  action: 1,
  message: {
    md5sum: 'e4851a68731a228ad70a0039da361d28',
    filename: '【第20期】小程序导流到企微案例.pdf',
    fileext: 'pdf',
    filesize: 1104095,
    sdkfileid: 'CiA2Zjk0NDEzMWNjMWJjYThlZjI5ZjllNjIzNDBhMWYwZBI4TkRkZk56ZzRNVE13TURRNE5Ua3pNVFUwT0Y4NE1EZ3hNRFl3TURkZk1UWXdNRFU1TWpBd01RPT0aIDBhNTY5MmZjZTQ3NWUzMDkwMGUxOGQ1YWFmMzljN2Fk',
    mediaUrl: 'https://juzi-work-message-media.s3.cn-northwest-1.amazonaws.com.cn/message/ww5ecc1acd5dce6e9d/【第20期】小程序导流到企微案例.pdf/e4851a68731a228ad70a0039da361d28'
  }
}

# Description:

name type required description
messageType number yes fixed to 11
action number yes fixed to 1
message.md5sum string yes the md5 for the file
message.filename string yes the name of the file
message.fileext string yes the ext of the file
message.filesize number yes the size of the file
message.sdkfileid string yes the file id
message.mediaUrl string yes the file url, permanent available

# Sample data:

{
  messageType: 12,
  action: 1,
  message: {
    title: '邀请你加入群聊',
    description: '技术支持群,进入可查看详情',
    link_url: 'https://work.weixin.qq.com/wework_admin/external_room/join/exceed?vcode=xxx',
    image_url: 'https://wework.qpic.cn/wwpic/xxx/0'
  }
}

# Description:

name type required description
messageType number yes fixed to 12
action number yes fixed to 1
message.title string yes the message title
message.description string yes the link description
message.link_url string yes the link url
message.image_url string yes the thumbnail image url

# Mini Program

# Sample data:

{
  messageType: 13,
  action: 1,
  message: {
    title: '开始聊天前请仔细阅读服务须知事项',
    description: '客户需同意存档聊天记录',
    username: 'xxx@app',
    displayname: '服务须知'
  }
}

# Description:

name type required description
messageType number yes fixed to 13
action number yes fixed to 1
message.title string yes the title of the mini program
message.description string yes the description of the mini program
message.username string yes the username
message.displayname string yes the name of the mini program

# Message History

# Sample data:

{
  messageType: 14,
  action: 1,
  message: {
    title: "群聊",
    item: [{
      type: "ChatRecordText",
      msgtime: 1603875610,
      content: "{\"content\":\"test\"}",
      from_chatroom: false
    }, {
      type: 'ChatRecordText",
      msgtime: 1603875620,
      content: "{\"content\":\"test2\"}",
      from_chatroom: false
    }]
  }
}

# Description:

name type required description
messageType number yes fixed to 14
action number yes fixed to 1
message.title string yes the title of the message history
message.item array yes the content of the message history
message.item.type string yes ChatRecordText/ ChatRecordFile/ ChatRecordImage/ ChatRecordVideo/ ChatRecordLink/ ChatRecordLocation/ ChatRecordVoice/ ChatRecordCard /ChatRecordMixed /ChatRecordEmotion /chatrecord
message.item.msgtime number yes message timestamp in milliseconds, utc
message.item.content string yes the content of the message in JSON string, can be parsed to corresponding message structure
message.item.from_chatroom boolean yes whether the history if from a group chat

# Todo

# Sample data:

{
  messageType: 15,
  action: 1,
  message: {
    title: "XX创建的待办",
    content: "todo1"
  }
}

# Description:

name type required description
messageType number yes fixed to 15
action number yes fixed to 1
message.title string yes the title of the todo
message.content string yes the content of the todo

# Vote

# Sample data:

{
  messageType: 16,
  action: 1,
  message: {
    votetitle: "投票主题",
    voteitem: ["早上","中午","晚上"],
    votetype: 101,
    voteid: "4a285e038cd509b33bad86747a9a4426"
  }
}

# Description:

name type required description
messageType number yes fixed to 16
action number yes fixed to 1
message.votetitle string yes the vote message title
message.voteitem array yes the vote options
message.votetype number yes vote type, 101 is initiate a vote, 102 is participate the vote
message.voteid string yes the vote id, can be used to group the vote initiate and participant together

# Form

# Sample data:

{
  messageType: 17,
  action: 1,
  message: {
    room_name: '这是一个群',
    creator: 'nick',
    create_time: '2019-12-11 11:21:22',
    title: '这是填表title',
    details: [{
      id: 1,
      ques: '表项1,文本',
      type: 'Text'
    }, {
      id: 2,
      ques: '表项2,数字',
      type: 'Number'
    }, {
      id: 3,
      ques: '表项3,日期',
      type: 'Date'
    }, {
      id: 4,
      ques: '表项4,时间',
      type: 'Time'
    }]
  }
}

# Description:

name type required description
messageType number yes fixed to 17
action number yes fixed to 1
message.room_name string yes the group chat name that the form sent out
message.creator string yes the name for the person who sent out the form
message.create_time string yes create timestamp
message.title string yes the title of the form
message.details.id string yes the id of a single item
message.details.ques string yes the name of a single item
message.details.type string yes form item type, Text, Number, Date, Time

# Red Packet

# Sample data:

{
  messageType: 18,
  action: 1,
  message: {
    type: 1,
    wish: '恭喜发财,大吉大利',
    totalcnt: 1,
    totalamount: 3000
  }
}

# Description:

name type required description
messageType number yes fixed to 18
action number yes fixed to 1
message.type number yes red packet type: 1 normal, 2 lucky group red packet, 3 motivate group red packet
message.wish string yes the memo of the red packet
message.totalcnt number yes total count of the red packet
message.totalamount number yes total amount of the red packet

# Meeting invitation

# Sample data:

{
  messageType: 19,
  action: 1,
  message: {
    topic: "夕会",
    starttime: 1603877400,
    endtime: 1603881000,
    address: "",
    remarks: "",
    meetingtype: 102,
    meetingid: 1210342560,
    status: 1
  }
}

# Description:

name type required description
messageType number yes fixed to 19
action number yes fixed to 1
message.topic string yes the meeting topic
message.starttime number yes start time of the meeting
message.endtime number yes end time of the meeting
message.address string yes the address of the meeting
message.remarks string yes the remarks of the meeting
message.meetingtype number yes meeting message type, 101 is initiate meeting, 102 is participate with the meeting
message.meetingid number yes meeting id, can be used to group the meeting initiate and participant together
message.status number yes meeting invitation status: 1 join 2 reject 3 pending 4 not invited 5 meeting canceled 6 meeting expired 7 not in the room. this will be available only if the meetingtype is 102

# Online Doc

# Sample data:

{
  messageType: 20,
  action: 1,
  message: {
    title: '测试&演示客户',
    doc_creator: 'test',
    link_url: 'https://doc.weixin.qq.com/txdoc/excel?docid=xxx'
  }
}

# Description:

name type required description
messageType number yes fixed to 20
action number yes fixed to 1
message.title string yes the name of the online doc
message.doc_creator string yes the creator of the online doc
message.link_url string yes the link of the online doc

# MarkDown

# Sample data:

{
  messageType: 21,
  action: 1,
  message: {
    content: '请前往系统查看,谢谢。'
  }
}

# Description:

name type required description
messageType number yes fixed to 21
action number yes fixed to 1
message.content string no markdown content

# News

# Sample data:

{
  messageType: 22,
  action: 1,
  message: {
    content: '请前往系统查看,谢谢。',
    item: [{
      title: 'service',
      description: 'test',
      url: 'http://xxx',
      picurl: 'https://www.qq.com/xxx.jpg'
    }]
  }
}

# Description:

name type required description
messageType number yes fixed to 22
action number yes fixed to 1
message.item object no news item array
message.item.title string yes the title of the news item
message.item.description string yes the description of the news item
message.item.url string yes the url of the news item
message.item.picurl string yes the thumbnail image url of the news item

# Calender

# Sample data:

{
  messageType: 23,
  action: 1,
  message: {
    title: "xxx业绩复盘会",
    creatorname: "test",
    attendeename: ["aaa","bbb"],
    starttime: 1603882800,
    endtime: 1603886400,
    place: "",
    remarks: ""
  }
}

# Description:

name type required description
messageType number yes fixed to 22
action number yes fixed to 1
message.title string yes the title of the calender event
message.creatorname string yes the creator of the calendar event
message.attendeename array yes the attendee of the calendar event
message.starttime number yes start time of the calendar event in millisecond, utc
message.endtime number yes end time of the calendar event in millisecond, utc
message.place string yes the address of the calendar event
message.remarks string yes the remarks of the calendar event

# Mixed

# Sample data:

{
  messageType: 24,
  action: 1,
  message: {
    item: [{
      type: "text",
      content: "{\"content\":\"你好[微笑]\\n\"}"
    }]
  }
}

# Description:

name type required description
messageType number yes fixed to 23
action number yes fixed to 1
message.item array yes each item is composed with type and content to represent a single message
message.item.type string yes the message type of the single message
message.item.content array yes the message content in JSON string, can be parsed to corresponding message types

# Meeting Call

# Sample data:

{
  messageType: 25,
  action: 1,
  message: {
    endtime: 1594197635,
    sdkfileid: 'CpsBKjAqd0xhb2JWRUJldGtwcE5DVTB6UjRUalN6c09vTjVyRnF4YVJ5M24rZC9YcHF3cHRPVzRwUUlaMy9iTytFcnc0SlBkZDU1YjRNb0MzbTZtRnViOXV5WjUwZUIwKzhjbU9uRUlxZ3pyK2VXSVhUWVN2ejAyWFJaTldGSkRJVFl0aUhkcVdjbDJ1L2RPbjJsRlBOamJaVDNnPT0SOE5EZGZNVFk0T0RnMU16YzVNVGt5T1RJMk9GOHhNalk0TXpBeE9EZzJYekUxT1RReE9UYzJNemM9GiA3YTYyNzA3NTY4Nzc2MTY3NzQ2MTY0NzA2ZTc4NjQ2OQ==',
    demofiledata: [{
      filename: '65eb1cdd3e7a3c1740ecd74220b6c627.docx',
      demooperator: 'wo137MCgAAYW6pIiKKrDe5SlzEhSgwbA',
      starttime: 1594197599,
      endtime: 1594197609
    }],
    sharescreendata: [{
      share: 'wo137MCgAAYW6pIiKKrDe5SlzEhSgwbA',
      starttime: 1594197624,
      endtime: 1594197624
    }]
  }
}

# Description:

name type required description
messageType number yes fixed to 24
action number yes fixed to 1
message.endtime number yes the end time of the meeting call
message.sdkfileid string yes audio file id
message.demofiledata.filename string yes share file name
message.demofiledata.demooperator string yes the userid of the demo operator
message.demofiledata.starttime number yes the start time of the meeting call
message.demofiledata.endtime number yes the end time of the file sharing
message.sharescreendata.share string yes the userid of the user that share the screen
message.sharescreendata.starttime number yes the start time of screen sharing
message.sharescreendata.endtime number yes the end time of screen sharing

# Audio Call

# Sample data:

{
  messageType: 26,
  action: 1,
  message: {
    filename: '欢迎使用微盘.pdf.pdf',
    md5sum: 'ff893900f24e55e216e617a40e5c4648',
    filesize: 4400654,
    sdkfileid: 'CpsBKjAqZUlLdWJMd2gvQ1JxMzd0ZjlpdW5mZzJOOE9JZm5kbndvRmRqdnBETjY0QlcvdGtHSFFTYm95dHM2VlllQXhkUUN5KzRmSy9KT3pudnA2aHhYZFlPemc2aVZ6YktzaVh3YkFPZHlqNnl2L2MvcGlqcVRjRTlhZEZsOGlGdHJpQ2RWSVNVUngrVFpuUmo3TGlPQ1BJemlRPT0SOE5EZGZNVFk0T0RnMU16YzVNVGt5T1RJMk9GODFNelUyTlRBd01qQmZNVFU1TkRFNU9USTFOZz09GiA3YTcwNmQ2Zjc5NjY3MDZjNjY2Zjc4NzI3NTZmN2E2YQ=='
  }
}

# Description:

name type required description
messageType number yes fixed to 25
action number yes fixed to 1
message.filename string yes the shared file name
message.md5sum string yes the md5 for the audio file
message.filesize number yes the size of the audio file
message.sdkfileid string yes the file id of the audio file
Latest update: 12/4/2020, 11:37:01 AM