Lodol Docs

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

ParameterTypeRequiredDescription
message_idstringYesGmail message ID
label_namestringYesName of the label to add
create_if_missingbooleanNoCreate 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

ParameterTypeRequiredDescription
message_idstringYesGmail message ID

Response

{
  "status": "success"
}

Create draft

Create an email draft in Gmail.

Parameters

ParameterTypeRequiredDescription
tostringYesRecipient email address
subjectstringYesEmail subject line
bodystringYesPlain text body of the email
html_bodystringNoHTML body of the email

Response

{
  "id": "r123456789",
  "message_id": "18abc123def456"
}

Create label

Create a new Gmail label.

Parameters

ParameterTypeRequiredDescription
labelstringYesName 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

ParameterTypeRequiredDescription
in_reply_tostringYesEmail address of the sender to reply to
subjectstringYesEmail subject line
bodystringYesPlain text body of the reply
referencesstringNoReferences header for threading
attachmentsarrayNoList of uploaded file references to attach.
html_bodystringNoHTML body of the reply

Response

{
  "status": "success"
}

Delete email

Move a Gmail message to the trash.

Parameters

ParameterTypeRequiredDescription
message_idstringYesGmail message ID

Response

{
  "status": "success"
}

Download attachments

Download all attachments from a Gmail message.

Parameters

ParameterTypeRequiredDescription
senderstringYesSender 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

ParameterTypeRequiredDescription
querystringYesGmail search query string
unread_onlybooleanNoIf true, only search unread emails
in_inboxbooleanNoIf 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

ParameterTypeRequiredDescription
message_idstringYesGmail 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

ParameterTypeRequiredDescription
limitnumberNoMaximum number of emails to return
qstringNoA raw Gmail search query (e.g., 'from:foo@example.com')
unread_onlybooleanNoIf true, only return unread emails
in_inboxbooleanNoIf 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

ParameterTypeRequiredDescription
message_idstringYesGmail message ID

Response

{
  "status": "success"
}

Remove label from message

Remove a label from a Gmail message.

Parameters

ParameterTypeRequiredDescription
message_idstringYesGmail message ID
label_namestringYesName 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

ParameterTypeRequiredDescription
tostringYesRecipient email address
subjectstringYesEmail subject line
bodystringYesPlain text body of the email
attachmentsarrayNoList of uploaded file references to attach.
html_bodystringNoHTML body of the email

Response

{
  "status": "success"
}

On this page