LiveChatMessages: delete

Deletes a chat message. The API request must be authorized by the channel owner or a moderator of the live chat associated with the ban. Try it now.


HTTP request



This request requires authorization with at least one of the following scopes (read more about authentication and authorization).



The following table lists the parameters that this query supports. All of the parameters listed are query parameters.

Required parameters
id string
The id parameter specifies the YouTube chat message ID of the resource that is being deleted.

Request body

Do not provide a request body when calling this method.


If successful, this method returns an HTTP 204 response code (No Content).


Note: The following code samples may not represent all supported programming languages. See the client libraries documentation for a list of supported languages.


This sample deletes the specified live chat message.

This example uses the Java client library.

 * Copyright (c) 2017 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.


import java.util.List;

 * Delets a message from a live broadcast, using OAuth 2.0 to authorize API requests.
 * @author Jim Rogers
public class DeleteLiveChatMessage {

     * Define a global instance of a Youtube object, which will be used
     * to make YouTube Data API requests.
    private static YouTube youtube;

     * Deletes a message from a live broadcast.
     * @param args The message id to delete (required) followed by the videoId (optional). If the
     * videoId is given, live chat messages will be retrieved from the chat associated with this
     * video. If the videoId is not specified, the signed in user's current live broadcast will be
     * used instead.
    public static void main(String[] args) {
        // Get the message id to delete
        if (args.length == 0) {
            System.err.println("No message id specified");
        String messageId = args[0];

        // This OAuth 2.0 access scope allows for write access to the authenticated user's account.
        List<String> scopes = Lists.newArrayList(YouTubeScopes.YOUTUBE_FORCE_SSL);

        try {
            // Authorize the request.
            Credential credential = Auth.authorize(scopes, "deletelivechatmessage");

            // This object is used to make YouTube Data API requests.
            youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential)

            // Delete the message from live chat
            YouTube.LiveChatMessages.Delete liveChatDelete =
            System.out.println("Deleted message id " + messageId);
        } catch (GoogleJsonResponseException e) {
                .println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : "
                    + e.getDetails().getMessage());
        } catch (IOException e) {
            System.err.println("IOException: " + e.getMessage());
        } catch (Throwable t) {
            System.err.println("Throwable: " + t.getMessage());


The following table identifies error messages that the API could return in response to a call to this method. Please see the error message documentation for more detail.

Error type Error detail Description
forbidden (403) forbidden You do not have the permissions required to delete the specified message.
forbidden (403) modificationNotAllowed The specified liveChatMessage resource cannot be deleted. The id parameter might identify a message created by a moderator or another user whose messages cannot be deleted.
notFound (404) liveChatMessageNotFound The message that you are trying to delete cannot be found. Check the value of the id parameter to ensure it is correct.

Try it!

Use the API Explorer to call this method on live data and see the API request and response.