# Update a Post, via API PUT: request

**URL:** https://meta.discourse.org/t/update-a-post-via-api-put-request/130252
**Category:** Development
**Tags:** rest-api
**Created:** [4 oktober 2019 om 15:01 UTC](https://meta.discourse.org/t/update-a-post-via-api-put-request/130252 "2019-10-04T15:01:16Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [4 oktober 2019 om 15:17 UTC](https://meta.discourse.org/t/update-a-post-via-api-put-request/130252/2 "2019-10-04T15:17:10Z")

</div>

I’m not actually sure what `raw_old` is for at the moment, but you just need to use the `raw` field and it will replace the entire post. So, in your code you would fetch the post you want to edit, add your line to the top, then update the post using the `raw` field.

It might be helpful to see how Discourse does it by editing a post live on your site and inspecting the browser calls:

> [@Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576):
>
> Discourse is backed by a complete JSON api. Anything you can do on the site you can also do using the JSON api. The API is documented at [docs.discourse.org](https://docs.discourse.org). You can also use the [discourse\_api](https://github.com/discourse/discourse_api) Ruby gem as a client library. However, not every endpoint is documented. To determine how to do something with the JSON API here are some steps you can follow. Example: recategorize a topic. Go to a topic and start editing a category: Open Chrome dev tools, switch to the Network tab, select …

This is also how the discourse\_api gem does it:

> <https://github.com/discourse/discourse_api/blob/main/lib/discourse_api/api/posts.rb#L30>

---

_[View the full topic](https://meta.discourse.org/t/update-a-post-via-api-put-request/130252)._
