# Cancel a job

`POST /api/v1/jobs/{jobType}/{jobId}/cancel`

Abort a running job and its underlying ffmpeg/child process. Only active jobs that support cancellation can be cancelled.

Authentication (security requirement alternatives):

```json
[
  {
    "OAuth2": [
      "admin"
    ]
  }
]
```

- OAuth2: oauth2. Authenticating via OAuth requires the following steps:
- Have an activated account
- [Generate] an access token for that account at `/api/v1/users/token`.
- Make requests with the *Authorization: Bearer <token\>* header
- Profit, depending on the role assigned to the account

Note that the __access token is valid for 1 day__ and is given
along with a __refresh token valid for 2 weeks__.

[Generate]: https://docs.joinpeertube.org/api/rest-getting-started
; scopes: admin

Parameters:

- `jobType` (path, JobType, required) - The type of the job to cancel
  Type: JobType
  
  Schema: [JobType](https://sourcey-peertube.pages.dev/api-rest-reference/models/jobtype.md)
  
  enum: ["activitypub-cleaner","activitypub-follow","activitypub-http-broadcast","activitypub-http-broadcast-parallel","activitypub-http-fetcher","activitypub-http-unicast","activitypub-refresher","actor-keys","after-video-channel-import","build-automatic-tags","build-object-automatic-tags","create-user-export","email","federate-video","generate-video-storyboard","import-user-archive","manage-video-torrent","move-to-file-system","move-to-object-storage","notify","transcoding-job-builder","video-channel-import","video-file-import","video-files-lifecycle","video-import","video-live-ending","video-redundancy","video-studio-edition","video-transcoding","video-transcription","videos-stats"]

- `jobId` (path, string, required) - The id of the job to cancel
  Type: string

Responses:

- 204: successful operation

- 404: job not found

- 409: job cannot be cancelled (not active or not cancellable)

## Examples

### cURL

```bash
curl -X POST 'https://peertube2.cpy.re/api/v1/jobs/activitypub-cleaner/string/cancel' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://peertube2.cpy.re/api/v1/jobs/activitypub-cleaner/string/cancel', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.post(
    'https://peertube2.cpy.re/api/v1/jobs/activitypub-cleaner/string/cancel',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```
