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

# Get Download Link

> Get a temporary download link for a file.

Returns a short-lived signed `download_url` for the file identified by
`file_id`, along with its `filename` and expiration. Responds with `404`
if no matching file exists.

Get a temporary signed URL to download the original file. The link expires after 60 minutes.

<RequestExample>
  ```python Python theme={null}
  from retab import Retab

  client = Retab()

  link = client.files.get_download_link("file_a1b2c3d4e5f6")

  print(f"URL: {link.download_url}")
  print(f"Expires in: {link.expires_in}")
  print(f"Filename: {link.filename}")
  ```

  ```typescript TypeScript theme={null}
  import { Retab } from "@retab/node";

  const client = new Retab({ apiKey: process.env.RETAB_API_KEY });

  const link = await client.files.get_download_link("file_a1b2c3d4e5f6");

  console.log(`URL: ${link.downloadUrl}`);
  console.log(`Expires in: ${link.expiresIn}`);
  console.log(`Filename: ${link.filename}`);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"

  	retab "github.com/retab-dev/retab/clients/go"
  )

  func ptr[T any](v T) *T { return &v }

  func main() {
  	ctx := context.Background()

  	client, err := retab.NewClient("")
  	if err != nil {
  		log.Fatal(err)
  	}

  	link, err := client.Files.GetDownloadLink(ctx, "file_a1b2c3d4e5f6")
  	if err != nil {
  		log.Fatal(err)
  	}

  	fmt.Printf("URL: %s\n", link.DownloadURL)
  	fmt.Printf("Expires in: %s\n", link.ExpiresIn)
  	fmt.Printf("Filename: %s\n", link.Filename)
  }
  ```

  ```ruby Ruby theme={null}
  require 'retab'

  client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])

  link = client.files.get_download_link(file_id: 'file_a1b2c3d4e5f6')

  puts "URL: #{link.download_url}"
  puts "Expires in: #{link.expires_in}"
  puts "Filename: #{link.filename}"
  ```

  ```rust Rust theme={null}
  use retab::Retab;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Retab::new(std::env::var("RETAB_API_KEY")?);

      let link = client.files().get_download_link("file_a1b2c3d4e5f6").await?;

      println!("URL: {}", link.download_url);
      println!("Expires in: {}", link.expires_in);
      println!("Filename: {}", link.filename);
      Ok(())
  }
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';

  use Retab\Client;

  $client = new Client(apiKey: getenv('RETAB_API_KEY'));

  $result = $client->files()->getDownloadLink(
      fileId: 'file_6dd6eb00688ad8d1',
  );
  print_r($result);
  ```

  ```csharp C# theme={null}
  using Retab;
  using RetabClient = Retab.Retab;

  var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
  var client = new RetabClient(apiKey);

  var result = await client.Files.GetDownloadLinkAsync("file_6dd6eb00688ad8d1");
  Console.WriteLine(result);
  ```

  ```java Java theme={null}
  import com.retab.RetabClient;

  public final class Example {
    public static void main(String[] args) throws Exception {
      RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));

      var result = client.files().getDownloadLink("file_abc123");
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  curl -X GET \
    'https://api.retab.com/v1/files/file_a1b2c3d4e5f6/download-link' \
    -H "Authorization: Bearer $RETAB_API_KEY"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "download_url": "https://storage.googleapis.com/retab-files/...",
    "expires_in": "60 minutes",
    "filename": "invoice.pdf"
  }
  ```

  ```json 404 theme={null}
  {
    "detail": "File not found"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /v1/files/{file_id}/download-link
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/files/{file_id}/download-link:
    get:
      tags:
        - Files
      summary: Download Link
      description: |-
        Get a temporary download link for a file.

        Returns a short-lived signed `download_url` for the file identified by
        `file_id`, along with its `filename` and expiration. Responds with `404`
        if no matching file exists.
      operationId: download_link
      parameters:
        - in: path
          name: file_id
          required: true
          schema:
            type: string
            title: File Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileLink'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    FileLink:
      properties:
        download_url:
          type: string
          title: Download Url
          description: The signed URL to download the file
        expires_in:
          type: string
          title: Expires In
          description: The expiration time of the signed URL
        filename:
          type: string
          title: Filename
          description: The name of the file
        mime_data:
          anyOf:
            - $ref: '#/components/schemas/MIMEData'
            - type: 'null'
          description: Durable Retab MIMEData reference for API reuse
      type: object
      required:
        - download_url
        - expires_in
        - filename
      title: FileLink
      description: >-
        A short-lived signed link to download a file, with its `filename` and
        expiry.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    MIMEData:
      properties:
        filename:
          type: string
          title: Filename
          description: The filename of the file
          examples:
            - file.pdf
            - image.png
            - data.txt
        url:
          type: string
          title: Url
          description: The URL of the file in base64 format
          examples:
            - data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA...
      additionalProperties: false
      type: object
      required:
        - filename
        - url
      title: MIMEData
      description: A file represented by its `filename` and a base64 data `url`.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
          default: null
        ctx:
          type: object
          title: Context
          default: {}
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````