How to create custom API Endpoints

In Cockpit you can create a custom api entry point pretty easy:

Create the following file /config/api/custom.php

we now do a custom query in that file:

<?php

// very simple code here

$test = $this->param('test');

if (!$test) {
    return false;
}

return $test;

now you can query /api/custom?token=xxx&test=foo,bar,baz

if you want to have the api public (without token) then create the file in a subfolder named public: /config/api/public/custom.php

now you can query /api/public/custom?test=foo,bar,baz

9 Likes