⌘I

Create leads and contacts in Hubspot using the Formspree CLI

Updated July 14, 2023·
goldplatinumpluginshubspotformspree-cli

Adding the hubspot action in the formspree.json file has the same effect as adding the Hubspot plugin in the Formspree dashboard. See the Hubspot plugin help article to know about leadStatus, lifeCycleStage and for more information.

Creating Private App

Hubspot deprecated the account API Key. For now, you should create a Private App instead and select specific scopes for the access token. Form more informations check here.

  • In your HubSpot account, click the settings icon in the main navigation bar.
  • In the left sidebar menu, navigate to Integrations>Private Apps.
  • Click Create private app.
  • Configure your app details
  • Click on the scopes tab and check
    • crm.objects.contacts.read (CRM->Contacts->Read)
    • crm.objects.contacts.write (CRM->Contacts->Read)
    • crm.objects.companies.read (CRM->Companies->Read)
    • crm.objects.companies.write (CRM->Companies->Write)
  • In the dialog box, review the info about your app’s access token, then click Continue creating.

To start making API calls, navigate to the details page of your app.

On the Access token card, click Show token to reveal your access token. Click Copy to copy the token to your clipboard and paste it in your Fomrpsree CLI deployment file as accessToken attribute.

Formspree.json configuration

Key Type Description
app String Must be hubspot
type String Must be createContact
apiKey String Your API key (must be a $env variable reference, required) (deprecated)
accessToken String Your Private APP access token (must be a $env variable reference, required)
leadStatus String Optional field. Must be one of NEW, OPEN, IN_PROGRESS, OPEN_DEAL, UNQUALIFIED, ATTEMPTED_TO_CONTACT, CONNECTED, or BAD_TIMING. Default is NEW.
lifeCycleStage String Optional field. Must be one of subscriber, lead, marketingqualifiedlead, salesqualifiedlead, opportunity, customer, or other. Default is empty.
overwriteContact Boolean Optional field. If true, overwrite contact information if the contact email already exists in Hubspot. Default is false

Example

{
  "forms": {
    "registrationForm": {
      "name": "Registration Form",
      "actions": [
        {
          "app": "hubspot",
          "type": "createContact",
          "accessToken": "$accessToken",
          "leadStatus": "NEW",
          "lifeCycleStage": "lead",
          "overwriteContact": true
        }
      ]
    }
  }
}

Validation rules

The create support ticket action adds the following validation rules implicitly:

Field Validation Rule
email Required
email Type is email

Still have questions? or .