Skip to content
techrace/
TECHRACE DOCUMENTATION

Gmail

Connect Gmail mailboxes to read mail and folders, and (with extra permissions) create drafts and send.

Quick reference

PropertyValue
Platform valuegmail
One connected accountOne Gmail mailbox.
SupportedMailbox reads, folders, drafts and controlled sending
FeaturesEmail ✓
Provider approvalGoogle OAuth verification; restricted mail scopes require applicable security assessment and customer consent
TokenAccess token plus refresh token (renewed automatically)

Before you start

The person connecting needs:

  • A Google account with Gmail.
  • While your Google app is unverified: added as a test user on the OAuth consent screen.

You (the platform owner) need:

  1. In console.cloud.google.com create (or reuse) a project and a Web application OAuth client; copy its Client ID and Client secret.
  2. Enable the Gmail API.
  3. Authorized redirect URI: https://YOUR_DOMAIN/auth/callback/gmail
  4. On the OAuth consent screen, add your Google account as a test user while the app is unverified.

Permissions (scopes)

Techrace puts these permissions in the login link. The person approves them on the provider's own screen; only approved permissions are granted.

PermissionRequested by defaultUsed for
openidYesIdentify the Google account
emailYesRead the account's email address
https://www.googleapis.com/auth/gmail.readonlyYesRead messages, threads and labels
https://www.googleapis.com/auth/gmail.composeOptionalCreate drafts
https://www.googleapis.com/auth/gmail.sendOptionalSend mail
https://www.googleapis.com/auth/gmail.modifyOptionalChange labels, archive, trash

Connect an account

POST/api/v1/projects/{project_id}/connect-sessionsconnections:write

Create a connect link with provider "gmail" and send the person's browser to the returned url. return_url is the page in your app where they land afterwards (https, or http://localhost while testing).

curl -X POST "https://YOUR_DOMAIN/api/v1/projects/$TECHRACE_PROJECT_ID/connect-sessions" \
  -H "Authorization: Bearer $TECHRACE_API_KEY" \
  -H "Content-Type: application/json" \
  --data @- <<EOF
{
  "customer_id": "$CUSTOMER_ID",
  "provider": "gmail",
  "return_url": "https://your-app.com/integrations/done"
}
EOF

After approval the person lands on your return_url with ?connected=gmail&customer_id=…&connection_id=…, or ?error=access_denied|expired|failed&provider=gmail. Your webhook also receives account.connected. Keep the connection_id: every call below uses it.

Read and send mail

POST/api/v1/projects/{project_id}/email/queryemail:read

Read messages, threads, folders and attachments.

POST/api/v1/projects/{project_id}/email/operationsemail:send / email:drafts:write / email:modify

Create drafts, send, reply, forward and organise mail. See the Email group in the API reference for each action's fields.

Limitations

  • Signing in to Techrace with Google does not connect Gmail; it is a separate connection.
  • Sending requires the restricted gmail.send scope.

Common errors

ErrorMeaningFix
unsupported_email_oauth_scopeA scope outside the allowed Gmail list was configured.Use only gmail.readonly, send, compose or modify.
account_reconnection_requiredThe refresh token is no longer valid.Reconnect the mailbox.