Apply Labels to Emails
Purpose
This API is used to apply labels to a particular email or a group of emails.
OAuth Scope
Use the scope
ZohoMail.messages.ALL (or) ZohoMail.messages.UPDATE
to generate the Authtoken.
ALL - Grants full access to messages.
UPDATE - Grants access to update messages.
Request URL
Method: PUT
https://mail.zoho.com/api/accounts/{accountId}/updatemessage
Path Parameters
- accountId* long
- This key is used to identify the specific account.
- This parameter can be retrieved from Get User Account Details API.
Request Body (JSON object)
- mode* string
- This parameter represents the type of operation that is to be performed.
- Provide the value as applyLabel.
- messageId* JSON Array of long
- This parameter should be passed as an array containing one or more message IDs for which labels needs to be applied. A message ID is a unique identifier for an email.
- This parameter can be retrieved from List Emails API.
- threadId JSON Array of long
- This parameter should be passed as an array containing one or more thread IDs for which labels needs to be set. A thread ID is a unique identifier for an email thread.
Note:If labels need to be applied for the entire thread, the threadId can be passed instead of the messageId. - This parameter can be retrieved from List Emails API.
- This parameter should be passed as an array containing one or more thread IDs for which labels needs to be set. A thread ID is a unique identifier for an email thread.
- labelId* JSON Array of long
- This parameter should be passed as an array of single or multiple label IDs that need to be applied to emails. Each label ID serves as a unique identifier for a label.
- This parameter can be retrieved from Get All Label Details API.
- isFolderSpecific boolean
- This parameter specifies whether this action is folder-specific.
- Allowed values:
- true - If true, folderId has to be mentioned.
- false
- The default value is false.
- folderId long
- This parameter is the unique identifier of the respective folder. Only messages that are present in this folder will be considered for this action.
- This parameter can be retrieved from Get All Folders API.
- isArchive boolean
- This parameter specifies whether archived emails should be included in this action.
- Allowed values:
- true - The flag action will include both archived and non-archived emails.
- false - The flag action will exclude archived emails, applying only to non-archived emails.
- The default value is false.
* - Mandatory parameter
Response Codes
Refer here for the response codes and their meaning.
Sample Request
Copiedcurl "https://mail.zoho.com/api/accounts/12345678/updatemessage" \
-X PUT \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization:Zoho-oauthtoken *****" \
-d '{
"mode":"applyLabel",
"labelId":["31321431","222667888"],
"messageId" : [11000000004001],
"isFolderSpecific":true,
"folderId": 12345,
"isArchive": true
}'