Time required. 30-50 minutes.
Prerequisites. A Google Workspace account with admin access, A running n8n instance (self-hosted or cloud), A Google account that can create GCP projects.
Wire up automated Google Workspace offboarding. This n8n workflow notifies every team, suspends the account on the last day, and logs it all in a Google Sheet.
The workflow automates employee offboarding. When an offboarding form is submitted, the workflow notifies IT, payroll, the manager, and the employee, then suspends the Google Workspace account on the employee's last day.
It uses Gmail, Google Sheets, and a Google Service Account with Domain-Wide Delegation to call the Admin SDK on your behalf. Three credentials in n8n.
HR submits the offboarding form: The Google Form submission triggers an Apps Script on the linked Sheet. The script reads the new row by header name and posts the form data (signed with HMAC) to the n8n form webhook.
n8n validates and creates a Sheet record: The workflow checks for missing fields (employee email, last day, manager email, IT email, payroll email) and confirms the suspension date is not before the last day. If valid, a new row is written to the Sheet with Status = Pending. The employee email must be in your workspace domain; if not, the row is marked as a duplicate.
n8n notifies IT, payroll, the manager, and the employee: Four emails go out immediately with the offboarding details. Each one includes the relevant context (equipment return instructions for IT, final pay timing for payroll, transition notes for the manager, farewell for the employee).
n8n waits until the suspension date: The workflow sleeps until the configured suspension date (defaults to the last day).
n8n suspends the Google Workspace account: On the suspension date, the workflow calls the Admin SDK via the Service Account to suspend the user's Google account.
Already-processed protection: If the same form row is submitted twice (or a duplicate is detected), the workflow skips notification and suspension and logs a duplicate error so HR can investigate.
The Google Form must have these six fields, in any order. The Apps Script matches them by header label, not position, so you can reorder the form fields freely:
| Form field | Sheet column header | Required? |
|---|---|---|
| Employee name | Employee name | Yes |
| Employee email | Employee email | Yes |
| Manager name | Manager name | No |
| Manager email | Manager email | Yes |
| Last day | Last day | Yes |
| Reason | Reason | No |
The workflow writes these columns to the sheet automatically:
| Column | Set by | When |
|---|---|---|
| Status | n8n | Pending on form submit, Suspended after Admin SDK call |
| Suspension date | n8n | If not in form, defaults to last day |
| Decision timestamp | n8n | When the account is suspended |
In addition, the Apps Script setup function creates an Error Log tab with these columns:
| Column | Type | Description |
|---|---|---|
| timestamp | date | ISO 8601, logged when an error occurs |
| error_type | string | validation_error, duplicate_error, or step_failure |
| employee_email | string | From the triggering record |
| employee_name | string | From the triggering record |
| node_name | string | Which node failed |
| error_message | string | Human-readable cause |
| resolved | string | Always "No" on insert; edit to "Yes" when resolved |
The Error Log tab stays empty during normal operation. It only gets populated when something fails (missing fields, API errors, etc.).
https://your-n8n.com/rest/oauth2-credential/callbackNote: You will only see the client secret once, so make sure to copy and/or download the JSON.
The Admin SDK API must be enabled in your Google Cloud project before the Service Account can use it.
If you skip this step, the Suspend Google Account node will fail with:
Admin SDK API has not been used in project [PROJECT_ID] before or it is disabled.
n8n-service-account@project-name.iam.gserviceaccount.com)Warning: New Google Workspace organizations have the following org policies enforced by default which will block service account and key creation:
iam.managed.disableServiceAccountCreationiam.disableServiceAccountKeyCreationiam.managed.disableServiceAccountKeyCreationBefore creating your service account key, you must temporarily unenforce these policies:
- Go to console.cloud.google.com
- In the top search bar, search for Organization Policies
- Note: The console only shows 50 policies at a time by default. Scroll past the first 50 or search by name to find each policy
- For each of the three policies listed above, click on it, select Override parent's policy, set to Not enforced, and save
Go to admin.google.com
Go to Security → Access and data control → API controls
Scroll down and click Manage Domain Wide Delegation
Find your Service Account's existing entry in the list and click Edit. If no entry exists yet, click Add new instead.
Paste in the Service Account Client ID (if adding new) or confirm it matches (if editing)
In the OAuth scopes field, add the following scope (if editing, append it to any existing scopes):
https://www.googleapis.com/auth/admin.directory.user
This is the only scope the Service Account needs for this workflow. Gmail and Google Sheets use separate OAuth2 credentials you will set up in n8n.
Using multiple templates with the same Service Account? The combined scopes across all Domain-Wide Delegation-using templates are
admin.directory.user(for onboarding and offboarding),calendar.events(for PTO), andspreadsheets.readonly(for PTO). Comma-separated scopes go in a single OAuth scopes field. Addingcalendar.events, spreadsheets.readonlyto an existing onboarding or offboarding Domain-Wide Delegation entry is all you need to also run PTO. Do not create a duplicate entry.
Click Authorize
Note: Domain Wide Delegation can take up to 24 hours to propagate but in my experience it updates fairly immediately.
When you create this credential in n8n, it is labeled Google Service Account (with DWD) by default. Keep that name during initial setup so the imported workflow auto-links the credential; after the link is established, n8n resolves it by credential ID at runtime, so any later rename is harmless.
client_email) and paste it into the Service Account Email fieldprivate_key) and paste the full value into the private key field (everything between and including -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----\n)https://www.googleapis.com/auth/admin.directory.useradmin.googleapis.comThe Service Account credential in n8n must have the following four settings configured correctly, otherwise the Suspend Google Account node will fail with Forbidden - perhaps check your credentials? / Request had insufficient authentication scopes.
To check or edit these on an existing credential:
-----BEGIN PRIVATE KEY-----)https://www.googleapis.com/auth/admin.directory.useradmin.googleapis.comIf any of these settings is wrong:
admin.directory.user → Google rejects the Admin SDK call with insufficient scopesadmin.googleapis.com → HTTP Request nodes are blocked from calling the Admin SDK APIunauthorized_client
n8n validates all Domain-Wide Delegation scopes when authenticating, not just the ones your workflow uses. If any scope is missing the entire authentication fails. Make sure the full scope list is added exactly as shown in the Google Workspace Admin Console under Security → Access and data control → API controls → Manage Domain Wide Delegation. No extra spaces, no missing scopes.
invalid_grant (Private key validation failed)
This is usually a propagation delay. After setting up or updating Domain-Wide Delegation in the Admin Console, it can take up to a few hours to take effect. If you see this error immediately after setup, wait a few hours and try again before troubleshooting further.
Authorization failed - please check your credentials
The "Set up for use in HTTP Request node" toggle on the Google Service Account credential in n8n is turned off. Open the credential in Settings → Credentials and turn it on. This is required for the credential to work with an HTTP Request node.
Forbidden - Request had insufficient authentication scopes
The Admin SDK rejected the request because the OAuth token does not include the directory scope. Two things must both be true:
https://www.googleapis.com/auth/admin.directory.user in its Scope field (per the Required n8n credential settings section above)If both are set, propagation may be the cause; Domain-Wide Delegation changes can take up to a few hours to take effect.
Once your service account credential is confirmed working in n8n, re-enforce the org policies to secure your Google Workspace:
Go to console.cloud.google.com
In the top search bar, search for Organization Policies
For each of the three policies below, click on it, select Override parent's policy, set to Enforced, and save:
iam.managed.disableServiceAccountCreationiam.disableServiceAccountKeyCreationiam.managed.disableServiceAccountKeyCreationThis ensures your organization is protected against unauthorized service account and key creation going forward.
Verify before moving on. All three policies should now read Enforced. If any still reads Not enforced, your Workspace org can still create service accounts and JSON keys without restriction. The workflow above this section will keep running either way, so this step won't fail loudly if it slips past you.
Each credential you create in n8n has a unique ID. You need these IDs to configure your workflow.
You need three credential IDs:
Want to skip the manual setup?
Our templates include a configuration tool. Enter your details once and download a ready-to-import workflow. View templates →
https://tl-hr.com/configure/employee-offboarding-google-workspace| Field | Description |
|---|---|
| Company name | Your company name |
| Google Workspace domain | e.g. acme.com |
| Gmail credential ID | The ID from the Gmail credential in n8n |
| Google Sheets credential ID | The ID from the Sheets credential in n8n |
| Google Service Account credential ID | The ID from the Service Account credential in n8n |
| n8n webhook URL | e.g. https://your-n8n-instance.com/webhook/employee-offboarding |
| Google Sheets ID | The ID from your Google Sheet URL (the long string in https://docs.google.com/spreadsheets/d/THIS-ID/edit) |
| Alert email | Email to receive error messages if the workflow fails |
| Default IT email | Email for IT services notifications |
| Default payroll email | Email for payroll/finance notifications |
Code.gs file should be emptyemployee-offboarding-google-workspace-appscript.gs file in a text editorCode.gs filesetup in the function dropdown and click the Run buttonemployee-offboarding-google-workspace-configured.json fileReady to automate?
The full Employee Offboarding workflow includes the complete workflow, Apps Script, error handling, automatic retry, and the configuration tool. Setup takes 30-60 minutes if you follow this guide.