Learn how to read, update, and clear the files column on monday boards using the platform API
The files column stores files, links, and documents attached to an item.
Via the API, the files column supports read, update, and clear operations.
Column Type | Implementation Type | Supported Operations |
|---|---|---|
|
|
|
Queries
Files columns can be queried through the column_values field on items queries using an inline fragment on FileValue.
query {
items(ids: [1234567890, 9876543210]) {
column_values {
... on FileValue {
id
files {
... on FileAssetValue {
asset_id
}
}
}
}
}
}import { ApiClient } from "@mondaydotcomorg/api";
const mondayApiClient = new ApiClient({ token: myToken });
const query = `
query($itemIds: [ID!], $columnType: [ColumnType!]) {
items(ids: $itemIds) {
id
column_values(types: $columnType) {
column { title id }
... on FileValue {
files {
... on FileAssetValue {
asset_id
}
}
}
}
}
}
`;
const variables = {
itemIds: [9571351485, 9572374902],
columnType: "file",
};
const response = await mondayApiClient.request(query, variables);Fields
You can use the following fields to specify what information your FileValue implementation will return.
Field | Description | Possible Types |
|---|---|---|
column | The column the value belongs to. | |
files | The column's attached files, links, and docs. |
|
id | The file column's unique identifier. | |
text | The column's value as text. Returns | |
type | The column's type. | |
value | The column's JSON-formatted raw value. |
Mutations
Update
Required scope: boards:write
The add_file_to_column mutation updates (adds files to) a files column. This uses the file upload endpoint (/v2/file).
mutation ($file: File!) {
add_file_to_column(
item_id: 1234567890
column_id: "files"
file: $file
) {
id
}
}import axios from "axios";
import fs from "fs";
import FormData from "form-data";
let data = new FormData();
data.append(
"query",
'mutation ($file: File!) { add_file_to_column(item_id: 9393173469, column_id: "file_mksrqze", file: $file) { id } }'
);
data.append("map", '{"image":"variables.file"}');
data.append("image", fs.createReadStream("/local/path/to/file.png"));
let config = {
method: "post",
url: "https://api.monday.com/v2/file",
headers: {
Authorization: myToken,
...data.getHeaders(),
},
data: data,
};
const response = await axios.request(config);Clear
You can clear a files column using change_column_value by passing the following in value:
{"clear_all": true}mutation {
change_column_value(
board_id: 1234567890
item_id: 9876543210
column_id: "files"
value: "{\"clear_all\": true}"
) {
id
}
}