How to Fill out PDF Form 1040 using PDF.co Web API with cURL

This instructional article will take you through the step-by-step process of filling out PDF Form 1040 using PDF.co Web API with cURL.

For this example, we will use IRS Form 1040. Official IRS Form 1040 link: https://www.irs.gov/forms-pubs/about-form-1040.

IRS Form 1040

Step 1: Get API Key and Get the List of PDF Form Fields

  • Sign up and get your API key here: https://app.pdf.co/signup
  • Use /pdf/info/fields endpoint to get the list of all fields in this PDF form

Step 2: Copy and Paste this Code and Add Your API Key

curl --location --request GET 'https://api.pdf.co/v1/pdf/info/fields?url=https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-form/f1040.pdf' \
--header 'x-api-key: YOUR_API_KEY_HERE'

It will return all the form fields information like this:

Form Field Information

Step 3: Use pdf/edit/add Endpoint to Fill Form

Now that we have a list of all fields, we can use the /pdf/edit/add endpoint to fill them out.

Step 4: Copy and Paste this Code and Add Your API Key:

curl --location --request POST 'https://api.pdf.co/v1/pdf/edit/add' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_API_KEY_HERE' \
--data-raw '{
"async": false,
"encrypt": false,
"name": "f1040-filled",
"url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-form/f1040.pdf",
"fields": [
{
"fieldName": "topmostSubform[0].Page1[0].FilingStatus[0].c1_01[1]",
"pages": "1",
"text": "True"
},
{
"fieldName": "topmostSubform[0].Page1[0].f1_02[0]",
"pages": "1",
"text": "John A."
},
{
"fieldName": "topmostSubform[0].Page1[0].f1_03[0]",
"pages": "1",
"text": "Doe"
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_04[0]",
"pages": "1",
"text": "123456789"
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_05[0]",
"pages": "1",
"text": "Joan B."
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_05[0]",
"pages": "1",
"text": "Joan B."
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_06[0]",
"pages": "1",
"text": "Doe"
},
{
"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_07[0]",
"pages": "1",
"text": "987654321"
}

],
“annotations”:[
{
“text”:”Sample Filled with PDF.co API using /pdf/edit/add. Get fields from forms using /pdf/info/fields”,
“x”: 10,
“y”: 10,
“size”: 12,
“pages”: “0-“,
“color”: “FFCCCC”,
“link”: “https://pdf.co”
}
],
“images”: [
]
}’

Step 5: See Result

Copy and paste the resulting URL on your browser to see your filled-out PDF form.

Copy and Paste URL

The filled-out IRS PDF Form will look like this:

Filled IRS PDF Form
Filled IRS PDF Form

Note: The output URL expires in 1 hour. You may need to generate a new URL once 1 hour has elapsed.