Operations (sample payloads)
Main operationsCopy
Create send-as aliasCopy
Creates a custom 'from' send-as alias. REQUIRES a service account.
Sample Input
1{2"user_id": "me",3"display_name": "John Doe",4"send_as_address": "john.doe@example.com",5"is_default": false,6"reply_to_address": "support@example.com",7"signature": "<p>Best regards,<br>John Doe<br>Customer Support</p>",8"treat_as_alias": true9}
Sample Output
1{2"sendAsEmail": "john.doe@example.com",3"displayName": "John Doe",4"replyToAddress": "support@example.com",5"signature": "<p>Best regards,<br>John Doe<br>Customer Support</p>",6"isDefault": false,7"treatAsAlias": true,8"verificationStatus": "pending"9}
Delete messageCopy
Deletes a message in your Inbox.
Sample Input
1{2"user_id": "me",3"message_id": "17a2d34b8c9e5f3d"4}
Sample Output
1{2"deleted": true3}
Delete send-as aliasCopy
Deletes a specified send-as alias. REQUIRES a service account.
Sample Input
1{2"user_id": "me",3"send_as_address": "marketing@example.com"4}
Sample Output
1{2"deleted": true3}
Download message attachmentsCopy
Get the attachments from a message.
Sample Input
1{2"user_id": "me",3"message_id": "17e3d45b8a9c2f3d"4}
Sample Output
1{2"files": [3{4"name": "report.pdf",5"url": "https://www.googleapis.com/gmail/v1/users/me/messages/17e3d45b8a9c2f3d/attachments/ANGjdJ8z9X_kL2fj...",6"mime_type": "application/pdf",7"expires": 16234567898},9{10"name": "image.jpg",11"url": "https://www.googleapis.com/gmail/v1/users/me/messages/17e3d45b8a9c2f3d/attachments/BGHjdJ8z9X_kL2fj...",12"mime_type": "image/jpeg",13"expires": 162345678914}15]16}
Get messageCopy
Get full details of a message in your Inbox.
Sample Input
1{2"user_id": "me",3"message_id": "17e3d45b8a9c2f3d"4}
Sample Output
1{2"id": "17e3d45b8a9c2f3d",3"threadId": "17e3d45b8a9c2f3d",4"labelIds": [5"INBOX",6"CATEGORY_PERSONAL"7],8"snippet": "Hello! I hope this email finds you well. I wanted to touch base about...",9"historyId": "543267",10"internalDate": "1652345678000",11"from": {12"name": "John Doe",13"email": "johndoe@example.com"14},15"to": [16{17"email": "recipient@example.com",18"name": "Jane Smith"19}20],21"cc": [],22"bcc": [],23"body_html": "<html><body><p>Hello!</p><p>I hope this email finds you well. I wanted to touch base about our upcoming meeting.</p><p>Best regards,<br>John</p></body></html>",24"body_text": "Hello!\n\nI hope this email finds you well. I wanted to touch base about our upcoming meeting.\n\nBest regards,\nJohn",25"payload": {26"partId": "0",27"mimeType": "multipart/alternative",28"filename": "",29"headers": [30{31"name": "From",32"value": "John Doe <johndoe@example.com>"33},34{35"name": "To",36"value": "Jane Smith <recipient@example.com>"37},38{39"name": "Subject",40"value": "Touching base"41}42],43"body": {44"size": 045},46"parts": [47{48"partId": "0.1",49"mimeType": "text/plain",50"filename": "",51"headers": [52{53"name": "Content-Type",54"value": "text/plain; charset=UTF-8"55}56],57"body": {58"size": 146,59"data": "SGVsbG8hCgpJIGhvcGUgdGhpcyBlbWFpbCBmaW5kcyB5b3Ugd2VsbC4gSSB3YW50ZWQgdG8gdG91Y2ggYmFzZSBhYm91dCBvdXIgdXBjb21pbmcgbWVldGluZy4KCkJlc3QgcmVnYXJkcywKSm9obg=="60}61},62{63"partId": "0.2",64"mimeType": "text/html",65"filename": "",66"headers": [67{68"name": "Content-Type",69"value": "text/html; charset=UTF-8"70}71],72"body": {73"size": 185,74"data": "PGh0bWw+PGJvZHk+PHA+SGVsbG8hPC9wPjxwPkkgaG9wZSB0aGlzIGVtYWlsIGZpbmRzIHlvdSB3ZWxsLiBJIHdhbnRlZCB0byB0b3VjaCBiYXNlIGFib3V0IG91ciB1cGNvbWluZyBtZWV0aW5nLjwvcD48cD5CZXN0IHJlZ2FyZHMsPGJyPkpvaG48L3A+PC9ib2R5PjwvaHRtbD4="75}76}77]78},79"sizeEstimate": 567880}
Get send-as aliasCopy
Returns data for a specified send-as alias. REQUIRES a service account.
Sample Input
1{2"user_id": "me",3"send_as_address": "marketing@example.com"4}
Sample Output
1{2"sendAsEmail": "marketing@example.com",3"displayName": "Marketing Team",4"replyToAddress": "replies@example.com",5"signature": "<div>Best regards,<br>The Marketing Team<br><img src='https://example.com/logo.png' alt='Company Logo'></div>",6"isDefault": false,7"treatAsAlias": true,8"verificationStatus": "verified"9}
Get threadCopy
Returns full details of a thread in your Inbox.
Sample Input
1{2"user_id": "me",3"thread_id": "17a2d34b8c9e5f3d"4}
Sample Output
1{2"id": "17a2d34b8c9e5f3d",3"historyId": "1234567",4"messages": [5{6"id": "17a2d34b8c9e5f3d",7"threadId": "17a2d34b8c9e5f3d",8"labelIds": [9"INBOX",10"CATEGORY_PERSONAL"11],12"snippet": "Hi John, I hope this email finds you well. I wanted to follow up on our...",13"historyId": "1234567",14"internalDate": "1623456789000",15"payload": {16"partId": "",17"mimeType": "multipart/alternative",18"filename": "",19"headers": [20{21"name": "From",22"value": "Jane Doe <jane.doe@example.com>"23},24{25"name": "To",26"value": "John Smith <john.smith@example.com>"27},28{29"name": "Subject",30"value": "Follow-up on project discussion"31}32],33"body": {34"size": 035},36"parts": [37{38"partId": "0",39"mimeType": "text/plain",40"filename": "",41"headers": [42{43"name": "Content-Type",44"value": "text/plain; charset=UTF-8"45}46],47"body": {48"size": 240,49"data": "SGkgSm9obiwKCkkgaG9wZSB0aGlzIGVtYWlsIGZpbmRzIHlvdSB3ZWxsLiBJIHdhbnRlZCB0byBmb2xsb3cgdXAgb24gb3VyIHByb2plY3QgZGlzY3Vzc2lvbiBmcm9tIGxhc3Qgd2Vlay4gSGF2ZSB5b3UgaGFkIGEgY2hhbmNlIHRvIHJldmlldyB0aGUgcHJvcG9zYWw/CgpMZXQgbWUga25vdyBpZiB5b3UgaGF2ZSBhbnkgcXVlc3Rpb25zIG9yIGNvbmNlcm5zLgoKQmVzdCByZWdhcmRzLApKYW5l"50}51}52]53},54"sizeEstimate": 567855}56]57}
Get user profileCopy
Returns information about the user authenticated to Tray.
Sample Input
1{2"user_id": "me"3}
Sample Output
1{2"emailAddress": "john.doe@example.com",3"messagesTotal": 15234,4"threadsTotal": 3789,5"historyId": "8374629"6}
List labelsCopy
Lists all labels in the user's inbox.
Sample Input
1{2"user_id": "me"3}
Sample Output
1{2"labels": [3{4"id": "INBOX",5"name": "INBOX",6"messageListVisibility": "show",7"labelListVisibility": "labelShow",8"type": "system"9},10{11"id": "SENT",12"name": "SENT",13"messageListVisibility": "show",14"labelListVisibility": "labelShow",15"type": "system"16},17{18"id": "TRASH",19"name": "TRASH",20"messageListVisibility": "show",21"labelListVisibility": "labelShow",22"type": "system"23},24{25"id": "Label_1",26"name": "Work",27"messageListVisibility": "show",28"labelListVisibility": "labelShow",29"type": "user"30},31{32"id": "Label_2",33"name": "Personal",34"messageListVisibility": "show",35"labelListVisibility": "labelShow",36"type": "user"37}38]39}
List messagesCopy
Returns a list of all the messages in the Gmail inbox.
Sample Input
1{2"user_id": "me",3"query": "is:unread",4"include_spam_trash": false,5"label_ids": [6"INBOX",7"IMPORTANT"8],9"limit": 50,10"page_token": "next_page_token_123"11}
Sample Output
1{2"messages": [3{4"id": "17a1b2c3d4e5f6g7",5"threadId": "17a1b2c3d4e5f6g7"6},7{8"id": "18b3c4d5e6f7g8h9",9"threadId": "18b3c4d5e6f7g8h9"10},11{12"id": "19c5d6e7f8g9h0i1",13"threadId": "19c5d6e7f8g9h0i1"14}15],16"nextPageToken": "next_page_token_456",17"resultSizeEstimate": 12718}
List send-as aliasesCopy
Lists a user's custom 'from' send-as alias. REQUIRES a service account.
Sample Input
1{2"user_id": "john.doe@example.com"3}
Sample Output
1{2"sendAs": [3{4"sendAsEmail": "john.doe@example.com",5"displayName": "John Doe",6"replyToAddress": "john.doe@example.com",7"signature": "Best regards,\nJohn Doe\nSales Manager",8"isPrimary": true,9"isDefault": true10},11{12"sendAsEmail": "support@example.com",13"displayName": "Example Support",14"replyToAddress": "support@example.com",15"signature": "Thank you for contacting Example Support,\n\nBest regards,\nJohn Doe",16"isPrimary": false,17"isDefault": false18},19{20"sendAsEmail": "marketing@example.com",21"displayName": "Example Marketing",22"replyToAddress": "marketing@example.com",23"signature": "Stay updated with our latest offers!\n\nJohn Doe\nMarketing Team",24"isPrimary": false,25"isDefault": false26}27]28}
List threadsCopy
Returns a list of all the conversation threads in the Gmail inbox.
Sample Input
1{2"user_id": "me",3"query": "is:unread",4"include_spam_trash": false,5"label_ids": [6"INBOX",7"IMPORTANT"8],9"limit": 50,10"page_token": "next_page_token_123"11}
Sample Output
1{2"threads": [3{4"id": "thread_id_1",5"snippet": "Hello, I wanted to discuss the project...",6"historyId": "12345"7},8{9"id": "thread_id_2",10"snippet": "Meeting reminder: Team sync at 2 PM...",11"historyId": "12346"12},13{14"id": "thread_id_3",15"snippet": "Your flight reservation has been confirmed...",16"historyId": "12347"17}18],19"nextPageToken": "next_page_token_456",20"resultSizeEstimate": 15021}
List user historyCopy
Lists the history of all changes to the given mailbox.
Sample Input
1{2"user_id": "me",3"start_history_id": "12345",4"history_types": "messageAdded",5"limit": 10,6"label_id": "INBOX",7"page_token": "nextPageToken123"8}
Sample Output
1{2"history": [3{4"id": "67890",5"messages": [6{7"id": "msg123",8"threadId": "thread456"9}10],11"messagesAdded": [12{13"message": {14"id": "msg123",15"threadId": "thread456",16"labelIds": [17"INBOX",18"UNREAD"19]20}21}22]23}24],25"nextPageToken": "nextPageToken789",26"historyId": "67890"27}
Reply to messageCopy
Sends a reply email message via your Gmail account. Messages will appear to the recipient as if you had sent the message yourself in the Gmail interface.
Sample Input
1{2"user_id": "me",3"message_id": "17e3d45b8a9c2f3d",4"body": "Thank you for your email. I've reviewed the proposal and have a few questions. Can we schedule a call to discuss further?",5"from": {6"email": "john.doe@example.com",7"name": "John Doe"8},9"to": [10{11"email": "jane.smith@company.com",12"name": "Jane Smith"13}14],15"cc": [16{17"email": "team@company.com",18"name": "Project Team"19}20],21"bcc": [22{23"email": "manager@company.com",24"name": "Manager"25}26],27"reply_to": {28"email": "john.doe@company.com",29"name": "John Doe"30},31"attachments": [32{33"filename": "questions.pdf",34"content": "base64encodedcontent..."35}36]37}
Sample Output
1{2"id": "17e3d45b8a9c2f3e",3"threadId": "17e3d45b8a9c2f3d",4"labelIds": [5"SENT",6"INBOX"7]8}
Send messageCopy
Sends an email message via your Gmail account. Messages will appear to the recipient as if you had sent the message yourself in the Gmail interface.
Sample Input
1{2"user_id": "me",3"to": [4{5"email": "recipient@example.com",6"name": "John Doe"7}8],9"subject": "Meeting Agenda for Tomorrow",10"body": "<p>Hello John,</p><p>I hope this email finds you well. I wanted to share the agenda for our meeting tomorrow:</p><ol><li>Project updates</li><li>Budget review</li><li>Q&A session</li></ol><p>Please let me know if you have any questions or if you'd like to add any items to the agenda.</p><p>Best regards,<br>Jane Smith</p>",11"from": {12"email": "jane.smith@example.com",13"name": "Jane Smith"14},15"cc": [16{17"email": "manager@example.com",18"name": "Team Manager"19}20],21"bcc": [22{23"email": "archive@example.com"24}25],26"reply_to": {27"email": "jane.smith@company.com",28"name": "Jane Smith"29},30"attachments": [31{32"filename": "meeting_agenda.pdf",33"content": "base64encodedcontent..."34}35]36}
Sample Output
1{2"id": "17a9f3b2c4d5e6f7",3"threadId": "17a9f3b2c4d5e6f7",4"labelIds": [5"SENT",6"INBOX"7]8}
Update message labelsCopy
Modifies the labels on the specified message.
Sample Input
1{2"user_id": "me",3"message_id": "17a2d34b8c9def0",4"add_label_ids": [5"IMPORTANT",6"CATEGORY_PERSONAL"7],8"remove_label_ids": [9"INBOX"10]11}
Sample Output
1{2"id": "17a2d34b8c9def0",3"threadId": "17a2d34b8c9def0",4"labelIds": [5"IMPORTANT",6"CATEGORY_PERSONAL",7"SENT"8]9}
Update send-as aliasCopy
Updates a custom 'from' send-as alias. REQUIRES a service account.
Sample Input
1{2"user_id": "me",3"display_name": "John Doe",4"send_as_address": "john.doe@example.com",5"is_default": true,6"reply_to_address": "support@example.com",7"signature": "<p>Best regards,<br>John Doe<br>Customer Support</p>",8"treat_as_alias": false9}
Sample Output
1{2"sendAsEmail": "john.doe@example.com",3"displayName": "John Doe",4"replyToAddress": "support@example.com",5"signature": "<p>Best regards,<br>John Doe<br>Customer Support</p>",6"isDefault": true,7"treatAsAlias": false,8"verificationStatus": "accepted"9}
Update vacationCopy
Updates vacation responder settings.
Sample Input
1{2"user_id": "me",3"enable_auto_reply": true,4"response_subject": "Out of Office: Vacation",5"response_body_plain_text": "I am currently on vacation and will return on July 15th. For urgent matters, please contact my colleague at colleague@example.com.",6"response_body_html": "<p>I am currently on vacation and will return on July 15th. For urgent matters, please contact my colleague at <a href='mailto:colleague@example.com'>colleague@example.com</a>.</p>",7"restrict_to_contact": false,8"restrict_to_domain": true,9"start_time": 1688169600000,10"end_time": 168937920000011}
Sample Output
1{2"enableAutoReply": true,3"responseSubject": "Out of Office: Vacation",4"responseBodyPlainText": "I am currently on vacation and will return on July 15th. For urgent matters, please contact my colleague at colleague@example.com.",5"restrictToContacts": false,6"restrictToDomain": true,7"startTime": "2023-07-01T00:00:00.000Z",8"endTime": "2023-07-15T00:00:00.000Z"9}
DDL operationsCopy
List labels (DDL)Copy
Note that DDL operations can only be called directly by Connectors API, or when using CustomJS in the Embedded solution editor for e.g. DDL-dependent data mapping
Sample Input
1{}
Sample Output
1{2"labels": [3{4"id": "INBOX",5"name": "INBOX",6"type": "system"7},8{9"id": "SENT",10"name": "SENT",11"type": "system"12},13{14"id": "TRASH",15"name": "TRASH",16"type": "system"17},18{19"id": "SPAM",20"name": "SPAM",21"type": "system"22},23{24"id": "Label_1",25"name": "Work",26"type": "user"27},28{29"id": "Label_2",30"name": "Personal",31"type": "user"32},33{34"id": "Label_3",35"name": "Urgent",36"type": "user"37}38]39}