Skip to content
Talk to an Engineer Dashboard

Gmail

Gmail is Google's cloud based email service that allows you to access your messages from any computer or device with just a web browser.

Gmail is Google’s cloud based email service that allows you to access your messages from any computer or device with just a web browser.

Gmail logo

Supports authentication: OAuth 2.0

Register your Scalekit environment with the Gmail connector so Scalekit handles the authentication flow and token lifecycle for you. The connection name you create will be used to identify and invoke the connection programmatically. Then complete the configuration in your application as follows:

  1. Set up auth redirects

    • In Scalekit dashboard, go to Agent AuthCreate Connection. Find Gmail and click Create.

    • Click Use your own credentials and copy the redirect URI. It looks like https://<SCALEKIT_ENVIRONMENT_URL>/sso/v1/oauth/<CONNECTION_ID>/callback.

      Copy redirect URI from Scalekit dashboard

    • Navigate to Google Cloud ConsoleAPIs & ServicesCredentials. Click + Create Credentials, then OAuth client ID. Choose Web application as the application type.

      Select Web application in Google Cloud Console

    • Under Authorized redirect URIs, click + Add URI, paste the redirect URI, and click Create.

      Add authorized redirect URI in Google Cloud Console

  2. Enable Gmail API

    • In Google Cloud Console, go to APIs & ServicesLibrary. Search for “Gmail API” and click Enable.

      Enable Gmail API in Google Cloud Console

  3. Get client credentials

    Google provides your Client ID and Client Secret after you create the OAuth client ID in step 1.

  4. Add credentials in Scalekit

    • In Scalekit dashboard, go to Agent AuthConnections and open the connection you created.

    • Enter your credentials:

      Add credentials for Gmail in Scalekit dashboard

    • Click Save.

Connect a user’s Gmail account and make API calls on their behalf — Scalekit handles OAuth and token management automatically.

You can interact with Gmail in two ways — via direct proxy API calls or via Scalekit optimized tool calls. Scroll down to see the list of available Scalekit tools.

Proxy API Calls

import { ScalekitClient } from '@scalekit-sdk/node';
import 'dotenv/config';
const connectionName = 'gmail'; // get your connection name from connection configurations
const identifier = 'user_123'; // your unique user identifier
// Get your credentials from app.scalekit.com → Developers → Settings → API Credentials
const scalekit = new ScalekitClient(
process.env.SCALEKIT_ENV_URL,
process.env.SCALEKIT_CLIENT_ID,
process.env.SCALEKIT_CLIENT_SECRET
);
const actions = scalekit.actions;
// Authenticate the user
const { link } = await actions.getAuthorizationLink({
connectionName,
identifier,
});
console.log('🔗 Authorize Gmail:', link); // present this link to your user for authorization, or click it yourself for testing
process.stdout.write('Press Enter after authorizing...');
await new Promise(r => process.stdin.once('data', r));
// Make a request via Scalekit proxy
const result = await actions.request({
connectionName,
identifier,
path: '/gmail/v1/users/me/profile',
method: 'GET',
});
console.log(result);

Scalekit Tools

Fetch emails from a connected Gmail account using search filters. Requires a valid Gmail OAuth2 connection.

NameTypeRequiredDescription
formatstringNoFormat of the returned message.
include_spam_trashbooleanNoWhether to fetch emails from spam and trash folders
label_idsarray<string>NoGmail label IDs to filter messages
max_resultsintegerNoMaximum number of emails to fetch
page_tokenstringNoPage token for pagination
querystringNoSearch query string using Gmail’s search syntax (e.g., ‘is:unread from:user@example.com’)
schema_versionstringNoOptional schema version to use for tool execution
tool_versionstringNoOptional tool version to use for execution

Retrieve a specific attachment from a Gmail message using the message ID and attachment ID.

NameTypeRequiredDescription
attachment_idstringYesUnique Gmail attachment ID
file_namestringNoPreferred filename to use when saving/returning the attachment
message_idstringYesUnique Gmail message ID that contains the attachment
schema_versionstringNoOptional schema version to use for tool execution
tool_versionstringNoOptional tool version to use for execution

Fetch a list of contacts from the connected Gmail account. Supports pagination and field filtering.

NameTypeRequiredDescription
max_resultsintegerNoMaximum number of contacts to fetch
page_tokenstringNoToken to retrieve the next page of results
person_fieldsarray<string>NoFields to include for each person
schema_versionstringNoOptional schema version to use for tool execution
tool_versionstringNoOptional tool version to use for execution

Retrieve a specific Gmail message using its message ID. Optionally control the format of the returned data.

NameTypeRequiredDescription
formatstringNoFormat of the returned message.
message_idstringYesUnique Gmail message ID
schema_versionstringNoOptional schema version to use for tool execution
tool_versionstringNoOptional tool version to use for execution

Retrieve a specific Gmail thread by thread ID. Optionally control message format and metadata headers. Requires a valid Gmail OAuth2 connection with read access.

NameTypeRequiredDescription
formatstringNoFormat of messages in the returned thread.
metadata_headersarray<string>NoSpecific email headers to include when format is metadata
schema_versionstringNoOptional schema version to use for tool execution
thread_idstringYesUnique Gmail thread ID
tool_versionstringNoOptional tool version to use for execution

List draft emails from a connected Gmail account. Requires a valid Gmail OAuth2 connection.

NameTypeRequiredDescription
max_resultsintegerNoMaximum number of drafts to fetch
page_tokenstringNoPage token for pagination
schema_versionstringNoOptional schema version to use for tool execution
tool_versionstringNoOptional tool version to use for execution

List threads in a connected Gmail account using optional search and label filters. Requires a valid Gmail OAuth2 connection with read access.

NameTypeRequiredDescription
include_spam_trashbooleanNoWhether to include threads from Spam and Trash
label_idsarray<string>NoGmail label IDs to filter threads (threads must match all labels)
max_resultsintegerNoMaximum number of threads to return
page_tokenstringNoPage token for pagination
querystringNoSearch query string using Gmail search syntax (for example, ‘is:unread from:user@example.com’)
schema_versionstringNoOptional schema version to use for tool execution
tool_versionstringNoOptional tool version to use for execution

Search people or contacts in the connected Google account using a query. Requires a valid Google OAuth2 connection with People API scopes.

NameTypeRequiredDescription
other_contactsbooleanNoWhether to include people not in the user’s contacts (from ‘Other Contacts’).
page_sizeintegerNoMaximum number of people to return.
person_fieldsarray<string>NoFields to retrieve for each person.
querystringYesText query to search people (e.g., name, email address).
schema_versionstringNoOptional schema version to use for tool execution
tool_versionstringNoOptional tool version to use for execution