> ## 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 File

> Retrieve a file.

Returns metadata for the file identified by `file_id`, including its
`filename`, `page_count`, and timestamps. Responds with `404` if no
matching file exists.

Retrieve metadata for a single file by ID.

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

  client = Retab()

  file = client.files.get("file_a1b2c3d4e5f6")

  print(f"Filename: {file.filename}")
  print(f"Pages: {file.page_count}")
  print(f"Created: {file.created_at}")
  ```

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

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

  const file = await client.files.get("file_a1b2c3d4e5f6");

  console.log(`Filename: ${file.filename}`);
  console.log(`Pages: ${file.pageCount}`);
  console.log(`Created: ${file.createdAt}`);
  ```

  ```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)
  	}

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

  	fmt.Printf("Filename: %s\n", file.Filename)
  	fmt.Printf("Pages: %v\n", file.PageCount)
  	fmt.Printf("Created: %v\n", file.CreatedAt)
  }
  ```

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

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

  file = client.files.get(file_id: 'file_a1b2c3d4e5f6')

  puts "Filename: #{file.filename}"
  puts "Pages: #{file.page_count}"
  puts "Created: #{file.created_at}"
  ```

  ```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 file = client.files().get("file_a1b2c3d4e5f6").await?;

      println!("Filename: {}", file.filename);
      println!("Pages: {}", file.page_count.unwrap_or_default());
      println!("Created: {}", file.created_at.as_deref().unwrap_or("unknown"));
      Ok(())
  }
  ```

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

  use Retab\Client;

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

  $result = $client->files()->get(
      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.GetAsync("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().get("file_abc123");
      System.out.println(result);
    }
  }
  ```

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "file_a1b2c3d4e5f6",
    "object": "file",
    "filename": "invoice.pdf",
    "page_count": 3,
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
  ```

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


## OpenAPI

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

        Returns metadata for the file identified by `file_id`, including its
        `filename`, `page_count`, and timestamps. Responds with `404` if no
        matching file exists.
      operationId: get_file
      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/File'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    File:
      properties:
        object:
          type: string
          const: file
          title: Object
          default: file
        id:
          type: string
          title: Id
          description: The unique identifier of the file
        filename:
          type: string
          title: Filename
          description: The name of the file
        mime_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mime Type
          description: The MIME type of the file
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
          description: When the file was created
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated At
          description: When the file was last updated
        page_count:
          anyOf:
            - type: integer
            - type: 'null'
          title: Page Count
          description: Number of pages in the file
      type: object
      required:
        - filename
        - id
      title: File
      description: >-
        An uploaded file: its `id`, `filename`, MIME type, page count, and
        timestamps.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    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

````