Skip to main content

Manage custom tags on your documents by API

Field to use as parameter in the API

You can update the tags on a document which is indexed in your project by using the modify document API. More information can be found here: Modifying documents with the Talkwalker API

The field tags_customer can be used to update the tags on a document. As it accept arrays, it supports operators + and - as prefix :

  • +tags_customer to add tags to the existing tags on the document.
  • -tags_customer to remove specific tags from the document.
  • tags_customer to reset the tags on the document.
Important

The value to use is the label of the tag, not their ID.

Add a tag on a document

To add a tags on a document, we can use following request:

curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "<document_url>",
"+tags_customer": [ “<tag_label>”, “<tag_label>”, ...]
}'
Important

If the tag does not exist in the project, it will be automatically created in the project configuration.

In our sample, we will add the tag “Pascal” on the following document with URL: http://www.youtube.com/watch?v=a3g7IROzfa0

Add tag by API

Result in Talkwalker platform:

Add tag by API - UI result

Create a tag in the project’s configuration

When you add a tag on a document, if the tag does not exist in the project, it will be automatically created in the project configuration.

Important

It's impossible to update/delete a tag from the project's configuration by API. This must be done from the platform.

In this sample, We will add the tag “Pascal2” on the document with URL: http://www.youtube.com/watch?v=a3g7IROzfa0. This tag is not part of the project’s configuration.

curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "http://www.youtube.com/watch?v=a3g7IROzfa0",
"+tags_customer": [ "Pascal2" ]
}'

Result in Talkwalker platform:

Create tag by API - UI result - document

And in the project settings:

Create tag by API - UI result - settingd

Remove a tag on a document

To remove tags on a document, we can use following request:

curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "<document_url>",
"-tags_customer": [ “<tag_label>”, “<tag_label>”, ...]
}'

In our sample we will remove the tag “Pascal” from the document with the URL: http://www.youtube.com/watch?v=a3g7IROzfa0.

remove tag by API

Result in talkwalker platform:

remove tag by API - UI result

Reset tags on a document

To reset and change all tags on a document, we can use following request:

curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "<document_url>",
"tags_customer": [ “<tag_label>”, “<tag_label>”, ...]
}'

It will remove all existing tags from a document and replace them with the new list of tags.

In our sample, we will change the tag “Pascal2” from the document with URL: http://www.youtube.com/watch?v=a3g7IROzfa0. It will be replaced by the tags “Employee type/Technical” and “Pascal”:

reset tag by API

Result in talkwalker platform:

reset tag by API - UI result

Remove all tags from a document

To remove all tags from a document, we can use following request with an empty array:

curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "<document_url>",
"tags_customer": [ ]
}'

It will remove all existing tags from a document.

In our sample, we will remove all tags from the document with URL: http://www.youtube.com/watch?v=a3g7IROzfa0.

remove all tags by API

Result in Talkwalker platform:

remove all tags by API - UI result