core.download
=============

Call a job that produces downloadable output and get a URL to retrieve the result.

This method executes jobs that generate files or streaming data for download. The job writes its output to a pipe, and this method returns a time-limited, single-use download URL.

1. Call ``core.download`` with the target job method, arguments, and desired filename

2. Receive an array containing the job ID and download URL

3. Make an HTTP GET request to the download URL to retrieve the data

4. The download URL expires after a timeout and can only be used once

**Jobs that can be downloaded:**

- :doc:`audit.download_report <api_methods_audit.download_report>`
- :doc:`config.save <api_methods_config.save>`
- :doc:`filesystem.get <api_methods_filesystem.get>`
- :doc:`pool.dataset.export_key <api_methods_pool.dataset.export_key>`
- :doc:`pool.dataset.export_keys <api_methods_pool.dataset.export_keys>`
- :doc:`pool.dataset.export_keys_for_replication <api_methods_pool.dataset.export_keys_for_replication>`
- :doc:`system.debug <api_methods_system.debug>`
- :doc:`vm.log_file_download <api_methods_vm.log_file_download>`

.. raw:: html

    <div id="json-schema">
    <span class="badge badge-dark value-type">Type: object</span><br/>
    <div class="accordion" id="accordionCall_parameters">
    <div class="card">
    <div class="card-header" id="headingCall_parameters">
    <h2 class="mb-0">
    <button aria-controls="Call_parameters" aria-expanded="" class="btn btn-link property-name-button" data-target="#Call_parameters" data-toggle="collapse" onclick="setAnchor('#Call_parameters')" type="button"><span class="property-name">Call parameters</span></button>
    </h2>
    </div>
    <div aria-labelledby="headingCall_parameters" class="collapse property-definition-div" data-parent="#accordionCall_parameters" id="Call_parameters">
    <div class="card-body pl-5">
    <span class="badge badge-dark value-type">Type: array</span><br/>
    <span class="badge badge-info no-additional">No Additional Items</span><h4>Tuple Validation</h4>
    <h5>Parameter 1: method</h5>
    <div class="card">
    <div class="card-body items-definition" id="Call_parameters_items_i0">
    <h4>method</h4><span class="badge badge-dark value-type">Type: string</span><br/>
    <span class="description"><p>Name of the job method to execute.</p>
    </span>
    <br/>
    <div class="badge badge-secondary">Example:</div>
    <br/><div class="jumbotron examples" id="Call_parameters_items_i0_ex1"><div class="highlight"><pre><span></span><span class="s2">"config.save"</span>
    </pre></div>
    </div>
    </div>
    </div>
    <h5>Parameter 2: args</h5>
    <div class="card">
    <div class="card-body items-definition" id="Call_parameters_items_i1">
    <h4>args</h4><span class="badge badge-dark value-type">Type: array</span><br/>
    <span class="description"><p>Arguments to pass to the job method.</p>
    </span>
    <span class="badge badge-info no-additional">No Additional Items</span><h5>Each item of this array must be:</h5>
    <div class="card">
    <div class="card-body items-definition" id="Call_parameters_items_i1_items">
    <span class="badge badge-dark value-type">Type: object</span><br/>
    </div>
    </div>
    </div>
    </div>
    <h5>Parameter 3: filename</h5>
    <div class="card">
    <div class="card-body items-definition" id="Call_parameters_items_i2">
    <h4>filename</h4><span class="badge badge-dark value-type">Type: string</span><br/>
    <span class="description"><p>Suggested filename for the downloaded file. Sets the <code>Content-Disposition</code> header.</p>
    </span>
    <br/>
    <div class="badge badge-secondary">Example:</div>
    <br/><div class="jumbotron examples" id="Call_parameters_items_i2_ex1"><div class="highlight"><pre><span></span><span class="s2">"system-config-backup.db"</span>
    </pre></div>
    </div>
    </div>
    </div>
    <h5>Parameter 4: buffered</h5>
    <div class="card">
    <div class="card-body items-definition" id="Call_parameters_items_i3">
    <h4>buffered</h4><span class="badge badge-dark value-type">Type: boolean</span> <span class="badge badge-success default-value">Default: false</span><br/>
    <span class="description"><p>Whether to buffer the job's output.</p>
    <ul>
    <li><code>false</code> (default): Job starts writing immediately to the download stream. The job blocks until the client       downloads the data or 60 seconds elapses. Use for large files or streaming data.</li>
    <li><code>true</code>: Job output is buffered in RAM until completion, then made available for download. The download       URL remains valid for 3600 seconds. Use for small files when you need to ensure the job completes before       downloading.</li>
    </ul>
    </span>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    <div class="accordion" id="accordionReturn_value">
    <div class="card">
    <div class="card-header" id="headingReturn_value">
    <h2 class="mb-0">
    <button aria-controls="Return_value" aria-expanded="" class="btn btn-link property-name-button" data-target="#Return_value" data-toggle="collapse" onclick="setAnchor('#Return_value')" type="button"><span class="property-name">Return value</span></button>
    </h2>
    </div>
    <div aria-labelledby="headingReturn_value" class="collapse property-definition-div" data-parent="#accordionReturn_value" id="Return_value">
    <div class="card-body pl-5">
    <h4>Result</h4><span class="badge badge-dark value-type">Type: array</span><br/>
    <span class="description"><p>Array containing the job ID and download URL.</p>
    <ul>
    <li>First element: Job ID that can be used with <code>core.get_jobs</code> to monitor progress</li>
    <li>Second element: Download URL in the format <code>/_download/{job_id}?auth_token={token}</code></li>
    </ul>
    </span>
    <p><span class="badge badge-light restriction min-items-restriction" id="Return_value_minItems">Must contain a minimum of <code>2</code> items</span></p><p><span class="badge badge-light restriction max-items-restriction" id="Return_value_maxItems">Must contain a maximum of <code>2</code> items</span></p> <span class="badge badge-info no-additional">No Additional Items</span><h4>Tuple Validation</h4>
    <h5>Item at 1 must be:</h5>
    <div class="card">
    <div class="card-body items-definition" id="Return_value_items_i0">
    <span class="badge badge-dark value-type">Type: integer</span><br/>
    </div>
    </div>
    <h5>Item at 2 must be:</h5>
    <div class="card">
    <div class="card-body items-definition" id="Return_value_items_i1">
    <span class="badge badge-dark value-type">Type: string</span><br/>
    </div>
    </div>
    <br/>
    <div class="badge badge-secondary">Example:</div>
    <br/><div class="jumbotron examples" id="Return_value_ex1"><div class="highlight"><pre><span></span><span class="p">[</span>
    <span class="w">    </span><span class="mf">86</span><span class="p">,</span>
    <span class="w">    </span><span class="s2">"/_download/86?auth_token=9WIqYg4jAYEOGQ4g319Bkr64Oj8CZk1VACfyN68M7hgjGTdeSSgZjSf5lJEshS8M"</span>
    <span class="p">]</span>
    </pre></div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div><br><br>

*Required roles:* 

