How to set a file field via the forms API


Thanks to some help on this community I was able to get my regular form fields to set through the v3 API. I'm wondering, though, for one field which is a file field (credit_report), how do I set that? I need to accept a credit report PDF. I'm a lending company doing sales through hubspot and I need to accept a PDF from people whoa re signing up. Do I post the entire file binary data in the request body? Like this..?

"fields": [
{"name": "email", "value": ""},
{"name": "firstname", "value": "Bob"},
{"name": "lastname", "value": "James"},
{"name": "phone", "value": "445233311"},
{"name": "address", "value": "My address"},
{"name": "state", "value": "Delaware"},
{"name": "city", "value": "Warm Springs"},
{"name": "country", "value": "USA"},
{"name": "dob", "value": "02261986"},
{"name": "company", "value": "MyCompany"},
{"name": "credit_report", "value": ""}
"legalConsentOptions": {
"legitimateInterest": {
"value": true,
"subscriptionTypeId": 999,
"legalBasis": "CUSTOMER",
"text": "Legitimate interest consent text"

I have noticed that if I fill out the form through Hubspot's provided form link, the resulting contact in hubspot shows the credit report as a link to a file which has a url like this: That's exactly what I want, except I want it to happen when I fill out the form via the forms API from my Javascript client code. Good news is all the other fields work, I just don't know how to do the file field.

Do I need to use a separate API for this? Such as the Files API. see that there are different APIs that might be relevant but I don't know how to connect them how will the uploaded file get referenced in the contact data set by the forms API?


Hi @calicoderco, File upload properties are text properties, and they’re designed to store the URL of a file that’s uploaded to some storage platform. The property itself cannot store an actual file, so if you’re using an upload property in a custom form, you’d need to upload the file separately, and then store a URL that could be used to access that file in the actual form field being sent to HubSpot. A call to the Files API could work, but it'd need to be done server side as doing so client side would expose your API key.