> ## Documentation Index
> Fetch the complete documentation index at: https://developer.pixelbyte.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel Job

> Cancel a pending job and receive a refund.

## Authentication

This endpoint requires an API key with the `submit_job` scope.

```
Authorization: Bearer YOUR_API_KEY
```

## Path Parameters

<ParamField path="jobId" type="string" required>
  The unique identifier of the job to cancel.
</ParamField>

## Details

Only jobs with `pending` status can be cancelled. Jobs that are already `processing`, `completed`, `failed`, or `cancelled` cannot be cancelled.

When a job is successfully cancelled, the charged credits are automatically refunded to your account.

## Response

<ResponseField name="jobId" type="string">
  Unique identifier of the cancelled job.
</ResponseField>

<ResponseField name="status" type="string">
  Updated job status. Always `"cancelled"` on success.
</ResponseField>

<ResponseField name="refundedMicroCents" type="number">
  The amount refunded in micro-cents.
</ResponseField>

## Error Codes

| Code                      | Description                                            |
| ------------------------- | ------------------------------------------------------ |
| `JOB_NOT_FOUND`           | The specified job ID does not exist.                   |
| `UNAUTHORIZED_ACCESS`     | Your API key does not have access to this job.         |
| `JOB_CANNOT_BE_CANCELLED` | The job is not in a cancellable state (not `pending`). |

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.muvi.video/v1/jobs/job_abc123def456/cancel \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.muvi.video/v1/jobs/job_abc123def456/cancel",
      headers={
          "Authorization": "Bearer YOUR_API_KEY"
      }
  )

  data = response.json()
  print(f"Job {data['jobId']} cancelled")
  print(f"Refunded: {data['refundedMicroCents']} micro-cents")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.muvi.video/v1/jobs/job_abc123def456/cancel",
    {
      method: "POST",
      headers: {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  );

  const data = await response.json();
  console.log(`Job ${data.jobId} cancelled`);
  console.log(`Refunded: ${data.refundedMicroCents} micro-cents`);
  ```
</CodeGroup>

### Example Response

```json theme={null}
{
  "jobId": "job_abc123def456",
  "status": "cancelled",
  "refundedMicroCents": 500000
}
```
