Basics
Response format
Every endpoint returns HTTP 200. The business result is in the code field of the body. Decide success by code, not by the HTTP status.
{
"code": 200,
"msg": "操作成功",
"type": "SUCCESS",
"data": {}
}
| Field | Description |
|---|---|
code | Business status code, see below |
msg | Message in Simplified Chinese, suitable for showing to users |
type | Enum name matching code; omitted by a few endpoints |
data | Payload. When there is none, the field is absent (not null) |
Status codes
| code | type | Meaning |
|---|---|---|
200 | SUCCESS | Success |
300 | WARN | Validation failed: bad signature, missing parameter, insufficient balance, wrong code, and so on. The reason is in msg |
500 | ERROR | Malformed parameters or a server error |
401 | UNAUTHORIZED | An endpoint that requires sign-in got no valid X-Auth-Token, or X-App-Code does not match the token |
-1001 | NULL_MOBILE | WeChat mini-program sign-in succeeded but the user has no phone number bound. data contains openId; prompt the user to bind a phone number, see WeChat sign-in |
tip
Most business failures return code=300 with the reason in msg. Log msg during integration to make troubleshooting easier.