Registration Interface

User registration interface, used to create a new user account.

Precautions

  • This interface uses the POST method and requires data to be submitted in application/ format
  • Supports multiple registration methods, can be registered using username and password or mobile phone number verification code
  • May require graphic verification code verification
  • Registration successful, returning user information and login credentials
  • Username, email, or phone number must be unique

Request address

{域名地址}/api/register

Description:{域名地址}Need to replace it with your domain address, such ashttps://en.anqicms.com/api/register

Request syntax

POST {域名地址}/api/register
Content-Type: application/json

Request header

Field Name Type Required Description
Content-Type string Yes Fixed value: application/

This interface also involves common request headers. For more information, please seeCommon 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 verification code ID
captcha string No Image verification code value
Real Name string No True Name
avatar_url string No Avatar address
email string No Email
phone string No Phone number
code string No Verification code (phone verification code)

Response Headers

This interface only involves public response headers. More information, please refer toCommon Request Headers (Common Request Headers).

Return parameters

Field Name Type Description
code integer Error code
message string Error Description
data object User information and login credentials

Data result parameters

Field Name Type Description
id integer User ID
parent_id integer Parent user ID
user_name string Username
Real Name string True Name
avatar_url string User avatar address
email string Email Address
phone string Phone number
group_id integer User Group ID
is_retailer integer Is the retailer
balance integer User Balance
Total Reward integer Distributor Cumulative Earnings
Invite Code string User invitation code
Last login integer Timestamp of the last login
Expire time integer Expiration timestamp
created_time integer registration timestamp
updated_time integer update timestamp
status integer User display status
token string Login credentials (JWT token)

Example Usage

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 Unauthorized
200 API request OK