# Cancel an upload

`PATCH https://api.cademi.com.br/api/v3/uploads/{upload_id}`

Operation ID: `uploads.update` · API v3

Cancels an open upload session. Set `status` to `cancelled`; no other change is supported.

Sessions that are already completed, cancelled, failed, or expired cannot be cancelled and return `state_conflict`. To remove a file produced by a completed upload, use the delete file operation.

Required permissions: `files.write`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `upload_id` | path | string | yes |  |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `status` | string, one of `cancelled` | yes |  |

## Responses

### 200

Returns the updated upload session.

Body: `data`: Upload.

Fields of Upload:

| Field | Type | Required | Description |
|---|---|---|---|
| `expires_at` | string (date-time) | yes |  |
| `failure_reason` | string or null | yes |  |
| `file` | File or null | yes |  |
| `filename` | string | yes |  |
| `id` | string | yes | Public ID, with the upl_ prefix. |
| `object` | string, one of `upload` | yes |  |
| `part_size` | integer or null | yes |  |
| `parts_total` | integer or null | yes |  |
| `purpose` | string | yes |  |
| `size_bytes` | integer | yes |  |
| `status` | string, one of `open`, `completed`, `cancelled`, `expired`, `failed` | yes |  |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 404

The upload session was not found or is not accessible with the current credentials.

Body: Error.

### 409

The upload session is no longer open. Returns the state_conflict error code.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

Full schema: https://cademi.dev/openapi/v3.json
