from retab import MIMEData, Retab
client = Retab()
document = MIMEData(
filename="form.pdf",
url="https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
)
edit = client.edits.create(
instructions="Name: John Doe, Date of Birth: 1990-01-15, Address: 123 Main Street",
document=document,
model="retab-small",
)
print(f"Edit ID: {edit.id}")
for field in edit.output.form_data:
print(f"{field.key} = {field.value}")
# Save the filled PDF
import base64
with open("filled_form.pdf", "wb") as f:
f.write(base64.b64decode(edit.output.filled_document.url.split(",", 1)[1]))
import { Retab } from "@retab/node";
const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
const document = {
filename: "form.pdf",
url: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
};
const edit = await client.edits.create("Name: John Doe, Date of Birth: 1990-01-15", document, undefined, "retab-small");
console.log(`Edit ID: ${edit.id}`);
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)
}
document := retab.MIMEData{
Filename: "form.pdf",
URL: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
}
edit, err := client.Edits.Create(ctx, &retab.EditsCreateParams{
Instructions: "Name: John Doe, Date of Birth: 1990-01-15",
Document: document,
Model: ptr("retab-small"),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Edit ID: %s\n", edit.ID)
}
require 'retab'
client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])
document = {
filename: 'form.pdf',
url: 'https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf',
}
edit = client.edits.create(
instructions: 'Name: John Doe, Date of Birth: 1990-01-15, Address: 123 Main Street',
document: document,
model: 'retab-small',
)
puts "Edit ID: #{edit.id}"
edit.output.form_data.each do |field|
puts "#{field.key} = #{field.value}"
end
use retab::resources::edits::CreateParams;
use retab::{MimeData, Retab};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Retab::new(std::env::var("RETAB_API_KEY")?);
let document = MimeData::new(
"form.pdf",
"https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
);
let mut params = CreateParams::new("Name: John Doe, Date of Birth: 1990-01-15");
params.body.document = Some(document);
params.body.model = Some("retab-small".into());
let edit = client.edits().create(params).await?;
println!("Edit ID: {}", edit.id);
for field in &edit.output.as_ref().unwrap().form_data {
println!("{} = {}", field.key, field.value.as_deref().unwrap_or(""));
}
Ok(())
}
<?php
require 'vendor/autoload.php';
use Retab\Client;
$client = new Client(apiKey: getenv('RETAB_API_KEY'));
$result = $client->edits()->create(
instructions: 'value',
);
print_r($result);
using System;
using System.Collections.Generic;
using Retab;
using RetabClient = Retab.Retab;
var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
var client = new RetabClient(apiKey);
var document = MimeData.FromUrl(new Uri("https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf"));
var result = await client.Edits.CreateAsync(new EditsCreateOptions
{
Instructions = "Name: John Doe, Date of Birth: 1990-01-15",
Document = document,
Model = "retab-small",
});
Console.WriteLine(result);
import com.retab.RetabClient;
import com.retab.models.MimeData;
import java.net.URI;
import java.util.List;
import java.util.Map;
public final class Example {
public static void main(String[] args) throws Exception {
RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));
MimeData document =
MimeData.fromUrl(URI.create("https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf"));
var result =
client
.edits()
.create(
"Name: John Doe, Date of Birth: 1990-01-15",
document,
null,
"retab-small",
null,
null,
null);
System.out.println(result);
}
}
# Option 1: with a document
curl -X POST \
'https://api.retab.com/v1/edits' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"instructions": "Name: John Doe, Date of Birth: 1990-01-15",
"document": {
"filename": "form.pdf",
"url": "https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf"
},
"model": "retab-small"
}'
# Option 2: with a template_id
curl -X POST \
'https://api.retab.com/v1/edits' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"instructions": "Name: John Doe",
"template_id": "edittplt_abc123",
"model": "retab-small"
}'
{
"id": "edit_01G34H8J2K",
"file": {
"id": "file_6dd6eb00688ad8d1",
"filename": "form.pdf",
"mime_type": "application/pdf"
},
"model": "retab-small",
"instructions": "Name: John Doe, Date of Birth: 1990-01-15",
"template_id": null,
"config": { "color": "#000080" },
"output": {
"form_data": [
{
"key": "full_name",
"description": "Full Name",
"type": "text",
"value": "John Doe",
"bbox": {
"left": 0.15,
"top": 0.2,
"width": 0.35,
"height": 0.03,
"page": 1
}
}
],
"filled_document": {
"filename": "form_filled.pdf",
"url": "data:application/pdf;base64,JVBERi0xLjQK..."
}
},
"usage": { "page_count": 1, "credits": 1.0 },
"created_at": "2024-03-15T10:30:00Z"
}
{
"detail": "Either document or template_id is required"
}
Create Edit
Create an edit.
Fills the form fields of a document according to instructions and renders
the values into a PDF. Provide exactly one of document (a PDF, DOCX, XLSX,
or PPTX) or template_id (an existing edit template) — supplying both or
neither responds with 400. Returns the created edit with the filled form
data and rendered document; responds with 201.
from retab import MIMEData, Retab
client = Retab()
document = MIMEData(
filename="form.pdf",
url="https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
)
edit = client.edits.create(
instructions="Name: John Doe, Date of Birth: 1990-01-15, Address: 123 Main Street",
document=document,
model="retab-small",
)
print(f"Edit ID: {edit.id}")
for field in edit.output.form_data:
print(f"{field.key} = {field.value}")
# Save the filled PDF
import base64
with open("filled_form.pdf", "wb") as f:
f.write(base64.b64decode(edit.output.filled_document.url.split(",", 1)[1]))
import { Retab } from "@retab/node";
const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
const document = {
filename: "form.pdf",
url: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
};
const edit = await client.edits.create("Name: John Doe, Date of Birth: 1990-01-15", document, undefined, "retab-small");
console.log(`Edit ID: ${edit.id}`);
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)
}
document := retab.MIMEData{
Filename: "form.pdf",
URL: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
}
edit, err := client.Edits.Create(ctx, &retab.EditsCreateParams{
Instructions: "Name: John Doe, Date of Birth: 1990-01-15",
Document: document,
Model: ptr("retab-small"),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Edit ID: %s\n", edit.ID)
}
require 'retab'
client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])
document = {
filename: 'form.pdf',
url: 'https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf',
}
edit = client.edits.create(
instructions: 'Name: John Doe, Date of Birth: 1990-01-15, Address: 123 Main Street',
document: document,
model: 'retab-small',
)
puts "Edit ID: #{edit.id}"
edit.output.form_data.each do |field|
puts "#{field.key} = #{field.value}"
end
use retab::resources::edits::CreateParams;
use retab::{MimeData, Retab};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Retab::new(std::env::var("RETAB_API_KEY")?);
let document = MimeData::new(
"form.pdf",
"https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
);
let mut params = CreateParams::new("Name: John Doe, Date of Birth: 1990-01-15");
params.body.document = Some(document);
params.body.model = Some("retab-small".into());
let edit = client.edits().create(params).await?;
println!("Edit ID: {}", edit.id);
for field in &edit.output.as_ref().unwrap().form_data {
println!("{} = {}", field.key, field.value.as_deref().unwrap_or(""));
}
Ok(())
}
<?php
require 'vendor/autoload.php';
use Retab\Client;
$client = new Client(apiKey: getenv('RETAB_API_KEY'));
$result = $client->edits()->create(
instructions: 'value',
);
print_r($result);
using System;
using System.Collections.Generic;
using Retab;
using RetabClient = Retab.Retab;
var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
var client = new RetabClient(apiKey);
var document = MimeData.FromUrl(new Uri("https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf"));
var result = await client.Edits.CreateAsync(new EditsCreateOptions
{
Instructions = "Name: John Doe, Date of Birth: 1990-01-15",
Document = document,
Model = "retab-small",
});
Console.WriteLine(result);
import com.retab.RetabClient;
import com.retab.models.MimeData;
import java.net.URI;
import java.util.List;
import java.util.Map;
public final class Example {
public static void main(String[] args) throws Exception {
RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));
MimeData document =
MimeData.fromUrl(URI.create("https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf"));
var result =
client
.edits()
.create(
"Name: John Doe, Date of Birth: 1990-01-15",
document,
null,
"retab-small",
null,
null,
null);
System.out.println(result);
}
}
# Option 1: with a document
curl -X POST \
'https://api.retab.com/v1/edits' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"instructions": "Name: John Doe, Date of Birth: 1990-01-15",
"document": {
"filename": "form.pdf",
"url": "https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf"
},
"model": "retab-small"
}'
# Option 2: with a template_id
curl -X POST \
'https://api.retab.com/v1/edits' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"instructions": "Name: John Doe",
"template_id": "edittplt_abc123",
"model": "retab-small"
}'
{
"id": "edit_01G34H8J2K",
"file": {
"id": "file_6dd6eb00688ad8d1",
"filename": "form.pdf",
"mime_type": "application/pdf"
},
"model": "retab-small",
"instructions": "Name: John Doe, Date of Birth: 1990-01-15",
"template_id": null,
"config": { "color": "#000080" },
"output": {
"form_data": [
{
"key": "full_name",
"description": "Full Name",
"type": "text",
"value": "John Doe",
"bbox": {
"left": 0.15,
"top": 0.2,
"width": 0.35,
"height": 0.03,
"page": 1
}
}
],
"filled_document": {
"filename": "form_filled.pdf",
"url": "data:application/pdf;base64,JVBERi0xLjQK..."
}
},
"usage": { "page_count": 1, "credits": 1.0 },
"created_at": "2024-03-15T10:30:00Z"
}
{
"detail": "Either document or template_id is required"
}
instructions. Persisted as an Edit resource, retrievable via GET /v1/edits/{edit_id}.
Either document or template_id must be provided; they are mutually exclusive.
from retab import MIMEData, Retab
client = Retab()
document = MIMEData(
filename="form.pdf",
url="https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
)
edit = client.edits.create(
instructions="Name: John Doe, Date of Birth: 1990-01-15, Address: 123 Main Street",
document=document,
model="retab-small",
)
print(f"Edit ID: {edit.id}")
for field in edit.output.form_data:
print(f"{field.key} = {field.value}")
# Save the filled PDF
import base64
with open("filled_form.pdf", "wb") as f:
f.write(base64.b64decode(edit.output.filled_document.url.split(",", 1)[1]))
import { Retab } from "@retab/node";
const client = new Retab({ apiKey: process.env.RETAB_API_KEY });
const document = {
filename: "form.pdf",
url: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
};
const edit = await client.edits.create("Name: John Doe, Date of Birth: 1990-01-15", document, undefined, "retab-small");
console.log(`Edit ID: ${edit.id}`);
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)
}
document := retab.MIMEData{
Filename: "form.pdf",
URL: "https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
}
edit, err := client.Edits.Create(ctx, &retab.EditsCreateParams{
Instructions: "Name: John Doe, Date of Birth: 1990-01-15",
Document: document,
Model: ptr("retab-small"),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Edit ID: %s\n", edit.ID)
}
require 'retab'
client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])
document = {
filename: 'form.pdf',
url: 'https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf',
}
edit = client.edits.create(
instructions: 'Name: John Doe, Date of Birth: 1990-01-15, Address: 123 Main Street',
document: document,
model: 'retab-small',
)
puts "Edit ID: #{edit.id}"
edit.output.form_data.each do |field|
puts "#{field.key} = #{field.value}"
end
use retab::resources::edits::CreateParams;
use retab::{MimeData, Retab};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Retab::new(std::env::var("RETAB_API_KEY")?);
let document = MimeData::new(
"form.pdf",
"https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf",
);
let mut params = CreateParams::new("Name: John Doe, Date of Birth: 1990-01-15");
params.body.document = Some(document);
params.body.model = Some("retab-small".into());
let edit = client.edits().create(params).await?;
println!("Edit ID: {}", edit.id);
for field in &edit.output.as_ref().unwrap().form_data {
println!("{} = {}", field.key, field.value.as_deref().unwrap_or(""));
}
Ok(())
}
<?php
require 'vendor/autoload.php';
use Retab\Client;
$client = new Client(apiKey: getenv('RETAB_API_KEY'));
$result = $client->edits()->create(
instructions: 'value',
);
print_r($result);
using System;
using System.Collections.Generic;
using Retab;
using RetabClient = Retab.Retab;
var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
var client = new RetabClient(apiKey);
var document = MimeData.FromUrl(new Uri("https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf"));
var result = await client.Edits.CreateAsync(new EditsCreateOptions
{
Instructions = "Name: John Doe, Date of Birth: 1990-01-15",
Document = document,
Model = "retab-small",
});
Console.WriteLine(result);
import com.retab.RetabClient;
import com.retab.models.MimeData;
import java.net.URI;
import java.util.List;
import java.util.Map;
public final class Example {
public static void main(String[] args) throws Exception {
RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));
MimeData document =
MimeData.fromUrl(URI.create("https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf"));
var result =
client
.edits()
.create(
"Name: John Doe, Date of Birth: 1990-01-15",
document,
null,
"retab-small",
null,
null,
null);
System.out.println(result);
}
}
# Option 1: with a document
curl -X POST \
'https://api.retab.com/v1/edits' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"instructions": "Name: John Doe, Date of Birth: 1990-01-15",
"document": {
"filename": "form.pdf",
"url": "https://my-bucket.s3.us-east-1.amazonaws.com/documents/form.pdf"
},
"model": "retab-small"
}'
# Option 2: with a template_id
curl -X POST \
'https://api.retab.com/v1/edits' \
-H "Authorization: Bearer $RETAB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"instructions": "Name: John Doe",
"template_id": "edittplt_abc123",
"model": "retab-small"
}'
{
"id": "edit_01G34H8J2K",
"file": {
"id": "file_6dd6eb00688ad8d1",
"filename": "form.pdf",
"mime_type": "application/pdf"
},
"model": "retab-small",
"instructions": "Name: John Doe, Date of Birth: 1990-01-15",
"template_id": null,
"config": { "color": "#000080" },
"output": {
"form_data": [
{
"key": "full_name",
"description": "Full Name",
"type": "text",
"value": "John Doe",
"bbox": {
"left": 0.15,
"top": 0.2,
"width": 0.35,
"height": 0.03,
"page": 1
}
}
],
"filled_document": {
"filename": "form_filled.pdf",
"url": "data:application/pdf;base64,JVBERi0xLjQK..."
}
},
"usage": { "page_count": 1, "credits": 1.0 },
"created_at": "2024-03-15T10:30:00Z"
}
{
"detail": "Either document or template_id is required"
}
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Public create-edit request body.
Instructions describing how to fill the form fields.
A file represented by its filename and a base64 data url.
Show child attributes
Show child attributes
EditTemplate id to fill. When provided, uses the template's pre-defined form fields and empty PDF. Mutually exclusive with document.
The model to use for edit inference.
Edit configuration (rendering options).
Show child attributes
Show child attributes
If true, skip the LLM cache and force a fresh completion.
If true, run asynchronously: returns immediately with status 'queued' and an empty output. Poll GET /v1//{id} until status is terminal. Mutually exclusive with stream.
Response
Successful Response
An edit result: form-field values written onto a document or template PDF.
Unique identifier of the edit.
Information about the source file (input document or template PDF).
Show child attributes
Show child attributes
Model used for the edit operation.
Configuration used for the edit operation.
Show child attributes
Show child attributes
Free-form instructions supplied with the edit request.
Template id used when the edit was created from a template; null for direct-document edits.
The edit result: filled form fields and the rendered PDF. An empty sentinel until status == 'completed'; gate reads on status.
Show child attributes
Show child attributes
Lifecycle status. The synchronous path returns 'completed'. Background runs progress pending -> queued -> in_progress -> completed | failed | cancelled.
pending, queued, in_progress, completed, failed, cancelled Error details when a background run fails; null otherwise. Always present so consumers can read it without an existence check.
Show child attributes
Show child attributes
Durable file reference for the filled document, when materialized.
Show child attributes
Show child attributes
Usage information for the edit operation.
Show child attributes
Show child attributes