Communication
Gmail in your product and your AI agents, through one API
The Gmail toolkit covers messages and conversations (list, read, send, label), labels (list, create) and drafts (create, update, send, delete). Customers connect Gmail once with OAuth on your own app, and Connect renews the tokens and logs every execution, so you skip the OAuth and Gmail API plumbing.
15 days to try it. No credit card.
POST https://connect.reportei.com/api/tools/gmail_send_message/execute
Authorization: Bearer <merchant token>
x-customer-token: <customer token>
Content-Type: application/json
Accept: application/json
{
"customer_toolkit": "<connection UUID>",
"arguments": {
"raw": "RnJvbTogc2VuZGVyQGV4YW1wbGUuY29tDQpUbzogcmVjaXBpZW50QGV4YW1wbGUuY29tDQpTdWJqZWN0OiBDb25uZWN0IGV4YW1wbGUNCk1JTUUtVmVyc2lvbjogMS4wDQpDb250ZW50LVR5cGU6IG11bHRpcGFydC9hbHRlcm5hdGl2ZTsgYm91bmRhcnk9ImNvbm5lY3QtZXhhbXBsZSINCg0KLS1jb25uZWN0LWV4YW1wbGUNCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD0iVVRGLTgiDQpDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA4Yml0DQoNCkhlbGxvISBUaGlzIGlzIGFuIGV4YW1wbGUgbWVzc2FnZS4NCg0KLS1jb25uZWN0LWV4YW1wbGUNCkNvbnRlbnQtVHlwZTogdGV4dC9odG1sOyBjaGFyc2V0PSJVVEYtOCINCkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IDhiaXQNCg0KPHAgc3R5bGU9Im1hcmdpbjowIDAgMTJweCAwO2ZvbnQtZmFtaWx5OkFyaWFsLHNhbnMtc2VyaWY7Zm9udC1zaXplOjE0cHg7bGluZS1oZWlnaHQ6MS40OyI-SGVsbG8hIFRoaXMgaXMgYW4gZXhhbXBsZSBtZXNzYWdlLjwvcD4NCi0tY29ubmVjdC1leGFtcGxlLS0NCg"
}
}How it works
From a connected customer to the first Gmail call.
- 1
Your customer connects the account
Your system opens a Connect session for the toolkit and your customer connects their Gmail account. You get the connection id.
- 2
Your product calls the tool
A POST to /api/tools/{tool}/execute with the connection id and arguments. On success, Connect preserves the app's response status and body.
- 3
Connect handles the rest
It stores the credential encrypted, renews tokens for OAuth connections that support renewal and records executions in an audit trail available through the API.
Use cases
What your product does with Gmail.
Send mail from the user's inbox
Send an email as the customer, or reply inside a conversation by passing the threadId and the Message-ID headers returned by Get message.
Draft, review, send
An AI agent writes a reply with Create draft, the user reviews it in your product, and Send draft delivers it only after approval.
Triage the inbox
List unread messages with a q filter, read each one, then archive it, star it or apply a label created with Create label.
Tools
12 Gmail tools
- List messagesGETLists the messages of the mailbox that match q and labelIds. Each item has only id and threadId: read the content with Get message. Pass nextPageToken as pageToken to read the next page.
- Get messageGETGets a message with its threadId, labelIds and snippet. With format full, the default, payload has the headers (From, To, Subject, Date, Message-ID) and the body parts, whose data is base64url encoded. Attachments come only as an attachmentId and are not downloaded.
- Get threadGETGets a conversation with all its messages. Each message has id, labelIds, snippet and, with format full, the default, the payload with the headers and the base64url encoded body parts.
- Send messagePOSTSends an email right away to the recipients in the To, Cc and Bcc headers of raw, and returns the sent message with id, threadId and labelIds. To reply inside a conversation, pass its threadId, keep the same Subject and set the In-Reply-To and References headers to the Message-ID of the message answered, which Get message returns in payload.headers.
- Update message labelsPOSTAdds and removes labels on a message and returns its labelIds. Remove UNREAD to mark it as read, remove INBOX to archive it, add STARRED to star it, or add TRASH to move it to the trash.
- List labelsGETLists the labels of the mailbox: the system labels, such as INBOX, SENT, DRAFT, UNREAD, STARRED and SPAM, and the labels the user created. The id of each one is what labelIds, addLabelIds and removeLabelIds take.
- Create labelPOSTCreates a label and returns it with its id, to apply with Update message labels. The name cannot be the name of a system label or of an existing label.
- List draftsGETLists the drafts of the mailbox. Each item has the draft id and a message with id and threadId: read the content with Get message using message.id. Pass nextPageToken as pageToken to read the next page.
- Create draftPOSTSaves an email as a draft without sending it, and returns the draft id and its message with id and threadId. Send it later with Send draft.
- Update draftPUTReplaces the whole email of a draft. The draft id stays and message.id changes. To edit the current text, read it first with Get message, format raw, using the message.id from List drafts.
OAuth with your product's app
You register your product's OAuth app once, with POST /api/merchants/credentials/gmail, and your customer authorizes the account on a consent screen. Connect renews the token when it is about to expire.
Questions about the Gmail toolkit
Do I need to build against the Gmail API?
No. Connect ships 12 Gmail tools, described and ready. Your customer connects the account and your system calls every tool through the same endpoint, with the same request format.
How does my customer connect their Gmail account?
With the mode the toolkit accepts: OAuth with your product's app. Connect stores the credential encrypted and never returns it to your system.
Does it work with AI agents?
Yes. Each tool's input is described in JSON Schema, which your agent uses directly as a tool definition. The agent picks the tool and the arguments, and your system makes the call to Connect.
Does my customer need a Reportei account?
No. Your customer connects the account on a Connect screen, or your system sends the credential through the API, and they keep using only your product.
See Connect applied to your product.
Try it for 15 days with no card, or walk our team through your use case.
