Skip to content

Cancel a file upload

client.file.cancel(stringid, FileCancelParams { body } params?, RequestOptionsoptions?): FileCancelResponse { id, completedAt, createdAt, 5 more }
POST/v1/files/{id}/cancel

Cancels a pending upload by transitioning the file to CANCELLED. Only files in PENDING status can be cancelled. Required scope: files:create

Rate limit category: Write

ParametersExpand Collapse
id: string

Unique identifier of the file to cancel.

params: FileCancelParams { body }
body?: Body
ReturnsExpand Collapse
FileCancelResponse { id, completedAt, createdAt, 5 more }
id: string

Unique identifier for the file.

completedAt: string | null

When the file upload was completed.

createdAt: string

When the file upload session was created.

expiresAt: string | null

When the upload session expires. Null once completed, cancelled, or expired.

filename: string

Original filename.

mimeType: string

MIME type of the file.

sizeBytes: number

File size in bytes.

minimum-9007199254740991
maximum9007199254740991
status: "PENDING" | "COMPLETED" | "CANCELLED" | "EXPIRED"

Current upload status of the file.

Accepts one of the following:
"PENDING"
"COMPLETED"
"CANCELLED"
"EXPIRED"

Cancel a file upload

import Lightfield from 'lightfield';

const client = new Lightfield({
  apiKey: 'My API Key',
});

const fileCancelResponse = await client.file.cancel('id');

console.log(fileCancelResponse.id);
{
  "id": "id",
  "completedAt": "completedAt",
  "createdAt": "createdAt",
  "expiresAt": "expiresAt",
  "filename": "filename",
  "mimeType": "mimeType",
  "sizeBytes": -9007199254740991,
  "status": "PENDING"
}
Returns Examples
{
  "id": "id",
  "completedAt": "completedAt",
  "createdAt": "createdAt",
  "expiresAt": "expiresAt",
  "filename": "filename",
  "mimeType": "mimeType",
  "sizeBytes": -9007199254740991,
  "status": "PENDING"
}