> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Chat Message

> Delete a chat message. Users can delete messages only in the following cases:
  * The **Allow Message Deleting** setting is enabled in the workspace's **Message** settings.
  * If the **Block Message Deleting After (n) Minutes** message setting has a non-zero value, the `bypass-time-limit-edit-and-delete` permission is required to delete messages after the defined time limit.
  * In read-only rooms, the `post-readonly` permission is required to delete messages, or the user must be unmuted.
  * The `delete-own-message` permission is required to delete users' own messages.
  * The `delete-message` permission is required for users to delete messages from other users.

### Changelog
| Version      | Description | 
| ---------------- | ------------|
| 0.48.0           | Added       |


## OpenAPI

````json POST /api/v1/chat.delete
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Messaging"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "tags": [
    {
      "name": "Chat"
    },
    {
      "name": "DM"
    },
    {
      "name": "Auto-Translate"
    }
  ],
  "paths": {
    "/api/v1/chat.delete": {
      "post": {
        "tags": [
          "Chat"
        ],
        "summary": "Delete Chat Message",
        "description": "Delete a chat message. Users can delete messages only in the following cases:\n  * The **Allow Message Deleting** setting is enabled in the workspace's **Message** settings.\n  * If the **Block Message Deleting After (n) Minutes** message setting has a non-zero value, the `bypass-time-limit-edit-and-delete` permission is required to delete messages after the defined time limit.\n  * In read-only rooms, the `post-readonly` permission is required to delete messages, or the user must be unmuted.\n  * The `delete-own-message` permission is required to delete users' own messages.\n  * The `delete-message` permission is required for users to delete messages from other users.\n\n### Changelog\n| Version      | Description | \n| ---------------- | ------------|\n| 0.48.0           | Added       |\n",
        "operationId": "post-api-v1-chat.delete",
        "parameters": [
          {
            "$ref": "#/components/parameters/Auth-Token"
          },
          {
            "$ref": "#/components/parameters/UserId"
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "roomId": {
                    "type": "string",
                    "description": "The room ID"
                  },
                  "msgId": {
                    "type": "string",
                    "description": "The ID of the message to delete."
                  },
                  "asUser": {
                    "type": "boolean",
                    "description": "Should the message be deleted as the user who sent it? It is `false` by default."
                  }
                },
                "required": [
                  "roomId",
                  "msgId"
                ]
              },
              "examples": {
                "Example": {
                  "value": {
                    "roomId": "ByehQjC44FwMeiLbX",
                    "msgId": "7aDSXtjMA3KPLxLjt",
                    "asUser": "false"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "_id": {
                      "type": "string"
                    },
                    "ts": {
                      "type": "string"
                    },
                    "message": {
                      "type": "object",
                      "properties": {
                        "_id": {
                          "type": "string"
                        },
                        "rid": {
                          "type": "string"
                        },
                        "u": {
                          "type": "object",
                          "properties": {
                            "_id": {
                              "type": "string"
                            },
                            "username": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "_id": "jEnjsxuoDJamGjbH2",
                      "ts": "1696533809813",
                      "message": {
                        "_id": "jEnjsxuoDJamGjbH2",
                        "rid": "6GFJ3tbmHiyHbahmC",
                        "u": {
                          "_id": "5fRTXMt7DMJbpPJfh",
                          "username": "test.test",
                          "name": "Testtest"
                        }
                      },
                      "success": "true"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "success": "false",
                      "error": "The room id provided does not match where the message is from."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "Auth-Token": {
        "name": "X-Auth-Token",
        "in": "header",
        "description": "The `authToken` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
      },
      "UserId": {
        "name": "X-User-Id",
        "in": "header",
        "description": "The `userId` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "rbAXPnMktTFbNpwtJ"
      }
    },
    "responses": {
      "authorizationError": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            },
            "examples": {
              "Authorization Error": {
                "value": {
                  "status": "error",
                  "message": "You must be logged in to do this."
                }
              }
            }
          }
        }
      }
    }
  }
}
````

