Group Tool Backend Development
1. Interface Description
The common server-side interfaces are encapsulated in the MiniAppCommonService service class from the public module. You can obtain an instance by injecting this service class. Usage example:
@Resource
private MiniAppCommonService miniAppCommonService;
ApplicationVo application = miniAppCommonService.getApplication();
// ...Before using the server-side interfaces, you must correctly configure the Group Tool's appKey and appSecret. These are mainly used for signing request parameters when the Group Tool backend initiates requests to the Mos server. Developers do not need to concern themselves with the specific signing method — the public service has already encapsulated it. After injecting the corresponding service, you can directly call the specific methods.
1.1 Interface BaseURL
- Test environment: https://mos-test.mos.me
- Production environment: https://mos.mos.me
1.2 Interface Signature
If calling directly via HTTP, the request Body must include the following fields:
- appKey: Group Tool App Key
- sign: Signature
Signature generation rule: Sort all parameters (including appKey) in ascending order, convert them to QueryString format (e.g., key1=value1&key2=value2...), then append secret=appSecret at the end, and finally perform MD5 on the resulting string. Java example code:
import org.springframework.util.DigestUtils;
/**
* Get signature
*
* @param request Request object (Object used here as example; replace with actual request type or base class)
* @return Signature
*/
public String getSign(Object request) {
// Convert request to a key-ordered TreeMap (ascending by default), "appKey" must be included
Map<String, String> requestSortedMap = JSON.parseObject(JSON.toJSONString(request), new TypeReference<TreeMap<String, String>>() {
});
requestSortedMap.put("appKey", "<your_app_key>");
// Convert request to QueryString format, e.g., key1=value1&key2=value2...
StringBuilder qsBuilder = new StringBuilder();
for (Map.Entry<String, String> entry : requestSortedMap.entrySet()) {
// "sign" or empty values do not participate in signing
if ("sign".equals(entry.getKey()) || entry.getValue() == null || entry.getValue().isEmpty()) {
continue;
}
qsBuilder.append(entry.getKey()).append("=").append(entry.getValue().trim()).append("&");
}
// Append "secret=your_app_secret" at the end
qsBuilder.append("secret=").append("<your_app_secret>");
// MD5 processing
return DigestUtils.md5DigestAsHex(qsBuilder.toString().getBytes(StandardCharsets.UTF_8));
}2. Login & Authentication
2.1 Get Application Information
API: MiniAppCommonService.getApplication()
HTTP: POST /open-apis/application/v1/getApplication
Get Group Tool application information
Parameters
None (signature still required)
Response
| Field | Type | Description |
|---|---|---|
| appName | String | Application name |
| appKey | String | Application key |
| appSecret | String | Application secret |
| description | String | Application description |
| status | Boolean | Application status |
| notifyUrl | String | Callback URL |
2.2 Universal Login
API: MiniAppCommonService.miniAppLogin(String code)
A universal login interface provided by the public module. It uses the code obtained from the Group Tool frontend and JWT to generate an identity token. After creating a new Group Tool module, a default login interceptor com.testproject.mos.miniapp.xxx.interceptor.LoginInterceptor is included. This interceptor validates the token passed from the Group Tool frontend in the format of Bearer token via HTTP Header:
Authorization: Bearer <token>After authentication passes, use the logged-in user's openid to call the "Get Current User Information" interface and retrieve Mos user profile information (the Group Tool must maintain its own user table with a column storing openid).
If the universal login does not meet your needs, you may override the login interceptor and implement your own login and current user information retrieval interfaces.
Note: Do not modify the code in the public module.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| code | String | Yes | Code obtained via mos.login in Group Tool |
Response TokenVo
| Field | Type | Description |
|---|---|---|
| token | String | Identity token |
2.3 Get Current User Information
HTTP: POST /open-apis/mp/v1/miniApp/getMosUserInfo
Get Mos user profile information by openid.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| openid | String | Yes | User unique identifier |
Response MosUserInfoVo
| Field | Type | Description |
|---|---|---|
| lastName | String | Last name |
| firstName | String | First name |
| headPortrait | String | Avatar |
| descriptor | String | Description |
| String | ||
| openId | String | User unique identifier |
| appKey | String | Application key |
2.4 Exchange Code for Mos Session
API: MiniAppCommonService.code2session(String code)
HTTP: POST /open-apis/mp/v1/auth/code2session
Get Mos session information using code
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| code | String | Yes | Code obtained via mos.login in Group Tool |
Response MosSessionVo
| Field | Type | Description |
|---|---|---|
| openid | String | User unique identifier |
| sessionKey | String | Session key (currently unused) |
3. QR Code Login
3.1 Generate QR Code
HTTP: POST /open-apis/mp/v1/auth/getLoginQrCodeUrl
Generate a QR code for Group Tool scan-to-login. Expires in 120 seconds. The Group Tool uses this string to generate the QR code image.
Request Body
None (signature still required)
Response Body
| Field | Type | Description |
|---|---|---|
| qrCode | String | QR code string, format: https://mos.me/miniapp-open/login/{uuid} |
| uuid | String | QR code UUID string |
3.2 Check QR Code Status
HTTP: POST /open-apis/mp/v1/auth/getLoginQrCodeStatus
Check the status of the QR code. Returns user information upon successful scan.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| qrCodeUuid | String | Yes | QR code UUID string |
Response Body
| Field | Type | Description |
|---|---|---|
| status | String | 'NO_SCAN': Not scanned | 'SCAN': Scanned |
| mosOpenUserVo | MosOpenUserVo | User info (available only after successful scan) |
Response MosOpenUserVo
| Field | Type | Description |
|---|---|---|
| openId | String | User unique identifier |
| firstName | String | First name |
| lastName | String | Last name |
| headPortrait | String | Avatar URL |
4. Customer Service Account
4.1 Create Customer Service Account
HTTP: POST /open-apis/mp/v1/customerServ/create
Create a customer service account
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| openid | String | Yes | User unique identifier |
| name | String | Yes | Customer service name |
| headPortrait | String | No | Customer service head portrait, no default value automatically generated |
Response Body
| Field | Type | Description |
|---|---|---|
| token | String | Customer service account identifier |
| webHook | String | Webhook address of the account |
| name | String | Customer service name |
| headPortrait | String | Customer service avatar |
| descriptor | String | Customer service description |
| idNumber | String | Unique ID of the customer service |
| link | String | Customer service link |
4.2 Send Message
HTTP: POST /open-apis/mp/v1/customerServ/{token}/sendMessage
Send a message to a specified user via the customer service bot (implemented by combining content and msgType fields in different ways)
Path Parameter
| Field | Type | Required | Description |
|---|---|---|---|
| token | String | Yes | Customer service account identifier |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| openid | String | Yes | Recipient user unique identifier |
| content | Content | Yes | Message content, see Content |
Content
| Field | Type | Required | Description |
|---|---|---|---|
| msgType | String | Yes | Message type: TEXT (plain text) | CARD (card message) | ORDER (order message) |
| text | String | No | Message text, max length 5000 characters (required when msgType=TEXT) |
| inlineButtons | List<List<InlineButton>> | No | Inline buttons (available for any message type), see InlineButton |
| cardMessage | CardMessage | No | Card message body (required when msgType=CARD), see CardMessage |
| orderMessage | OrderMessage | No | Order message body (required when msgType=ORDER), see OrderMessage |
InlineButton
| Field | Type | Required | Description |
|---|---|---|---|
| text | String | Yes | Button label, max length 100 characters |
| type | String | Yes | Button type: callback (callback request) | miniApp (group tool jump) | url (external link or internal link opened in Mos) |
| data | String | Yes | Button data, developer-defined content |
Inline Button Limits
- Up to 4 buttons per row (i.e., each inner list can contain at most 4
InlineButtonobjects) - No more than 40 buttons in total
Inline Button Type Details
callback: When the user clicks, MosApp sends an event to the customer service group tool backend via webhook, passing the button’sdatavalue.url: Opens the specified link in the browser; for internal links (such as user, group, channel), opens inside MosApp.miniApp: Opens the bound group tool directly when clicked.
Inline Button Data Description
- For
callback,datais a string configured by the customer service group tool backend; MosApp forwards it transparently when the user clicks.
Callback webhook request body format:
{
"reqId": "Unique request id",
"data": "data"
}- For
url,datais an external URL or a MosApp internal link. - For
miniApp,datacan configure page path and other info; MosApp appends it to the group tool URL as query parameters.
CardMessage
| Field | Type | Required | Description |
|---|---|---|---|
| title | String | Yes | Title, max length 500 characters |
| messageTitle | String | No | Message title, max length 500 characters |
| cover | String | No | Cover image URL, max length 1000 characters |
| price | String | No | Price, range[0.00-99999999.99] |
| linePrice | String | No | Strikethrough price, range[0.00-99999999.99] |
OrderMessage
| Field | Type | Required | Description |
|---|---|---|---|
| title | String | Yes | Title, max length 500 characters |
| status | String | Yes | Status, max length 100 characters |
| color | String | No | Status color, optional: BLUE,GREEN,RED,GREY, default: GREY |
| text | String | Yes | Text, max length 5000 characters |
| paymentStatus | String | No | Payment status, max length 100 characters |
| currency | String | No | currency , optional: USD, if price is provided, this field must be filled |
| price | String | No | Price, range[0.00-99999999.99] |
Response Body
None
4.3 Get Customer Service Account Info
HTTP: POST open-apis/mp/v1/customerServ/getInfo
Get customer service account information
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| token | String | Yes | Customer service account identifier |
Response Body
| Field | Type | Description |
|---|---|---|
| token | String | Customer service account identifier |
| webHook | String | Webhook address of the account |
| name | String | Customer service name |
| headPortrait | String | Customer service avatar |
| descriptor | String | Customer service description |
| idNumber | String | Unique ID of the customer service |
| link | String | Customer service link |
4.4 Update Customer Service Account Info
HTTP: POST /open-apis/mp/v1/customerServ/updateInfo
Update customer service account information
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| token | String | Yes | Customer service account identifier |
| name | String | No | Customer service name, max length 30 |
| headPortrait | String | No | Customer service avatar, max length 1000 |
| descriptor | String | No | Customer service description, max length 300 |
| idNumber | String | No | Unique ID of the customer service, max length 30 |
Notes
- At least one of name, headPortrait, descriptor, idNumber must be provided
- idNumber is the unique identifier of the customer service and must be unique
Response Body
| Field | Type | Description |
|---|---|---|
| token | String | Customer service account identifier |
| webHook | String | Webhook address of the account |
| name | String | Customer service name |
| headPortrait | String | Customer service avatar |
| descriptor | String | Customer service description |
| idNumber | String | Unique ID of the customer service |
| link | String | Customer service link |
4.5 Reset Customer Service Account Token
HTTP: POST /open-apis/mp/v1/customerServ/resetToken
Reset the customer service account token
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| token | String | Yes | Customer service account identifier |
Response Body
| Field | Type | Description |
|---|---|---|
| token | String | Customer service account identifier |
| webHook | String | Webhook address of the account |
| name | String | Customer service name |
| headPortrait | String | Customer service avatar |
| descriptor | String | Customer service description |
| idNumber | String | Unique ID of the customer service |
| link | String | Customer service link |
4.6 Set Customer Service Account Webhook
HTTP: POST /open-apis/mp/v1/customerServ/setWebHook
Set the webhook of the customer service account, i.e., the callback URL for button events
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| token | String | Yes | Customer service account identifier |
| webHook | String | Yes | Webhook URL , if empty then delete the webhook, max length 300 |
Response Body
| Field | Type | Description |
|---|---|---|
| token | String | Customer service account identifier |
| webHook | String | Webhook address of the account |
| name | String | Customer service name |
| headPortrait | String | Customer service avatar |
| descriptor | String | Customer service description |
| idNumber | String | Unique ID of the customer service |
| link | String | Customer service link |
4.7 Create Customer Service Group
HTTP: POST /open-apis/mp/v1/customerServ/createGroup
Create a customer service group as the owner of the customer service account.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| token | String | Yes | Unique identifier of the customer service account |
| name | String | Yes | Name of the customer service group, maximum length 30 |
| headPortrait | String | No | Avatar of the customer service group, maximum length 1000 |
| description | String | No | Description of the customer service group, maximum length 300 |
| inviteUserList | List<InviterUser> | Yes | List of users to invite to the customer service group |
InviterUser Parameter
| Field | Type | Required | Description |
|---|---|---|---|
| miniAppUser | miniAppUser | No | Group tool user information, refer to the parameters below |
| MosUser | mosUser | No | Mos user information, refer to the parameters below |
miniAppUser Parameter
| Field | Type | Required | Description |
|---|---|---|---|
| openid | String | Yes | Group tool user unique openid |
| appKey | String | Yes | Group tool unique appKey |
mosUser Parameter
| Field | Type | Required | Description |
|---|---|---|---|
| phone | String | Yes | User phone number |
| dialCode | String | Yes | User dial code |
Response Body
| Field | Type | Description |
|---|---|---|
| link | String | Link of the customer service group |
| name | String | Name of the customer service group |
| headPortrait | String | Avatar of the customer service group |
| description | String | Description of the customer service group |
4.8 Disband Customer Service Group
HTTP: POST /open-apis/mp/v1/customerServ/disbandGroup
Disband a customer service group as the owner of the customer service account.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| token | String | Yes | Unique identifier of the customer service account |
| link | String | Yes | Link of the customer service group |
Response Body
None
5. Group Tool
After a group tool launches, call mos.getLaunchOptions() to get the group ID (conversationId) for subsequent Open APIs.
try {
const res = await mos.getLaunchOptions()
console.log('launch options', res)
const conversationId = res?.query?.conversationId
} catch (error) {
console.error('failed to get launch options')
}5.1 Page Group Members
HTTP: POST /open-apis/mp/v1/conversation/pageMemberRole
Page valid group members by conversation (group) ID. Supports filtering by role and nickname keyword.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| conversationId | Long | Yes | Conversation (group) ID, from launch options query.conversationId |
| roles | List<Integer> | No | Role filter: 1 member, 2 admin, 3 owner; omit or empty to query all roles |
| name | String | No | Nickname keyword; omit to skip this filter |
| pageNum | Integer | No | Page number, default 1 |
| pageSize | Integer | No | Page size, default 30, max 100 |
Response Body
| Field | Type | Description |
|---|---|---|
| total | Integer | Total count |
| pageNum | Integer | Page number |
| pageSize | Integer | Page size |
| records | List<Member> | Member list, see Member |
Response Member
| Field | Type | Description |
|---|---|---|
| openId | String | User unique identifier |
| firstName | String | First name |
| lastName | String | Last name |
| headPortrait | String | Avatar |
| role | Integer | Role: 1 member, 2 admin, 3 owner |