Project: Pet Feeder | page_id: 1727
Family Authentication Interface Documentation
Overview
- Base path: /api
- Documentation scope: family module interfaces in the authenticated routes
- Authentication method: request header X-Token
- Content-Type: application/json
Authentication Header
| Field |
Type |
Required |
Description |
| X-Token |
string |
Yes |
The JWT Token obtained after the user logs in |
Unified Response Format
{
"code": 200,
"msg": "Operation successful",
"data": {}
}
Response Field Description
| Field |
Type |
Description |
| code |
integer |
Business status code; 200 means success, other values mean failure |
| msg |
string |
Response message |
| data |
object/array/null |
Business data |
Family Object Field Description
| Field |
Type |
Description |
| id |
string |
Family ID |
| name |
string |
Family name |
| ownerId |
integer |
User ID of the family creator |
| createdAt |
string |
Creation time |
| updatedAt |
string |
Update time |
Family Detail Member Field Description
| Field |
Type |
Description |
| id |
integer |
User ID |
| nickname |
string |
User nickname |
| phone |
string |
Mobile phone number |
| role |
string |
Role, owner or member |
1. Get the Family List
- Path: /api/family/list
- Method: POST
- Authentication required: Yes
Request Body
No business parameters; an empty object can be passed:
{}
Success Response Example
{
"code": 200,
"msg": "Operation successful",
"data": [
{
"id": "family_001",
"name": "My Family",
"ownerId": 1,
"createdAt": "2026-05-09T10:00:00Z",
"updatedAt": "2026-05-09T10:00:00Z"
}
]
}
Response Parameter Description
| Field |
Type |
Description |
| code |
integer |
200 on success |
| msg |
string |
Operation successful on success |
| data |
array |
Family list |
| data[].* |
object |
Family object fields, see the family object field description above |
Failure Response Example
{
"code": 500,
"msg": "Failed to get the family list",
"data": null
}
2. Get Family Details
- Path: /api/family/detail
- Method: POST
- Authentication required: Yes
Request Body Parameters
| Field |
Type |
Required |
Description |
| id |
string |
Yes |
Family ID |
Request Example
{
"id": "family_001"
}
Success Response Example
{
"code": 200,
"msg": "Operation successful",
"data": {
"id": "family_001",
"name": "My Family",
"ownerId": 1,
"members": [
{
"id": 1,
"nickname": "Xiaoming",
"phone": "13800138000",
"role": "owner"
}
],
"createdAt": "2026-05-09T10:00:00Z"
}
}
Response Parameter Description
| Field |
Type |
Description |
| code |
integer |
200 on success |
| msg |
string |
Operation successful on success |
| data.id |
string |
Family ID |
| data.name |
string |
Family name |
| data.ownerId |
integer |
Creator user ID |
| data.members |
array |
Family member list |
| data.members[].* |
object |
Member object fields, see the family detail member field description above |
| data.createdAt |
string |
Creation time |
Failure Response Example
{
"code": 400,
"msg": "Parameter error",
"data": null
}
{
"code": 404,
"msg": "Family does not exist",
"data": null
}
3. Create a Family
- Path: /api/family/create
- Method: POST
- Authentication required: Yes
Request Body Parameters
| Field |
Type |
Required |
Description |
| name |
string |
Yes |
Family name, at most 30 characters, allowing only Chinese characters, letters, digits, underscores and hyphens |
Request Example
{
"name": "My Family"
}
Success Response Example
{
"code": 200,
"msg": "Family created successfully",
"data": {
"id": "family_001",
"name": "My Family",
"ownerId": 1,
"createdAt": "2026-05-09T10:00:00Z",
"updatedAt": "2026-05-09T10:00:00Z"
}
}
Response Parameter Description
| Field |
Type |
Description |
| code |
integer |
200 on success |
| msg |
string |
Family created successfully on success |
| data.* |
object |
Family object fields, see the family object field description above |
Failure Response Example
{
"code": 400,
"msg": "The family name cannot exceed 30 characters",
"data": null
}
{
"code": 400,
"msg": "The family name can only contain Chinese characters, letters, digits, underscores and hyphens",
"data": null
}
4. Change the Family Name
- Path: /api/family/updateName
- Method: POST
- Authentication required: Yes
Request Body Parameters
| Field |
Type |
Required |
Description |
| familyId |
string |
Yes |
Family ID |
| name |
string |
Yes |
New family name |
Request Example
{
"familyId": "family_001",
"name": "New family name"
}
Success Response Example
{
"code": 200,
"msg": "Family name changed successfully",
"data": null
}
Response Parameter Description
| Field |
Type |
Description |
| code |
integer |
200 on success |
| msg |
string |
Family name changed successfully on success |
| data |
null |
No returned data |
Failure Response Example
{
"code": 400,
"msg": "Family does not exist",
"data": null
}
{
"code": 400,
"msg": "Only the family creator can change the family name",
"data": null
}
5. Generate an Invitation Link
- Path: /api/family/invite
- Method: POST
- Authentication required: Yes
Request Body Parameters
| Field |
Type |
Required |
Description |
| familyId |
string |
Yes |
Family ID |
Request Example
{
"familyId": "family_001"
}
Success Response Example
{
"code": 200,
"msg": "Invitation link generated",
"data": {
"inviteCode": "a1b2c3d4",
"inviteUrl": "https://example.com/invite/a1b2c3d4",
"expireSeconds": 86400
}
}
Response Parameter Description
| Field |
Type |
Description |
| code |
integer |
200 on success |
| msg |
string |
Invitation link generated on success |
| data.inviteCode |
string |
Invitation code |
| data.inviteUrl |
string |
Invitation link |
| data.expireSeconds |
integer |
Invitation code validity period, in seconds |
Failure Response Example
{
"code": 400,
"msg": "Family does not exist",
"data": null
}
{
"code": 400,
"msg": "Only the family creator can invite members",
"data": null
}
{
"code": 400,
"msg": "Operation failed, please try again",
"data": null
}
{
"code": 400,
"msg": "Failed to generate the invitation code, please try again",
"data": null
}
6. Join a Family with an Invitation Code
- Path: /api/family/join
- Method: POST
- Authentication required: Yes
Request Body Parameters
| Field |
Type |
Required |
Description |
| inviteCode |
string |
Yes |
Invitation code |
Request Example
{
"inviteCode": "a1b2c3d4"
}
Success Response Example
{
"code": 200,
"msg": "Joined successfully",
"data": {
"familyId": "family_001",
"familyName": "My Family"
}
}
Response Parameter Description
| Field |
Type |
Description |
| code |
integer |
200 on success |
| msg |
string |
Joined successfully on success |
| data.familyId |
string |
Family ID after joining |
| data.familyName |
string |
Family name after joining |
Failure Response Example
{
"code": 400,
"msg": "Parameter error",
"data": null
}
{
"code": 400,
"msg": "You are already a member of this family",
"data": null
}
7. Remove a Member
- Path: /api/family/removeMember
- Method: POST
- Authentication required: Yes
Request Body Parameters
| Field |
Type |
Required |
Description |
| familyId |
string |
Yes |
Family ID |
| memberId |
integer |
Yes |
User ID of the member to remove |
Request Example
{
"familyId": "family_001",
"memberId": 2
}
Success Response Example
{
"code": 200,
"msg": "Member removed",
"data": null
}
Response Parameter Description
| Field |
Type |
Description |
| code |
integer |
200 on success |
| msg |
string |
Member removed on success |
| data |
null |
No returned data |
Failure Response Example
{
"code": 400,
"msg": "Family does not exist",
"data": null
}
{
"code": 400,
"msg": "Only the family creator can remove members",
"data": null
}
{
"code": 400,
"msg": "You cannot remove yourself",
"data": null
}
Appendix
Description
- family/list currently does not read the business request body; either an empty object or an empty body works.
- This document only covers the authenticated routes and does not include the public invitation page /invite/:code.
Failure Response Example
{
"code": 400,
"msg": "Family does not exist",
"data": null
}
{
"code": 400,
"msg": "Only the family creator can remove members",
"data": null
}
{
"code": 400,
"msg": "You cannot remove yourself",
"data": null
}
Appendix
Description
- family/list currently does not read the business request body; either an empty object or an empty body works.
- This document only covers the authenticated routes and does not include the public invitation page /invite/:code.