Portal Community

label/delete

Delete a user-created Gmail label. The label is removed from all messages and cannot be recovered.

System Labels Cannot Be Deleted: Labels like INBOX, SENT, TRASH, SPAM, STARRED, IMPORTANT, and UNREAD are system labels and cannot be deleted. Attempting to delete them returns CANNOT_DELETE_SYSTEM_LABEL. Only user-created labels (type: user) can be deleted.
Label Removal from Messages: Deleting a label removes it from ALL messages it was applied to. The messages themselves are not deleted — only the label association is removed.

When to Use

Configuration

Connection

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

Operation Fields

FieldTypeDefaultDescription
labelIdstring requiredGmail label ID to delete. Must be a user-created label (type: user). Use label/getMany to resolve the ID.

Sample Configuration

{
  "nodeType": "Gmail",
  "operation": "label/delete",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "labelId": "{{labelLookup.projectLabelId}}"
}

Validation Errors

ErrorCauseResolution
MISSING_FIELD: labelIdlabelId is emptyProvide a valid user label ID
CANNOT_DELETE_SYSTEM_LABELAttempting to delete a system labelOnly user-created labels can be deleted — check type field before deleting
LABEL_NOT_FOUNDLabel ID does not exist or was already deletedTreat as idempotent success in cleanup workflows
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 label was permanently deleted
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
{{labelLookup.projectLabelId}}Label ID resolved from label/getMany earlier in workflowlabelId field
{{loop.current.labelId}}Current label ID in a batch cleanup LoopBatch label deletion
{{labelCreate.labelId}}Label ID from earlier label/create in same workflowDelete after test workflow completes

Node Policies & GuardRails

PolicyRule
System Label GuardAlways verify type: 'user' before deleting — system labels throw CANNOT_DELETE_SYSTEM_LABEL
Message Impact AwarenessDeleting a label removes it from all messages it was applied to — messages are NOT deleted, only the label association is removed
Credential StorageStore OAuth credentials in BizFirst Credentials Manager — never hardcode tokens in workflow configuration
IdempotencyDeleting a label that no longer exists returns LABEL_NOT_FOUND — handle this gracefully in the error port for cleanup workflows
Quota ManagementLabel delete operations cost minimal quota — safe for batch cleanup workflows
Test IsolationTest label deletion against a dedicated Gmail test account to avoid deleting production labels

Examples

Example 1: Project Archive Cleanup

When a project is archived, resolve and delete its Gmail label as part of the offboarding workflow.

{
  "nodeType": "Gmail",
  "operation": "label/delete",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "labelId": "{{labelList.labels | where: 'name', 'Projects/{{project.name}}' | first | prop: 'labelId'}}"
}

Example 2: Test Cleanup

After a test workflow completes, delete the temporary label that was created for testing.

{
  "nodeType": "Gmail",
  "operation": "label/delete",
  "credentialId": "test-credential-id",
  "labelId": "{{testSetup.createdLabelId}}"
}

Example 3: Stale Label Batch Cleanup

A scheduled workflow finds all user labels with 0 messages and deletes them via a Loop node.

{
  "nodeType": "Gmail",
  "operation": "label/delete",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "labelId": "{{loop.current.labelId}}"
}