Articles on: Advanced Features

Auto-fill using API

How to Auto Fill Forms with External Data



Pre-filling form fields using APIs can save time, reduce errors, and streamline workflows for both form creators and respondents. With Formester, you can pull data from external sources like Google Sheets, Airtable, Notion, or your CRM, and fill your form fields automatically.


Available on: Business plan or higher.


Why Use API-Powered Pre-Fill


This feature is ideal when you want to:


  • Auto-fill employee information in HR forms based on employee ID.
  • Populate client details in onboarding or project request forms.
  • Sync data between multiple databases, reducing manual entry and errors.
  • Automate workflows by pre-filling forms and sending follow-ups based on existing data.


For example, if a respondent enters their employee ID, the form can automatically fill in their name, email, and department, saving them the effort of typing out details and reducing the risk of mistakes.


How to Set Up API-Powered Pre-Fill


  1. Open your form: Open the form in the builder and click the Settings (gear) icon at the top right.
  2. Open Prefill: In Settings, select Prefill, then Auto-fill via API. If the form already has an API prefill, click Create new.



    Settings with Prefill selected and Auto-fill via API highlighted


  1. Name it and choose a template: Enter a Prefill name. Under Choose API Template, pick Google Sheets, Airtable, Notion, HubSpot CRM, or Custom to write your own code.
  2. Store API keys safely: Click Manage variables and, on the Environment variables tab, click Add Environment Variable for each API key or secret. Read it in your code with process.env.YOUR_KEY_NAME. For Google Sheets, you can generate an API key in the Google Cloud Console.
  3. Use a respondent's answer in your code: Still in Manage variables, open the Form field variables tab. Click the copy icon next to the field you want to use, such as Employee ID. This copies the field's ID in double curly braces, for example {{143d9b71-c020-468e-9af4-a2c6b1d50137}}.



    Form field variables tab with the copy icon next to Employee ID highlighted


  1. Add a test value: In the same row, type a value under Default Value (used for testing), such as a real employee ID, and click Save. This value is only used when you click Test.
  2. Paste the field ID into your code: Paste what you copied wherever you need the respondent's answer. Formester replaces it with the value the respondent entered before your code runs. For example:


    const employeeId = {{143d9b71-c020-468e-9af4-a2c6b1d50137}};
    const res = await fetch(`https://api.example.com/employees/${employeeId}`);
    return await res.json();



    Your code must return the data as JSON.


  1. Test it: Click Test. The Response panel shows what your code returned. Save stays disabled until a test succeeds. The values you can pick in step 11 come from this response, so make sure it shows the record you expect before you save.



    API prefill form with the field ID highlighted in the code and the test response on the right


  1. Set the API trigger: Under Set the API Trigger, decide when the code runs:
    • On Page Load: runs as soon as the form opens.
    • On Field Change: runs when the respondent fills in a field you choose under Select Fields. Use this when your code needs an answer from the respondent, like the employee ID above. Pick at least one field, or the code never runs.
    • After Form Submit: runs once the respondent submits the form, for example to send the answers to another system.
  2. Click Save.
  3. Fill your fields with the API data: Close Settings and select a field you want filled. On its Advanced tab, set Default value to Variable Value. Then open Variable Default Value, go to Dynamic Data, choose your prefill, and pick the value to use, such as name.


Field settings with Default value set to Variable Value and Employee lookup.name selected


  1. Repeat for each field you want filled, then click Publish.


Testing the API Pre-Fill


Open your published form and enter a sample search value, like an employee ID. The fields you linked fill in with the details from your database, and respondents only need to complete the rest before submitting.


Benefits of Auto-Filled Forms


  • Saves Time: Reduces repetitive data entry for respondents.
  • Reduces Errors: Minimizes mistakes in names, emails, or other critical information.
  • Supports Complex Workflows: Can integrate multiple databases and pre-fill fields dynamically based on input.
  • Enhances Professionalism: Creates a smoother, automated experience for clients, employees, and other respondents.


Frequently asked questions


Why do I get "values is not defined"?
Formester doesn't provide a values object. To use a respondent's answer, copy the field's ID from Manage variables > Form field variables and paste it into your code, as in steps 5–7.


Can I type the field's label instead of its ID?
No. Only the copied ID works. With a label inside the braces, your code gets no value.


Why is the Save button disabled?
Enter a Prefill name, add your code, and click Test. Save turns on once a test succeeds.


Why does Test return nothing for my field, or the wrong data?
Test values aren't kept when you close and reopen a prefill. Open Manage variables > Form field variables, enter the test value again, click Save, then click Test.


Why don't my fields fill in on the live form?
Check that each field's Variable Default Value points to the prefill you just saved, and that the last Test before you saved returned a single record rather than a list. Then click Publish again.

Updated on: 16/11/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!