Skip to main content
POST
/
v1
/
edits
/
templates
from retab import Retab

client = Retab()

template = client.edits.templates.create(
    name="W-9 Form",
    document="w9_empty.pdf",
    form_fields=[
        {
            "key": "full_name",
            "description": "Full legal name of the taxpayer",
            "type": "text",
            "bbox": {"left": 0.15, "top": 0.20, "width": 0.35, "height": 0.03, "page": 1},
        },
        {
            "key": "tax_id",
            "description": "Taxpayer Identification Number",
            "type": "text",
            "bbox": {"left": 0.15, "top": 0.28, "width": 0.25, "height": 0.03, "page": 1},
        },
    ],
)

print(f"Template ID: {template.id}")
{
  "id": "edittplt_abc123",
  "name": "W-9 Form",
  "file": {
    "id": "file_6dd6eb00688ad8d1",
    "filename": "w9_empty.pdf",
    "mime_type": "application/pdf"
  },
  "form_fields": [
    {
      "key": "full_name",
      "description": "Full legal name",
      "type": "text",
      "value": null,
      "bbox": {"left": 0.15, "top": 0.20, "width": 0.35, "height": 0.03, "page": 1}
    }
  ],
  "field_count": 1,
  "organization_id": "org_abc123",
  "created_at": "2024-03-15T10:30:00Z",
  "updated_at": "2024-03-15T10:30:00Z"
}
Register an EditTemplate — a PDF plus a set of pre-defined form fields that can be filled repeatedly via POST /v1/edits/templates/fill or POST /v1/edits.
from retab import Retab

client = Retab()

template = client.edits.templates.create(
    name="W-9 Form",
    document="w9_empty.pdf",
    form_fields=[
        {
            "key": "full_name",
            "description": "Full legal name of the taxpayer",
            "type": "text",
            "bbox": {"left": 0.15, "top": 0.20, "width": 0.35, "height": 0.03, "page": 1},
        },
        {
            "key": "tax_id",
            "description": "Taxpayer Identification Number",
            "type": "text",
            "bbox": {"left": 0.15, "top": 0.28, "width": 0.25, "height": 0.03, "page": 1},
        },
    ],
)

print(f"Template ID: {template.id}")
{
  "id": "edittplt_abc123",
  "name": "W-9 Form",
  "file": {
    "id": "file_6dd6eb00688ad8d1",
    "filename": "w9_empty.pdf",
    "mime_type": "application/pdf"
  },
  "form_fields": [
    {
      "key": "full_name",
      "description": "Full legal name",
      "type": "text",
      "value": null,
      "bbox": {"left": 0.15, "top": 0.20, "width": 0.35, "height": 0.03, "page": 1}
    }
  ],
  "field_count": 1,
  "organization_id": "org_abc123",
  "created_at": "2024-03-15T10:30:00Z",
  "updated_at": "2024-03-15T10:30:00Z"
}

Request Body

name
string
required
Name of the template.
document
MIMEData
required
The PDF to use as the empty template.
form_fields
array[FormField]
required
Form fields attached to the template. Each field has key, description, type (text or checkbox), and a bbox.

Authorizations

Api-Key
string
header
required

Query Parameters

access_token
string | null

Body

application/json
name
string
required

Name of the template.

document
MIMEData · object
required

The PDF document to use as the empty template.

form_fields
FormField · object[]
required

Form fields to attach to the template.

Response

Successful Response

id
string
required

Unique identifier of the template.

name
string
required

Name of the template.

file
FileRef · object
required

File information for the empty PDF template.

created_at
string<date-time>
required

Timestamp of creation.

updated_at
string<date-time>
required

Timestamp of last update.

form_fields
FormField · object[]

Form fields attached to the template.

field_count
integer
default:0

Number of form fields in the template.

organization_id
string | null

Organization that owns this template.