Lightyear LogoLightyear Docs

Step 7 - Run and verify

Time to test our integration! Let's run the script and create a company in HubSpot.

Make the script executable

First, make your script executable:

chmod +x create-hubspot-company.js

Set your API key

You'll need your Lightyear API key. You can find this in your account settings in the Lightyear dashboard.

Set it as an environment variable:

export LIGHTYEAR_API_KEY="your-api-key-here"

Tip: You can also create a .env file to store your API key, but make sure to add it to .gitignore!

Run the script

Now run the script:

./create-hubspot-company.js

You should see output like this:

🚀 HubSpot Company Creator via Lightyear

Getting HubSpot access token...
✅ Access token retrieved

Enter company name: Acme Corporation

Creating company "Acme Corporation" in HubSpot...

✅ Company created successfully!
Company ID: 12345678
Company Name: Acme Corporation
Domain: acme-corporation.com

Verify in HubSpot

Let's confirm the company was created:

  1. Log into your HubSpot account
  2. Navigate to Contacts → Companies
  3. You should see your newly created company!

The company will have:

  • The name you entered
  • An auto-generated domain based on the company name
  • A creation timestamp
  • Default HubSpot properties

Troubleshooting

If you encounter errors:

"Please set LIGHTYEAR_API_KEY environment variable"

  • Make sure you've exported your API key
  • Check that the key is valid

"Request failed: 401 - Unauthorized"

  • Your Lightyear API key might be incorrect
  • The managed user might not exist

"Request failed: 404 - Not Found"

  • The managed user ID might be wrong
  • The integration might not be added to the user

"Error creating company"

  • The HubSpot access token might be invalid
  • You might not have authorized the integration yet
  • Check HubSpot API limits

Success!

Congratulations! You've successfully:

  • Created a managed user in Lightyear
  • Connected a HubSpot integration
  • Built a script that uses Lightyear's API
  • Created data in HubSpot through your integration

What's next?

Let's explore how to make this production-ready and what else you can build.

On this page