--- id: kibDevTutorialServerEndpoint slug: /kibana-dev-docs/tutorials/registering-endpoints title: Registering and accessing an endpoint summary: Learn how to register a new endpoint and access it date: 2021-10-05 tags: ['kibana', 'dev', 'architecture', 'tutorials'] --- ## Registering an endpoint The server-side `HttpService` allows server-side plugins to register endpoints with built-in support for request validation. These endpoints may be used by client-side code or be exposed as a public API for users. Most plugins integrate directly with this service. The service allows plugins to: - to extend the Kibana server with custom HTTP API. - to execute custom logic on an incoming request or server response. - to implement custom authentication and authorization strategy. See [the server-side HTTP service API docs](https://github.com/elastic/kibana/blob/main/docs/development/core/server/kibana-plugin-core-server.httpservicesetup.md) **Registering a basic GET endpoint** ```ts import { schema } from '@kbn/config-schema'; import type { CoreSetup, Plugin } from 'kibana/server'; export class MyPlugin implements Plugin { public setup(core: CoreSetup) { const router = core.http.createRouter(); const validate = { params: schema.object({ id: schema.string(), }), }; router.get({ path: '/api/my_plugin/{id}', validate }, async (context, request, response) => { const data = await findObject(request.params.id); if (!data) return response.notFound(); return response.ok({ body: data, headers: { 'content-type': 'application/json' } }); }); } } ``` See [the routing example plugin](https://github.com/elastic/kibana/blob/main/examples/routing_example) for more route registration examples. ## Consuming the endpoint from the client-side The client-side HTTP service provides an API to communicate with the Kibana server via HTTP interface. The client-side `HttpService` is a preconfigured wrapper around `window.fetch` that includes some default behavior and automatically handles common errors (such as session expiration). **The service should only be used for access to backend endpoints registered by the same plugin.** Feel free to use another HTTP client library to request 3rd party services. ```ts import { HttpStart } from 'kibana/public'; interface ResponseType {…}; async function fetchData(http: HttpStart, id: string) { return await http.get( `/api/my_plugin/${id}`, { query: … }, ); } ``` See [the client-side HTTP service API docs](https://github.com/elastic/kibana/blob/main/docs/development/core/public/kibana-plugin-core-public.httpsetup.md) See [the routing example plugin](https://github.com/elastic/kibana/blob/main/examples/routing_example) for more endpoint consumption examples.