# Custom endpoint settings

**URL:** <https://discuss.elastic.co/t/custom-endpoint-settings/184595>\
**Category:** Kibana\
**Created:** [June 6, 2019, 1:47pm UTC](https://discuss.elastic.co/t/custom-endpoint-settings/184595 "2019-06-06T13:47:50Z")\
**Posts on this page:** 4\
**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:** [June 6, 2019, 1:47pm UTC](https://discuss.elastic.co/t/custom-endpoint-settings/184595/1 "2019-06-06T13:47:50Z")

</div>

Hi team,  
How to set custom endpoint to write JSON from front-end to two indicies simultaneously?  
Use Kibana 6.7.0.

---

<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:** [June 6, 2019, 8:23pm UTC](https://discuss.elastic.co/t/custom-endpoint-settings/184595/2 "2019-06-06T20:23:41Z")

</div>

You'll need to create a custom plugin and add a server route with the path you want to call from the front end. This route can then handle talking to Elasticsearch on behalf of the client.

```auto
return new kibana.Plugin({
  // ...
  init(server, options) {
    server.route({
      path: '/api/my_plugin/my_endpoint',
      method: 'GET',
      handler(req, reply) {
        const response = await server.plugins.elasticsearch.callWithRequest(req, ...args);
        // ... do something with response
        reply('message to send to client');
      }
    });
  }
});

```

Then you can talk to your API from the front end by calling `/api/my_plugin/my_endpoint`

[This blog post](https://www.timroes.de/writing-kibana-plugins-custom-applications#creating-a-new-server-api), though a few years old, provides some good examples with further detail on how to configure server routes in your plugin & query Elasticsearch using `callWithRequest`.

Kibana's server-side plugin code relies heavily on hapi, so [those docs](https://hapijs.com/api) will also be a good point of reference in terms of how to configure your server routes.

---

<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:** [June 7, 2019, 7:42am UTC](https://discuss.elastic.co/t/custom-endpoint-settings/184595/3 "2019-06-07T07:42:22Z")

</div>

issue resolved

---

<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:** [July 5, 2019, 7:42am UTC](https://discuss.elastic.co/t/custom-endpoint-settings/184595/4 "2019-07-05T07:42:22Z")

</div>

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