# When to use PUT versus POST?

**URL:** <https://discuss.elastic.co/t/when-to-use-put-versus-post/68550>\
**Category:** Elasticsearch\
**Created:** [December 9, 2016, 11:00am UTC](https://discuss.elastic.co/t/when-to-use-put-versus-post/68550 "2016-12-09T11:00:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 9, 2016, 2:36pm UTC](https://discuss.elastic.co/t/when-to-use-put-versus-post/68550/2 "2016-12-09T14:36:02Z")

</div>

It's all about REST semantics.

POST basically that you are posting a request which is going to modify the server state.

```auto
POST index/type
{
  "foo": "bar"
}

```

will generate an `_id` server side and will index the document with this `_id`.

PUT is used to send a resource to the server.

```auto
PUT index/type/id
{
  "foo": "bar"
}

```

will put or update a document named `index/type/id` in the server.

Makes sense?

More details here: [https://en.wikipedia.org/wiki/Representational\_state\_transfer](https://en.wikipedia.org/wiki/Representational_state_transfer)

---

_[View the full topic](https://discuss.elastic.co/t/when-to-use-put-versus-post/68550)._
