Author a plugin
A plugin is a directory containing a manifest and an entry module. Plugins run inside the server with its filesystem and network permissions. Develop on an isolated local instance and install only code you trust.
This example exposes the public JSONPlaceholder demo API without authentication. Its data is synthetic. Once the service works, use the built-in API Keys or OAuth helpers to add authentication for your own API.
Create the files
Under your configured SWITCHBOARD_DATA_DIR, create plugins/demo-api/. Keep these two files in that folder.
plugin.json
{
"id": "demo-api",
"name": "Demo API",
"version": "1.0.0",
"description": "Read synthetic demo posts.",
"main": "index.js"
}
index.js
export default function setup() {
return {
services: [
{
id: "demo-api",
name: "Demo API",
description: "Synthetic demo posts",
baseUrl: "https://jsonplaceholder.typicode.com",
allowedHosts: ["jsonplaceholder.typicode.com"],
authMethods: [
{
id: "none",
name: "No authentication",
fields: [],
connect() {
return { credentials: {} };
},
authorize() {},
},
],
},
],
};
}
main chooses the entry file. Use a stable, lowercase plugin ID. A plugin can use JavaScript or erasable TypeScript; it cannot have its own node_modules. Runtime dependencies on other plugins go through ctx.require() and must be declared in dependencies. Imports from core are type-only.
Load and verify
- Start or restart your demo instance. By default Switchboard watches plugin files. Under Plugins, find Demo API, ensure it is enabled and use its Reload action after edits.
- Under Connections, add Demo API → No authentication, naming it
demo-api. - In Console select that connection and run GET
/posts/1. - Expect HTTP 200,
id: 1and synthetic post text. Find the request in Activity.
With a Switchboard API token that allows this connection, the same read works from a script:
export SWITCHBOARD_URL=http://127.0.0.1:8770
curl --fail-with-body \
-H "Authorization: Bearer $SWITCHBOARD_TOKEN" \
"$SWITCHBOARD_URL/proxy/demo-api/posts/1"
Edit the service description and reload again. Confirm the new description appears in the service list and the read still works. This verifies local loading and reload behavior.
If the plugin is missing, check the configured data folder and manifest JSON. If it is inactive, inspect its log under Plugins for syntax errors, missing dependencies or a disabled state. A refused upstream host means the URL is outside allowedHosts; add only the hosts your service actually needs.
Add authentication
For a bearer-token API, add "dependencies": ["api-key"] to the manifest and accept ctx in setup. Inside setup(ctx), create this array and use it as the service’s authMethods property:
const keys = ctx.require("api-key");
const authMethods = [keys.bearerToken({ name: "API token" })];
Do not paste credentials into plugin source. The helper collects secrets and attaches them at request time. Credentials are encrypted at rest; the core checks allowed hosts after authorization. For OAuth, declare the oauth2 dependency and follow its authorization-code or device-code contract.
An OpenAPI URL or object in the service’s openapi field enables operation discovery. Plugin setup guides in docs/ appear in the app. Read the complete plugin contract for refresh, settings, disposal, dependencies and installation previews.
Publish and submit a listing
Put the plugin in its own repository. Include its manifest, entry file, README, license, setup requirements and verification steps. Publish a stable release; repository installations use stable releases by default. Test installation through Plugins → Install from GitHub using that repository and inspect the preview before applying it.
Submit a pull request to the official registry adding its ID, name, description and repository to plugins.json. Family repositories also specify a folder (path); ref is optional. Run the registry’s node validate.mjs before submitting. Listing is reviewed separately from publishing your repository.