draft/delete
Permanently delete a Gmail draft. The draft is removed from the Drafts folder and cannot be recovered.
When to Use
- Rejected approval cleanup: When a Human-in-the-Loop reviewer rejects a draft, delete it from Gmail to prevent accidental sends and inbox clutter.
- Content modification pipeline: Delete the old draft after retrieving its content and creating an updated replacement draft with modified fields.
- Workflow error path cleanup: In the error branch of a draft-send workflow, delete drafts that failed validation to prevent them from lingering in the inbox.
- Test draft cleanup: During automated test workflows, delete drafts created as part of test cases after assertions are verified.
- Draft inbox hygiene: Periodically identify and delete stale drafts that were never sent, as part of a scheduled cleanup workflow.
Configuration
Connection
| Field | Type | Description |
credentialId | Guid required | OAuth2 credential ID from BizFirst Credentials Manager. Requires gmail.modify scope. |
Operation Fields
| Field | Type | Default | Description |
draftId | string required | — | Gmail draft ID to permanently delete. Returned by draft/create or draft/getMany. |
Sample Configuration
{
"nodeType": "Gmail",
"operation": "draft/delete",
"credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
"draftId": "{{approval.rejectedDraftId}}"
}
Validation Errors
| Error | Cause | Resolution |
MISSING_FIELD: draftId | draftId is empty | Ensure upstream node provides a valid draft ID |
DRAFT_NOT_FOUND | Draft does not exist or was already sent/deleted | Treat as idempotent success if draft was already cleaned up |
INVALID_CREDENTIAL | OAuth token expired or credential not found | Re-authenticate in BizFirst Credentials Manager |
PERMISSION_DENIED | Credential lacks gmail.modify scope | Re-grant OAuth permissions with the correct scope |
Output
Success Port
| Field | Type | Description |
success | bool | true when the draft was permanently deleted |
status | string | success |
errorCode | string | Empty 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
| Expression | Resolves To | Example Use |
{{approval.rejectedDraftId}} | Draft ID from rejected approval node | draftId field |
{{draftCreate.draftId}} | Draft ID from upstream draft/create | Delete after failed validation |
{{loop.current.draftId}} | Current draft ID in a batch cleanup Loop | Batch draft deletion |
Node Policies & GuardRails
| Policy | Rule |
| Draft Lifecycle Management | Always delete rejected or abandoned drafts — include a draft/delete node in all rejection/error branches of draft workflows |
| Credential Storage | Store OAuth credentials in BizFirst Credentials Manager — never hardcode tokens in workflow configuration |
| Idempotency | Calling draft/delete on a draft that no longer exists returns DRAFT_NOT_FOUND — handle this gracefully in the error port |
| Quota Management | Draft delete operations cost minimal quota units — safe for batch cleanup workflows |
| No Recovery | Deleted drafts cannot be recovered — ensure the deletion is intentional and the draft content is no longer needed |
| Test Isolation | Test delete workflows against a dedicated Gmail test account to avoid deleting production drafts |
Examples
Example 1: Rejected Approval Cleanup
After a HIL approver rejects a draft, delete it from Gmail to prevent accidental sends.
{
"nodeType": "Gmail",
"operation": "draft/delete",
"credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
"draftId": "{{approvalNode.rejectedDraftId}}"
}
Example 2: Error Path Cleanup
A CatchBlock in a draft-send workflow deletes the draft when a downstream validation error occurs.
{
"nodeType": "Gmail",
"operation": "draft/delete",
"credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
"draftId": "{{catchBlock.draftId}}"
}
Example 3: Stale Draft Batch Cleanup
A scheduled workflow lists all drafts older than 7 days and deletes them via a Loop node.
{
"nodeType": "Gmail",
"operation": "draft/delete",
"credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
"draftId": "{{loop.current.draftId}}"
}