Hi everyone,
I’m trying to automatically create an invoice from a deal’s line items when the deal is moved to Closed Won, using a Deal-based workflow with a Custom Code (Node.js) action.
What I’m trying to achieve
-
Trigger: Deal moves to Closed Won
-
Action: Create an invoice
-
Copy the deal’s line items onto the invoice
-
Use HubSpot’s CRM APIs inside a workflow custom code action
What I followed
I followed this YouTube tutorial step by step:
https://www.youtube.com/watch?v=uG5mT2kiRqgThe video references this GitHub Gist for the code:
Generate an invoice with HubSpot's APIs · GitHubI implemented everything exactly as shown in the video.
My setup
-
Deal-based workflow
-
Trigger: Deal stage = Closed Won
-
Custom code action (Node.js)
-
Private App access token stored as a Secret
-
hs_object_id (Deal ID) added under Properties to include in code
-
Token is read via process.env.Token
What happens
-
The custom code action executes successfully
-
Workflow shows Status: Success
-
However, the logs show this error:
2026-01-16T20:51:06.410Z ERROR Invalid request ` ` There’s no additional detail returned in the log about which request is invalid. --- ### My question Has anyone:-
Successfully used this exact approach recently?
-
Run into “Invalid request” errors when creating invoices via custom code?
-
Noticed changes or limitations with the Invoices object or required properties?
Any guidance on:-
Required invoice properties
-
Account limitations for invoices
-
Or debugging this “Invalid request” error inside workflows
would be greatly appreciated. Thanks in advance!
-
-
-
-
