Update draft with the Gmail API
Replaces 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.
- Identifier
- gmail_update_draft
The request
POST https://connect.reportei.com/api/tools/gmail_update_draft/execute
Authorization: Bearer <merchant token>
x-customer-token: <customer token>
Content-Type: application/json
Accept: application/json
{
"customer_toolkit": "<connection UUID>",
"arguments": {
"draftId": "<draftId>",
"message": {}
}
}Your system sends your customer's connection id and the tool arguments. The headers are the same as the rest of the Connect API: your product's token and your customer's token.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| draftId | string | Yes | Draft id from List drafts or Create draft. |
| message | object | Yes | The new email of the draft. |
Supported connections
Your customer connects their Gmail account once, with one of the modes below. The same connection serves every tool of the toolkit.
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.
The response
On success, Connect preserves the app's response status and body. HTTP errors returned by the app use the {error, api_error} envelope; authentication or validation can fail before execution. The X-Toolkit-Execution-Id header identifies the recorded execution, available at GET /api/tools/executions/{uuid}.
Ready for AI agents
This tool's input is a JSON Schema, available at GET /api/tools/gmail_update_draft. It becomes your agent's tool definition with no conversion.
Other 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.
See Connect applied to your product.
Try it for 15 days with no card, or walk our team through your use case.
