Download file by URI (with redirect) - SuperAI Flows

Download file by URI (with redirect)

cURL

curl --request GET \
  --url 'https://flows.super.ai/api/files/download?redirect=true' \
  --header 'Authorization: Bearer <token>' \
  --header 'X-API-Key: <api-key>'

Python

import requests

url = "https://flows.super.ai/api/files/download?redirect=true"

headers = {
    "X-API-Key": "<api-key>",
    "Authorization": "Bearer <token>"
}

response = requests.get(url, headers=headers)

print(response.text)

JavaScript (Fetch API)

const options = {
  method: 'GET',
  headers: {'X-API-Key': '<api-key>', Authorization: 'Bearer <token>'}
};

fetch('https://flows.super.ai/api/files/download?redirect=true', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://flows.super.ai/api/files/download?redirect=true",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "GET",\
  CURLOPT_HTTPHEADER => [\
    "Authorization: Bearer <token>",\
    "X-API-Key: <api-key>"\
  ],\
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>

Go

package main

import (
    "fmt"
    "net/http"
    "io"
)

func main() {

url := "https://flows.super.ai/api/files/download?redirect=true"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("X-API-Key", "<api-key>")
    req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Java (Unirest)

HttpResponse<String> response = Unirest.get("https://flows.super.ai/api/files/download?redirect=true")
  .header("X-API-Key", "<api-key>")
  .header("Authorization", "Bearer <token>")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://flows.super.ai/api/files/download?redirect=true")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body

Example Response

{
  "download_url": "<string>",
  "expires_at": "<string>",
  "expires_in_seconds": 123
}

Authorizations

X-API-Key
Type: string
Required: yes

Include your API key in the X-API-Key header as: X-API-Key YOUR_API_KEY

Authorization
Type: string
Required: yes

Include your access token in the Authorization header as: Bearer YOUR_ACCESS_TOKEN

Query Parameters

uri
Type: string
Required: yes

The gs:// storage URI to download. Pass the exact URI from your task output (URL-encoded for special characters).

redirect
Type: boolean
Default: true

If true (default), returns 302 redirect to download URL. If false, returns JSON with the download URL for programmatic use.

Response

200
Type: application/json

JSON response with download URL (when redirect=false). Response containing a temporary pre-signed download URL. The download_url can be used directly to download the file without additional authentication. URLs expire after 1 hour.

download_url
Type: string
Required: yes

Pre-signed URL for downloading the file. Valid for 1 hour.

expires_at
Type: string
Required: yes

ISO 8601 timestamp when the download URL expires. Request a new URL after this time.

expires_in_seconds
Type: integer
Required: yes

Seconds remaining until the download URL expires. Always 3600 (1 hour) for new URLs.