Skip to main content
POST
Fill form fields with new data

Overview

Fill a PDF form from natural-language instructions. Returns a FormResult synchronously by default (with a pdf_url you can GET to download the filled PDF). Set async: true to run in the background and poll GET /jobjobId for the result.
/form/fill writes values into the fields of a PDF form based on a natural-language instructions prompt. It works on both PDFs with native form fields (where the values are written directly into the form) and on flat or scanned PDFs (where the values are placed into the detected fields).

Providing the PDF

Provide the PDF in exactly one of the following ways:
  • form_id: chain off a prior /form/detect, /form/fill, or /form/clear call. The cached PDF and form_fields are reused, so there is no need to re-upload.
  • file_url: public or presigned URL to a PDF.
  • file: PDF uploaded inline with the request.
Sending more than one (or none) returns 400.
All three input modes ride on the same multipart/form-data request body — that’s how the SDKs send every call. JSON bodies (Content-Type: application/json) with form_id or file_url are still accepted server-side for backward compatibility, but the SDKs only model the multipart form.

Pricing

Billed at 3 credits per page of the PDF being filled. Every response also returns a top-level credits_used for this request and a cumulative plan_info.total_credits_used snapshot for your organization.

Request

Request Body


Response

Sync (200): FormResult

When async is false (default), the call returns a FormResult body directly.
All cell coordinates (bounding_box, checkbox_details[].center_coord) are normalized to [0, 1] with a top-left origin. Multiply by your render width / height to convert to pixel coordinates.

Async (202): FormJobAccepted

When async is true:
Poll GET /job/jobId. The job’s result carries the same FormResult shape that the sync flow would have returned inline.

Status Codes


Example Usage

Fill From URL

File Upload

Detect First, Then Fill

Run /form/detect to inspect the detected cells, optionally edit them, then chain a fill that reuses the same form_id. There is no need to re-upload the PDF.

Async Fill With Polling

Use async: true for long-running jobs (large PDFs, multi-page fills) so the client does not have to keep a connection open.

Download The Filled PDF

The pdf_url returned in FormResult points at GET /results/{job_id}/pdf and requires authentication (API key or JWT).

Authorizations

x-api-key
string
header
required

Body

multipart/form-data

/form/fill request body. All three input modes (file, file_url, form_id) ride on this single multipart/form-data schema; the server validates that exactly one is provided.

instructions
string
required

Required natural-language fill prompt.

file
file

Direct binary upload of the PDF. Mutually exclusive with file_url and form_id.

file_url
string<uri>

Public or pre-signed URL of a PDF Pulse will download. Mutually exclusive with file and form_id.

form_id
string<uuid>

Reference to a previously processed form. Mutually exclusive with file / file_url.

form_fields
string

Optional JSON-encoded array of FormCell objects to override detected cells. Multipart bodies must serialise this field as a string.

page_range
string

Restrict the operation to a subset of pages, e.g. "1-3,5".

async
string

Set to "true" to run asynchronously and receive {job_id, status} immediately.

Response

Filled FormResult returned synchronously.

Result body returned by /form/detect, /form/fill, and /form/clear. For async jobs (async: true) the same shape is served back under result on GET /job/{jobId} [blocked].

form_id
string<uuid>

ID of the form record produced by this run. Pass to a subsequent /form/detect, /form/fill, or /form/clear call as the single input source to iterate without re-uploading the PDF.

page_count
integer

Number of pages in the output PDF.

Required range: x >= 1
pdf_url
string

URL to download the resulting PDF binary. Always points at GET /results/{jobId}/pdf [blocked] for the originating job. Authenticated callers can replay this URL until the underlying artifact is garbage-collected.

form_fields
object[]

Detected cells of the resulting PDF (refreshed from the filled/cleared output for fill/clear, or freshly detected for /form/detect). Use these as a starting point for further edits.

fields_filled
integer

Number of cells that were filled by this run. Present on /form/fill responses only.

Required range: x >= 0
fields_cleared
integer

Number of cells that were cleared by this run. Present on /form/clear responses only.

Required range: x >= 0
credits_used
number<float>

Number of credits consumed by this request. Detect charges 1 credit per page; fill and clear charge 3 credits per page.

plan_info
object

Billing tier and cumulative usage information for the calling org, including this form run.