# Making API POST request in Kibana plugin

**URL:** <https://discuss.elastic.co/t/making-api-post-request-in-kibana-plugin/337003>\
**Category:** Kibana\
**Tags:** kibana-plugin-development\
**Created:** [June 27, 2023, 1:57pm UTC](https://discuss.elastic.co/t/making-api-post-request-in-kibana-plugin/337003 "2023-06-27T13:57:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![trosagnant](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@trosagnant](https://discuss.elastic.co/u/trosagnant)\
**Post date:** [June 27, 2023, 1:57pm UTC](https://discuss.elastic.co/t/making-api-post-request-in-kibana-plugin/337003/1 "2023-06-27T13:57:19Z")

</div>

Hello everyone,  
I'm trying to create a simple Kibana plugin which should send \_update\_by\_query request to elasticsearch, with values to updated provided by GUI in said plugin, but I can't quite grasp how making API calls works from a plugin.

At first I've tried doing it with `fetch(node/_update_by_query, method: "POST)"`, but I realized it's the wrong way to do it entirely.

From what I've learned, I believe I should use the `data` plugin in order to prepare a query and send it, but I cannot comprehend, how it should be done and the documentation provided with it doesn't make anything clearer for me. Could you please provide me with some tutorial/examples on how such request should be done?

I realize this is a pretty basic question, but this plugin is my first contact with the entire ELK stack I feel a bit lost...  
Thank you in advance. 🙂

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [June 27, 2023, 7:32pm UTC](https://discuss.elastic.co/t/making-api-post-request-in-kibana-plugin/337003/2 "2023-06-27T19:32:49Z")

</div>

data plugin is for `_search` API access.

Kibana client does not have direct access to elasticsearch. You will need to create a rest endpoint in server folder of your plugin. This end point will internally call elasticsearch API and forward a response. Then you can call this endpoint with fetch in the client. Here is an example.

server route [/internal/file\_upload/import](https://github.com/elastic/kibana/blob/main/x-pack/plugins/file_upload/server/routes.ts#L138)

calling route in client [kibana/x-pack/plugins/file\_upload/public/importer/importer.ts at main · elastic/kibana · GitHub](https://github.com/elastic/kibana/blob/main/x-pack/plugins/file_upload/public/importer/importer.ts#L298)

---

<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 25, 2023, 7:33pm UTC](https://discuss.elastic.co/t/making-api-post-request-in-kibana-plugin/337003/3 "2023-07-25T19:33:41Z")

</div>

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