Important
You need admin access to both Google Workspace and Foundry to set this up.
-
Setup Google Workspace
- Enable Gmail API in Google Cloud Console
- Create service account with domain delegation
- Grant
https://www.googleapis.com/auth/gmail.sendscope - Create/Download service account credentials as JSON
-
Prepare Credentials
echo "$(cat service_account.json)" | base64 => ewogICJ0...
[!TIP] Base64 encoding helps handle the complex JSON cleanly in Foundry's secrets
-
Configure Foundry
- Create REST API Data Connection
- Set egress policies for Gmail API
- Import the compute module
- Add base64 credentials as secret
Click to expand step-by-step instructions with screenshots
| Create Service Account |
![]() |
| Enable exports | Set import rules | Name your API |
![]() |
![]() |
![]() |
| Store Service Account |
![]() |
| Create compute module | Choose Functions mode |
![]() |
![]() |
| Import data connection | Build function |
![]() |
![]() |
| Create artifact | Deploy container |
![]() |
![]() |
| Update configuration | Verify deployment |
![]() |
![]() |
Whatever you called your namespace in compute module config is how you import the module in code: @<namespace>/computemodules
import { sendEmail } from "@gmail/computemodules";
await sendEmail({
recipients: ['user@domain.com'],
subject: 'Hello from Foundry!',
message: '<h1>It works!</h1><p>Email sent via Gmail API.</p>'
});Tip
Supports HTML formatting in email messages
Warning
Due to the limitations of importing the Foundry Data Connection source locally the project has a test.js feature and some Compute Module initialization logic that only runs once you deploy the module. (likely chance this was just a 'me' problem)
# Local testing
npm run test
# Expected output:
Starting email test...
[Email Module] Processing email request: {...}
Test completed successfully!Important
Common issues:
- Check service account delegation
- Verify OAuth scopes
- Confirm egress policies
- Validate base64 credentials
Caution
- Never commit credentials -- if you test locally name the 'secret'
service_account.json - Ensure .gitignore and .dockerignore are up to date
- Rotate keys regularly
- Monitor API usage
- Limit permissions
🚀 Part of Codestrap CommsForge
Part of CommsForge - Open source for Palantir Developers (Q2 2025)
Ontology is all you need.


















