Gmail Webhook Payload
Gmail webhooks are sent for incoming and outgoing emails.
Example payload
1 { 2 "event": { 3 "id": "evt_gmail_abc123", 4 "channel": "gmail", 5 "timestamp": 1706640000.0, 6 "data": { 7 "timestamp": 1706640000.0, 8 "direction": "inbound", 9 "platform": "gmail", 10 "email_id": "email_xyz789", 11 "message_id": "<CADmL4p5xyz@mail.gmail.com>", 12 "subject": "Question about your services", 13 "body": "<html><body><p>Hi, I'm interested in learning more about...</p></body></html>", 14 "body_plain": "Hi, I'm interested in learning more about...", 15 "is_from_account": false, 16 "account_id": "acc_123", 17 "from_attendee": { 18 "display_name": "John Doe", 19 "identifier": "john@example.com", 20 "identifier_type": "EMAIL_ADDRESS" 21 }, 22 "to_attendees": [ 23 { 24 "display_name": "Your Business", 25 "identifier": "hello@yourbusiness.com", 26 "identifier_type": "EMAIL_ADDRESS" 27 } 28 ], 29 "cc_attendees": [], 30 "bcc_attendees": [], 31 "reply_to_attendees": [], 32 "email_event_type": "mail_received", 33 "date": 1706640000.0, 34 "read_date": null, 35 "folders": ["INBOX"], 36 "has_attachments": true, 37 "attachments": [ 38 { 39 "id": "att_001", 40 "name": "proposal.pdf", 41 "size": 102400, 42 "mimetype": "application/pdf", 43 "url": "https://..." 44 } 45 ], 46 "in_reply_to": null, 47 "is_complete": true, 48 "tracking_id": "track_abc", 49 "origin": "external", 50 "usage_data": { 51 "prompt_tokens": 300, 52 "completion_tokens": 150, 53 "model": "gpt-4" 54 }, 55 "tools_called": ["check_availability"], 56 "analysis_result": { 57 "sentiment": "positive", 58 "intent": "inquiry" 59 } 60 } 61 }, 62 "lead_id": "lead_123", 63 "lead_contact": { 64 "number": "", 65 "email": "john@example.com", 66 "name": "John Doe" 67 }, 68 "business_id": "biz_456", 69 "lead_created": true 70 }
Field reference
Core fields
| Field | Type | Required | Description |
|---|---|---|---|
timestamp | float | Yes | Unix epoch timestamp |
direction | string | Yes | inbound or outbound |
platform | string | Yes | Always gmail |
email_id | string | Yes | Internal email ID |
message_id | string | Yes | RFC822 Message-ID header |
subject | string | Yes | Email subject line |
body | string | Yes | HTML email body |
is_from_account | boolean | Yes | True if sent by connected account |
account_id | string | Yes | Connected Gmail account ID |
email_event_type | string | Yes | Event type |
date | float | Yes | Server acknowledgment timestamp |
email_event_type values
| Value | Description |
|---|---|
mail_received | Incoming email |
mail_sent | Outgoing email |
from_attendee object
| Field | Type | Description |
|---|---|---|
display_name | string | Sender display name (optional) |
identifier | string | Email address |
identifier_type | string | Always EMAIL_ADDRESS |
to_attendees array
Array of recipient objects with same structure as from_attendee.
Optional fields
| Field | Type | Description |
|---|---|---|
body_plain | string | Plain text version of body |
cc_attendees | array | CC recipients |
bcc_attendees | array | BCC recipients |
reply_to_attendees | array | Reply-To addresses |
read_date | float | When email was read |
folders | array | Email folders (INBOX, SENT, etc.) |
role | string | Folder role |
has_attachments | boolean | Whether has attachments |
attachments | array | Email attachments |
in_reply_to | object | Parent email reference |
is_complete | boolean | Whether fully loaded |
tracking_id | string | Internal tracking ID |
origin | string | unipile or external |
usage_data | object | LLM token usage |
tools_called | array | Tool names executed |
analysis_result | object | AI analysis output |
appointments | array | Extracted appointments |
execution_context | object | Source trigger context |
attachments array
| Field | Type | Description |
|---|---|---|
id | string | Attachment ID |
name | string | Filename |
size | integer | Size in bytes |
mimetype | string | MIME type |
url | string | Download URL |
in_reply_to object
| Field | Type | Description |
|---|---|---|
message_id | string | Parent RFC822 Message-ID |
id | string | Parent internal ID |
origin values
| Value | Description |
|---|---|
external | Email from external sender |
unipile | Email sent via BookedIn |