> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackone.com/llms.txt
> Use this file to discover all available pages before exploring further.

# download_file

> Step function: download_file

## Input

<Tabs>
  <Tab title="v1">
    <table>
      <colgroup>
        <col width="210" />

        <col width="400" />

        <col width="90" />

        <col width="90" />
      </colgroup>

      <thead>
        <tr>
          <th>Field</th>
          <th>Description</th>
          <th>Type</th>
          <th>Required</th>
        </tr>
      </thead>

      <tbody>
        <tr>
          <td>[`args`](#args)</td>
          <td>Additional request parameters sent as query params, headers, or the request body, per each entry's `in`.</td>
          <td>object\[]</td>
          <td>No</td>
        </tr>

        <tr>
          <td>[`authorization`](#authorization)</td>
          <td>Overrides the connector's default authentication for this request.</td>
          <td>union</td>
          <td>No</td>
        </tr>

        <tr>
          <td>`baseUrl`</td>
          <td>Overrides the connector's base URL for the download.</td>
          <td>string</td>
          <td>No</td>
        </tr>

        <tr>
          <td>[`customErrors`](#customerrors)</td>
          <td>Remaps matching provider error responses to different statuses or messages.</td>
          <td>object\[]</td>
          <td>No</td>
        </tr>

        <tr>
          <td>`encoding`</td>
          <td>Encoding applied to the returned data when responseMode is buffer. Use none to return a raw Buffer.<br />Allowed: `base64`, `utf8`, `binary`, `raw`, `none`<br />Default: `base64`</td>
          <td>enum</td>
          <td>Yes</td>
        </tr>

        <tr>
          <td>`followRedirects`</td>
          <td>Whether to follow HTTP redirects.<br />Default: `true`</td>
          <td>boolean</td>
          <td>Yes</td>
        </tr>

        <tr>
          <td>`maxRedirects`</td>
          <td>Maximum number of redirects to follow.<br />Default: `5`</td>
          <td>number</td>
          <td>Yes</td>
        </tr>

        <tr>
          <td>`method`</td>
          <td>HTTP method to use for the download.<br />Allowed: `get`, `post`, `put`, `delete`, `patch`<br />Default: `get`</td>
          <td>enum</td>
          <td>Yes</td>
        </tr>

        <tr>
          <td>[`response`](#response)</td>
          <td>Options for extracting file content from a JSON-wrapped response.</td>
          <td>object</td>
          <td>No</td>
        </tr>

        <tr>
          <td>`responseMode`</td>
          <td>How the file is returned: buffer downloads it fully into memory, stream returns a readable stream for piping to the client.<br />Allowed: `buffer`, `stream`<br />Default: `buffer`</td>
          <td>enum</td>
          <td>Yes</td>
        </tr>

        <tr>
          <td>`responseType`</td>
          <td>Underlying HTTP response type requested. Used only when responseMode is buffer.<br />Allowed: `arraybuffer`, `blob`, `text`, `json`<br />Default: `arraybuffer`</td>
          <td>enum</td>
          <td>Yes</td>
        </tr>

        <tr>
          <td>`url`</td>
          <td>Download endpoint path appended to the base URL.</td>
          <td>string</td>
          <td>Yes</td>
        </tr>
      </tbody>
    </table>

    <AccordionGroup>
      <Accordion title="args">
        Additional request parameters sent as query params, headers, or the request body, per each entry's `in`.

        <table>
          <colgroup>
            <col width="210" />

            <col width="400" />

            <col width="90" />

            <col width="90" />
          </colgroup>

          <thead>
            <tr>
              <th>Field</th>
              <th>Description</th>
              <th>Type</th>
              <th>Required</th>
            </tr>
          </thead>

          <tbody>
            <tr>
              <td>`arrayFormat`</td>
              <td>How array values are serialized in the query string: repeat, brackets, comma, or stringify.<br />Allowed: `repeat`, `brackets`, `comma`, `stringify`</td>
              <td>enum</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`condition`</td>
              <td>A JEXL expression that includes the parameter only when it evaluates true.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`in`</td>
              <td>Where to send the parameter: query, body, or headers.<br />Allowed: `query`, `body`, `headers`</td>
              <td>enum</td>
              <td>Yes</td>
            </tr>

            <tr>
              <td>`name`</td>
              <td>Name of the request parameter.</td>
              <td>string</td>
              <td>Yes</td>
            </tr>

            <tr>
              <td>`spread`</td>
              <td>Merges the value's object entries into the target location instead of setting a single named field.</td>
              <td>boolean</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`value`</td>
              <td>Value of the parameter. Supports expressions.</td>
              <td>any</td>
              <td>Yes</td>
            </tr>
          </tbody>
        </table>
      </Accordion>

      <Accordion title="authorization">
        Overrides the connector's default authentication for this request.

        <Tabs>
          <Tab title="none">
            <table>
              <colgroup>
                <col width="210" />

                <col width="400" />

                <col width="90" />

                <col width="90" />
              </colgroup>

              <thead>
                <tr>
                  <th>Field</th>
                  <th>Description</th>
                  <th>Type</th>
                  <th>Required</th>
                </tr>
              </thead>

              <tbody>
                <tr>
                  <td>`redirectUri`</td>
                  <td>OAuth callback URL carried as connect-time metadata. Not used when authorizing requests.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>[`signing`](#authorization-none-signing)</td>
                  <td>Optional request signing applied to outgoing requests. Selects AWS SigV4 or HMAC signing.</td>
                  <td>union</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`type`</td>
                  <td>Sends requests without an authorization header.</td>
                  <td>string</td>
                  <td>Yes</td>
                </tr>
              </tbody>
            </table>

            <AccordionGroup>
              <Accordion title="authorization.none.signing">
                Optional request signing applied to outgoing requests. Selects AWS SigV4 or HMAC signing.

                <Tabs>
                  <Tab title="aws4">
                    <table>
                      <colgroup>
                        <col width="210" />

                        <col width="400" />

                        <col width="90" />

                        <col width="90" />
                      </colgroup>

                      <thead>
                        <tr>
                          <th>Field</th>
                          <th>Description</th>
                          <th>Type</th>
                          <th>Required</th>
                        </tr>
                      </thead>

                      <tbody>
                        <tr>
                          <td>`region`</td>
                          <td>AWS region used in the signing credential scope. Falls back to the credential region or `us-east-1` when omitted.</td>
                          <td>string</td>
                          <td>No</td>
                        </tr>

                        <tr>
                          <td>`service`</td>
                          <td>AWS service name used in the signing credential scope. For example `s3` or `execute-api`.</td>
                          <td>string</td>
                          <td>Yes</td>
                        </tr>

                        <tr>
                          <td>`strategy`</td>
                          <td>Signs requests with AWS Signature Version 4.</td>
                          <td>string</td>
                          <td>Yes</td>
                        </tr>
                      </tbody>
                    </table>
                  </Tab>

                  <Tab title="hmac">
                    <table>
                      <colgroup>
                        <col width="210" />

                        <col width="400" />

                        <col width="90" />

                        <col width="90" />
                      </colgroup>

                      <thead>
                        <tr>
                          <th>Field</th>
                          <th>Description</th>
                          <th>Type</th>
                          <th>Required</th>
                        </tr>
                      </thead>

                      <tbody>
                        <tr>
                          <td>`algorithm`</td>
                          <td>Hash algorithm for the HMAC signature. Defaults to `sha256`.<br />Allowed: `sha1`, `sha256`, `sha512`</td>
                          <td>enum</td>
                          <td>No</td>
                        </tr>

                        <tr>
                          <td>`dateFormat`</td>
                          <td>Timestamp format used in the signed string. Either `iso8601` (default) or `rfc2822`.<br />Allowed: `iso8601`, `rfc2822`</td>
                          <td>enum</td>
                          <td>No</td>
                        </tr>

                        <tr>
                          <td>`headerName`</td>
                          <td>Header the signature is written into. Defaults to `X-Signature`.</td>
                          <td>string</td>
                          <td>No</td>
                        </tr>

                        <tr>
                          <td>`includeBodyHash`</td>
                          <td>Hash the request body into the signed string, defaulting to `true`. When `false`, form-urlencoded body params are folded into the canonical string instead.</td>
                          <td>boolean</td>
                          <td>No</td>
                        </tr>

                        <tr>
                          <td>`includeHost`</td>
                          <td>Include the request hostname in the signed canonical string. Defaults to `false`.</td>
                          <td>boolean</td>
                          <td>No</td>
                        </tr>

                        <tr>
                          <td>`outputFormat`</td>
                          <td>Where the signature is emitted. `header` writes a signature header and `basic` writes an HTTP Basic `Authorization` header.<br />Allowed: `header`, `basic`</td>
                          <td>enum</td>
                          <td>No</td>
                        </tr>

                        <tr>
                          <td>`prefix`</td>
                          <td>Prefix prepended to the signature value in the header. Defaults to `hmac-&lt;algorithm&gt;`.</td>
                          <td>string</td>
                          <td>No</td>
                        </tr>

                        <tr>
                          <td>`strategy`</td>
                          <td>Signs requests with an HMAC signature over a canonical request string.</td>
                          <td>string</td>
                          <td>Yes</td>
                        </tr>

                        <tr>
                          <td>`username`</td>
                          <td>Username paired with the signature when `outputFormat` is `basic`.</td>
                          <td>string</td>
                          <td>No</td>
                        </tr>
                      </tbody>
                    </table>
                  </Tab>
                </Tabs>
              </Accordion>
            </AccordionGroup>
          </Tab>

          <Tab title="basic">
            <table>
              <colgroup>
                <col width="210" />

                <col width="400" />

                <col width="90" />

                <col width="90" />
              </colgroup>

              <thead>
                <tr>
                  <th>Field</th>
                  <th>Description</th>
                  <th>Type</th>
                  <th>Required</th>
                </tr>
              </thead>

              <tbody>
                <tr>
                  <td>`encoding`</td>
                  <td>Encoding applied to the `username:password` pair. Defaults to `base64`.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`password`</td>
                  <td>Password for HTTP Basic authentication.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`redirectUri`</td>
                  <td>OAuth callback URL carried as connect-time metadata. Not used when authorizing requests.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`type`</td>
                  <td>Configures HTTP Basic authentication.</td>
                  <td>string</td>
                  <td>Yes</td>
                </tr>

                <tr>
                  <td>`username`</td>
                  <td>Username for HTTP Basic authentication.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>
              </tbody>
            </table>
          </Tab>

          <Tab title="bearer">
            <table>
              <colgroup>
                <col width="210" />

                <col width="400" />

                <col width="90" />

                <col width="90" />
              </colgroup>

              <thead>
                <tr>
                  <th>Field</th>
                  <th>Description</th>
                  <th>Type</th>
                  <th>Required</th>
                </tr>
              </thead>

              <tbody>
                <tr>
                  <td>`includeBearer`</td>
                  <td>Prefix the token with `Bearer ` in the `Authorization` header. Defaults to `true`.<br />Default: `true`</td>
                  <td>boolean</td>
                  <td>Yes</td>
                </tr>

                <tr>
                  <td>`redirectUri`</td>
                  <td>OAuth callback URL carried as connect-time metadata. Not used when authorizing requests.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`token`</td>
                  <td>Token sent on each request. Supports expressions.</td>
                  <td>string</td>
                  <td>Yes</td>
                </tr>

                <tr>
                  <td>`type`</td>
                  <td>Configures bearer token authentication.</td>
                  <td>string</td>
                  <td>Yes</td>
                </tr>
              </tbody>
            </table>
          </Tab>

          <Tab title="oauth2">
            <table>
              <colgroup>
                <col width="210" />

                <col width="400" />

                <col width="90" />

                <col width="90" />
              </colgroup>

              <thead>
                <tr>
                  <th>Field</th>
                  <th>Description</th>
                  <th>Type</th>
                  <th>Required</th>
                </tr>
              </thead>

              <tbody>
                <tr>
                  <td>`additionalTokenFields`</td>
                  <td>Extra credential fields to read from the token endpoint response. Each key is a credential name and each value an expression.</td>
                  <td>object</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`authorizationParams`</td>
                  <td>Extra query parameters appended to the authorization URL. Values support expressions.</td>
                  <td>object</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`authorizationUrl`</td>
                  <td>Provider authorization endpoint where the user grants access.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`callbackParams`</td>
                  <td>Maps OAuth callback query parameter names to the credential keys their values are stored under. Cannot target reserved credential keys.</td>
                  <td>object</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`customHeaders`</td>
                  <td>Additional HTTP headers sent with token endpoint requests.</td>
                  <td>object</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`includeBearer`</td>
                  <td>Prefix the token with `Bearer ` in the `Authorization` header. Defaults to `true`.<br />Default: `true`</td>
                  <td>boolean</td>
                  <td>Yes</td>
                </tr>

                <tr>
                  <td>`issuer`</td>
                  <td>OpenID Connect issuer identifier for the provider.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`pkce`</td>
                  <td>Enable PKCE for the authorization code flow.</td>
                  <td>boolean</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`redirectUri`</td>
                  <td>Overrides the OAuth callback URL. The computed callback URL can be seen on the connector profile.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`scopeDelimiter`</td>
                  <td>Delimiter used to separate scopes when requesting authorization.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`scopes`</td>
                  <td>OAuth scopes requested during authorization.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`token`</td>
                  <td>Expression that resolves the access token sent on each request.</td>
                  <td>string</td>
                  <td>Yes</td>
                </tr>

                <tr>
                  <td>`tokenExpiresIn`</td>
                  <td>Access token lifetime in seconds.</td>
                  <td>number</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`tokenParams`</td>
                  <td>Extra parameters sent to the token endpoint. Values support expressions.</td>
                  <td>object</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`tokenRefreshExpiresIn`</td>
                  <td>Refresh token lifetime in seconds.</td>
                  <td>number</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>[`tokenResponse`](#authorization-oauth2-tokenresponse)</td>
                  <td>Adjusts how a non-standard token endpoint response is parsed.</td>
                  <td>object</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`tokenUrl`</td>
                  <td>Provider token endpoint used to exchange the authorization code and to refresh tokens.</td>
                  <td>string</td>
                  <td>No</td>
                </tr>

                <tr>
                  <td>`type`</td>
                  <td>Configures OAuth 2.0 authentication.</td>
                  <td>string</td>
                  <td>Yes</td>
                </tr>
              </tbody>
            </table>

            <AccordionGroup>
              <Accordion title="authorization.oauth2.tokenResponse">
                Adjusts how a non-standard token endpoint response is parsed.

                <table>
                  <colgroup>
                    <col width="210" />

                    <col width="400" />

                    <col width="90" />

                    <col width="90" />
                  </colgroup>

                  <thead>
                    <tr>
                      <th>Field</th>
                      <th>Description</th>
                      <th>Type</th>
                      <th>Required</th>
                    </tr>
                  </thead>

                  <tbody>
                    <tr>
                      <td>`acceptTokenTypes`</td>
                      <td>Allowlist of `token_type` values to accept from the token endpoint beyond `Bearer` and `DPoP`. Matched case-insensitively.</td>
                      <td>string\[]</td>
                      <td>No</td>
                    </tr>

                    <tr>
                      <td>`accessToken`</td>
                      <td>Expression locating the access token in the token endpoint response. Takes precedence over the standard `access_token` field when it resolves to a non-empty string.</td>
                      <td>string</td>
                      <td>No</td>
                    </tr>

                    <tr>
                      <td>`refreshToken`</td>
                      <td>Expression locating the refresh token in the token endpoint response. Takes precedence over the standard `refresh_token` field when it resolves to a non-empty string.</td>
                      <td>string</td>
                      <td>No</td>
                    </tr>
                  </tbody>
                </table>
              </Accordion>
            </AccordionGroup>
          </Tab>
        </Tabs>
      </Accordion>

      <Accordion title="customErrors">
        Remaps provider error responses to different statuses or messages. Useful for GraphQL APIs that return errors with a 200 status, normalizing provider-specific error formats, and giving AI agents clearer error messages.

        <table>
          <colgroup>
            <col width="210" />

            <col width="400" />

            <col width="90" />

            <col width="90" />
          </colgroup>

          <thead>
            <tr>
              <th>Field</th>
              <th>Description</th>
              <th>Type</th>
              <th>Required</th>
            </tr>
          </thead>

          <tbody>
            <tr>
              <td>`condition`</td>
              <td>A JEXL expression that applies the remap only when it evaluates true.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`message`</td>
              <td>Error message to return in place of the provider's.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`receivedStatus`</td>
              <td>Provider HTTP status code to match.</td>
              <td>number</td>
              <td>Yes</td>
            </tr>

            <tr>
              <td>`targetStatus`</td>
              <td>HTTP status code to return in place of the matched one.</td>
              <td>number</td>
              <td>Yes</td>
            </tr>
          </tbody>
        </table>
      </Accordion>

      <Accordion title="response">
        Options for extracting file content from a JSON-wrapped response.

        <table>
          <colgroup>
            <col width="210" />

            <col width="400" />

            <col width="90" />

            <col width="90" />
          </colgroup>

          <thead>
            <tr>
              <th>Field</th>
              <th>Description</th>
              <th>Type</th>
              <th>Required</th>
            </tr>
          </thead>

          <tbody>
            <tr>
              <td>`contentIsBase64`</td>
              <td>Whether the content in the JSON response is already base64 encoded.<br />Default: `false`</td>
              <td>boolean</td>
              <td>Yes</td>
            </tr>

            <tr>
              <td>`contentType`</td>
              <td>Fallback content type used when the JSON response exposes none to extract. `contentTypeKey` wins if it resolves.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`contentTypeKey`</td>
              <td>JSONPath to the content type within a JSON-wrapped response.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`dataKey`</td>
              <td>JSONPath to the file content within a JSON-wrapped response.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`fileNameKey`</td>
              <td>JSONPath to the filename within a JSON-wrapped response.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`forwardAuth`</td>
              <td>Whether to forward authentication headers to the secondary download request when following urlKey.<br />Default: `false`</td>
              <td>boolean</td>
              <td>Yes</td>
            </tr>

            <tr>
              <td>`urlKey`</td>
              <td>JSONPath to a download URL in the response to follow for the file.</td>
              <td>string</td>
              <td>No</td>
            </tr>
          </tbody>
        </table>
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

## Output

<Tabs>
  <Tab title="v1">
    <table>
      <colgroup>
        <col width="210" />

        <col width="400" />

        <col width="90" />

        <col width="90" />
      </colgroup>

      <thead>
        <tr>
          <th>Field</th>
          <th>Description</th>
          <th>Type</th>
          <th>Required</th>
        </tr>
      </thead>

      <tbody>
        <tr>
          <td>`contentDisposition`</td>
          <td>Content-Disposition header value for the client to use.</td>
          <td>string</td>
          <td>No</td>
        </tr>

        <tr>
          <td>`data`</td>
          <td>Downloaded file content. A string in the format set by the `encoding` input (base64 by default), or a raw binary Buffer when `encoding: "none"`. Absent when `responseMode: "stream"` (content is piped via the stream output instead).</td>
          <td>union</td>
          <td>No</td>
        </tr>

        <tr>
          <td>[`fileMetadata`](#filemetadata)</td>
          <td>File metadata extracted from response headers or a JSON-wrapped response.</td>
          <td>object</td>
          <td>No</td>
        </tr>

        <tr>
          <td>`finalUrl`</td>
          <td>Final URL the file was downloaded from after redirects or a followed link.</td>
          <td>string</td>
          <td>No</td>
        </tr>

        <tr>
          <td>`headers`</td>
          <td>All response headers returned with the download.</td>
          <td>object</td>
          <td>No</td>
        </tr>

        <tr>
          <td>`message`</td>
          <td>Status or error message from the response.</td>
          <td>string</td>
          <td>No</td>
        </tr>

        <tr>
          <td>`raw`</td>
          <td>The raw provider response before parsing.</td>
          <td>any</td>
          <td>No</td>
        </tr>

        <tr>
          <td>`statusCode`</td>
          <td>HTTP status code of the provider response.</td>
          <td>number</td>
          <td>Yes</td>
        </tr>
      </tbody>
    </table>

    <AccordionGroup>
      <Accordion title="fileMetadata">
        File metadata extracted from response headers or a JSON-wrapped response.

        <table>
          <colgroup>
            <col width="210" />

            <col width="400" />

            <col width="90" />

            <col width="90" />
          </colgroup>

          <thead>
            <tr>
              <th>Field</th>
              <th>Description</th>
              <th>Type</th>
              <th>Required</th>
            </tr>
          </thead>

          <tbody>
            <tr>
              <td>`contentLength`</td>
              <td>Size of the file in bytes.</td>
              <td>number</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`contentType`</td>
              <td>MIME type of the downloaded file.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`etag`</td>
              <td>Entity tag identifying the file version.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`fileName`</td>
              <td>Name of the downloaded file.</td>
              <td>string</td>
              <td>No</td>
            </tr>

            <tr>
              <td>`lastModified`</td>
              <td>Last-modified timestamp reported for the file.</td>
              <td>string</td>
              <td>No</td>
            </tr>
          </tbody>
        </table>
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>
