Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors
22.5k Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

Delete Relation

Use this node to clean up entity graph edges at runtime — for example, removing a device’s LocatedIn relation when it is moved to a new location, or clearing all ConnectedTo relations from a gateway that goes offline. The relation type and target entity identifier support templatization.

  • Direction — required. The direction of relations to delete relative to the message originator:
    • From originator — relations where the originator is the from entity.
    • To originator — relations where the originator is the to entity.
  • Relation type — required. The type of relation(s) to delete. Supports templatization.
  • Delete relation with specific entity — toggle:
    • Enabled — delete only the relation between the originator and a specific target entity (configured below).
    • Disabled — delete all relations of the specified type and direction involving the originator.

When targeting a specific entity:

  • Type — entity type of the target. Supported: TENANT, DEVICE, ASSET, CUSTOMER, ENTITY_VIEW, DASHBOARD, USER, EDGE, CONVERTER, ROLE.
  • Entity identifier — name, title, or email of the target entity (depends on type). Supports templatization. TENANT requires no identifier.
  1. Resolve the relation type by substituting patterns from message data and metadata.
  2. If Delete relation with specific entity is enabled:
    • Resolve the target entity identifier.
    • Look up the target entity. If not found, route via Failure.
    • Delete the specific relation between the originator and the target.
  3. If Delete relation with specific entity is disabled:
    • Delete all relations of the specified type and direction involving the originator.
  4. Route via Success on completion, or Failure on error.
Connection Condition
Success Relation(s) deleted successfully.
Failure Target entity not found, or an unexpected error occurred.

Example 1 — Delete all relations of a type

Section titled “Example 1 — Delete all relations of a type”
{
"direction": "FROM",
"relationType": "Contains",
"deleteForSingleEntity": false
}

State: originator has Contains relations to devices A, B, and C; also a Uses relation to asset D.

Result: all Contains relations deleted. Uses relation preserved.


Example 2 — Delete specific relation using patterns

Section titled “Example 2 — Delete specific relation using patterns”

Incoming data: { "targetAssetName": "Building" } | Metadata: { "relationType": "LocatedIn" }

{
"direction": "FROM",
"relationType": "${relationType}",
"deleteForSingleEntity": true,
"entityType": "ASSET",
"entityNamePattern": "$[targetAssetName]"
}

Result: only the LocatedIn relation between the originator device and asset Building is deleted.


Example 3 — Delete relation with current tenant

Section titled “Example 3 — Delete relation with current tenant”
{
"direction": "TO",
"relationType": "Owns",
"deleteForSingleEntity": true,
"entityType": "TENANT"
}

Result: the Owns relation from the tenant to the originator is deleted. No entity identifier is needed.


Example 4 — Target entity not found → Failure

Section titled “Example 4 — Target entity not found → Failure”
{
"direction": "FROM",
"relationType": "Contains",
"deleteForSingleEntity": true,
"entityType": "ASSET",
"entityNamePattern": "nonexistent_asset"
}

Result: no asset named nonexistent_asset — routes via Failure. No relations modified.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TbDeleteRelationNodeConfiguration",
"type": "object",
"properties": {
"direction": { "type": "string", "enum": ["FROM", "TO"] },
"relationType": { "type": "string" },
"deleteForSingleEntity": { "type": "boolean" },
"entityType": { "type": "string", "enum": ["TENANT", "DEVICE", "ASSET", "CUSTOMER", "ENTITY_VIEW", "DASHBOARD", "USER", "EDGE", "CONVERTER", "ROLE"] },
"entityNamePattern": { "type": "string" }
}
}