Portal Community

message/trash

Move a Gmail message to the trash. The message is recoverable for 30 days before permanent auto-deletion.

Recoverable: Trashed messages are retained for 30 days and can be restored with message/untrash. This is the recommended default deletion method over message/delete.

When to Use

Configuration

Connection

FieldTypeDescription
credentialIdGuid requiredOAuth2 credential ID from BizFirst Credentials Manager. Requires gmail.modify scope.

Operation Fields

FieldTypeDefaultDescription
messageIdstring requiredGmail message ID to move to the trash.

Sample Configuration

{
  "nodeType": "Gmail",
  "operation": "message/trash",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{processedMessage.messageId}}"
}

Validation Errors

ErrorCauseResolution
MISSING_FIELD: messageIdmessageId is emptyEnsure upstream node provides a valid message ID
MESSAGE_NOT_FOUNDMessage does not exist or is already trashedVerify the message ID; already-trashed messages return this error
INVALID_CREDENTIALOAuth token expired or credential not foundRe-authenticate in BizFirst Credentials Manager
PERMISSION_DENIEDCredential lacks gmail.modify scopeRe-grant OAuth permissions with the correct scope

Output

Success Port

FieldTypeDescription
successbooltrue when the message was moved to trash
statusstringsuccess
errorCodestringEmpty on success

Error Port

On failure, routes to the error port with status: "error", errorCode, and errorMessage.

Sample Output

{
  "success": true,
  "status": "success",
  "errorCode": ""
}

Expression Reference

ExpressionResolves ToExample Use
{{processedMessage.messageId}}Message ID from upstream processing nodemessageId field
{{loop.current.messageId}}Current message ID in a batch Loop nodeBatch trash operation
{{imapTrigger.messageId}}Message ID from IMAP triggerPost-processing cleanup

Node Policies & GuardRails

PolicyRule
Preferred Deletion MethodUse message/trash instead of message/delete for all standard deletion scenarios — trashed messages are recoverable for 30 days
Credential StorageStore OAuth credentials in BizFirst Credentials Manager — never hardcode tokens in workflow configuration
Quota ManagementTrash operation costs minimal quota units — safe for batch workflows using a Loop node
Recovery WindowMessages in trash are auto-permanently-deleted after 30 days — ensure recovery workflows run within this window if reversal is needed
PII ProtectionDo not log message IDs in a way that cross-references with PII data in workflow execution history
Test IsolationTest trash workflows against a dedicated Gmail test account before connecting a production inbox

Examples

Example 1: Post-Processing Inbox Cleanup

After extracting data from a processed email and creating a CRM record, move the source email to trash.

{
  "nodeType": "Gmail",
  "operation": "message/trash",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{crmIngestion.sourceMessageId}}"
}

Example 2: Batch Trash Spam-Classified Messages

After a classification node identifies spam messages, loop through the results and trash each one.

{
  "nodeType": "Gmail",
  "operation": "message/trash",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{loop.current.messageId}}"
}

Example 3: Inbox Zero After Label Routing

After applying project labels to an email and syncing to a project management system, trash the inbox copy.

{
  "nodeType": "Gmail",
  "operation": "message/trash",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{labelApply.messageId}}"
}