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
POSThttps://huntwiz.com/v1/wechat-message
params
parameter | type | description | default |
---|---|---|---|
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 missingbad_request
: Incorrect request formatsending_failed
: Message sending failedinsufficient_credits
: Account doesn't have enough credits for this operationunbind_wechat
: User has not bound their WeChat accountillegal_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:
- Take full responsibility for the content of the messages sent
- Ensure message content complies with laws, regulations, and WeChat platform's content policies
- Do not send illegal, non-compliant, pornographic, violent, or other inappropriate content
- Any legal disputes or penalties caused by content issues are the sole responsibility of the developer
Best Practices
- Before sending a message, ensure the user has successfully bound their WeChat account
- Handle various possible error situations, especially when users haven't bound their WeChat account
- As the API uses asynchronous processing, it's recommended to implement a retry mechanism to ensure messages are sent successfully
- Use this API reasonably, avoid sending messages frequently to prevent user disturbance
- Comply with WeChat platform's usage rules and content policies
- Implement a content review mechanism to ensure sent messages comply with regulations
- 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.