Learn how to read, update, and clear the files column on monday boards using the platform API
The files column contains files attached to a board. The API allows you to read, update, and clear the files column.
Read a files column
You can query the files column using the column_values object that enables you to return column-specific subfields by sending a fragment in your query. Values for the files column are of the FileValue type.
query {
items (ids:[1234567890, 9876543210]) {
column_values {
... on FileValue {
id
column
}
}
}
}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
| Field | Description |
|---|---|
column Column! | The column the value belongs to. |
files [FileValueItem!]! | The column's attached files, links, and docs. |
id ID! | The column's unique identifier. |
text String | The column's value as text. This field will return "" if the column has an empty value. |
type ColumnType! | The column's type. |
value JSON | The column's JSON-formatted raw value. |
Update a files column
You can update the files column using the add_file_to_column mutation. This requires the boards:write scope.
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',
maxBodyLength: Infinity,
url: 'https://api.monday.com/v2/file',
headers: {
'Authorization': myToken,
...data.getHeaders()
},
data : data
};
const response = await axios.request(config)Clear the files column
You can clear a files column using the change_column_value mutation and passing "{\"clear_all\": true}" in the value argument.
mutation {
change_column_value(
board_id: 1234567890
item_id: 9876543210
column_id: "files"
value: "{\"clear_all\": true}"
) {
id
}
}const query = `mutation ($myBoardId:ID!, $myItemId:ID!, $myColumnValues:JSON!) { change_multiple_column_values(item_id:$myItemId, board_id:$myBoardId, column_values: $myColumnValues) { id } }`;
const variables = {
myBoardId: 9571351437,
myItemId: 9571351485,
myColumnValues: JSON.stringify({
file_mksvetb0: {
clear_all: true
}
}),
};
const response = await mondayApiClient.request(query, variables); 