Search code examples
jsontagslabelconfluence-rest-api

How to Add Labels to Confluence Page via REST


I've been hunting for the correct way to add labels to a confluence page via REST (tags, categories, or whatever they are calling them today)

the documentation simply says "add json to the body" and then shows this example

[{"prefix":"global","name":"label1"},{"prefix":"global","name":"label2"}]

Has anyone successfully done this


Solution

  • You need to POST the JSON body using this endpoint: POST /rest/api/content/{id}/label where the id is the id for the content (page).

    Reference: https://docs.atlassian.com/confluence/REST/latest/#content/{id}/label-addLabels

    For example:

    POST /rest/api/content/{id}/label HTTP/1.1

    Host: yourinstance.atlassian.net

    Authorization: Basic YaRtsWdg4VzdAzazhib2FyZA==

    Content-Type: application/json

    Cache-Control: no-cache

    [ { "prefix": "global", "name": "label1" }, { "prefix": "global", "name": "label2" } ]