Skip to main content

AtlanTag: tag and classify assets programmatically

Use AtlanTag in the Atlan Python SDK to programmatically add, update, and remove tags on assets.

Atlan tags must exist before tagging assets

Remember that you must first create the Atlan tag before you will be able to tag any assets.

Can't add tags when creating assets

Currently it'sn't possible to add tags when creating assets, other than via dbt.

Add to existing asset

To add tags to an existing asset:

Add tags to an existing asset
models:
- name: TOP_BEVERAGE_USERS # (1)
meta:
atlan:
classificationNames: # (2)
- PII # (3)
- Marketing Analysis
classificationNames: # (4)
- name: PII # (5)
propagate: true # (6)
removePropagationsOnEntityDelete: true # (7)
restrictPropagationThroughLineage: false # (8)
restrictPropagationThroughHierarchy: false # (9)
- name: Marketing Analysis
propagate: true
removePropagationsOnEntityDelete: true
restrictPropagationThroughLineage: false
restrictPropagationThroughHierarchy: false
classifications: # (10)
- typeName: yQBDoKHdTLJhqAsdR3RMq6 # (11)
propagate: true
removePropagationsOnEntityDelete: true
restrictPropagationThroughLineage: false
restrictPropagationThroughHierarchy: false
- typeName: WCVjmgKnW40G151dESXZ03
propagate: true
removePropagationsOnEntityDelete: true
restrictPropagationThroughLineage: false
restrictPropagationThroughHierarchy: false
  1. You must of course give the name of the object.
  2. The simplest way to tag an asset, using the default values for propagation (those shown below), is to use the meta.atlan.classificationNames structure.
  3. When using this simplified form, you can give the normal human-readable name of the tags rather than the hashed-string representation.
  4. Alternatively, if you want to override the propagation settings, you can use this more detailed structure.
  5. Each listed item must itself be a YAML object consisting of the human-readable name of the tag and the propagation setting overrides:
  6. (Optional) You can decide whether to propagate this tag (true) or not (false). If you choose false, no propagation of this tag from the asset will occur—neither through lineage nor parent-child relationships.
  7. (Optional) If propagation is allowed, you can then define whether propagated tags should be removed if this asset is deleted (true) or not (false).
  8. (Optional) If propagation is allowed, you can also decide whether to disable propagation of the tag only for lineage (true) or still allow it through lineage (false).
  9. (Optional) If propagation is allowed, you can also decide whether to disable propagation of the tag only for hierarchy (true) or still allow it through hierarchy (false).
  10. Alternatively, you can specify tags nested within the meta.atlan.classifications structure.
  11. In this structure, each tag you want to add must be given using its hashed-string representation. Its propagation settings can be overridden using the same options described above.
Replaces all tags

Unlike the examples for the SDKs and raw APIs, dbt will always replace all tags on the asset. Any tags that already exist on the asset that aren't specified here will be removed.

Update on existing asset

To update tags on an existing asset:

Not possible through dbt

In dbt, the tags will be replaced in their entirety. It'sn't possible to just update a single tag through dbt.

Remove from existing assets

Remove single tag

To remove a single tag from an existing asset:

Remove one tag from an existing asset
models:
- name: TOP_BEVERAGE_USERS # (1)
meta:
atlan:
classificationNames: # (2)
- PII # (3)
classifications: # (4)
- typeName: yQBDoKHdTLJhqAsdR3RMq6 # (5)
propagate: true
removePropagationsOnEntityDelete: true
restrictPropagationThroughLineage: false
restrictPropagationThroughHierarchy: false

  1. You must of course give the name of the object.

  2. You can use the meta.atlan.classificationNames structure, as above.

  3. When using this simplified form, you can give the normal human-readable name of the tags you want to remain, rather than the hashed-string representation.

    The tag being removed is no longer present

You are removing the tag by not specifying it anymore here in dbt. ::: 4. The tags must be nested within the meta.atlan.classifications structure. 5. Each tag you want to remain must be given using its hashed-string representation.

The tag being removed is no longer present

You are removing the tag by not specifying it anymore here in dbt.

Remove multiple tags

To remove one or more tags from an existing asset:

Coming soon

Remove all tags

Could create a new asset

Remember that Atlan matches the provided qualifiedName to determine whether to update or create the asset.

To remove all tags from an existing asset, you need to specify no tags in your object:

Remove all tags from an existing asset
models:
- name: TOP_BEVERAGE_USERS # (1)
meta:
atlan:
classifications: [] # (2)
  1. You must of course give the name of the object.
  2. The tags must be nested within the meta.atlan.classifications structure. To remove all of them, send an explicit empty list.

In bulk

You can modify many tags, for many assets, at the same time.

Operates as a replace

