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"
}
Edits
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.
POST
/
v1
/
edits
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"
}
Automatically detect fillable regions in a document (or reuse a pre-defined template) and apply the values described in
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
Body
application/json
Public create-edit request body.
Response
Successful Response
An edit result: form-field values written onto a document or template PDF.