Automatic Field Detection
DocSpring can set up a PDF template’s fields for you. It finds the fields on each page, or imports the fields embedded in the PDF, and uses AI to name them and choose their types and settings. It can also read the whole form and set up conditional logic, required fields and formulas.
You can review and edit everything in the template editor before you publish the template.
When you upload a PDF
Section titled “When you upload a PDF”When you create a PDF template in the DocSpring web app, the Automatically detect fields checkbox is enabled by default.
If the checkbox is enabled:
- Fillable PDFs (with embedded form fields): DocSpring imports the form fields and uses AI to give them clearer names and the right data types. It also adds fields the PDF’s form leaves out, such as a signature line that’s only printed on the page.
- Flat PDFs (without embedded form fields): DocSpring finds the fields in the page layout and uses AI to name them.
Along with names and types, the AI sets each field’s title, description, whether it’s required, decimal places, and read-only fields. It recognizes repeated rows as arrays and groups of checkboxes where several can be checked. Segmented fields, such as SSN boxes, are set up as comb fields.
If the checkbox is disabled, DocSpring imports a fillable PDF’s form fields without AI, converting their names to DocSpring’s format (lowercase snake_case, with a / for each ., so form1.name becomes form1/name). It doesn’t detect fields on a flat PDF.
AI leaves out the fields that only the office, agency or court receiving the form fills in, such as a “For office use only” box, a received stamp, or its reviewer’s decision and signature. The people who fill in your form never see them. To keep them, for example when your own system fills in the office’s part, enable Include office-use fields. Fields for the person the form is about, their lawyer, preparer or interpreter, and the form’s other signers are never left out.
The Set up conditional logic with AI checkbox runs one more step after the fields are named. The AI reads the whole form and adds conditional logic (fields that only apply in some situations, such as “if married”), required fields and formulas. The editor shows a summary of what it added, and you can see and change every rule with the Logic button in the editor header. See Conditional Logic.
While a page is set up, the editor shows “Detecting fields…” or “Naming fields…” on it. Each page can take up to a minute. To stop and add the fields yourself, click Skip and set up fields myself. AI stops naming fields and doesn’t set up conditional logic: fillable pages keep the PDF’s own form fields, and the other pages get the fields that were detected, with plain names. A page that’s still being detected gets its fields when detection finishes.
Set Up Fields
Section titled “Set Up Fields”To set up the fields of an existing template, open Settings in the template editor and click Set Up Fields under Fields.
- Field source:
- Import PDF form fields imports the form fields embedded in the PDF.
- Detect fields from PDF finds the fields in the page layout.
- Use current fields keeps the template’s fields where they are and only names and sets them up. It’s selected when the template already has fields.
- Name fields:
- Rename fields with AI gives the fields names and types. With Use current fields, it only replaces generic names such as “Text1” and keeps descriptive ones.
- Preserve form field names keeps the PDF’s own field names (when you import PDF form fields).
- Keep field names and settings (with Use current fields) only sets up conditional logic.
- Field name language, shown with Rename fields with AI, chooses the language of the names AI gives the fields. It starts with the template’s language, and your choice is saved on the template.
- Existing fields, shown when the template already has fields and you import or detect new ones:
- Keep adds the new fields and keeps the existing ones.
- Replace deletes the existing fields first.
- Options:
- Set up conditional logic with AI: set up conditional logic and required fields with AI.
- Include office-use fields, shown with Rename fields with AI when you import or detect fields: keep the fields that only the office receiving the form fills in. Without it, AI leaves them out (see When you upload a PDF).
- Review changes before applying: instead of changing the template, DocSpring lists each suggested change: fields to add, remove or rename, field settings and conditional logic. Select the changes you want and apply them, or discard them all. Nothing changes until you apply them, and you can undo the changes until you leave the editor.
Clear fields, under Fields, deletes all of the template’s fields.
Set Up Fields isn’t available in the embedded template editor.
Settings
Section titled “Settings”Your account’s Template defaults page, in the left sidebar, sets the defaults for field setup.
-
AI Field Name Language: the language of the field names, which become the keys in your API data.
- Automatic (the default) uses the form’s own language when it’s written in the Latin alphabet, without accents, and English for other scripts.
- Always English.
- Same language as the form, including non-Latin scripts.
New templates start with this language. To change it for templates you already have, use Update Templates at the bottom of the page, or choose a Field name language in a template’s Set Up Fields.
-
AI Conditional Logic: whether to set up conditional logic and required fields with AI.
-
Include office-use fields: whether AI keeps the fields that only the office receiving the form fills in. It’s off by default.
-
Review AI changes to existing fields before applying them: whether Review changes before applying starts enabled in Set Up Fields when a template already has fields.
Things to know
Section titled “Things to know”- Replacing a PDF never detects fields again. It keeps the template’s fields, or replaces them with the new PDF’s fillable fields if you choose to re-import them. Use Set Up Fields after replacing the PDF if you want AI to set up the fields.
- Publishing a new version waits until the pages are processed and AI has finished setting up the fields.
- Cost: each plan includes free AI pages every month (5 on Developer, 50 on Starter, 250 on Growth and 500 on Scale). After that, each page AI sets up costs $0.25, paid from your credits (see AI field setup). Free accounts share a daily allowance of free AI pages, so on a busy day they may need to wait until the next day (UTC). Detecting fields without AI names is free, and so is applying changes you’ve reviewed. If your account can’t pay for every page of a run, the run doesn’t start: new uploads still get their fields, but without AI names or conditional logic.
- Limits: AI field setup can run 5 times an hour on each template.
- AI processing: DocSpring sends the page images and the detected fields to Anthropic’s Claude models on Amazon Bedrock, in the same geography as your account’s data (US or EU).
For templates created with the API, field detection is disabled by default, so DocSpring doesn’t create fields when your integration adds them separately.
Set detect_fields to true when you create a PDF template (with POST /templates or POST /templates/upload) to set up its fields. These options choose how, like the choices in Set Up Fields:
field_source: where the fields come from.auto(the default) imports a fillable PDF’s form fields, and detects the fields of a PDF without them.pdf_detectiondetects the fields from the page layout, even on a fillable PDF.pdf_form_fieldsonly imports the PDF’s form fields.field_naming:ai(the default) names the fields with AI and sets their types and settings.preservekeeps the names of the PDF’s form fields, and only detected fields get AI names.preserveneedsfield_sourceautoorpdf_form_fields.field_logic:aisets up conditional logic and required fields with AI once the fields are named, andnoneskips it. It defaults to your account’s AI Conditional Logic setting.include_office_use_fields:truekeeps the fields that only the office receiving the form fills in, such as a “For office use only” box, andfalseleaves them out. It defaults to your account’s Include office-use fields setting, which is off. It applies only withfield_namingai:preservekeeps every field.ai_field_naming_language(auto,englishorform_language): the language of the field names. It defaults to your account’s AI Field Name Language setting, and is saved on the template, where you can change it later.
field_source, field_naming, field_logic and include_office_use_fields only apply with detect_fields set to true; sending one without it returns an error.
{ "template_type": "pdf", "name": "W-9", "cache_id": "cache/...", "detect_fields": true, "field_logic": "none", "ai_field_naming_language": "english"}To import a fillable PDF’s form fields with their own names and no AI, send "field_source": "pdf_form_fields", "field_naming": "preserve" and "field_logic": "none". This doesn’t use any AI pages.
Field setup runs after the template is created. A new PDF for an existing template keeps the template’s fields: run Set Up Fields in the editor to set them up again. To know when field setup is done, either:
- listen for the
template.updatedwebhook, which DocSpring sends when the fields are ready, or - poll the template (
GET /templates/{template_id}) untildocument.stateisprocessed, which means every page’s fields are done, and then until the AI logic pass has finished. Each item ofdocument.page_processing_statusesdescribes a page: itsfieldsstatus ends asprocessed,failedordisabled, andai_namingandai_errorsay when AI didn’t name its fields. After the last page,document.field_logic_statusispendingorprocessingwhile AI sets up conditional logic, which can still rename fields and add rules, and thenprocessed,failedorskipped. It’snullwhen there’s no logic pass.
Editing detected fields
Section titled “Editing detected fields”Detected fields are normal DocSpring template fields. You can move, resize, rename, delete and reconfigure them in the visual editor.
For fields that split one value across several boxes, such as an SSN, see the comb field guide: