Portal Community

message/untrash

Restore a Gmail message from the trash back to the inbox (or its previous label location).

Recovery Window: Messages remain in trash for 30 days before auto-permanent-deletion. message/untrash must be called within this window. After 30 days, the message is permanently gone.

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 restore from trash.

Sample Configuration

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

Validation Errors

ErrorCauseResolution
MISSING_FIELD: messageIdmessageId is emptyEnsure the upstream node provides a valid message ID
MESSAGE_NOT_FOUNDMessage does not exist, not in trash, or permanently deletedCheck that the message is currently in the TRASH label and within the 30-day window
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 restored from 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
{{recoveryRequest.messageId}}Message ID from a recovery request form or eventmessageId field
{{errorHandler.trashedMessageId}}Message ID recorded before an erroneous trash actionRollback in error recovery flow
{{loop.current.messageId}}Current message in a batch restore LoopBulk untrash operation

Node Policies & GuardRails

PolicyRule
30-Day WindowMessages are permanently deleted from trash after 30 days — recovery workflows must execute within this window
Credential StorageStore OAuth credentials in BizFirst Credentials Manager — never hardcode tokens in workflow configuration
IdempotencyCalling untrash on a message that is not in trash returns MESSAGE_NOT_FOUND — handle this in the error port gracefully
Audit LoggingLog the untrash action (messageId, timestamp, reason) in an audit trail for compliance tracking
Quota ManagementUntrash operations cost minimal API quota — safe for batch usage in a Loop node
Test IsolationTest restore workflows against a dedicated Gmail test account before connecting production

Examples

Example 1: Restore False-Positive Spam

After a spam classifier flags a legitimate email, the review node detects the error and restores the message.

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

Example 2: User-Requested Email Recovery

A user submits a recovery request via a form. The workflow retrieves the message ID from the request and restores the email.

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

Example 3: Workflow Error Rollback

A CatchBlock node detects that a trash operation was triggered incorrectly and rolls back by restoring the message.

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