The CircleCI cancel job API is used to cancel a job with a given job number.
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.
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.
Please see the link to our documentation for this feature here for other examples of how you can use this API endpoint.