# Multi-word custom API endpoint

**URL:** <https://discourse.getcockpit.com/t/multi-word-custom-api-endpoint/2184>\
**Category:** Support\
**Created:** [December 10, 2021, 8:52am UTC](https://discourse.getcockpit.com/t/multi-word-custom-api-endpoint/2184 "2021-12-10T08:52:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeManiac](https://avatars.discourse-cdn.com/v4/letter/c/2bfe46/32.png) [@CodeManiac](https://discourse.getcockpit.com/u/CodeManiac)\
**Post date:** [December 10, 2021, 8:52am UTC](https://discourse.getcockpit.com/t/multi-word-custom-api-endpoint/2184/1 "2021-12-10T08:52:36Z")

</div>

Hi, I am trying to set up my own API endpoint by addon. I need to have a controller methods under some multi-word API path. My goal is to have endpoint like this:

> `http://localhost:8080/api/custom/collections/get?token=xxx`

where ‘get’ will be one of actions from my addon controller.

So in my addon bootstrap.php I added:

```auto
if (COCKPIT_API_REQUEST) {
    $this->on('cockpit.rest.init', function ($routes) {
        $routes['custom/collections'] = 'CustomAddon\\Modules\Collections\\Controller\\RestApi';
    });
}

```

It not works. I have also tested with dot, full api path etc. And I also couldn’t find information about how I can do this. Maybe some of us know how can I hook full conroller methods under complex API path from addons or mabe from other way?
