How to cancel a job using the Cancel Job API

The CircleCI cancel job API is used to cancel a job with a given job number.

Prerequisites

You will need to have a form of authentication to be able to perform the API request, this can either be basic auth or a personal API token.

For basic authentication, the following support article titled Utilizing 'Basic' Authorization in CircleCI API Calls is linked here.

For setting up a personal API token our documentation is linked here.

Instructions

An example is given below, you will need to replace the project slug, the job number, and the authorization with the job you would like to cancel.

curl --request POST \
--url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123/cancel \
--header 'authorization: Basic REPLACE_BASIC_AUTH'

If successful the job will be canceled, if it has not been please wait a few seconds for the API call to propagate.

Additional Notes

Please see the link to our documentation for this feature here for other examples of how you can use this API endpoint.

Was this article helpful?
0 out of 1 found this helpful

Comments

0 comments

Article is closed for comments.