For AI agents: markdown of this page — /docs-content-en/chats/messages/favorites-create.md documentation index — /llms.txt

Add a message to favorites

POST /v1/chats/messages/:messageId/favorite

Adds a message to the current user’s favorites in the chat where the message was sent.

Parameters

Parameter Type Required Description
ParametermessageId (path) Typeinteger Requiredyes DescriptionMessage id from message history

Requires the im scope. The credentials identify the current user. The API rejects parameters that specify the owner and any unknown parameters.

The body may be absent or {}. No body fields or query parameters are accepted. Use an API key with write access.

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/chats/messages/845/favorite" \
  -H "X-Api-Key: YOUR_API_KEY"

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/chats/messages/845/favorite" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/845/favorite', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})
const { data } = await res.json()
console.log(data)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/messages/845/favorite', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})
const { data } = await res.json()
console.log(data)

Response fields

Field Type Description
Fieldsuccess Typeboolean Descriptiontrue
Fielddata Typeboolean Descriptiontrue — the message was added to favorites

Response example

JSON
{
  "success": true,
  "data": true
}

Error response example

400 — unexpected parameter:

JSON
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Query parameter `ownerId` is not accepted by POST /v1/chats/messages/:messageId/favorite. It takes no query parameters."
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptionMalformed ID, or an unexpected or repeated parameter or body field
HTTP422 CodeBITRIX_ERROR Descriptionerror.b24Code is MESSAGE_NOT_FOUND — there is no message with this id
HTTP422 CodeBITRIX_ERROR Descriptionerror.b24Code is MESSAGE_IS_ALREADY_FAVORITE — the message is already in favorites
HTTP401 CodeMISSING_API_KEY DescriptionNo API key was provided
HTTP401 CodeTOKEN_MISSING DescriptionNo Bitrix24 credentials are configured
HTTP403 CodeSCOPE_DENIED DescriptionThe key does not have im scope
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe current user has no access
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key cannot change Bitrix24 data
HTTP404 CodeENTITY_NOT_FOUND DescriptionThe record was not found
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 refused the operation with another code, which is in error.b24Code

Common API errors.

See also