Gmail

Gmail: read, search, draft and send email, and manage labels

Connects by
Signing in with Google
Category
Email
Part of
Google
Tools
80
ServiceKey
Gmailgmail

Connecting

Your client presses Connect on their link and approves on Google's own screen. Operate As never sees their password.

Check they're connected
curl https://api.operate.as/v1/me/clients \  -H "Authorization: Bearer $OPERATE_AS_API_KEY"
Response
[  {    "id": "6f1c2a7e-...",    "name": "Miller Dental",    "services": [      "gmail"    ]  }]

Permissions

What the client readsPermission it asks for
Send email as youhttps://www.googleapis.com/auth/gmail.send
Read your emailhttps://www.googleapis.com/auth/gmail.readonly

Tools

Install Gmail's typed package for your language:

pip install operate-as-gmail
Run gmail.send_email
curl -X POST https://api.operate.as/v1/actions/gmail.send_email \  -H "Authorization: Bearer $OPERATE_AS_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "clientId": "6f1c2a7e-...",    "input": {      "to": "<to>",      "subject": "<subject>",      "body": "<body>"    }  }'
InputTypeWhat it is
torequiredstringWho to send it to
subjectrequiredstringSubject
bodyrequiredstringText
Response
{  "status": 200,  "data": {    "…": "the service's own response"  },  "encoding": "json"}

Pass-through

Paths continue from https://gmail.googleapis.com/gmail/v1. Your Operate As key goes in Authorization; the client's access is added for you.

See Pass-through requests for the full request and response format.

Call any endpoint
curl "https://api.operate.as/v1/clients/6f1c2a7e-.../gmail/..." \  -H "Authorization: Bearer $OPERATE_AS_API_KEY"
Response
{  "status": 200,  "data": {    "…": "the service's own response"  },  "encoding": "json"}

When access ends

Operate As renews the sign-in before it runs out and checks it daily. If Google refuses to renew it, the service shows Expired, you're alerted, and your client reconnects from the same link.

See Keeping access alive and Removing access.

Calls answer
HTTP/1.1 409 ConflictContent-Type: application/json{  "detail": "Miller Dental's Google access ended. Send them their link to reconnect."}
Your webhook receives
{  "id": "evt_3f9a1c…",  "type": "connection.expired",  "createdAt": "2026-10-16T08:00:00+00:00",  "data": {    "clientId": "6f1c2a7e-...",    "clientName": "Miller Dental",    "provider": "google",    "services": [      "gmail"    ],    "reconnectUrl": "https://…"  }}