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

# List Files

> List files with pagination and optional filtering.

List uploaded files with pagination and optional filtering by filename or MIME type.

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

  client = Retab()

  # List recent files
  files = client.files.list(limit=20)
  for f in files:
      print(f"{f.id}: {f.filename}")

  # Filter by filename prefix and MIME type
  files = client.files.list(
      filename="invoice",
      mime_type="application/pdf",
      limit=50
  )
  ```

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

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

  // List recent files
  const files = await client.files.list({ limit: 20 });
  for (const f of files.data) {
    console.log(`${f.id}: ${f.filename}`);
  }

  // Filter by filename prefix
  const filtered = await client.files.list({
    filename: "invoice",
    mimeType: "application/pdf",
    limit: 50,
  });
  ```

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

  	// List recent files
  	files, err := client.Files.List(ctx, &retab.FilesListParams{
  		PaginationParams: retab.PaginationParams{Limit: ptr(20)},
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	for _, f := range files.Data {
  		fmt.Printf("%s: %s\n", f.ID, f.Filename)
  	}

  	// Filter by filename prefix and MIME type
  	filtered, err := client.Files.List(ctx, &retab.FilesListParams{
  		PaginationParams: retab.PaginationParams{Limit: ptr(50)},
  		Filename:         ptr("invoice"),
  		MIMEType:         ptr("application/pdf"),
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	_ = filtered
  }
  ```

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

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

  # List recent files
  files = client.files.list(limit: 20)
  files.data.each do |f|
    puts "#{f.id}: #{f.filename}"
  end

  # Filter by filename prefix and MIME type
  filtered = client.files.list(
    filename: 'invoice',
    mime_type: 'application/pdf',
    limit: 50,
  )
  ```

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

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

      // List recent files
      let files = client
          .files()
          .list(ListParams {
              limit: Some(20),
              ..Default::default()
          })
          .await?;
      for f in &files.data {
          println!("{}: {}", f.id, f.filename);
      }

      // Filter by filename prefix and MIME type
      let _filtered = client
          .files()
          .list(ListParams {
              filename: Some("invoice".into()),
              mime_type: Some("application/pdf".into()),
              limit: Some(50),
              ..Default::default()
          })
          .await?;
      Ok(())
  }
  ```

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

  use Retab\Client;

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

  $result = $client->files()->list();
  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.ListAsync(new FilesListOptions());
  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().list(null, null, 10L, null, "invoice.pdf", null, null, null, null, "created_at");
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  # List all files
  curl -X GET \
    'https://api.retab.com/v1/files?limit=20' \
    -H "Authorization: Bearer $RETAB_API_KEY"

  # Filter by filename and MIME type
  curl -X GET \
    'https://api.retab.com/v1/files?filename=invoice&mime_type=application/pdf&limit=50' \
    -H "Authorization: Bearer $RETAB_API_KEY"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "data": [
      {
        "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"
      },
      {
        "id": "file_g7h8i9j0k1l2",
        "object": "file",
        "filename": "receipt.png",
        "page_count": 1,
        "created_at": "2024-01-14T08:15:00Z",
        "updated_at": "2024-01-14T08:15:00Z"
      }
    ],
    "list_metadata": {
      "before": null,
      "after": "file_g7h8i9j0k1l2"
    }
  }
  ```

  ```json 200 (empty) theme={null}
  {
    "data": [],
    "list_metadata": {
      "before": null,
      "after": null
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /v1/files
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/files:
    get:
      tags:
        - Files
      summary: List Files
      description: List files with pagination and optional filtering.
      operationId: list_files
      parameters:
        - in: query
          name: before
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Before
          required: false
        - in: query
          name: after
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: After
          required: false
        - in: query
          name: limit
          schema:
            type: integer
            maximum: 100
            minimum: 1
            description: Items per page
            default: 10
            title: Limit
          required: false
          description: Items per page
        - in: query
          name: order
          schema:
            enum:
              - asc
              - desc
            type: string
            default: desc
            title: Order
          required: false
        - in: query
          name: filename
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Filename
          required: false
        - in: query
          name: mime_type
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Mime Type
          required: false
        - in: query
          name: from_date
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: From Date
          required: false
        - in: query
          name: to_date
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: To Date
          required: false
        - in: query
          name: include_embeddings
          schema:
            type: boolean
            description: Include embeddings in the response
            default: false
            title: Include Embeddings
          required: false
          description: Include embeddings in the response
        - in: query
          name: sort_by
          schema:
            type: string
            default: created_at
            title: Sort By
          required: false
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileList'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    FileList:
      properties:
        data:
          items:
            $ref: '#/components/schemas/File'
          type: array
          title: Data
        list_metadata:
          $ref: '#/components/schemas/ListMetadata'
      type: object
      required:
        - data
        - list_metadata
      title: FileList
      description: >-
        A page of `File` resources. `data` holds the items and `list_metadata`
        carries the `before`/`after` cursors; pass `after` to fetch the next
        page.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    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.
    ListMetadata:
      properties:
        before:
          anyOf:
            - type: string
            - type: 'null'
          title: Before
        after:
          anyOf:
            - type: string
            - type: 'null'
          title: After
      type: object
      required:
        - after
        - before
      title: ListMetadata
      description: Boundary resource IDs for page navigation.
    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

````