Method: users.messages.modify
Modifies the labels on the specified message.
HTTP request
POST https://gmail.googleapis.com/gmail/v1/users/{userId}/messages/{id}/modify
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters |
userId |
string
The user's email address. The special value me can be used to indicate the authenticated user.
|
id |
string
The ID of the message to modify.
|
Request body
The request body contains data with the following structure:
JSON representation |
{
"addLabelIds": [
string
],
"removeLabelIds": [
string
]
} |
Fields |
addLabelIds[] |
string
A list of IDs of labels to add to this message. You can add up to 100 labels with each update.
|
removeLabelIds[] |
string
A list IDs of labels to remove from this message. You can remove up to 100 labels with each update.
|
Response body
If successful, the response body contains an instance of Message
.
Authorization scopes
Requires one of the following OAuth scopes:
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
For more information, see the Authorization guide.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-04 UTC.
[null,null,["Last updated 2024-09-04 UTC."],[[["This endpoint modifies labels on a specific message by adding or removing label IDs."],["The request requires the user's email address (`userId`), the message ID (`id`), and a JSON body specifying label IDs to add or remove."],["A successful response returns the updated message details."],["Authorization is required using specific OAuth scopes, such as `https://mail.google.com/` or `https://www.googleapis.com/auth/gmail.modify`."],["Users can leverage this functionality to programmatically manage email labels within their Gmail accounts."]]],["This API modifies labels on a specified Gmail message. It uses a `POST` request to the provided URL, with `userId` and `id` as path parameters, representing the user's email and the message's ID. The request body, in JSON format, includes `addLabelIds` and `removeLabelIds` arrays of label IDs, allowing up to 100 labels per array to be added or removed. Successful requests return a Message instance and require OAuth scopes `https://mail.google.com/` or `https://www.googleapis.com/auth/gmail.modify`.\n"]]