Documents
server-api
server-api
Type
External
Status
Published
Created
Mar 5, 2026
Updated
Mar 11, 2026
Updated by
Dosu Bot

import Prerequisite from '/docs/snippets/plugins-development-create-plugin-prerequisite.md'

Server API for plugins: An overview#

The Server API defines what a plugin registers, exposes, and executes on the Strapi server. It covers lifecycle hooks, routes, controllers, services, policies, middlewares, and configuration. Use the entry file to declare what the plugin contributes, then navigate to the dedicated pages below for each capability.

A Strapi plugin can interact with both the back end and the front end of a Strapi application. The Server API covers the back-end part: it defines what the plugin registers, exposes, and executes on the Strapi server. The server part is defined in the entry file, which exports an object (or a function returning an object). That object describes what the plugin contributes to the server.

For more information on how plugins can customize the admin panel UI, see Admin Panel API.

Entry file#

The entry file for the Server API is [plugin-name]/server/src/index.js|ts. This file exports the required interface, with the following parameters available:

Parameter typeAvailable parameters
Lifecycle functionsregister(), bootstrap(), destroy()
Configurationconfig object
Backend customizationscontentTypes, routes, controllers, services, policies, middlewares

A minimal entry file looks like this:

'use strict';

const register = require('./register');
const bootstrap = require('./bootstrap');
const destroy = require('./destroy');
const config = require('./config');
const contentTypes = require('./content-types');
const routes = require('./routes');
const controllers = require('./controllers');
const services = require('./services');
const policies = require('./policies');
const middlewares = require('./middlewares');

module.exports = () => ({
  register,
  bootstrap,
  destroy,
  config,
  contentTypes,
  routes,
  controllers,
  services,
  policies,
  middlewares,
});
import register from './register';
import bootstrap from './bootstrap';
import destroy from './destroy';
import config from './config';
import contentTypes from './content-types';
import routes from './routes';
import controllers from './controllers';
import services from './services';
import policies from './policies';
import middlewares from './middlewares';

export default () => ({
  register,
  bootstrap,
  destroy,
  config,
  contentTypes,
  routes,
  controllers,
  services,
  policies,
  middlewares,
});

All server code can technically live in the single entry file, but splitting each concern into its own folder, as generated by the Plugin SDK, is strongly recommended. The examples in this documentation follow that structure.

:::note Notes

  • The entry file accepts either an object literal or a function that returns the same object shape. When the function form is used, Strapi calls it with { env } (not { strapi }) while loading the plugin module.
  • config is a configuration object, not an executable lifecycle hook. Unlike register(), bootstrap(), or destroy(), it is not called as a function during the plugin lifecycle. It is loaded at startup and used to set defaults and validate user configuration. See server lifecycle for more information.
    :::

Available actions#

The Server API lets a plugin take advantage of several building blocks to define its server-side behavior.

Use the following table to find which capability matches your goal:

GoalParameter to useWhen it runs
Run code before the server startsregister()Before database and routing initialization
Run code after all plugins are loadedbootstrap()After database, routes, and permissions are initialized
Clean up resources on shutdowndestroy()On shutdown
Define plugin options with defaults and validationconfigLoaded at startup
Declare plugin content-typescontentTypesLoaded at startup
Expose HTTP endpointsroutesLoaded at startup
Handle HTTP requestscontrollersCalled per request
Implement business logicservicesCalled from controllers or lifecycle hooks
Enforce access rules on routespoliciesEvaluated per request, before controller
Intercept and modify request/response flowmiddlewaresAttached in register() or referenced in route config
Access plugin features at runtimeGettersAny lifecycle or request handler

The following cards link directly to each dedicated page:

:::strapi Backend customization
Plugin routes, controllers, services, policies, and middlewares follow the same conventions as backend customization in a standard Strapi application. The Server API wraps these into the plugin namespace automatically (see server content types for details on UIDs and naming conventions).
:::