Access the Gmail API with managed OAuth authentication. Read, send, and manage emails, threads, labels, and drafts.
Reference
List Messages
GET /google-mail/gmail/v1/users/me/messages?maxResults=10maton google-mail message list -L 10With query filter:
GET /google-mail/gmail/v1/users/me/messages?q=is:unread&maxResults=10maton google-mail message list --query 'is:unread' -L 10Get Message
GET /google-mail/gmail/v1/users/me/messages/{messageId}maton google-mail message view {messageId} --headersWith metadata only:
GET /google-mail/gmail/v1/users/me/messages/{messageId}?format=metadata&metadataHeaders=From&metadataHeaders=Subject&metadataHeaders=Datematon google-mail message view {messageId} --fetch-format metadata --metadata-header From,Subject,DateSend Message
POST /google-mail/gmail/v1/users/me/messages/send
Content-Type: application/json
{
"raw": "BASE64_ENCODED_EMAIL"
}maton google-mail message send --to alice@example.com --subject 'Hello' --body 'Hi there!'Reply to Message
maton google-mail message reply {messageId} --body 'Thanks!'Forward Message
maton google-mail message forward {messageId} --to dave@example.com --body 'FYI'List Labels
GET /google-mail/gmail/v1/users/me/labelsmaton google-mail label listList Threads
GET /google-mail/gmail/v1/users/me/threads?maxResults=10maton google-mail thread list -L 10Get Thread
GET /google-mail/gmail/v1/users/me/threads/{threadId}maton google-mail thread view {threadId}Modify Message Labels
POST /google-mail/gmail/v1/users/me/messages/{messageId}/modify
Content-Type: application/json
{
"addLabelIds": ["STARRED"],
"removeLabelIds": ["UNREAD"]
}maton google-mail message modify {messageId} --add-label STARRED --remove-label UNREADTrash Message
POST /google-mail/gmail/v1/users/me/messages/{messageId}/trashmaton google-mail message trash {messageId}Create Draft
POST /google-mail/gmail/v1/users/me/drafts
Content-Type: application/json
{
"message": {
"raw": "BASE64URL_ENCODED_EMAIL"
}
}maton google-mail draft create --to alice@example.com --subject 'Hello' --body 'Draft content here'Send Draft
POST /google-mail/gmail/v1/users/me/drafts/send
Content-Type: application/json
{
"id": "{draftId}"
}maton google-mail draft send {draftId}Get Profile
GET /google-mail/gmail/v1/users/me/profileMaton Events
email.received
Parameters
labels(optional): Label IDs that any of which will fire the trigger. If blank, defaults to["INBOX].
System label IDs:
| Label ID | Meaning |
|---|---|
INBOX | In the inbox |
DRAFT | Unsent draft |
UNREAD | Not yet read |
STARRED | Starred |
IMPORTANT | Marked important |
SPAM | In spam |