Files (assets)

The files column contains files attached to a board.

Our API fully supports the files column, so you can read, update, and clear it via the API. However, you cannot filter your items_page query results by the files column.

Reading the files column

You can query the files column using the column_values object. The object has different fields based on which API version you are using. Column values v2 fields will be available in API versions 2023-10 and later, while column values v1 fields are only supported in versions 2023-07 and 2023-04.

Column values v2

The column_values object enables you to return column-specific subfields by sending a fragment in your query. Values for the files column are of the FileValue type.

👍

Pro tip

column_values v2 fields are only available in API version 2023-10 and later..

query {
  items (ids:[1234567890, 9876543210]) {
    column_values {
      ... on FileValue {
        files
        id
      }
    }
  }
}

Fields

FieldDescription
column Column!The column the value belongs to.
files [FileValueItem!]!The column's attached files.
id ID!The column's unique identifier.
text StringThe column's value as text.
type ColumnType!The column's type.
value JSONThe column's JSON-formatted raw value.

Column values v1

You can return the data in a files column in two different formats when you query by column values. The text field will return the URL of the file as a simple string. The value field will return metadata about the file as a JSON string. You cannot select which metadata you want to return.

🚧

Removing column values v1 support

column_values v1 fields will no longer be supported in API versions 2023-10 and later.

{
  "text": "https://test.monday.com/protected_static/987654321/resources/123456789/dark_orange.png",
  "value": "{\"files\":[{\"name\":\"dark_orange.png\",\"assetId\":895853378,\"isImage\":\"true\",\"fileType\":\"ASSET\",\"createdAt\":1685465035372,\"createdBy\":\"123456789\"}]}"
}

Therefore, we recommend querying the assets field instead of the file column to simplify your query. Doing so allows you to specify the exact information you want to return. You will also have additional fields to choose from that can return more metadata than querying the files column.

query {
  boards (ids:1234567890) {
    items (ids:9876543210) {
      assets {
        id
        name
        url
      }
    }
  }
}
fetch ("https://api.monday.com/v2", {
  method: 'post',
  headers: {
    'Content-Type': 'application/json',
    'Authorization' : 'YOUR_API_KEY_HERE'
   },
   body: JSON.stringify({
     query : "query { boards (ids:1234567890) { items (ids:9876543210) {  assets  { id name url }}";
   })
  });

Updating the files column

You can update the files column using the add_file_to_column mutation. Please note that this requires the boards:write scope.

mutation {
    add_file_to_column (item_id: 1234567890, column_id: "files", file: YOUR_FILE) {
        id
    }
}
var fs = require('fs');
var fetch = require('node-fetch'); // requires node-fetch as dependency

// adapted from: https://gist.github.com/tanaikech/40c9284e91d209356395b43022ffc5cc

// set filename
var upfile = 'sample.png';

// set auth token and query
var API_KEY = "MY_API_KEY"
var query = 'mutation ($file: File!) { add_file_to_column (file: $file, item_id: 1234567890, column_id: "files") { id } }';

// set URL and boundary
var url = "https://api.monday.com/v2/file";
var boundary = "xxxxxxxxxx";
var data = "";

fs.readFile(upfile, function(err, content){

    // simple catch error
    if(err){
        console.error(err);
    }

    // construct query part
    data += "--" + boundary + "\r\n";
    data += "Content-Disposition: form-data; name=\"query\"; \r\n";
    data += "Content-Type:application/json\r\n\r\n";
    data += "\r\n" + query + "\r\n";

    // construct file part
    data += "--" + boundary + "\r\n";
    data += "Content-Disposition: form-data; name=\"variables[file]\"; filename=\"" + upfile + "\"\r\n";
    data += "Content-Type:application/octet-stream\r\n\r\n";
    var payload = Buffer.concat([
            Buffer.from(data, "utf8"),
            new Buffer.from(content, 'binary'),
            Buffer.from("\r\n--" + boundary + "--\r\n", "utf8"),
    ]);

    // construct request options
    var options = {
        method: 'post',
        headers: {
          "Content-Type": "multipart/form-data; boundary=" + boundary,
          "Authorization" : API_KEY
        },
        body: payload,
    };

    // make request
    fetch(url, options)
      .then(res => res.json())
      .then(json => console.log(json));
});

Clearing the files column

You can clear a files column using the change_column_value mutation and passing "{\"clear_all\": true}" in the value argument. Check out this mutation in action in our Postman library or follow along with these code samples!

mutation {
 change_column_value(board_id:1234567890, item_id:9876543210, column_id: "files", value: "{\"clear_all\": true}") {
  id
 }
}
var query = "mutation { change_column_value (board_id: 1234567890, item_id: 9876543210, column_id: \"files\", value: \"{\\\"clear_all\\\": true}\") {id}}";

fetch ("https://api.monday.com/v2", {
  method: 'post',
  headers: {
    'Content-Type': 'application/json',
    'Authorization' : 'YOUR_API_KEY_HERE'
   },
   body: JSON.stringify({
     'query': query
   })
  })
   .then(res => res.json())
   .then(res => console.log(JSON.stringify(res, null, 2)));

📘

Join our developer community!

We've created a community specifically for our devs where you can search through previous topics to find solutions, ask new questions, hear about new features and updates, and learn tips and tricks from other devs. Come join in on the fun! 😎