Maton

Gmail

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=10
maton google-mail message list -L 10

With query filter:

GET /google-mail/gmail/v1/users/me/messages?q=is:unread&maxResults=10
maton google-mail message list --query 'is:unread' -L 10

Get Message

GET /google-mail/gmail/v1/users/me/messages/{messageId}
maton google-mail message view {messageId} --headers

With metadata only:

GET /google-mail/gmail/v1/users/me/messages/{messageId}?format=metadata&metadataHeaders=From&metadataHeaders=Subject&metadataHeaders=Date
maton google-mail message view {messageId} --fetch-format metadata --metadata-header From,Subject,Date

Send 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/labels
maton google-mail label list

List Threads

GET /google-mail/gmail/v1/users/me/threads?maxResults=10
maton google-mail thread list -L 10

Get 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 UNREAD

Trash Message

POST /google-mail/gmail/v1/users/me/messages/{messageId}/trash
maton 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/profile

Maton 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 IDMeaning
INBOXIn the inbox
DRAFTUnsent draft
UNREADNot yet read
STARREDStarred
IMPORTANTMarked important
SPAMIn spam

Resources

On this page