WeChat Message Sending API

The WeChat Message Sending API allows applications to send messages to users who have bound their WeChat accounts. This API is designed to help developers easily push messages to users' WeChat accounts, enabling real-time notifications and interactions.


API Protocol

End Point

POST
https://huntwiz.com/v1/wechat-message

params

parametertypedescriptiondefault
message*
string
The content of the message to be sent

Code Example

curl -X POST 'https://huntwiz.com/v1/wechat-message'
--header 'Authorization: Bearer {api_key}'
--header 'Content-Type: application/json'
--data-raw '{
"message": "Hello, world\nThis is the second line"
}'

Note:

  • The message parameter should contain the content of the message to be sent and cannot be empty.
  • Use \n to represent line breaks in the message.
  • Developers are responsible for the content of the messages sent, ensuring they are legal and compliant.

Response Format

The API will return a JSON object containing the sending result:

{
"status": "success",
"message": "WeChat message sent",
"data": {
"result": "success",
"message": "Command sent successfully, waiting for execution"
},
"metadata": {
"usage": {
"credits": 3,
"remark": "api used for /v1/wechat-message"
}
}
}

Error Handling

If an error occurs, the API will return a JSON object containing error details:

{
"status": "error",
"error": {
"code": "missing_message",
"message": "Message content is required"
}
}

Common error codes include:

  • missing_message: Message content is empty or missing
  • bad_request: Incorrect request format
  • sending_failed: Message sending failed
  • insufficient_credits: Account doesn't have enough credits for this operation
  • unbind_wechat: User has not bound their WeChat account
  • illegal_content: Message content contains illegal or inappropriate information

Billing Description

Each successful API call will consume 3 credits:

  • The system will check if the account has sufficient credits before sending the message
  • If credits are insufficient, the API will return an error and not execute the sending operation
  • You can view the number of credits consumed for this request in the metadata of the API response

Usage Limitations

  • The API requires users to bind their WeChat account before sending messages
  • Message content length limit depends on WeChat platform regulations
  • The API uses asynchronous processing, it may take some time to confirm if the message was sent successfully
  • Do not send illegal, non-compliant, or other inappropriate content

Content Responsibility

Developers need to be aware when using this API:

  1. Take full responsibility for the content of the messages sent
  2. Ensure message content complies with laws, regulations, and WeChat platform's content policies
  3. Do not send illegal, non-compliant, pornographic, violent, or other inappropriate content
  4. Any legal disputes or penalties caused by content issues are the sole responsibility of the developer

Best Practices

  1. Before sending a message, ensure the user has successfully bound their WeChat account
  2. Handle various possible error situations, especially when users haven't bound their WeChat account
  3. As the API uses asynchronous processing, it's recommended to implement a retry mechanism to ensure messages are sent successfully
  4. Use this API reasonably, avoid sending messages frequently to prevent user disturbance
  5. Comply with WeChat platform's usage rules and content policies
  6. Implement a content review mechanism to ensure sent messages comply with regulations
  7. Use \n to add line breaks in messages to improve readability

Technical Support

If you have any questions or need further assistance, please feel free to contact our technical support team.