Files

Files let you attach documents and images to other objects: evidence to a dispute, attachments to an invoice and images to a product.

The File object

Name
object
Type
"file",
Description
The object's type.
Name
id
Type
string,
Description
Unique identifier for the object.
Name
live
Type
boolean or null,
Description
true if the object is live, or false if it's in a sandbox.
Name
created_at
Type
integer,
Description
When the object was created, in milliseconds since the Unix epoch.
Name
name
Type
string,
Description
The name of the file.
Name
purpose
Type
enum,
Description
The file's intended use.
Properties
Name
size
Type
integer,
Description
The size of the file in bytes.

The File object

{
  "object": "file",
  "live": false,
  "id": "file_nwjUEfzvIm7skTF9hlH4P2",
  "created_at": 1750000000000,
  "name": "receipt.png",
  "purpose": "dispute_evidence",
  "size": 1024
}

Get a file

Retrieve a file by its ID.

Required parameters

Name
id
Type
string,
Description
The ID of the file to retrieve.

Optional parameters

Name
expand
Type
empty object,
Description
Related objects to expand in the response.

Returns

Returns the file object.

Retrieve a file

const file = await bias.files.get("id");

Response example

{
  "object": "file",
  "live": false,
  "id": "file_nwjUEfzvIm7skTF9hlH4P2",
  "created_at": 1750000000000,
  "name": "receipt.png",
  "purpose": "dispute_evidence",
  "size": 1024
}

View a file

Viewing a file returns its contents. Browsers display images and PDFs, and download other files.

Required parameters

Name
id
Type
string,

Returns

Returns the file’s contents.

View a file

const file = await bias.files.view("id");

List all files

Retrieve a paginated list of files, most recently created first.

Optional parameters

Name
expand
Type
empty object,
Description
Related objects to expand in the response.
Name
ending_before
Type
string,
Description
The ID of the object to list before, for pagination.
Name
starting_after
Type
string,
Description
The ID of the object to list after, for pagination.
Name
limit
Type
integer, at least 1, at most 1000, default is 50
Description
The maximum number of objects to return, from 1 to 1000. Defaults to 50.
Name
filters
Type
object, object, or object,
Description
Filters for the list, combined with and and or.
Properties

Returns

Returns a list of file objects.

List all files

const file = await bias.files.list();

Response example

{
  "object": "list",
  "items": [
    {
      "object": "file",
      "live": false,
      "id": "file_nwjUEfzvIm7skTF9hlH4P2",
      "created_at": 1750000000000,
      "name": "receipt.png",
      "purpose": "dispute_evidence",
      "size": 1024
    }
  ],
  "has_more": true
}

Create a file

Uploading a file returns the ID that a dispute, invoice or product references. The request body is multipart/form-data, not JSON.

Files attached to a dispute as evidence must be PDF, JPEG, PNG or plain text.

Required parameters

Name
file
Type
string,
Description
The file to upload, as binary data.
Name
purpose
Type
enum,
Description
The file's intended use.
Properties

Returns

Returns the file object.

Create a file

const file = await bias.files.create({
  file: {},
  purpose: "dispute_evidence"
});

Response example

{
  "object": "file",
  "live": false,
  "id": "file_nwjUEfzvIm7skTF9hlH4P2",
  "created_at": 1750000000000,
  "name": "receipt.png",
  "purpose": "dispute_evidence",
  "size": 1024
}

Update a file

Updating a file changes its name.

Required parameters

Name
id
Type
string,

Optional parameters

Name
name
Type
string,
Description
The name of the file.

Returns

Returns the file object.

Update a file

const file = await bias.files.update("id", {
  name: "receipt.png"
});

Response example

{
  "object": "file",
  "live": false,
  "id": "file_nwjUEfzvIm7skTF9hlH4P2",
  "created_at": 1750000000000,
  "name": "receipt.png",
  "purpose": "dispute_evidence",
  "size": 1024
}