# POST custom endpoint

**URL:** <https://discuss.elastic.co/t/post-custom-endpoint/179952>\
**Category:** Kibana\
**Created:** [May 7, 2019, 11:34am UTC](https://discuss.elastic.co/t/post-custom-endpoint/179952 "2019-05-07T11:34:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![masterThomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/masterthomas/32/42765_2.png) [@masterThomas](https://discuss.elastic.co/u/masterThomas)\
**Post date:** [May 7, 2019, 11:34am UTC](https://discuss.elastic.co/t/post-custom-endpoint/179952/1 "2019-05-07T11:34:04Z")

</div>

hi team,  
new in kibana and writiing custom endpoint for the POST requests for my plugin to update data from frontend.

my GET endpoint looks like this:

```auto
server.route({
    path: '/getmydata',
    method: 'GET',
    handler(req, reply) {
         return callWithRequest(req, 'search',{
 		'index':'myindex',
 		'q':'all'
 	});
  }
});

```

and how the POST endpoint should look like ? It should update my index from frontend.  
P.S. timelion open code, unfortunately does not explain any sense for me.

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [May 7, 2019, 10:53pm UTC](https://discuss.elastic.co/t/post-custom-endpoint/179952/2 "2019-05-07T22:53:01Z")

</div>

Hey @masterThomas -

One example you might check out is the `/fns` endpoint [in the core interpreter plugin](https://github.com/elastic/kibana/blob/master/src/legacy/core_plugins/interpreter/server/routes/server_functions.js#L36-L118).

In a nutshell:

```auto
  server.route({
    method: 'POST',
    path: `${API_ROUTE}/your_endpoint`,
    options: {
      payload: {
        allow: 'application/json',
        maxBytes: 26214400, // payload limit (25MB in this example)
      },
      validate: {
        payload: Joi.object({
           // your Joi validation config here
        }).required(),
      },
    },
    handler(req) {
      const { payload } = req;
      // do something with payload
    },
  });

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 4, 2019, 10:53pm UTC](https://discuss.elastic.co/t/post-custom-endpoint/179952/3 "2019-06-04T22:53:04Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
