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

> List and paginate extractions with optional filtering.

Returns a paginated list of extraction documents matching the filter criteria.

The `metadata` parameter accepts a JSON string of key-value pairs to filter by.

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

  client = Retab()

  # List recent extractions
  extractions = client.extractions.list(
      limit=10,
      order="desc"
  )

  # Filter by date range
  extractions = client.extractions.list(
      from_date=datetime(2024, 1, 1),
      to_date=datetime(2024, 12, 31),
      limit=50
  )

  # Filter by metadata
  extractions = client.extractions.list(
      metadata={"source": "docs"},
  )
  ```

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

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

  // List recent extractions
  const recent = await client.extractions.list({
    limit: 10,
    order: "desc",
  });

  // Filter by date range
  const byDate = await client.extractions.list({
    fromDate: new Date("2024-01-01").toISOString(),
    toDate: new Date("2024-12-31").toISOString(),
    limit: 50,
  });

  // Filter by metadata
  const byMetadata = await client.extractions.list({
    metadata: JSON.stringify({ source: "docs" }),
  });
  ```

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

  import (
  	"context"
  	"fmt"
  	"log"
  	"time"

  	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 extractions
  	extractions, err := client.Extractions.List(ctx, &retab.ExtractionsListParams{
  		PaginationParams: retab.PaginationParams{Limit: ptr(10), Order: ptr("desc")},
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(extractions)

  	// Filter by date range
  	from := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)
  	to := time.Date(2024, 12, 31, 0, 0, 0, 0, time.UTC)
  	extractions, err = client.Extractions.List(ctx, &retab.ExtractionsListParams{
  		PaginationParams: retab.PaginationParams{
  			Limit: ptr(50),
  		},
  		FromDate: ptr(from.Format("2006-01-02")),
  		ToDate:   ptr(to.Format("2006-01-02")),
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(extractions)

  	// Filter by metadata
  	extractions, err = client.Extractions.List(ctx, &retab.ExtractionsListParams{
  		Metadata: ptr(`{"source":"docs"}`),
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(extractions)
  }
  ```

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

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

  # List recent extractions
  extractions = client.extractions.list(
    limit: 10,
    order: 'desc',
  )

  # Filter by date range
  extractions = client.extractions.list(
    from_date: DateTime.new(2024, 1, 1),
    to_date: DateTime.new(2024, 12, 31),
    limit: 50,
  )

  # Filter by metadata
  extractions = client.extractions.list(
    metadata: { 'source' => 'docs' },
  )

  extractions.data.each do |extraction|
    puts extraction.id
  end
  ```

  ```rust Rust theme={null}
  use retab::enums::ExtractionsOrder;
  use retab::resources::extractions::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 extractions
      let _extractions = client
          .extractions()
          .list(ListParams {
              limit: Some(10),
              order: Some(ExtractionsOrder::Desc),
              ..Default::default()
          })
          .await?;

      // Filter by date range
      let _ranged = client
          .extractions()
          .list(ListParams {
              from_date: Some("2024-01-01".into()),
              to_date: Some("2024-12-31".into()),
              limit: Some(50),
              ..Default::default()
          })
          .await?;

      // Filter by metadata
      let _by_metadata = client
          .extractions()
          .list(ListParams {
              metadata: Some(r#"{"source":"docs"}"#.into()),
              ..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->extractions()->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.Extractions.ListAsync(new ExtractionsListOptions());
  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.extractions().list(null, null, 10L, null, "invoice.pdf", null, null, null, null, null, null, null);
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  curl -X 'GET' \
    'https://api.retab.com/v1/extractions?limit=10&order=desc' \
    -H 'accept: application/json' \
    -H 'Authorization: Bearer <your-api-key>'

  # With filters (metadata is JSON-encoded)
  curl -X 'GET' \
    'https://api.retab.com/v1/extractions?limit=50&from_date=2024-01-01T00:00:00&to_date=2024-12-31T00:00:00&metadata=%7B%22source%22%3A%22docs%22%7D' \
    -H 'accept: application/json' \
    -H 'Authorization: Bearer <your-api-key>'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "data": [
      {
        "id": "extr_01G34H8J2K",
        "created_at": "2024-03-15T10:30:00Z",
        "file": {
          "id": "file_6dd6eb00688ad8d1",
          "filename": "invoice.pdf"
        },
        "output": {
          "invoice_number": "INV-2024-0042",
          "total_amount": 1234.56
        },
        "json_schema": {
          "type": "object",
          "properties": {
            "invoice_number": { "type": "string" },
            "total_amount": { "type": "number" }
          }
        },
        "metadata": {}
      }
    ],
    "list_metadata": {
      "before": null,
      "after": "extr_01G34H8J2K",
      "total_count": 150
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /v1/extractions
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/extractions:
    get:
      tags:
        - Extractions
      summary: List Extractions
      description: >-
        List and paginate extractions with optional filtering.


        Returns a paginated list of extraction documents matching the filter
        criteria.


        The `metadata` parameter accepts a JSON string of key-value pairs to
        filter by.
      operationId: list_extractions
      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
            default: 10
            title: Limit
          required: false
        - 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: filename_regex
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Deprecated alias for prefix filename filtering. Regex patterns are
              rejected.
            title: Filename Regex
          required: false
          description: >-
            Deprecated alias for prefix filename filtering. Regex patterns are
            rejected.
        - in: query
          name: filename_contains
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Plain-text search over the filename.
            title: Filename Contains
          required: false
          description: Plain-text search over the filename.
        - in: query
          name: document_type
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Filter by document type. Can be repeated. Accepted values: bmp,
              csv, doc, docm, docx, dotm, dotx, eml, gif, heic, heif, htm, html,
              jpeg, jpg, json, md, mhtml, msg, odp, ods, odt, ots, ott, pdf,
              png, ppt, pptx, rtf, svg, tif, tiff, tsv, txt, webp, xlam, xls,
              xlsb, xlsm, xlsx, xltm, xltx, xml, yaml, yml.
            title: Document Type
          required: false
          description: >-
            Filter by document type. Can be repeated. Accepted values: bmp, csv,
            doc, docm, docx, dotm, dotx, eml, gif, heic, heif, htm, html, jpeg,
            jpg, json, md, mhtml, msg, odp, ods, odt, ots, ott, pdf, png, ppt,
            pptx, rtf, svg, tif, tiff, tsv, txt, webp, xlam, xls, xlsb, xlsm,
            xlsx, xltm, xltx, xml, yaml, yml.
        - in: query
          name: status
          schema:
            anyOf:
              - enum:
                  - pending
                  - queued
                  - in_progress
                  - completed
                  - failed
                  - cancelled
                type: string
              - type: 'null'
            title: Status
          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: metadata
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Metadata
          required: false
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtractionList'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ExtractionList:
      description: >-
        A page of `Extraction` resources. `data` holds the items and
        `list_metadata` carries the `before`/`after` cursors; pass `after` to
        fetch the next page.
      properties:
        data:
          items:
            $ref: '#/components/schemas/Extraction'
          type: array
          title: Data
        list_metadata:
          $ref: '#/components/schemas/ListMetadata'
      type: object
      required:
        - data
        - list_metadata
      title: ExtractionList
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    Extraction:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the extraction
        file:
          $ref: '#/components/schemas/FileRef'
          description: Information about the extracted file
        model:
          type: string
          title: Model
          description: Model used for the extraction
        json_schema:
          additionalProperties: true
          type: object
          title: Json Schema
          description: JSON schema used for the extraction
        n_consensus:
          type: integer
          title: N Consensus
          description: Number of consensus votes used
          default: 1
        instructions:
          anyOf:
            - type: string
            - type: 'null'
          title: Instructions
          description: Free-form instructions supplied with the extraction request.
        output:
          additionalProperties: true
          type: object
          title: Output
          description: The extracted structured data
        status:
          type: string
          enum:
            - pending
            - queued
            - in_progress
            - completed
            - failed
            - cancelled
          title: Status
          description: >-
            Lifecycle status. The synchronous path returns 'completed'.
            Background runs progress pending -> queued -> in_progress ->
            completed | failed | cancelled.
          default: pending
        error:
          anyOf:
            - $ref: '#/components/schemas/PrimitiveError'
            - type: 'null'
          description: >-
            Error details when a background run fails; null otherwise. Always
            present so consumers can read it without an existence check.
        consensus:
          anyOf:
            - $ref: '#/components/schemas/ExtractionConsensus'
            - type: 'null'
          description: Consensus metadata for multi-vote extraction runs
        metadata:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Metadata
        usage:
          anyOf:
            - $ref: '#/components/schemas/RetabUsage'
            - type: 'null'
          description: Usage information for the extraction
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
      type: object
      required:
        - file
        - id
        - json_schema
        - model
        - output
      title: Extraction
      description: A stored extraction record from the Retab API.
    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
    FileRef:
      properties:
        id:
          type: string
          title: Id
          description: ID of the file
        filename:
          type: string
          title: Filename
          description: Filename of the file
        mime_type:
          type: string
          title: Mime Type
          description: MIME type of the file
      type: object
      required:
        - filename
        - id
        - mime_type
      title: FileRef
      description: Public/shared file reference used across SDK and customer-facing APIs.
    PrimitiveError:
      properties:
        code:
          type: string
          title: Code
          description: Machine-readable error code.
        message:
          type: string
          title: Message
          description: Human-readable error message.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: Optional structured error context.
      type: object
      required:
        - code
        - message
      title: PrimitiveError
    ExtractionConsensus:
      properties:
        choices:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Choices
          description: >-
            Alternative extraction vote outputs used to build the consolidated
            result.
          default: []
        likelihoods:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Likelihoods
          description: >-
            Consensus likelihood tree mirroring the extraction output. Scalar
            leaves carry per-value voter-agreement in [0, 1]; list leaves carry
            one entry per matched list item.
      type: object
      title: ExtractionConsensus
    RetabUsage:
      properties:
        credits:
          type: number
          title: Credits
          description: Credits consumed for processing
      type: object
      required:
        - credits
      title: RetabUsage
      description: Usage information for document processing.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````