---
# System prepended metadata

title: Tags API

---

# Tags API

ALL api routes hosted by ADMIN but It's not important for you, because we use API service

1) Create a new tag

POST
/tags
body:
{
    "name": "max-test",
    "scope": { "type": "workspace", "ids": [17]},
    "description":"max-test"
}

resp:
{
data: {
"_id" : ObjectId("6225c76e8da19d000be765d5"),
	"scope" : {
		"ids" : [
			7
		],
		"type" : "workspace",
		"parentId" : 3
	},
	"usageCount" : 0,
	"name" : "iriny",
	"description" : "мпр",
	"tagId" : 405,
	"__v" : 0
}
}

PATCH
/tags/:tagId
body:
{
    "description":"max-test(upd)"
}
resp:
{
data: {
"_id" : ObjectId("6225c76e8da19d000be765d5"),
	"scope" : {
		"ids" : [
			7
		],
		"type" : "workspace",
		"parentId" : 3
	},
	"usageCount" : 0,
	"name" : "iriny",
	"description" : "мпр",
	"tagId" : 405,
	"__v" : 0
}
}

DELETE
/tags/:tagId
body: { ids?: [ {workspaceId} ]}
resp: { message: 'ok'}


2) Assign tag to entities

PATCH
/entities/tags/:tagId
body: {
    workspaceId,
    entityIds: [1,2]
}
statusCode: 207
resp:
data:[{
  entityId: 1, success: true|false
},
{
  entityId: 2, success: true|false
}]

3) Detach tag from entities

DELETE
/entities/tags/:tagId
body: {
    workspaceId,
    entityIds: [1,2]
}
statusCode: 207
resp: 
data: [{
  entityId: 1, success: true|false
},
{
  entityId: 2, success: true|false
}]

4) Assign tag to sessions

PATCH
/sessions/tags/:tagId
body: {
    sessionIds: [1,2]
}
statusCode: 207
resp: 
data:[{
  sessionId: 1, success: true|false
},
{
  sessionId: 2, success: true|false
}]

5) Detach tag from sessions

DELETE
/sessions/tags/:tagId
body: {
    sessionIds: [1,2]
}
resp: statusCode: 207
data: [{
  sessionId: 1, success: true|false
},
{
  sessionId: 2, success: true|false
}]

6) Assign tag to script items

PATCH
/scripts/script-items/tags/:tagId
body: {
    scriptItemIds: [1,2]
}
resp: statusCode: 207
data: [{
  scriptItemId: 1, success: true|false
},
{
  scriptItemId: 2, success: true|false
}]

7) Detach tag from script items

DELETE
/scripts/script-items/tags/:tagId
body: {
    scriptItemIds: [1,2]
}
resp: statusCode: 207
data: [{
  scriptItemId: 1, success: true|false
},
{
  scriptItemId: 2, success: true|false
}]


8) Get tags

GET
/tags?workspaceId=7&includeScopes=project,organization

resp: {
data: [
{
"_id" : ObjectId("6225c76e8da19d000be765d5"),
	"scope" : {
		"ids" : [
			7
		],
		"type" : "workspace",
		"parentId" : 3
	},
	"usageCount" : 0,
	"name" : "iriny",
	"description" : "мпр",
	"tagId" : 405,
	"__v" : 0
}
]
}


cur => next => prev(not correct mongo id in "next" cursor)