> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-restapi-chatapi-eng-38785.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Save a CometChat message to a user's private saved list with REST API on behalf of that user.

# Save Message

For the complete error reference, see [Error Guide](/articles/error-guide).


## OpenAPI

````yaml post /messages/{id}/save
openapi: 3.0.0
info:
  title: Chat APIs
  description: Manage messages, users, groups for a particular app using our Chat API.
  version: '3.0'
servers:
  - url: https://{appId}.api-{region}.cometchat.io/v3
    variables:
      appId:
        default: appId
        description: (Required) App ID
      region:
        enum:
          - us
          - eu
          - in
        default: us
        description: Select Region
security: []
tags:
  - name: API Keys
    description: The API keys are used to authorise the APIs
  - name: Roles
    description: The roles are used to give user access rights
  - name: Users
    description: The REST collection for users.
  - name: Auth Tokens
    description: The auth tokens are used to login end users using client SDKs.
  - name: Blocked Users
    description: The REST collections for blocked users.
  - name: Friends
    description: List,add and remove friends by passing UID in path variables
  - name: Groups
    description: The REST collections for groups.
  - name: Banned Users
    description: Ban and Unban user by passing other UID in path variables.
  - name: Group Members
    description: The REST collections for group members.
  - name: Messages
    description: The REST collections for messages.
  - name: Conversations
    description: The REST collections for conversations.
  - name: Restrict Features
    description: Allows Restricting Features
  - name: Metrics
    description: Allows accessing Data Metrics
  - name: Triggers
    description: Allows adding triggers to a webhook.
  - name: Webhooks
    description: Allows accessing Webhooks.
  - name: Notifications
    description: Allows configuring Notifications core.
  - name: Moderation
    description: The REST collections for Moderations.
paths:
  /messages/{id}/save:
    post:
      tags:
        - Messages
      summary: Save Message
      description: >-
        Saves a message for a user. Saved messages are private to that user, so
        the onBehalfOf header is required. Idempotent - re-saving keeps the
        original savedAt.
      operationId: save-message
      parameters:
        - $ref: '#/components/parameters/requiredonBehalfOf'
        - name: id
          in: path
          description: Id of the message to save.
          required: true
          schema:
            type: string
          examples:
            string:
              summary: Message ID
              value: ''
      responses:
        '200':
          description: >-
            Saving a message. savedAt appears only for the user the message was
            saved for.
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/messageSchema'
                type: object
              example:
                data:
                  id: '2'
                  conversationId: superhero1_user_superhero2
                  sender: superhero1
                  receiverType: user
                  receiver: superhero2
                  category: message
                  type: text
                  data:
                    text: Hi,
                  sentAt: 1700210266
                  updatedAt: 1700210266
                  savedAt: 1700210300
        '400':
          description: The user has reached their saved message limit
          content:
            application/json:
              schema:
                type: object
              example:
                error:
                  code: ERR_SAVED_MESSAGES_LIMIT_EXCEEDED
                  message: >-
                    The number of saved messages for the user with uid
                    superhero1 exceeds the allowed limit of 100.
      security:
        - apiKey: []
components:
  parameters:
    requiredonBehalfOf:
      name: onBehalfOf
      in: header
      description: UID of the user on whose behalf the action is performed.
      required: true
      schema:
        type: string
  schemas:
    messageSchema:
      description: Response data
      properties:
        id:
          type: string
        conversationId:
          type: string
        sender:
          type: string
        receiverType:
          type: string
        receiver:
          type: string
        category:
          type: string
        type:
          type: string
        data:
          properties:
            text:
              type: string
            metadata:
              type: object
            entities:
              properties:
                sender:
                  properties:
                    entity:
                      properties:
                        uid:
                          type: string
                        name:
                          type: string
                        role:
                          type: string
                        avatar:
                          type: string
                        status:
                          type: string
                        createdAt:
                          type: integer
                        conversationId:
                          type: string
                      type: object
                    entityType:
                      type: string
                  type: object
                receiver:
                  properties:
                    entity:
                      properties:
                        uid:
                          type: string
                        name:
                          type: string
                        role:
                          type: string
                        avatar:
                          type: string
                        status:
                          type: string
                        createdAt:
                          type: integer
                        conversationId:
                          type: string
                      type: object
                    entityType:
                      type: string
                  type: object
              type: object
          type: object
        sentAt:
          type: integer
        updatedAt:
          type: integer
        pinnedBy:
          description: >-
            UID of the user who pinned the message, or app_system when the app
            pinned it. Left out of the response when the message is not pinned.
          type: string
        pinnedAt:
          description: >-
            When the message was pinned, in seconds. Left out of the response
            when the message is not pinned.
          type: integer
        savedAt:
          description: >-
            When the message was saved, in seconds. Only present for the user
            who saved it, and left out of the response when they have not saved
            it.
          type: integer
      type: object
  securitySchemes:
    apiKey:
      type: apiKey
      description: API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
      name: apikey
      in: header

````