Add Admin API Endpoint
Create Admin API Endpoint
Instructions
- If creating an endpoint for an entirely new resource, create a new endpoint file in
ghost/core/core/server/api/endpoints/. Otherwise, locate the existing endpoint file in the same directory. - The endpoint file should create a controller object using the JSDoc type from (@tryghost/api-framework).Controller, including at minimum a
docNameand a single endpoint definition, i.e.browse. - Add routes for each endpoint to
ghost/core/core/server/web/api/endpoints/admin/routes.js. - Add basic
e2e-apitests for the endpoint inghost/core/test/e2e-api/adminto ensure the new endpoints function as expected. - Run the tests and iterate until they pass:
cd ghost/core && yarn test:single test/e2e-api/admin/{test-file-name}.
Reference
For a detailed reference on Ghost's API framework and how to create API controllers, see reference.md.
More from tryghost/ghost
create database migration
Create a database migration to add a table, add columns to an existing table, add a setting, or otherwise change the schema of Ghost's MySQL database. Use this skill whenever the task involves modifying Ghost's database schema — including adding, removing, or renaming columns or tables, adding new settings, creating indexes, updating data, or any change that requires a migration file in ghost/core. Also use when the user references schema.js, knex-migrator, the migrations directory, or asks to "add a field" or "add a column" to any Ghost model/table. Even if the user frames it as a feature or Linear issue, if the implementation requires a schema change, this skill applies.
83format numbers
Format numbers using the formatNumber function from Shade whenever someone edits a TSX file.
45commit
Commit message formatting and guidelines
4add-private-feature-flag
Use when adding a new private (developer experiments) feature flag to Ghost, including the backend registration and settings UI toggle.
1