User registration interface, used to create a new user account.
Points to note
- The API uses the POST method and requires data to be submitted in application/ format
- Supports various registration methods, can use username and password or mobile phone number verification code to register
- May require graphic captcha verification
- User information and login credentials will be returned after successful registration
- Username, email, or phone number must be unique
Request address
{域名地址}/api/register
Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/register
Request Syntax
POST {域名地址}/api/register
Content-Type: application/json
Request Headers
| Field name |
Type |
Required |
Description |
| Content-Type |
string |
Is |
Fixed value: application/ |
This interface also involves common request headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Request parameters
| Field name |
Type |
Required |
Description |
| user_name |
string |
No |
Username |
| password |
string |
No |
Password |
| captcha_id |
string |
No |
Image captcha ID |
| Captcha |
string |
No |
Graphical captcha value |
| real_name |
string |
No |
Real Name |
| avatar_url |
string |
No |
Avatar address |
| email |
string |
No |
Email |
| phone |
string |
No |
Phone number |
| code |
string |
No |
Verification code (mobile verification code) |
Response header
This interface only involves public response headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Return parameters
| Field name |
Type |
Description |
| code |
int |
Error code |
| msg |
string |
Error description |
| data |
object |
User information and login credentials |
Data result parameter
| Field name |
Type |
Description |
| id |
int |
User ID |
| parent_id |
int |
Parent User ID |
| user_name |
string |
Username |
| real_name |
string |
Real Name |
| avatar_url |
string |
User avatar address |
| email |
string |
Email address |
| phone |
string |
Phone number |
| group_id |
int |
user group ID |
| is_retailer |
int |
Is a Distributor |
| balance |
int |
User Balance |
| Total Reward |
int |
Distributor Accumulated Earnings |
| Invite Code |
string |
User Invite Code |
| last login |
int |
timestamp of last login |
| expire time |
int |
expiration timestamp |
| created_time |
int |
registration timestamp |
| updated_time |
int |
update timestamp |
| status |
int |
User Display Status |
| token |
string |
Login Credentials (JWT Token) |
Usage Example
Request example (username and password registration)
POST /api/register HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"user_name": "newuser",
"password": "MyPassword123",
"real_name": "新用户",
"email": "[email protected]",
"captcha_id": "captcha123",
"captcha": "abcd"
}
Request example (phone number verification code registration)
POST /api/register HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"phone": "13800138000",
"code": "123456",
"password": "MyPassword123",
"real_name": "新用户",
"captcha_id": "captcha123",
"captcha": "abcd"
}
Response Example
{
"code": 0,
"msg": "注册成功",
"data": {
"id": 1000,
"created_time": 1669012062,
"updated_time": 1679536756,
"parent_id": 0,
"user_name": "newuser",
"real_name": "新用户",
"avatar_url": "uploads/202211/21/14f56760596b5328.webp",
"email": "[email protected]",
"phone": "13800138000",
"group_id": 2,
"status": 1,
"is_retailer": 0,
"balance": 0,
"total_reward": 0,
"invite_code": "anqicms",
"last_login": 1702912236,
"expire_time": 1997404800,
"extra": null,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"group": null,
"full_avatar_url": "",
"link": ""
}
}
error code
| Error code |
Description |
| 0 |
OK (registration successful) |
| -1 |
Error, the reason is indicated in msg |
| 1001 |
Not logged in |
| 1002 |
Not authorized |
| 200 |
API request OK |