> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# Cancel ongoing upload

PUT https://api.fastpix.com/v1/on-demand/upload/{uploadId}/cancel

This endpoint allows you to cancel ongoing upload by its `uploadId`. Once cancelled, the upload is marked as cancelled. Use this if a user aborts an upload or if you want to programmatically stop an in-progress upload.

#### How it works

1. Make a PUT request to this endpoint, replacing `{uploadId}` with the unique upload ID received after starting the upload.
2. The response confirms the cancellation and provide the status of the upload.

#### Webhook Events

Once the upload is cancelled, you must receive the webhook event video.media.upload.cancelled.

#### Example

Suppose a user starts uploading a large video file but decides to cancel before completion. By calling this API, you can immediately stop the upload and free up resources.

Reference: https://fastpix.com/docs/video-on-demand-api/manage-videos/cancel-upload

## Authentication

- `Authorization` header (basic auth, required) — FastPix APIs are secured with Basic Authentication. Use your Access Token ID as the username and Secret Key as the password in the Authorization header of each API request. * Username: Access Token ID * Password: Secret Key Activate your FastPix account to generate your API credentials. See the guide here

## Request

### Path parameters

- `uploadId` (string, required) — When uploading the media, FastPix assigns a universally unique identifier with a maximum length of 255 characters.

## Response

### 200

Upload cancelled successfully

- `success` (boolean, required) — Demonstrates whether the request is successful or not.
- `data` (MediaCancelResponse, required) — Response returned when an upload is cancelled.

## Types

### MediaCancelResponse

Response returned when an upload is cancelled.

- `uploadId` (string, optional) — The unique identifier of the cancelled upload.
- `trial` (boolean, optional) — Indicates if the upload was a trial.
- `status` (string, optional) — The status of the upload after cancellation.
- `url` (string, optional) — The upload URL (if available) after cancellation.
- `timeout` (integer, optional, nullable) — The timeout value for the upload.
- `corsOrigin` (string, optional) — CORS origin allowed for the upload.
- `maxResolution` (string, optional) — The maximum resolution allowed for the upload.
- `accessPolicy` (string, optional) — The access policy for the upload.
- `metadata` (map from string to string, optional) — You can search for videos with specific key value pairs using metadata, when you tag a video in "key" : "value" pairs. Dynamic metadata allows you to define a key that allows any value pair. You can have maximum of 255 characters and upto 10 entries are allowed.
- `title` (string, optional, nullable) — Title of the media file.
- `creatorId` (string, optional, nullable) — The unique identifier of the user who created this media.

## Examples

**Response**

```json
{
  "success": true,
  "data": {
    "uploadId": "beff5537-de85-42e1-a673-2a405cd94177",
    "trial": false,
    "status": "cancelled",
    "url": "https://storage.googleapis.com/uploads-fp-asia/338acdeb-29d4-438b-a40c-1d4105134462/26b1a17d-4b0b-44f8-96b8-cc33cabc962e?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=fp-prod@fastpix-vms.iam.gserviceaccount.com/20250716/auto/storage/goog4_request&X-Goog-Date=20250716T132746Z&X-Goog-Expires=14400&X-Goog-SignedHeaders=host;x-goog-resumable&X-Goog-Signature=4eb42c38711d915f2b6792edacc48ed79bde9f02f829a084dfe09830e6d0e5ec50f2f3157964ed7e32d44b02e3967bf2e0ffeb7ca9335d65ae15b3ac33c7cb40ec710939c4a12202b749bdb4e3f7af8aba2746b41a642130280a372e4615e9773cea98f231388c9fde385f96142ffa901a900949e305c7d5b4c82590c3493aaf60ac5424d4f112fbf4120b7891adf9a7e17968328cd1128fe7b6f55447d15b562624a8e7539824d10e808a729906ac6fe8b2f561424f3e0db14eecad6e21f4f18513519a975c2c50e8304a5a723723e32aa9ac659d9b9875a85f29f007d57bb69c49b5ff9099e5a9834db7199e73ca01cf0dd85cae599203d3180fa27cfdd08d&upload_id=ABgVH88kcXwWvPOlER2G4UvAnrdQw80h_nfjMqwL-jFe6wpLvfBifpBtlnvPtN2BQQTOWggTpKAQ6uGHIJLDp1LHo2g1eePyfjqNi3oRiwxOBU8",
    "timeout": 14400,
    "corsOrigin": "*",
    "maxResolution": "1080p",
    "accessPolicy": "public",
    "metadata": {
      "key1": "value1"
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.fastpix.com/v1/on-demand/upload/4fa85f64-5717-4562-b3fc-2c963f66afa6/cancel"

response = requests.put(url, auth=("<username>", "<password>"))

print(response.json())
```

```javascript
const url = 'https://api.fastpix.com/v1/on-demand/upload/4fa85f64-5717-4562-b3fc-2c963f66afa6/cancel';
const credentials = btoa("<username>:<password>");

const options = {method: 'PUT', headers: {Authorization: `Basic ${credentials}`}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.fastpix.com/v1/on-demand/upload/4fa85f64-5717-4562-b3fc-2c963f66afa6/cancel"

	req, _ := http.NewRequest("PUT", url, nil)

	req.SetBasicAuth("<username>", "<password>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.fastpix.com/v1/on-demand/upload/4fa85f64-5717-4562-b3fc-2c963f66afa6/cancel")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request.basic_auth("<username>", "<password>")

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.fastpix.com/v1/on-demand/upload/4fa85f64-5717-4562-b3fc-2c963f66afa6/cancel")
  .basicAuth("<username>", "<password>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.fastpix.com/v1/on-demand/upload/4fa85f64-5717-4562-b3fc-2c963f66afa6/cancel', [
  'headers' => [
  ],
    'auth' => ['<username>', '<password>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://api.fastpix.com/v1/on-demand/upload/4fa85f64-5717-4562-b3fc-2c963f66afa6/cancel");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.PUT);

IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<username>:<password>".utf8).base64EncodedString()

let headers = ["Authorization": "Basic \(credentials)"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.fastpix.com/v1/on-demand/upload/4fa85f64-5717-4562-b3fc-2c963f66afa6/cancel")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```