Home / Docs Center / Pet Feeder (ODM Case) / Message Module

Message Module

Pet Feeder (ODM Case) · App Server-Side API

Project: Pet Feeder | page_id: 1730

Message Authentication Interface Documentation

Overview

  • Base path: /api
  • Documentation scope: message 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": {}
}

Message Object Field Description

Field Type Description
userId integer Owning user ID
type string Message type, usually feed, device or system
title string Message title
content string Message content
read boolean Whether it has been read
createdAt string Creation time

1. Get the Message List

  • Path: /api/message/list
  • Method: POST
  • Authentication required: Yes

Request Body Parameters

Field Type Required Description
type string No Message type filter
page integer No Page number, default 1, cannot be less than 0
pageSize integer No Number of items per page, default 20, cannot be less than 0

Request Example

{
  "type": "feed",
  "page": 1,
  "pageSize": 20
}

Success Response Example

{
  "code": 200,
  "msg": "Operation successful",
  "data": {
    "list": [
      {
        "userId": 1,
        "type": "feed",
        "title": "Feeding successful",
        "content": "Device dev_001 has completed feeding",
        "read": false,
        "createdAt": "2026-05-09T10:00:00Z"
      }
    ],
    "total": 1,
    "page": 1,
    "pageSize": 20
  }
}

Failure Response Example

{
  "code": 400,
  "msg": "Incorrect page parameter",
  "data": null
}
{
  "code": 400,
  "msg": "Incorrect pageSize parameter",
  "data": null
}
{
  "code": 500,
  "msg": "Failed to get the message list",
  "data": null
}

2. Mark a Message as Read

  • Path: /api/message/markRead
  • Method: POST
  • Authentication required: Yes

Request Body Parameters

Field Type Required Description
id integer No Message ID. When 0 is passed or it is not passed, all messages of the current user are marked as read

Request Example

{
  "id": 123
}

Mark all as read:

{}

Success Response Example

{
  "code": 200,
  "msg": "Marked as read",
  "data": null
}
{
  "code": 200,
  "msg": "All marked as read",
  "data": null
}

Failure Response Example

{
  "code": 400,
  "msg": "Parameter error",
  "data": null
}
{
  "code": 400,
  "msg": "Marking failed",
  "data": null
}
{
  "code": 500,
  "msg": "Operation failed",
  "data": null
}

3. Clear Messages

  • Path: /api/message/clear
  • Method: POST
  • Authentication required: Yes

Request Body

No business parameters; an empty object can be passed:

{}

Success Response Example

{
  "code": 200,
  "msg": "Messages cleared",
  "data": null
}

Failure Response Example

{
  "code": 500,
  "msg": "Failed to clear messages",
  "data": null
}
Didn't find what you need?Contact us,Talk to our engineers directly.

Request a Quote

Fill in the form and we will get back with a quote and proposal within 1 business day.

Click "Generate inquiry email" to open your mail client with the body pre-filled. If no mail client is configured, click "Copy" and paste it into webmail — recipient: sunshiyang@xstrive.com.