Fill PDF form by Mapping Filling Method
If you want to use only the Mapping Filling method (without any Dynamic input), this approach is ideal for structured data like Excel sheets, CSV exports, or simple datasets—perfect for things like tickets, receipts, or registration forms.
In this tutorial, we’ll walk through 3 simple steps:
Get an API key
Upload a Form
Get the Mapping Schema and sample input json
Call the Fill API with Mapping Data
Retrieve the Filled PDF Form
Let’s get started!
Step 1: Get an API Key API Key
Before using any of the steps below, make sure to:
Register a new account on the TakeForm platform.
Receive $5 in free credits instantly—enough to start testing right away.
Generate your API key to begin integrating with our API.
Once you have your API key, you're ready to move on to the next section.
Step 2: Upload the form
Now, you need a form to work with. You have two options:
Choose an existing form from your Form Library
Upload your own form by following the instructions in the section below (Video guide included)
Step 3: Get the Mapping Schema and sample input json
To get the Mapping Schema and sample json input. You can follow this Mapping Schema (Mapping Filling Method) to get it.
In this example, we’ll use the W-9 tax form from the United States, available on TakeForm here: W-9 Form Link - Mapping Schema Example
Step 4: Fill via API
Full example code here: https://github.com/cptrodgers/takeform-examples/blob/master/fill-form-example/mapping-filling-method.py
The following example demonstrates how to call the TakeForm API to fill the W-9 form using mapping data only.
# Get API Key in https://platform.takeform.app/developer
TAKE_FORM_API_KEY="YOUR_API_KEY"
# This is W-9 Form. You can view here https://platform.takeform.app/forms/854d35dc-c401-4079-aadc-63c309a052e8
FORM_ID="854d35dc-c401-4079-aadc-63c309a052e8"
def fill_form():
url = f"https://api.takeform.app/developer/v1/forms/{FORM_ID}/fill"
headers = {
'X-API-Key': TAKE_FORM_API_KEY,
'Content-Type': 'application/json; charset=utf-8',
}
response = requests.post(
url,
headers=headers,
json={
"mapping": mapping_data,
},
)
print("Fill succesfully: Filled Form Object", response.json())
# Expected Output: Fill succesfully: Filled Form Object {'created_at': 1744736364, 'file_id': '4a1609c5-7113-4f11-b22d-af70d40f9bed', 'filled_via': 'Api', 'form_id': '854d35dc-c401-4079-aadc-63c309a052e8', 'id': 'e31c24cc-6883-4e52-ab9b-474601d89543', 'name': 'w-9.pdf', 'status': 'Filling', 'updated_at': 1744736363, 'user_id': 'df0bebb1-c460-4263-a654-6d9f5dda7428'}
return response.json()["id"]
Step 5: Retrieve the filled form
Once you've received the filled_form_id
from the API response, you can download the form using the provided download_url
.
def download_form(filled_form_id: str):
url = f"https://api.takeform.app/developer/v1/filled-forms/{filled_form_id}/download-url"
headers = {
'X-API-Key': TAKE_FORM_API_KEY,
'Content-Type': 'application/json; charset=utf-8',
}
response = requests.get(
url,
headers=headers,
)
print("Filled Form", response.json())
# Output: Filled Form https://storage.googleapis.com/takeform/8da53c8c-5334-4ebb-8074-a1c6cd79d1ca?...
Now, you can download the filled form by open the link response.json()
Last updated