diff --git a/docs/backend-system/core-services/scheduler.md b/docs/backend-system/core-services/scheduler.md index 55cd23d989..97a807982e 100644 --- a/docs/backend-system/core-services/scheduler.md +++ b/docs/backend-system/core-services/scheduler.md @@ -156,6 +156,39 @@ Responds with - `404 Not Found` if there was no such registered task for this plugin - `409 Conflict` if the task was already in a running state +### `POST /.backstage/scheduler/v1/tasks//cancel` + +Cancels the running task with the given task ID. + +Note that `` must be URL-encoded so that it remains a single path segment +in the URL (for example by using `encodeURIComponent` in JavaScript or standard +percent-encoding). + +For example, to cancel a specific Catalog task: + +```bash +curl -X POST "https:///api/catalog/.backstage/scheduler/v1/tasks/InternalOpenApiDocumentationProvider%3Arefresh/cancel" +``` + +A working example would be: + +```bash +curl -X POST "https://demo.backstage.io/api/catalog/.backstage/scheduler/v1/tasks/InternalOpenApiDocumentationProvider%3Arefresh/cancel" +``` + +Note that there can still be an additional small delay before a worker discovers +that the task is cancelled. This can take up to a few seconds. Note also that it +is up to the task implementation to properly react to the abort signal that was +passed into it. + +The request has no body. + +Responds with + +- `200 OK` if successful +- `404 Not Found` if there was no such registered task for this plugin +- `409 Conflict` if the task was not in a running state + ## Testing The `@backstage/backend-test-utils` package provides `mockServices.scheduler`, which provides a mocked implementation of the scheduler service that can be used in tests. This mocked implementation is used by default in `startTestBackend`, and it will immediately run any registered tasks on startup as long as they're not configured to run manually or with an initial delay.