Gmail
API actions for the Gmail integration.
Gmail
Send email and read messages with a service account or OAuth.
Add label to message
Add a label to a Gmail message.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
message_id | string | Yes | Gmail message ID |
label_name | string | Yes | Name of the label to add |
create_if_missing | boolean | No | Create the label if it does not exist |
Response
{
"label_id": "Label_123",
"message_id": "18abc123def456",
"thread_id": "18abc123def456"
}Archive email
Archive a Gmail message by removing the INBOX label.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
message_id | string | Yes | Gmail message ID |
Response
{
"status": "success"
}Create draft
Create an email draft in Gmail.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Recipient email address |
subject | string | Yes | Email subject line |
body | string | Yes | Plain text body of the email |
html_body | string | No | HTML body of the email |
Response
{
"id": "r123456789",
"message_id": "18abc123def456"
}Create label
Create a new Gmail label.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
label | string | Yes | Name of the label to create |
Response
{
"label": "My Label",
"label_id": "Label_123",
"label_list_visibility": "labelShow",
"message_list_visibility": "show"
}Create reply message
Create a reply message in a thread.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
in_reply_to | string | Yes | Email address of the sender to reply to |
subject | string | Yes | Email subject line |
body | string | Yes | Plain text body of the reply |
references | string | No | References header for threading |
attachments | array | No | List of uploaded file references to attach. |
html_body | string | No | HTML body of the reply |
Response
{
"status": "success"
}Delete email
Move a Gmail message to the trash.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
message_id | string | Yes | Gmail message ID |
Response
{
"status": "success"
}Download attachments
Download all attachments from a Gmail message.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sender | string | Yes | Sender email address to filter messages |
Response
{
"documents": [
{
"content_type": "application/pdf",
"filename": "attachment1.pdf",
"size_bytes": 2048
}
],
"filepaths": [
"/tmp/attachment1.pdf",
"/tmp/attachment2.docx"
]
}Find email
Find the first Gmail email that matches the provided search query.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Gmail search query string |
unread_only | boolean | No | If true, only search unread emails |
in_inbox | boolean | No | If true, only search in inbox |
Response
{
"email": {
"body": "Hey, just wanted to follow up on our conversation from last week. Let me know if you have any questions.",
"from": "sender@example.com",
"id": "18abc123def456",
"reply_body": "Hey, just wanted to follow up on our conversation from last week. Let me know if you have any questions.",
"sender": "sender@example.com",
"snippet": "Hey, just wanted to follow up on...",
"subject": "Hello",
"thread_id": "18abc123def456"
}
}Get message headers
Fetch headers for a specific Gmail message.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
message_id | string | Yes | Gmail message ID |
Response
{
"Date": "Mon, 1 Jan 2024 12:00:00 +0000",
"From": "sender@example.com",
"Subject": "Hello World",
"To": "recipient@example.com"
}Get most recent email
Fetch the most recently received email from Gmail inbox.
Response
{
"date": "Mon, 1 Jan 2024 12:00:00 +0000",
"from_": "sender@example.com",
"id": "18abc123def456",
"snippet": "This is a preview of the email content...",
"subject": "Hello World",
"thread_id": "18abc123def456"
}List emails
List emails matching filters and return message details.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | number | No | Maximum number of emails to return |
q | string | No | A raw Gmail search query (e.g., 'from:foo@example.com') |
unread_only | boolean | No | If true, only return unread emails |
in_inbox | boolean | No | If true, only return emails in the inbox |
Response
{
"emails": [
{
"body": "Hello there, this is the full email body content.",
"from": "sender@example.com",
"id": "18abc123def456",
"reply_body": "Hello there, this is the full email body content.",
"sender": "sender@example.com",
"snippet": "Hello there",
"subject": "Hello",
"thread_id": "18abc123def456"
}
]
}Mark as read
Mark a Gmail message as read by removing the UNREAD label.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
message_id | string | Yes | Gmail message ID |
Response
{
"status": "success"
}Remove label from message
Remove a label from a Gmail message.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
message_id | string | Yes | Gmail message ID |
label_name | string | Yes | Name of the label to remove |
Response
{
"label_id": "Label_123",
"message_id": "18abc123def456",
"thread_id": "18abc123def456"
}Send message
Send an email message or reply to a thread.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Recipient email address |
subject | string | Yes | Email subject line |
body | string | Yes | Plain text body of the email |
attachments | array | No | List of uploaded file references to attach. |
html_body | string | No | HTML body of the email |
Response
{
"status": "success"
}