how we can create dynamically tags form our webapp using api or plugin.
so i can attach later to some topic.
AI-generated summary
In a discussion about customizing the Discourse tagging plugin, vikash159 inquires how to dynamically create tags from a web application using an API or plugin to attach them to topics. cpradio responds that the most effective method is utilizing the Discourse API. To tag an existing topic, one must first retrieve the current tags by calling the topic’s JSON endpoint, append the new tag to the list, and then send a PUT request to the topic endpoint with the updated tags in the tags[] form data. cpradio notes that to clear all tags from an existing topic, a PUT request with tags_empty_array set to true is required. For creating a new topic with tags, a POST request to /posts should include the raw content, title, category, archetype, and the tags[] array. They clarify that tags_empty_array is unnecessary when creating a new topic without tags.
The easiest way that I can think of is using the Discourse API.
So you will need to either use an existing topic or create a new one, then using the API you submit a PUT request to that topic with the form data containing tags[] with the tags you want the topic to have.
If you use an existing topic, you will need to call the topic.json to get the current list of tags so you can append your new one to it.
Existing Topic:
- Call the json for the existing topic,
/t/testing-something-with-classes/76/1.json - Read the tags property
- Append new tag to the existing tags
- Send PUT to
/t/testing-something-with-classes/76with form data key oftags[]and the value containing the tags you are sending (each tag should be on its own – see screenshot below)

Note: Deleting all tags, you send a PUT command to the topic with a form data key of tags_empty_array and a value of true
Creating a Topic
- Send POST command to
/postscontaining the raw, title, category, archetype (equal to regular), and tags (as noted above)
Note: You do not need to send tags_empty_array if you do not apply any tags to a new topic