WeChat Open Platform

Mini Programs Documentation

Send Service Center messages

When a user and the Mini Program Service Center generate a specific interaction (please see the descriptions below for a list of the specific actions), WeChat will push the message data to the developer. The developer can call the Service Center interface within a period of time (currently amended to 48 hours) and send messages to ordinary users by posting a JSON packet. This interface is mainly used for Service Center manual message processing functions. It makes it easier for the developer to provide users with higher quality services.

The list of currently permitted actions is as below. The number of messages that are allowed to be sent by the Service Center interface and the time limits for sending them are different after different actions are triggered. After the number of messages sent reaches the limit, an error return code will be received. Please see the return code description page for details:

User action Permitted limit for number of messages sent Time limit for sending message(s)
User enters session via Service Center Messaging Button 1 message 1 minute
User sends message 3 messages 48 hours

Service Center Interface-Send Message

Interface call request descriptions

http request methods: POST
https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN

The JSON packets required for each message type are as follows:

Text messaging

{
    "touser":"OPENID",
    "msgtype":"text",
    "text":
    {
         "content":"Hello World"
    }
}

Image messaging

{
    "touser":"OPENID",
    "msgtype":"image",
    "image":
    {
      "media_id":"MEDIA_ID"
    }

Parameter descriptions

Parameter Required Description
access_token Yes Calls interface credential
touser Yes Ordinary user openid
msgtype Yes Message type, text or image
content Yes Text message content
media_id Yes Media ID for sent image, obtained by uploading an image file using the new material interface.

Return code descriptions

Parameter Description
-1 System is busy, developers are requested to try again later
0 Request successful
40001 AppSecret error when getting access_token, or access_token invalid. Developers are requested to carefully verify AppSecret correctness, or see whether the interface for the appropriate Mini Program is being called.
40002 Illegal credential type
40003 Illegal OpenID, developers are requested to confirm whether the OpenID is the OpenID for another Mini Program
45015 Response time exceeded limit
45047 Number of messages sent by Service Center interface exceeded limit
48001 Unauthorized api function, please confirm that the Mini Program has obtained this interface