# API: Create a category but append/add to description more details

**URL:** https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728
**Category:** Development
**Tags:** rest-api
**Created:** [September 28, 2019, 11:18am UTC](https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728 "2019-09-28T11:18:45Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![alank](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@alank](https://meta.discourse.org/u/alank)
#### Post date: [September 28, 2019, 11:18am UTC](https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728/1 "2019-09-28T11:18:46Z")

</div>

I’m using API request to Discourse to create a category, however in the same process I would like to add text or URL reference etc, to Category description (or is it description\_text as I try to understand the properties or differences).

Note also that there might be a “robot” adding to this, so the best way…

1. create category (working)
2. Update category or more so append the link, but to category.description or category.description\_text)?

However there are no properties on update except `name`, `color`, `text_color`, so are there other properties I can send? Like (and which) `description` or/maybe `description_text`?

All I want to do is add a slug link to a site related to the category I’m creating… or simply add at the end of the Discourse Category description “[link][https/example.projectxxx”

---

<div class="post-metadata">

### Author: ![ClawdiaWolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clawdiawolf/32/262518_2.png) [@ClawdiaWolf](https://meta.discourse.org/u/ClawdiaWolf)
#### Post date: [September 28, 2019, 11:03pm UTC](https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728/2 "2019-09-28T23:03:27Z")

</div>

Hi, Andrew.

Although the [docs](https://docs.discourse.org/#tag/Categories/paths/~1categories.json/post) only list those 3 properties, most of the properties mentioned in the Response object can be set on the create call. I found this out when I needed to script the creation of a large number of categories with the same settings except for the name and slugs.

The only property I needed to set and consistently had issues with is the permissions.

---

<div class="post-metadata">

### Author: ![alank](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@alank](https://meta.discourse.org/u/alank)
#### Post date: [October 8, 2019, 12:07pm UTC](https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728/3 "2019-10-08T12:07:33Z")

</div>

Yes, I’ve noticed that properties allowed are not those defined in the API documentation.

However to set the Category “description” which is very confusing as the category description is not at all what is displayed, in fact below the category name is the HTML element “cooked” which is empty, so how to set that…

From what I’ve been able to understand, I must set a post in the “About the --category name-- …” and it must be the first post in that category, but I think there is other critaria, like the cooked or also the fact that we have a Bot that first posts there.

I’ve tried adjusting the created\_at/updated\_at dates to make my post appear above so that the category will grab or use that description, but no luck! There must be something I’m not understanding about the “cooked” and/or category description. Very confusing and I’ve found no docs, but I’ll keep looking, if anyone has ideas on what to try, please let me know.

---

<div class="post-metadata">

### Author: ![artur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/artur/32/260740_2.png) [@artur](https://meta.discourse.org/u/artur)
#### Post date: [November 16, 2021, 11:42am UTC](https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728/4 "2021-11-16T11:42:06Z")

</div>

Hi, digging up this old topic..  
Is there any way to understand what the difference between `description_text` and `description` is?  
I mean except finding it out by doing 🙂  
maybe @alank found it out by now!  
Thanks!

---

<div class="post-metadata">

### Author: ![Simon\_Manning](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon_manning/32/198596_2.png) [@Simon\_Manning](https://meta.discourse.org/u/Simon_Manning)
#### Post date: [November 16, 2021, 12:05pm UTC](https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728/5 "2021-11-16T12:05:37Z")

</div>

If it’s not documented elsewhere, searching within the spec files in the discourse repository will answer things like this with a basic understanding of how programming languages work.

In this case, the following lines in the category spec show that `description_text` is derived from `description` and immediately available after setting `description`.

This says to me that `description` is the raw string for the description and upon setting it, it gets cooked and assigned to `description_text`. Or `description_text` could be calculated when accessed but I doubt it, either way `description` is the one to set.

> <https://github.com/discourse/discourse/blob/c4843fc1c18fc9fb077d61e59615f54c4735bb42/spec/models/category_spec.rb#L367-L374>

---

<div class="post-metadata">

### Author: ![artur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/artur/32/260740_2.png) [@artur](https://meta.discourse.org/u/artur)
#### Post date: [November 16, 2021, 1:06pm UTC](https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728/6 "2021-11-16T13:06:10Z")

</div>

thanks Simon, that clarifies the difference between both parameters.

However, I just tried and none of those two parameters are actually set in the category description (or the About category post). So the issue of the OP remains.

Adding: I see in the categories.json file that these description parameters are what I want, but I somehow cannot set them through the API!

---

<div class="post-metadata">

### Author: ![Simon\_Manning](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon_manning/32/198596_2.png) [@Simon\_Manning](https://meta.discourse.org/u/Simon_Manning)
#### Post date: [November 16, 2021, 1:45pm UTC](https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728/7 "2021-11-16T13:45:33Z")

</div>

If they aren’t documented for the POST request payload, you can’t rely on being able to set them like that even if it happened to work.

I suspect the thing to do is to look at the `topic_url` in the response after creating category, then [get a single topic](https://docs.discourse.org/#operation/getTopic) using the id from that URL. Look at the `post_stream` in the response which has an array of posts, I imagine that will have one element.

Get the id of that post and then [update a single post](https://docs.discourse.org/#operation/updatePost) to add your description. That should trigger the category description being updated the same as editing the post in Discourse, same first line rule.

---

<div class="post-metadata">

### Author: ![artur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/artur/32/260740_2.png) [@artur](https://meta.discourse.org/u/artur)
#### Post date: [November 16, 2021, 2:03pm UTC](https://meta.discourse.org/t/api-create-a-category-but-append-add-to-description-more-details/129728/8 "2021-11-16T14:03:34Z")

</div>

I was just going to post, that’s exactly what I did 🙂

```python
    ## create category
    ret_cat = client.create_category(name, color = color, **kwargs)

    ## get first post id 
    cat_id = ret_cat["category"]["id"]
    print("Cat id", cat_id)
    topics = client.category_topics(cat_id)
    first_post_id = client.topic_posts(topics["topic_list"]['topics'][0]["id"])['post_stream']['posts'][0]['id']
    ## modify first post
    ret_post = client.update_post(first_post_id, cat["about_msg"],"set up")

```
