Reference

Guide

api

Set options for Kirby's REST API

Disable the API

You can completely disable the API for the frontend.

return [
  'api' => false
];

Change the API slug

You can set a custom slug. The default slug is api.

return [
  'api' => [
    'slug' => 'rest'
  ]
];

All endpoints are now available at https://yourdomain.com/rest/.

Allow insecure requests

By default authentication via basic auth is only permitted when https is enabled. In rare cases (e.g. during local development), it might be necessary to allow basic auth even when https is not enabled.

return [
  'api' => [
    'allowInsecure' => 'true'
  ]
];

Custom API elements

Check out the API extension reference to learn more about adding custom API endpoints, models, collections or more. Instead of using a plugin, you can add them to your config options in the same manner.

/site/config/config.php
return [
  'api' => [
    'routes' => [
      [
        'pattern' => 'my-endpoint',
        'action'  => function () {
          return [
            'hello' => 'world'
          ];
        }
      ]
    ]
  ]
];