from retab import Retab
client = Retab()
result = client.splits.create_reconstruct(
document={
"id": "doc_01G34H8J2K",
"filename": "orders_workbook.xlsx",
"mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
},
subdocuments=[
{
"name": "orders",
"regions": [
{
"sheet_name": "Orders",
"sheet_index": 0,
"row_start": 2,
"row_end": 148,
"header_rows": [1],
}
],
"partition_key": "order_number",
}
],
)
for table in result.tables:
print(f"{table.label}: {len(table.rows)} rows")
import { Retab } from "@retab/node";
const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
const result = await client.splits.create_reconstruct(
{
id: "doc_01G34H8J2K",
filename: "orders_workbook.xlsx",
mimeType:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
},
[
{
name: "orders",
regions: [
{
sheetName: "Orders",
sheetIndex: 0,
rowStart: 2,
rowEnd: 148,
headerRows: [1],
},
],
partitionKey: "order_number",
},
],
);
result.tables.forEach((table) => {
console.log(`${table.label}: ${table.rows.length} rows`);
});
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() {
client, err := retab.NewClient("")
if err != nil {
log.Fatal(err)
}
result, err := client.Splits.CreateReconstruct(context.Background(), &retab.SplitsCreateReconstructParams{
Document: retab.ReconstructDocumentRef{
ID: "doc_01G34H8J2K",
Filename: "orders_workbook.xlsx",
MIMEType: ptr("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
},
Subdocuments: []*retab.ReconstructSubdocument{
{
Name: "orders",
Regions: []*retab.SheetRegion{
{
SheetName: "Orders",
SheetIndex: 0,
RowStart: 2,
RowEnd: 148,
HeaderRows: []int{1},
},
},
PartitionKey: ptr("order_number"),
},
},
})
if err != nil {
log.Fatal(err)
}
for _, table := range result.Tables {
fmt.Printf("%s: %d rows\n", table.Label, len(table.Rows))
}
}
import com.retab.RetabClient;
import com.retab.models.ReconstructDocumentRef;
import com.retab.models.ReconstructRequest;
import com.retab.models.ReconstructSubdocument;
import com.retab.models.SheetRegion;
import java.util.List;
public final class Example {
public static void main(String[] args) throws Exception {
RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));
var document =
new ReconstructDocumentRef(
"orders_workbook.xlsx",
"doc_01G34H8J2K",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
var region = new SheetRegion(null, null, List.of(1L), 148L, 2L, 0L, "Orders");
var subdocument =
new ReconstructSubdocument(null, "orders", "order_number", List.of(region));
var result =
client.splits().createReconstruct(new ReconstructRequest(document, List.of(subdocument)));
result.getTables().forEach(t -> System.out.println(t.getLabel()));
}
}
require 'retab'
client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])
result = client.splits.create_reconstruct(
document: {
id: 'doc_01G34H8J2K',
filename: 'orders_workbook.xlsx',
mime_type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
},
subdocuments: [
{
name: 'orders',
regions: [
{
sheet_name: 'Orders',
sheet_index: 0,
row_start: 2,
row_end: 148,
header_rows: [1]
}
],
partition_key: 'order_number'
}
]
)
result.tables.each { |table| puts table.label }
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 result = client
.splits()
.create_reconstruct(retab::resources::splits::CreateReconstructParams::new(
retab::models::ReconstructRequest::new(
{
let mut document = retab::models::ReconstructDocumentRef::new(
"orders_workbook.xlsx",
"doc_01G34H8J2K",
);
document.mime_type = Some(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".into(),
);
document
},
{
let mut region = retab::models::SheetRegion::new(148, 2, 0, "Orders");
region.header_rows = Some(vec![1]);
let mut subdocument =
retab::models::ReconstructSubdocument::new("orders", vec![region]);
subdocument.partition_key = Some("order_number".into());
vec![subdocument]
},
),
))
.await?;
for table in result.tables {
println!("{}", table.label);
}
Ok(())
}
<?php
require 'vendor/autoload.php';
use Retab\Client;
$client = new Client(apiKey: getenv('RETAB_API_KEY'));
$result = $client->splits()->createReconstruct(
document: [
'id' => 'doc_01G34H8J2K',
'filename' => 'orders_workbook.xlsx',
'mime_type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
],
subdocuments: [
[
'name' => 'orders',
'regions' => [
[
'sheet_name' => 'Orders',
'sheet_index' => 0,
'row_start' => 2,
'row_end' => 148,
'header_rows' => [1],
],
],
'partition_key' => 'order_number',
],
],
);
foreach ($result->tables as $table) {
echo $table->label . PHP_EOL;
}
using System.Collections.Generic;
using Retab;
using RetabClient = Retab.Retab;
var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
var client = new RetabClient(apiKey);
var document = new ReconstructDocumentRef
{
Filename = "orders_workbook.xlsx",
Id = "doc_01G34H8J2K",
MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
};
var region = new SheetRegion
{
HeaderRows = new List<long> { 1 },
RowEnd = 148,
RowStart = 2,
SheetIndex = 0,
SheetName = "Orders",
};
var subdocument = new ReconstructSubdocument
{
Name = "orders",
PartitionKey = "order_number",
Regions = new List<SheetRegion> { region },
};
var result = await client.Splits.CreateReconstructAsync(
new SplitsCreateReconstructOptions
{
Document = document,
Subdocuments = new List<ReconstructSubdocument> { subdocument },
});
foreach (var table in result.Tables)
{
Console.WriteLine(table.Label);
}
curl -X POST \
'https://api.retab.com/v1/splits/reconstruct' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {
"id": "doc_01G34H8J2K",
"filename": "orders_workbook.xlsx",
"mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
},
"subdocuments": [
{
"name": "orders",
"regions": [
{
"sheet_name": "Orders",
"sheet_index": 0,
"row_start": 2,
"row_end": 148,
"header_rows": [1]
}
],
"partition_key": "order_number"
}
]
}'
{
"tables": [
{
"label": "orders",
"header": ["order_number", "sku", "quantity", "unit_price"],
"rows": [
{ "cells": ["SO-1001", "WIDGET-A", "12", "4.50"] },
{ "cells": ["SO-1001", "WIDGET-B", "3", "17.00"] }
],
"csv": "order_number,sku,quantity,unit_price\nSO-1001,WIDGET-A,12,4.50\nSO-1001,WIDGET-B,3,17.00\n"
}
]
}
{
"detail": "document 'doc_01G34H8J2K' not found"
}
Splits
Reconstruct Split
Reconstruct each named subdocument of a stored spreadsheet into an enriched, partition-ready table: one flat complete header, the key carried on every row, section banners promoted to a column, and wide size-matrices melted. Returns the enriched tables (header + rows + clean CSV) for hand-off to extraction.
POST
/
v1
/
splits
/
reconstruct
from retab import Retab
client = Retab()
result = client.splits.create_reconstruct(
document={
"id": "doc_01G34H8J2K",
"filename": "orders_workbook.xlsx",
"mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
},
subdocuments=[
{
"name": "orders",
"regions": [
{
"sheet_name": "Orders",
"sheet_index": 0,
"row_start": 2,
"row_end": 148,
"header_rows": [1],
}
],
"partition_key": "order_number",
}
],
)
for table in result.tables:
print(f"{table.label}: {len(table.rows)} rows")
import { Retab } from "@retab/node";
const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
const result = await client.splits.create_reconstruct(
{
id: "doc_01G34H8J2K",
filename: "orders_workbook.xlsx",
mimeType:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
},
[
{
name: "orders",
regions: [
{
sheetName: "Orders",
sheetIndex: 0,
rowStart: 2,
rowEnd: 148,
headerRows: [1],
},
],
partitionKey: "order_number",
},
],
);
result.tables.forEach((table) => {
console.log(`${table.label}: ${table.rows.length} rows`);
});
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() {
client, err := retab.NewClient("")
if err != nil {
log.Fatal(err)
}
result, err := client.Splits.CreateReconstruct(context.Background(), &retab.SplitsCreateReconstructParams{
Document: retab.ReconstructDocumentRef{
ID: "doc_01G34H8J2K",
Filename: "orders_workbook.xlsx",
MIMEType: ptr("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
},
Subdocuments: []*retab.ReconstructSubdocument{
{
Name: "orders",
Regions: []*retab.SheetRegion{
{
SheetName: "Orders",
SheetIndex: 0,
RowStart: 2,
RowEnd: 148,
HeaderRows: []int{1},
},
},
PartitionKey: ptr("order_number"),
},
},
})
if err != nil {
log.Fatal(err)
}
for _, table := range result.Tables {
fmt.Printf("%s: %d rows\n", table.Label, len(table.Rows))
}
}
import com.retab.RetabClient;
import com.retab.models.ReconstructDocumentRef;
import com.retab.models.ReconstructRequest;
import com.retab.models.ReconstructSubdocument;
import com.retab.models.SheetRegion;
import java.util.List;
public final class Example {
public static void main(String[] args) throws Exception {
RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));
var document =
new ReconstructDocumentRef(
"orders_workbook.xlsx",
"doc_01G34H8J2K",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
var region = new SheetRegion(null, null, List.of(1L), 148L, 2L, 0L, "Orders");
var subdocument =
new ReconstructSubdocument(null, "orders", "order_number", List.of(region));
var result =
client.splits().createReconstruct(new ReconstructRequest(document, List.of(subdocument)));
result.getTables().forEach(t -> System.out.println(t.getLabel()));
}
}
require 'retab'
client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])
result = client.splits.create_reconstruct(
document: {
id: 'doc_01G34H8J2K',
filename: 'orders_workbook.xlsx',
mime_type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
},
subdocuments: [
{
name: 'orders',
regions: [
{
sheet_name: 'Orders',
sheet_index: 0,
row_start: 2,
row_end: 148,
header_rows: [1]
}
],
partition_key: 'order_number'
}
]
)
result.tables.each { |table| puts table.label }
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 result = client
.splits()
.create_reconstruct(retab::resources::splits::CreateReconstructParams::new(
retab::models::ReconstructRequest::new(
{
let mut document = retab::models::ReconstructDocumentRef::new(
"orders_workbook.xlsx",
"doc_01G34H8J2K",
);
document.mime_type = Some(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".into(),
);
document
},
{
let mut region = retab::models::SheetRegion::new(148, 2, 0, "Orders");
region.header_rows = Some(vec![1]);
let mut subdocument =
retab::models::ReconstructSubdocument::new("orders", vec![region]);
subdocument.partition_key = Some("order_number".into());
vec![subdocument]
},
),
))
.await?;
for table in result.tables {
println!("{}", table.label);
}
Ok(())
}
<?php
require 'vendor/autoload.php';
use Retab\Client;
$client = new Client(apiKey: getenv('RETAB_API_KEY'));
$result = $client->splits()->createReconstruct(
document: [
'id' => 'doc_01G34H8J2K',
'filename' => 'orders_workbook.xlsx',
'mime_type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
],
subdocuments: [
[
'name' => 'orders',
'regions' => [
[
'sheet_name' => 'Orders',
'sheet_index' => 0,
'row_start' => 2,
'row_end' => 148,
'header_rows' => [1],
],
],
'partition_key' => 'order_number',
],
],
);
foreach ($result->tables as $table) {
echo $table->label . PHP_EOL;
}
using System.Collections.Generic;
using Retab;
using RetabClient = Retab.Retab;
var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
var client = new RetabClient(apiKey);
var document = new ReconstructDocumentRef
{
Filename = "orders_workbook.xlsx",
Id = "doc_01G34H8J2K",
MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
};
var region = new SheetRegion
{
HeaderRows = new List<long> { 1 },
RowEnd = 148,
RowStart = 2,
SheetIndex = 0,
SheetName = "Orders",
};
var subdocument = new ReconstructSubdocument
{
Name = "orders",
PartitionKey = "order_number",
Regions = new List<SheetRegion> { region },
};
var result = await client.Splits.CreateReconstructAsync(
new SplitsCreateReconstructOptions
{
Document = document,
Subdocuments = new List<ReconstructSubdocument> { subdocument },
});
foreach (var table in result.Tables)
{
Console.WriteLine(table.Label);
}
curl -X POST \
'https://api.retab.com/v1/splits/reconstruct' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {
"id": "doc_01G34H8J2K",
"filename": "orders_workbook.xlsx",
"mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
},
"subdocuments": [
{
"name": "orders",
"regions": [
{
"sheet_name": "Orders",
"sheet_index": 0,
"row_start": 2,
"row_end": 148,
"header_rows": [1]
}
],
"partition_key": "order_number"
}
]
}'
{
"tables": [
{
"label": "orders",
"header": ["order_number", "sku", "quantity", "unit_price"],
"rows": [
{ "cells": ["SO-1001", "WIDGET-A", "12", "4.50"] },
{ "cells": ["SO-1001", "WIDGET-B", "3", "17.00"] }
],
"csv": "order_number,sku,quantity,unit_price\nSO-1001,WIDGET-A,12,4.50\nSO-1001,WIDGET-B,3,17.00\n"
}
]
}
{
"detail": "document 'doc_01G34H8J2K' not found"
}
Reconstruct each named subdocument of a stored spreadsheet into an enriched, partition-ready table: one flat complete header, the key carried on every row, section banners promoted to a column, and wide size-matrices melted. Returns the enriched tables (header + rows + clean CSV) for hand-off to extraction.
from retab import Retab
client = Retab()
result = client.splits.create_reconstruct(
document={
"id": "doc_01G34H8J2K",
"filename": "orders_workbook.xlsx",
"mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
},
subdocuments=[
{
"name": "orders",
"regions": [
{
"sheet_name": "Orders",
"sheet_index": 0,
"row_start": 2,
"row_end": 148,
"header_rows": [1],
}
],
"partition_key": "order_number",
}
],
)
for table in result.tables:
print(f"{table.label}: {len(table.rows)} rows")
import { Retab } from "@retab/node";
const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
const result = await client.splits.create_reconstruct(
{
id: "doc_01G34H8J2K",
filename: "orders_workbook.xlsx",
mimeType:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
},
[
{
name: "orders",
regions: [
{
sheetName: "Orders",
sheetIndex: 0,
rowStart: 2,
rowEnd: 148,
headerRows: [1],
},
],
partitionKey: "order_number",
},
],
);
result.tables.forEach((table) => {
console.log(`${table.label}: ${table.rows.length} rows`);
});
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() {
client, err := retab.NewClient("")
if err != nil {
log.Fatal(err)
}
result, err := client.Splits.CreateReconstruct(context.Background(), &retab.SplitsCreateReconstructParams{
Document: retab.ReconstructDocumentRef{
ID: "doc_01G34H8J2K",
Filename: "orders_workbook.xlsx",
MIMEType: ptr("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
},
Subdocuments: []*retab.ReconstructSubdocument{
{
Name: "orders",
Regions: []*retab.SheetRegion{
{
SheetName: "Orders",
SheetIndex: 0,
RowStart: 2,
RowEnd: 148,
HeaderRows: []int{1},
},
},
PartitionKey: ptr("order_number"),
},
},
})
if err != nil {
log.Fatal(err)
}
for _, table := range result.Tables {
fmt.Printf("%s: %d rows\n", table.Label, len(table.Rows))
}
}
import com.retab.RetabClient;
import com.retab.models.ReconstructDocumentRef;
import com.retab.models.ReconstructRequest;
import com.retab.models.ReconstructSubdocument;
import com.retab.models.SheetRegion;
import java.util.List;
public final class Example {
public static void main(String[] args) throws Exception {
RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));
var document =
new ReconstructDocumentRef(
"orders_workbook.xlsx",
"doc_01G34H8J2K",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
var region = new SheetRegion(null, null, List.of(1L), 148L, 2L, 0L, "Orders");
var subdocument =
new ReconstructSubdocument(null, "orders", "order_number", List.of(region));
var result =
client.splits().createReconstruct(new ReconstructRequest(document, List.of(subdocument)));
result.getTables().forEach(t -> System.out.println(t.getLabel()));
}
}
require 'retab'
client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])
result = client.splits.create_reconstruct(
document: {
id: 'doc_01G34H8J2K',
filename: 'orders_workbook.xlsx',
mime_type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
},
subdocuments: [
{
name: 'orders',
regions: [
{
sheet_name: 'Orders',
sheet_index: 0,
row_start: 2,
row_end: 148,
header_rows: [1]
}
],
partition_key: 'order_number'
}
]
)
result.tables.each { |table| puts table.label }
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 result = client
.splits()
.create_reconstruct(retab::resources::splits::CreateReconstructParams::new(
retab::models::ReconstructRequest::new(
{
let mut document = retab::models::ReconstructDocumentRef::new(
"orders_workbook.xlsx",
"doc_01G34H8J2K",
);
document.mime_type = Some(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".into(),
);
document
},
{
let mut region = retab::models::SheetRegion::new(148, 2, 0, "Orders");
region.header_rows = Some(vec![1]);
let mut subdocument =
retab::models::ReconstructSubdocument::new("orders", vec![region]);
subdocument.partition_key = Some("order_number".into());
vec![subdocument]
},
),
))
.await?;
for table in result.tables {
println!("{}", table.label);
}
Ok(())
}
<?php
require 'vendor/autoload.php';
use Retab\Client;
$client = new Client(apiKey: getenv('RETAB_API_KEY'));
$result = $client->splits()->createReconstruct(
document: [
'id' => 'doc_01G34H8J2K',
'filename' => 'orders_workbook.xlsx',
'mime_type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
],
subdocuments: [
[
'name' => 'orders',
'regions' => [
[
'sheet_name' => 'Orders',
'sheet_index' => 0,
'row_start' => 2,
'row_end' => 148,
'header_rows' => [1],
],
],
'partition_key' => 'order_number',
],
],
);
foreach ($result->tables as $table) {
echo $table->label . PHP_EOL;
}
using System.Collections.Generic;
using Retab;
using RetabClient = Retab.Retab;
var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
var client = new RetabClient(apiKey);
var document = new ReconstructDocumentRef
{
Filename = "orders_workbook.xlsx",
Id = "doc_01G34H8J2K",
MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
};
var region = new SheetRegion
{
HeaderRows = new List<long> { 1 },
RowEnd = 148,
RowStart = 2,
SheetIndex = 0,
SheetName = "Orders",
};
var subdocument = new ReconstructSubdocument
{
Name = "orders",
PartitionKey = "order_number",
Regions = new List<SheetRegion> { region },
};
var result = await client.Splits.CreateReconstructAsync(
new SplitsCreateReconstructOptions
{
Document = document,
Subdocuments = new List<ReconstructSubdocument> { subdocument },
});
foreach (var table in result.Tables)
{
Console.WriteLine(table.Label);
}
curl -X POST \
'https://api.retab.com/v1/splits/reconstruct' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {
"id": "doc_01G34H8J2K",
"filename": "orders_workbook.xlsx",
"mime_type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
},
"subdocuments": [
{
"name": "orders",
"regions": [
{
"sheet_name": "Orders",
"sheet_index": 0,
"row_start": 2,
"row_end": 148,
"header_rows": [1]
}
],
"partition_key": "order_number"
}
]
}'
{
"tables": [
{
"label": "orders",
"header": ["order_number", "sku", "quantity", "unit_price"],
"rows": [
{ "cells": ["SO-1001", "WIDGET-A", "12", "4.50"] },
{ "cells": ["SO-1001", "WIDGET-B", "3", "17.00"] }
],
"csv": "order_number,sku,quantity,unit_price\nSO-1001,WIDGET-A,12,4.50\nSO-1001,WIDGET-B,3,17.00\n"
}
]
}
{
"detail": "document 'doc_01G34H8J2K' not found"
}
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Response
Successful Response
Show child attributes
Show child attributes
⌘I