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

# Extraction

> Get extraction by ID

Retrieves extraction data by ID, including fields, tables, and document information.

## Usage Notes

* This endpoint returns extraction data including all fields
* For tables, it includes up to 100 rows per table (the default pagination limit)
* For tables with more than 100 rows, use the pagination information from each table and the [Get Extraction Table Rows](/api-reference/get-extraction-table-rows) endpoint to retrieve additional rows

## Request

<ParamField path="id" type="string" required>
  The ID of the extraction to retrieve.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET https://api.tableflow.com/v2/extractions/uT2bJNWN75YPU95r \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const axios = require("axios");

  async function getExtraction(extractionId) {
    try {
      const response = await axios.get(
        `https://api.tableflow.com/v2/extractions/${extractionId}`,
        {
          headers: {
            Authorization: "Bearer YOUR_API_KEY",
          },
        }
      );
      console.log(response.data);
      return response.data;
    } catch (error) {
      console.error(error);
      throw error;
    }
  }

  getExtraction("uT2bJNWN75YPU95r")
    .then(extraction => {
      console.log(`Extracted data for ${extraction.file_name}`);
    });
  ```

  ```python Python theme={null}
  import requests

  def get_extraction(extraction_id):
      url = f"https://api.tableflow.com/v2/extractions/{extraction_id}"
      headers = {
          "Authorization": "Bearer YOUR_API_KEY"
      }

      response = requests.get(url, headers=headers)
      response.raise_for_status()  # Raise exception for 4XX/5XX responses

      return response.json()

  # Example usage
  try:
      extraction = get_extraction("uT2bJNWN75YPU95r")
      print(f"Extracted data for {extraction['file_name']}")
  except requests.exceptions.HTTPError as e:
      print(f"Error fetching extraction: {e}")
  ```
</RequestExample>

## Response

<ResponseField name="id" type="string">
  The unique identifier for the extraction.
</ResponseField>

<ResponseField name="workspace_id" type="string">
  The ID of the workspace this extraction belongs to.
</ResponseField>

<ResponseField name="template_id" type="string">
  The ID of the template used for extraction.
</ResponseField>

<ResponseField name="template_name" type="string">
  The name of the template used for extraction.
</ResponseField>

<ResponseField name="file_name" type="string">
  The name of the uploaded file.
</ResponseField>

<ResponseField name="file_size" type="integer">
  The size of the uploaded file in bytes.
</ResponseField>

<ResponseField name="file_type" type="object">
  Information about the file type.

  <Expandable title="file_type">
    <ResponseField name="key" type="string">
      The file type key (e.g., "document", "spreadsheet").
    </ResponseField>

    <ResponseField name="extension" type="string">
      The file extension (e.g., "pdf", "xlsx").
    </ResponseField>

    <ResponseField name="mime_type" type="string">
      The file's MIME type.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="status" type="string">
  The current status of the extraction (e.g., "processing", "completed", "failed").
</ResponseField>

<ResponseField name="status_history" type="array">
  History of status changes for this extraction.
</ResponseField>

<ResponseField name="error" type="string">
  Error message if the extraction failed.
</ResponseField>

<ResponseField name="metadata" type="object">
  Additional metadata associated with the extraction.
</ResponseField>

<ResponseField name="created_at" type="integer">
  Unix timestamp when the extraction was created.
</ResponseField>

<ResponseField name="updated_at" type="integer">
  Unix timestamp when the extraction was last updated.
</ResponseField>

<ResponseField name="data" type="object">
  The extracted data.

  <Expandable title="data">
    <ResponseField name="fields" type="object">
      Field data extracted from the document.

      <Expandable title="fields">
        <ResponseField name="values" type="object">
          Map of field keys to their extracted values.
        </ResponseField>

        <ResponseField name="validations" type="object">
          Map of field keys to arrays of validation issues.

          <Expandable title="validations">
            <ResponseField name="{field_key}" type="array">
              <ResponseField name="validate" type="string">
                The validation that failed.
              </ResponseField>

              <ResponseField name="severity" type="string">
                Severity of the validation issue ("error", "warn", "info").
              </ResponseField>

              <ResponseField name="message" type="string">
                Error message describing the validation issue.
              </ResponseField>
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="tables" type="object">
      Map of table keys to their data and pagination information.
      <strong>Note:</strong> This endpoint includes up to 100 rows per table. For tables with more rows, use the pagination information and the [Get Extraction Table Rows](/api-reference/get-extraction-table-rows) endpoint to retrieve additional rows.

      <Expandable title="tables">
        <ResponseField name="{table_key}" type="object">
          <ResponseField name="pagination" type="object">
            Pagination information for this table.

            <Expandable title="pagination">
              <ResponseField name="offset" type="integer">
                Current offset.
              </ResponseField>

              <ResponseField name="limit" type="integer">
                Current limit (typically 100 for the main extraction endpoint).
              </ResponseField>

              <ResponseField name="total" type="integer">
                Total number of rows in the table.
              </ResponseField>

              <ResponseField name="next_offset" type="integer">
                Offset for the next page of results. Will be null if all rows are included.
              </ResponseField>

              <ResponseField name="filter" type="string">
                The applied filter ("all", "valid", "error").
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="rows" type="array">
            Array of table rows, limited to first 100 rows. For complete access to all rows, use the [Get Extraction Table Rows](/api-reference/get-extraction-table-rows) endpoint.

            <Expandable title="rows">
              <ResponseField name="index" type="integer">
                The row index (0-based).
              </ResponseField>

              <ResponseField name="values" type="object">
                Map of column keys to their cell values.
              </ResponseField>

              <ResponseField name="validations" type="object">
                Map of column keys to arrays of validation issues.
              </ResponseField>
            </Expandable>
          </ResponseField>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="stats" type="object">
  Statistics about the extraction data.

  <Expandable title="stats">
    <ResponseField name="fields" type="object">
      Statistics about the extracted fields.

      <Expandable title="fields">
        <ResponseField name="valid" type="integer">
          Number of fields that passed all validations.
        </ResponseField>

        <ResponseField name="invalid" type="integer">
          Number of fields that failed at least one validation.
        </ResponseField>

        <ResponseField name="total" type="integer">
          Total number of fields.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="tables" type="object">
      Map of table keys to their statistics.

      <Expandable title="tables">
        <ResponseField name="{table_key}" type="object">
          <ResponseField name="rows" type="object">
            Row statistics for this table.

            <Expandable title="rows">
              <ResponseField name="valid" type="integer">
                Number of rows that passed all validations.
              </ResponseField>

              <ResponseField name="invalid" type="integer">
                Number of rows that failed at least one validation.
              </ResponseField>

              <ResponseField name="total" type="integer">
                Total number of rows.
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="columns" type="object">
            Column statistics for this table.

            <Expandable title="columns">
              <ResponseField name="total" type="integer">
                Total number of columns.
              </ResponseField>

              <ResponseField name="cells" type="object">
                Map of column keys to their cell statistics.

                <Expandable title="cells">
                  <ResponseField name="{column_key}" type="object">
                    <ResponseField name="valid" type="integer">
                      Number of cells that passed all validations.
                    </ResponseField>

                    <ResponseField name="invalid" type="integer">
                      Number of cells that failed at least one validation.
                    </ResponseField>

                    <ResponseField name="not_blank" type="integer">
                      Number of cells that are not blank.
                    </ResponseField>
                  </ResponseField>
                </Expandable>
              </ResponseField>
            </Expandable>
          </ResponseField>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="template" type="object">
  The template used at the time of extraction.
</ResponseField>

<ResponseExample>
  ```json theme={null}
  {
    "id": "uT2bJNWN75YPU95r",
    "workspace_id": "dk4g1tUg1uHLs8YU",
    "template_id": "JlLZVabDjYWzu7C9",
    "template_name": "Invoice Template",
    "file_name": "acme-invoice-apr2023.pdf",
    "file_size": 245872,
    "file_type": {
      "key": "document",
      "extension": "pdf",
      "mime_type": "application/pdf"
    },
    "status": "completed",
    "status_history": [
      {
        "status": "processing",
        "time": 1682366228,
        "message": "File uploaded"
      },
      {
        "status": "completed",
        "time": 1682366240,
        "message": "Extraction completed"
      }
    ],
    "created_at": 1682366228,
    "updated_at": 1682366240,
    "data": {
      "fields": {
        "values": {
          "invoice_number": "INV-20230415",
          "invoice_date": "2023-04-15",
          "customer_name": "Acme Corporation",
          "payment_terms": "Net 30",
          "total_amount": "1245.75"
        },
        "validations": {}
      },
      "tables": {
        "line_items": {
          "pagination": {
            "offset": 0,
            "limit": 100,
            "total": 2,
            "next_offset": null,
            "filter": "all"
          },
          "rows": [
            {
              "index": 0,
              "values": {
                "description": "Ergonomic Office Chair",
                "quantity": "1",
                "unit_price": "249.99",
                "amount": "249.99"
              },
              "validations": {}
            },
            {
              "index": 1,
              "values": {
                "description": "Wireless Keyboard",
                "quantity": "2",
                "unit_price": "59.95",
                "amount": "119.90"
              },
              "validations": {}
            }
          ]
        }
      }
    },
    "stats": {
      "fields": {
        "valid": 5,
        "invalid": 0,
        "total": 5
      },
      "tables": {
        "line_items": {
          "rows": {
            "valid": 2,
            "invalid": 0,
            "total": 2
          },
          "columns": {
            "total": 4
          }
        }
      }
    },
    "template": {
      "id": "JlLZVabDjYWzu7C9",
      "name": "Invoice Template",
      "fields": [
        {
          "key": "invoice_number",
          "name": "Invoice Number",
          "data_type": "string"
        }
      ],
      "tables": [
        {
          "key": "line_items",
          "name": "Line Items",
          "columns": [
            {
              "key": "description",
              "name": "Description",
              "data_type": "string"
            }
          ]
        }
      ]
    }
  }
  ```
</ResponseExample>

## Error Responses

<ResponseField name="error" type="string">
  Error message describing what went wrong.
</ResponseField>

<ResponseExample>
  ```json 400 Bad Request theme={null}
  {
    "error": "No extraction ID provided"
  }
  ```
</ResponseExample>
