Skip to content
Last updated

Listing and Reviewing Tags Using the REST API

You can view the list and view the usage of each tag, including details, policy, and column information.

Policy tags are not isolated in the detail and usage lists for all tags. Therefore, namespace: POLICY and namespace: RESOURCE are combined in the results.

List Tags

List and view details for all tags.

curl --request GET "https://api-data-def-repo.treasuredata.com/v1/annotation-type/custom" \
--header 'Authorization: TD1 ${6542/1120000023340000042320000016789000005438}'

Sample Response

{
  "data": [
    {
      "id": "2f27b00e-9377-419e-91c3-4456598c30a8",
      "attributes": {
        "name": "PII",
        "humanReadableName": "PII",
        "comment": null,
        "version": 1,
        "createdAt": "2021-05-20T22:10:32.872791Z",
        "updatedAt": "2021-05-20T22:10:32.872791Z",
        "color": "POLICY_DEFAULT",
        "namespace": "POLICY"
      },
      "type": "annotation-type"
    },
    {
      "id": "6d4ed012-9a68-4de4-820d-e9b70c22382e",
      "attributes": {
        "name": "KarinTag",
        "humanReadableName": "KarinTag",
        "comment": "",
        "version": 1,
        "createdAt": "2022-01-07T17:08:32.255631Z",
        "updatedAt": "2022-01-07T17:08:32.255631Z",
        "color": "RESOURCE_DEFAULT",
        "namespace": "RESOURCE"
      },
      "type": "annotation-type"
    },
    ....
  ]
}

View Usage for Each Tag

You can view how each tag is used. In the following example, you can see usage for PII.

$ curl --request GET "https://api-data-def-repo.treasuredata.com/v1/column-annotation/lookup?annotationTypeName=PII" \
       --header 'Authorization: TD1 ${6542/1120000023340000042320000016789000005438}'

Sample Response

{
  "data": [
    {
      "id": "465302e6-67c0-4b33-9462-2f501c511601",
      "attributes": {
        "comment": "",
        "createdAt": "2021-09-30T07:40:01.792499Z",
        "sensitive": false
      },
      "relationships": {
        "annotation-type": {
          "data": {
            "type": "annotation-type",
            "id": "2f27b00e-9377-419e-91c3-4456598c30a8",
            "name": "PII"
          }
        },
        "table": {
          "data": {
            "type": "treasure-data-table",
            "id": "607222.3276426"
          }
        },
        "column": {
          "data": {
            "type": "treasure-data-column",
            "id": "dob"
          }
        },
        "created-by": {
          "data": {
            "type": "treasure-data-user",
            "id": "33648"
          }
        }
      },
      "type": "column-annotation"
    },
    ...
  ],
  "links": {
    "first": "/v1/column-annotation/lookup?annotationTypeName=PII",
    "self": "/v1/column-annotation/lookup?annotationTypeName=PII"
  },
  "meta": {
    "perPage": 250
  }
}

List Tags with a Specific Project

You can use a GET command along with the query parameter filter[projectId] to list tags with a specific project. In the following example, the user is requesting to list tags for project 187725.

curl --request GET 'https://api-data-def-repo.treasuredata.com/v1/project-annotation?filter[projectId]=187725' \
     --header 'Authorization: TD1 ${6542/1120000023340000042320000016789000005438}'

Sample Response

As the response reveals, the project 187725 has two tags: 4a45b1de-b27b-4414-92d6-4224490a5078 and 8afc7323-432c-46f8-bb19-b0cc4f5b8e77.

{
    "data": [
        {
            "id": "4ad2008c-1019-4ced-8e53-74b155df0c0f",
            "attributes": {
                "comment": null,
                "createdAt": "2022-05-17T02:50:36.586640Z"
            },
            "relationships": {
                "annotation-type": {
                    "data": {
                        "type": "annotation-type",
                        "id": "4a45b1de-b27b-4414-92d6-4224490a5078",
                        "name": "seasonal-sales"
                    }
                },
                "project": {
                    "data": {
                        "type": "treasure-data-workflow-project",
                        "id": "187725"
                    }
                },
                "created-by": {
                    "data": {
                        "type": "treasure-data-user",
                        "id": "1273"
                    }
                }
            },
            "type": "project-annotation"
        },
        {
            "id": "57eef758-23d4-4236-add5-837e9f398c33",
            "attributes": {
                "comment": null,
                "createdAt": "2022-05-17T02:50:36.586640Z"
            },
            "relationships": {
                "annotation-type": {
                    "data": {
                        "type": "annotation-type",
                        "id": "8afc7323-432c-46f8-bb19-b0cc4f5b8e77",
                        "name": "online-sales"
                    }
                },
                "project": {
                    "data": {
                        "type": "treasure-data-workflow-project",
                        "id": "187725"
                    }
                },
                "created-by": {
                    "data": {
                        "type": "treasure-data-user",
                        "id": "1273"
                    }
                }
            },
            "type": "project-annotation"
        }
    ],
    "links": {
        "first": "/v1/project-annotation?filter%5BprojectId%5D=187725",
        "self": "/v1/project-annotation?filter%5BprojectId%5D=187725"
    },
    "meta": {
        "perPage": 250
    }
}