Gmail API . users . labels

Instance Methods

create(userId, body)

Creates a new label.

delete(userId, id)

Immediately and permanently deletes the specified label and removes it from any messages and threads that it is applied to.

get(userId, id)

Gets the specified label.

list(userId)

Lists all labels in the user's mailbox.

patch(userId, id, body)

Updates the specified label. This method supports patch semantics.

update(userId, id, body)

Updates the specified label.

Method Details

create(userId, body)
Creates a new label.

Args:
  userId: string, The user's email address. The special value me can be used to indicate the authenticated user. (required)
  body: object, The request body. (required)
    The object takes the form of:

{ # Labels are used to categorize messages and threads within the user's mailbox.
  "name": "A String", # The display name of the label.
  "messagesTotal": 42, # The total number of messages with the label.
  "type": "A String", # The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
  "threadsUnread": 42, # The number of unread threads with the label.
  "messagesUnread": 42, # The number of unread messages with the label.
  "labelListVisibility": "A String", # The visibility of the label in the label list in the Gmail web interface.
  "threadsTotal": 42, # The total number of threads with the label.
  "messageListVisibility": "A String", # The visibility of the label in the message list in the Gmail web interface.
  "id": "A String", # The immutable ID of the label.
}


Returns:
  An object of the form:

    { # Labels are used to categorize messages and threads within the user's mailbox.
    "name": "A String", # The display name of the label.
    "messagesTotal": 42, # The total number of messages with the label.
    "type": "A String", # The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
    "threadsUnread": 42, # The number of unread threads with the label.
    "messagesUnread": 42, # The number of unread messages with the label.
    "labelListVisibility": "A String", # The visibility of the label in the label list in the Gmail web interface.
    "threadsTotal": 42, # The total number of threads with the label.
    "messageListVisibility": "A String", # The visibility of the label in the message list in the Gmail web interface.
    "id": "A String", # The immutable ID of the label.
  }
delete(userId, id)
Immediately and permanently deletes the specified label and removes it from any messages and threads that it is applied to.

Args:
  userId: string, The user's email address. The special value me can be used to indicate the authenticated user. (required)
  id: string, The ID of the label to delete. (required)
get(userId, id)
Gets the specified label.

Args:
  userId: string, The user's email address. The special value me can be used to indicate the authenticated user. (required)
  id: string, The ID of the label to retrieve. (required)

Returns:
  An object of the form:

    { # Labels are used to categorize messages and threads within the user's mailbox.
    "name": "A String", # The display name of the label.
    "messagesTotal": 42, # The total number of messages with the label.
    "type": "A String", # The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
    "threadsUnread": 42, # The number of unread threads with the label.
    "messagesUnread": 42, # The number of unread messages with the label.
    "labelListVisibility": "A String", # The visibility of the label in the label list in the Gmail web interface.
    "threadsTotal": 42, # The total number of threads with the label.
    "messageListVisibility": "A String", # The visibility of the label in the message list in the Gmail web interface.
    "id": "A String", # The immutable ID of the label.
  }
list(userId)
Lists all labels in the user's mailbox.

Args:
  userId: string, The user's email address. The special value me can be used to indicate the authenticated user. (required)

Returns:
  An object of the form:

    {
    "labels": [ # List of labels.
      { # Labels are used to categorize messages and threads within the user's mailbox.
        "name": "A String", # The display name of the label.
        "messagesTotal": 42, # The total number of messages with the label.
        "type": "A String", # The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
        "threadsUnread": 42, # The number of unread threads with the label.
        "messagesUnread": 42, # The number of unread messages with the label.
        "labelListVisibility": "A String", # The visibility of the label in the label list in the Gmail web interface.
        "threadsTotal": 42, # The total number of threads with the label.
        "messageListVisibility": "A String", # The visibility of the label in the message list in the Gmail web interface.
        "id": "A String", # The immutable ID of the label.
      },
    ],
  }
patch(userId, id, body)
Updates the specified label. This method supports patch semantics.

Args:
  userId: string, The user's email address. The special value me can be used to indicate the authenticated user. (required)
  id: string, The ID of the label to update. (required)
  body: object, The request body. (required)
    The object takes the form of:

{ # Labels are used to categorize messages and threads within the user's mailbox.
  "name": "A String", # The display name of the label.
  "messagesTotal": 42, # The total number of messages with the label.
  "type": "A String", # The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
  "threadsUnread": 42, # The number of unread threads with the label.
  "messagesUnread": 42, # The number of unread messages with the label.
  "labelListVisibility": "A String", # The visibility of the label in the label list in the Gmail web interface.
  "threadsTotal": 42, # The total number of threads with the label.
  "messageListVisibility": "A String", # The visibility of the label in the message list in the Gmail web interface.
  "id": "A String", # The immutable ID of the label.
}


Returns:
  An object of the form:

    { # Labels are used to categorize messages and threads within the user's mailbox.
    "name": "A String", # The display name of the label.
    "messagesTotal": 42, # The total number of messages with the label.
    "type": "A String", # The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
    "threadsUnread": 42, # The number of unread threads with the label.
    "messagesUnread": 42, # The number of unread messages with the label.
    "labelListVisibility": "A String", # The visibility of the label in the label list in the Gmail web interface.
    "threadsTotal": 42, # The total number of threads with the label.
    "messageListVisibility": "A String", # The visibility of the label in the message list in the Gmail web interface.
    "id": "A String", # The immutable ID of the label.
  }
update(userId, id, body)
Updates the specified label.

Args:
  userId: string, The user's email address. The special value me can be used to indicate the authenticated user. (required)
  id: string, The ID of the label to update. (required)
  body: object, The request body. (required)
    The object takes the form of:

{ # Labels are used to categorize messages and threads within the user's mailbox.
  "name": "A String", # The display name of the label.
  "messagesTotal": 42, # The total number of messages with the label.
  "type": "A String", # The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
  "threadsUnread": 42, # The number of unread threads with the label.
  "messagesUnread": 42, # The number of unread messages with the label.
  "labelListVisibility": "A String", # The visibility of the label in the label list in the Gmail web interface.
  "threadsTotal": 42, # The total number of threads with the label.
  "messageListVisibility": "A String", # The visibility of the label in the message list in the Gmail web interface.
  "id": "A String", # The immutable ID of the label.
}


Returns:
  An object of the form:

    { # Labels are used to categorize messages and threads within the user's mailbox.
    "name": "A String", # The display name of the label.
    "messagesTotal": 42, # The total number of messages with the label.
    "type": "A String", # The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the INBOX and UNREAD labels from messages and threads, but cannot apply or remove the DRAFTS or SENT labels from messages or threads.
    "threadsUnread": 42, # The number of unread threads with the label.
    "messagesUnread": 42, # The number of unread messages with the label.
    "labelListVisibility": "A String", # The visibility of the label in the label list in the Gmail web interface.
    "threadsTotal": 42, # The total number of threads with the label.
    "messageListVisibility": "A String", # The visibility of the label in the message list in the Gmail web interface.
    "id": "A String", # The immutable ID of the label.
  }