What does z.dehydrateFile output look like in JSON format for Zapier file triggers?

I’m building a Zapier trigger that needs to handle files. My trigger endpoint should return a reference to the file instead of the actual file content.

I found this code example in the docs:

var ZapierApp = {
  file_trigger_handler: function(data) {
    var items = z.JSON.parse(data.response.content);
    return _.map(items, function(item) {
      item.document = z.dehydrateFile('https://myapp.com/download/' + item.uuid);
      return item;
    });
  }
}

But I’m not using JavaScript for my integration. I need to know what JSON structure z.dehydrateFile creates so I can return the same format from my code. Does anyone have an example of the actual JSON output?

Had this exact problem last month. Just mimic the JS function - return an object with $type: "file" and your download URL. Something like {"$type": "file", "url": "https://yourapp.com/files/123"} works perfectly. Don’t overthink it - Zapier just needs that marker to recognize it’s a file reference, not regular JSON data.

I’ve built file triggers without the JavaScript SDK before - the structure’s pretty simple. When you look at what z.dehydrateFile creates, it’s just an object with a special marker that tells Zapier “hey, this is a file, not regular data.” You need the $type field set to “file” and a public URL. I always include the filename so users can actually see what file they’re working with in their Zap runs, but it’s not required. The length field helps with bigger files, but Zapier works fine without it. Two things to watch: make sure your download endpoint handles auth correctly since Zapier fetches the file later, and keep that URL valid for at least 24 hours - that’s what’s worked reliably for me.

The z.dehydrateFile function generates a JSON structure that Zapier interprets as a file reference. It typically appears as follows:

{
  "$type": "file",
  "url": "https://myapp.com/download/your-file-id",
  "name": "filename.pdf",
  "length": 1024
}

The $type: "file" is essential as it signals to Zapier that it is processing a file reference. The url should direct to your download endpoint. While name and length are optional, they enhance user experience in the Zapier interface. Ensure your download URL is publicly accessible and returns the appropriate content-type headers. Providing a filename aids users in tracking their files in the Zap history.