How to add and remove a Tag in a plugin

How can we add a tag to a post, and also remove the tag of the post using the discourse functions?

Hello. Use this to figure out how to use the Discourse API if you don’t understand how to use the Discourse API and wish to learn:

This is actually a duplicated topic. :+1:
I’ve answered him here: How to Add and Remove a Flag for a Post.

1 Like

Actually, this is not a duplicate topic as I’ve asked another question on “Flag” and this question is related to “Tag”. I’m trying to use the functions in developing a plugin.

As I’m developing a plugin and I have checked all possible resources, I didn’t find a relevant function that will help me add and remove a tag for the post.

Dev isn’t my strong suit, but there are often examples of how to do things in existing plugins. I think the Automation plugin has a script to add tags based on AI triage. Perhaps looking at that could be helpful?

In general, I’d also recommend including some more detail about what you’ve tried so far/how far you’ve got when asking for dev help. This can help provide context for any answers you might be hoping for.

Just to point out: you can’t Tag a Post.

You can Tag a Topic though.

Which might explain why you couldn’t find an example of the former.

Here’s an example of the latter:


Is there any function or feature that works same as a tag and then by clicking on it will list all those posts?