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

> List partitions.

Returns a paginated list of partitions for the authenticated environment, newest first
by default. Filter by `filename` prefix (case-insensitive) and by a `created_at` window
using `from_date`/`to_date` (`YYYY-MM-DD`). Page through results with `before`/`after`,
`limit`, and `order`.

List persisted partitions for your organization, with id-based pagination and optional filename / date filtering.

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

  client = Retab()

  partitions = client.partitions.list(limit=20, order="desc")
  for partition in partitions.data:
      print(f"{partition.id}: {partition.file.filename}")

  partitions = client.partitions.list(
      from_date=datetime(2024, 1, 1),
      to_date=datetime(2024, 12, 31),
      limit=50,
  )
  ```

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

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

  const partitions = await client.partitions.list({ limit: 20, order: "desc" });
  for (const partition of partitions.data) {
    console.log(`${partition.id}: ${partition.file.filename}`);
  }

  const ranged = await client.partitions.list({
    fromDate: new Date("2024-01-01").toISOString(),
    toDate: new Date("2024-12-31").toISOString(),
    limit: 50,
  });
  ```

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

  	partitions, err := client.Partitions.List(ctx, &retab.PartitionsListParams{
  		PaginationParams: retab.PaginationParams{Limit: ptr(20), Order: ptr("desc")},
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	for _, partition := range partitions.Data {
  		fmt.Printf("%s: %s\n", partition.ID, partition.File.Filename)
  	}

  	from := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)
  	to := time.Date(2024, 12, 31, 0, 0, 0, 0, time.UTC)
  	ranged, err := client.Partitions.List(ctx, &retab.PartitionsListParams{
  		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(ranged)
  }
  ```

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

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

  partitions = client.partitions.list(limit: 20, order: 'desc')
  partitions.data.each do |partition|
    puts "#{partition.id}: #{partition.file.filename}"
  end

  partitions = client.partitions.list(
    from_date: DateTime.new(2024, 1, 1),
    to_date: DateTime.new(2024, 12, 31),
    limit: 50,
  )
  ```

  ```rust Rust theme={null}
  use retab::enums::PartitionsOrder;
  use retab::resources::partitions::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")?);

      let partitions = client
          .partitions()
          .list(ListParams {
              limit: Some(20),
              order: Some(PartitionsOrder::Desc),
              ..Default::default()
          })
          .await?;
      for partition in &partitions.data {
          println!("{}: {}", partition.id, partition.file.filename);
      }

      let _ranged = client
          .partitions()
          .list(ListParams {
              from_date: Some("2024-01-01".into()),
              to_date: Some("2024-12-31".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->partitions()->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.Partitions.ListAsync(new PartitionsListOptions());
  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.partitions().list(null, null, 10L, null, "invoice.pdf", null, null, null);
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  curl -X GET \
    'https://api.retab.com/v1/partitions?limit=20&order=desc' \
    -H "Authorization: Bearer $RETAB_API_KEY"

  curl -X GET \
    'https://api.retab.com/v1/partitions?filename=invoice&from_date=2024-01-01&to_date=2024-12-31&limit=50' \
    -H "Authorization: Bearer $RETAB_API_KEY"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "data": [
      {
        "id": "part_01G34H8J2K",
        "file": {
          "id": "file_6dd6eb00688ad8d1",
          "filename": "invoice_batch.pdf",
          "mime_type": "application/pdf"
        },
        "model": "retab-small",
        "key": "invoice_number",
        "instructions": "Return one chunk per invoice number and keep all pages for the same invoice together.",
        "n_consensus": 3,
        "allow_overlap": true,
        "output": [
          { "key": "INV-001", "pages": [1, 2] },
          { "key": "INV-002", "pages": [3, 4] }
        ],
        "consensus": {
          "likelihoods": [
            { "key": 0.99, "pages": [0.99, 0.98] },
            { "key": 0.96, "pages": [0.95, 0.95] }
          ],
          "choices": [
            [
              { "key": "INV-001", "pages": [1, 2] },
              { "key": "INV-002", "pages": [3, 4] }
            ]
          ]
        },
        "usage": {
          "credits": 3.0
        },
        "created_at": "2024-03-15T10:30:00Z"
      }
    ],
    "list_metadata": {
      "before": null,
      "after": "part_01G34H8J2K",
      "total_count": 12
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /v1/partitions
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/partitions:
    get:
      tags:
        - Partitions
      summary: List Partitions
      description: >-
        List partitions.


        Returns a paginated list of partitions for the authenticated
        environment, newest first

        by default. Filter by `filename` prefix (case-insensitive) and by a
        `created_at` window

        using `from_date`/`to_date` (`YYYY-MM-DD`). Page through results with
        `before`/`after`,

        `limit`, and `order`.
      operationId: list_partitions
      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: 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
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartitionList'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    PartitionList:
      description: >-
        A page of `Partition` 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/Partition'
          type: array
          title: Data
        list_metadata:
          $ref: '#/components/schemas/ListMetadata'
      type: object
      required:
        - data
        - list_metadata
      title: PartitionList
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    Partition:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the partition
        file:
          $ref: '#/components/schemas/FileRef'
          description: Information about the partitioned file
        model:
          type: string
          title: Model
          description: Model used for the partition operation
        key:
          type: string
          title: Key
          description: Partition key used for the run
        instructions:
          anyOf:
            - type: string
            - type: 'null'
          title: Instructions
          description: Free-form instructions supplied with the partition request
        n_consensus:
          type: integer
          title: N Consensus
          description: Number of consensus votes used
          default: 1
        allow_overlap:
          type: boolean
          title: Allow Overlap
          description: >-
            Whether pages were allowed to appear in more than one partition
            chunk
          default: true
        output:
          items:
            $ref: '#/components/schemas/PartitionChunk'
          type: array
          title: Output
          description: >-
            The list of partition chunks with their assigned pages. Empty []
            until status == 'completed'.
          default: []
        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/PartitionConsensus'
            - type: 'null'
          description: Consensus metadata for multi-vote partition runs
        usage:
          anyOf:
            - $ref: '#/components/schemas/RetabUsage'
            - type: 'null'
          description: Usage information for the partition operation
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
      type: object
      required:
        - file
        - id
        - key
        - model
      title: Partition
      description: >-
        A partition result: a document segmented into chunks along the requested
        `key`.
    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.
    PartitionChunk:
      properties:
        key:
          type: string
          title: Key
          description: The partition key value for this chunk
        pages:
          items:
            type: integer
          type: array
          title: Pages
          description: The pages assigned to this partition chunk (1-indexed)
          default: []
      type: object
      required:
        - key
      title: PartitionChunk
    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
    PartitionConsensus:
      properties:
        choices:
          items:
            items:
              $ref: '#/components/schemas/PartitionChunk'
            type: array
          type: array
          title: Choices
          description: >-
            Alternative partition vote outputs used to build the consolidated
            result.
          default: []
        likelihoods:
          items:
            $ref: '#/components/schemas/PartitionChunkLikelihood'
          type: array
          title: Likelihoods
          description: Consensus likelihoods aligned with the partition output.
          default: []
      type: object
      title: PartitionConsensus
    RetabUsage:
      properties:
        credits:
          type: number
          title: Credits
          description: Credits consumed for processing
      type: object
      required:
        - credits
      title: RetabUsage
      description: Usage information for document processing.
    PartitionChunkLikelihood:
      properties:
        key:
          anyOf:
            - type: number
            - type: 'null'
          title: Key
          description: Confidence that this partition key value is correct
        pages:
          items:
            type: number
          type: array
          title: Pages
          description: >-
            Confidence for each page in the corresponding partition chunk.pages
            array
          default: []
      type: object
      title: PartitionChunkLikelihood
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````