Applying tags in bulk can currently only be done as a replacement. All tags on the assets you upate will be replaced with the tags you specify. This means any tags that already exist on the asset in Atlan that are not in your update will be removed from that asset.

Replace tags on multiple assets
models:
- name: TOP_BEVERAGE_USERS # (1)
meta:
atlan:
classificationNames: # (2)
- PII # (3)
- Marketing Analysis
classificationNames: # (4)
- name: PII # (5)
propagate: true # (6)
removePropagationsOnEntityDelete: true # (7)
restrictPropagationThroughLineage: false # (8)
restrictPropagationThroughHierarchy: false # (9)
- name: Marketing Analysis
propagate: true
removePropagationsOnEntityDelete: true
restrictPropagationThroughLineage: false
restrictPropagationThroughHierarchy: false
classifications: # (10)
- typeName: yQBDoKHdTLJhqAsdR3RMq6 # (11)
propagate: true
removePropagationsOnEntityDelete: true
restrictPropagationThroughLineage: false
restrictPropagationThroughHierarchy: false
- typeName: WCVjmgKnW40G151dESXZ03
propagate: true
removePropagationsOnEntityDelete: true
restrictPropagationThroughLineage: false
restrictPropagationThroughHierarchy: false
- name: ANOTHER_ASSET # (12)
meta:
atlan:
classificationNames:
- ...
  1. You must of course give the name of the object.
  2. The simplest way to tag an asset, using the default values for propagation (those shown below), is to use the meta.atlan.classificationNames structure.
  3. When using this simplified form, you can give the normal human-readable name of the tags rather than the hashed-string representation.
  4. Alternatively, if you want to override the propagation settings, you can use this more detailed structure.
  5. Each listed item must itself be a YAML object consisting of the human-readable name of the tag and the propagation setting overrides:
  6. (Optional) You can decide whether to propagate this tag (true) or not (false). If you choose false, no propagation of this tag from the asset will occur—neither through lineage nor parent-child relationships.
  7. (Optional) If propagation is allowed, you can then define whether propagated tags should be removed if this asset is deleted (true) or not (false).
  8. (Optional) If propagation is allowed, you can also decide whether to disable propagation of the tag only for lineage (true) or still allow it through lineage (false).
  9. (Optional) If propagation is allowed, you can also decide whether to disable propagation of the tag only for hierarchy (true) or still allow it through hierarchy (false).
  10. Alternatively, you can specify tags nested within the meta.atlan.classifications structure.
  11. In this structure, each tag you want to add must be given using its hashed-string representation. Its propagation settings can be overridden using the same options described above.
  12. To apply tags to multiple assets, just list all of the assets in the model file.

Find hashed-string names

When using either the raw APIs or dbt, you must provide the custom metadata names using Atlan's hashed-string representation.

Not necessary for SDKs

Note that this isn't needed when using the SDKs, which translate these for you!

To look up the hashed-string representations:

The response will include displayName and name for each tag. The displayName is what you see in Atlan's UI, and the name is the hashed-string representation:

Simplified response
{
"enumDefs": [],
"structDefs": [],
"classificationDefs": [
{
"category": "CLASSIFICATION",
"guid": "c43e2f52-975f-40b6-88fa-93697fb54f52",
"name": "WCVjmgKnW40G151dESXZ03", // (1)
"displayName": "Marketing Analysis",
"description": "Assets relevant to the marketing domain"
},
{
"category": "CLASSIFICATION",
"guid": "ec641061-d8fa-4090-9145-a5f23c9c3e99",
"name": "yQBDoKHdTLJhqAsdR3RMq6", // (2)
"displayName": "PII",
"description": "Personally-identifiable information can be used to uniquely identify an individual person."
},
{
"category": "CLASSIFICATION",
"guid": "70211696-f3fb-4a4a-a81a-db589e29f436",
"name": "Z96sGJrF0S68PxYTUdKG6b", // (3)
"displayName": "Sensitivity",
"attributeDefs": [
{
"name": "rt5N3mHZTcxXafuu6ZPpyL", // (4)
"displayName": "sourceTagAttachment",
"description": "",
"typeName": "array<SourceTagAttachment>",
"isDefaultValueNull": false,
"isOptional": true,
"cardinality": "SET",
"valuesMinCount": 0,
"valuesMaxCount": 2147483647,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false,
"skipScrubbing": false,
"searchWeight": -1,
"isNew": true
}
],
}
],
"entityDefs": [],
"relationshipDefs": [],
"businessMetadataDefs": []
}
  1. Hashed-string name for the tag named Marketing Analysis.
  2. Hashed-string name for the tag named PII.
  3. Hashed-string name for the tag named Sensitivity.
  4. Hashed-string name for the sourceTagAttachment attribute in the Sensitivity classification.
Was this page helpful?