MessagesMessagesPin Message

Pin a Message

Overview

This endpoint allows chatroom owners or administrators to pin a specified message to the top of a chatroom, making it easy for members to quickly access important messages. Each chatroom can only have one pinned message at a time.


API Endpoint

Pin a Message

Pin a specified message to the top of a chatroom.

POST /messages/:id/pin

Headers

ParameterTypeRequiredDescription
IM-CLIENT-KEYstringClient Key
IM-AuthorizationstringClient Token

Path Parameters

ParameterTypeRequiredDescription
:idstringMessage unique ID

This API does not require a Request Body.

Example Request

cURL Example:

curl -X "POST" "https://your-app.imkit.io/messages/5f890cf37d980e06f6aaf349/pin" \
     -H 'IM-CLIENT-KEY: {IM-CLIENT-KEY}' \
     -H 'IM-Authorization: {IM-Authorization}'

JavaScript Example:

const response = await axios.post(
  `https://your-app.imkit.io/messages/${messageID}/pin`,
  null,
  {
    headers: {
      "IM-CLIENT-KEY": `${IM_CLIENT_KEY}`,
      "IM-Authorization": `${TOKEN}`,
    },
  }
);

Response

Success Response (200 OK)

ParameterTypeDescription
RCnumberResponse code (0 indicates success)
RMstringResponse message
result._idstringMessage unique ID
result.messagestringMessage content
result.roomstringAssociated chatroom ID
result.senderobjectMessage sender information
result.messageTypestringMessage type
result.pinnedbooleanWhether the message is pinned (true after pinning)
result.messageTimeMSnumberMessage sent timestamp (milliseconds)
result.updatedAtMSnumberLast updated timestamp (milliseconds)

Example Response

{
  "RC": 0,
  "RM": "OK",
  "result": {
    "_id": "5f890cf37d980e06f6aaf349",
    "message": "重要公告:明天下午兩點開會",
    "room": "demo-room",
    "sender": {
      "_id": "aaa",
      "nickname": "AAA",
      "avatarUrl": "http://loremflickr.com/240/240/style?1569804629",
      "isRobot": false,
      "id": "aaa",
      "lastLoginTimeMS": 1602817267900
    },
    "messageType": "text",
    "appID": "SampleApp",
    "pinned": true,
    "id": "5f890cf37d980e06f6aaf349",
    "messageTimeMS": 1602817267923,
    "updatedAtMS": 1602817290000,
    "createdAtMS": 1602817267925
  }
}

Error Response

When a request fails, you will receive an error response containing error details. Common error scenarios include:

  • Invalid client key or authorization token
  • The specified message does not exist
  • The current user is not the chatroom owner or administrator
  • Internal server error

Use Cases

Important Message Management

  • Pin Announcements: Pin important announcements to the top of a chatroom to ensure all members can see them
  • Quick Reference: Allow members to find key information without scrolling through message history

Notes

  • Permission Restriction: Only chatroom owners or admins can perform the pin operation
  • To unpin a message, use the Unpin a Message API
© 2026 FUNTEK Software Inc. All rights reserved.