I’m having trouble with the HubSpot API when trying to create new deals. Every time I send a POST request with deal data, the API creates a deal but all the fields are empty instead of using the values I’m sending.
Your request looks right, but you’re hitting a classic date formatting issue. HubSpot’s API wants Unix timestamps in milliseconds for dates, not ISO strings. Change your close_date to something like ‘closedate’: ‘1623751800000’ instead of that ISO format. I wasted days on this exact problem when we migrated our CRM. Also, double-check that “negotiation” actually exists as a stage ID in your default pipeline. If it doesn’t, HubSpot just ignores the field silently - no error, nothing. Hit the pipelines endpoint first to grab the valid stage IDs, then use those in your deal requests.
Had this exact problem last month - drove me nuts for hours. You’re sending deal properties directly in the request body, but HubSpot wants them wrapped in a specific structure. The v3 API needs all properties nested under a “properties” object. Your deal_data should look like: deal_data = {\"properties\": {\"amount\": \"2500.00\", \"closedate\": \"2021-06-15T10:30:00.000Z\", \"dealname\": \"Website redesign project\"}}. Also check your property names - use "amount" not "deal_amount", "dealname" not "deal_title", and "closedate" not "close_date". The API docs aren’t clear about this, but once you wrap everything properly it works fine.
Quick fix - you’re missing auth in the headers. The hapikey in the URL is deprecated, so switch to a bearer token. Update your headers to {“Authorization”: “Bearer YOUR_TOKEN”, “Content-Type”: “application/json”} and drop the hapikey from the endpoint. Also do what the others said about wrapping it in a properties object.
You’re mixing up property names between different HubSpot API versions. I hit the same problem migrating from v1 to v3. Besides the properties wrapper FlyingStar mentioned, you need HubSpot’s internal property names, not the descriptive ones. “deal_phase” should be “dealstage” with the actual stage ID, not the stage name like “negotiation”. “sales_pipeline” becomes “pipeline” with the pipeline ID. And “owner_id” is actually “hubspot_owner_id”. Hit the properties endpoint first to grab the exact property names and valid values before creating deals. Way easier to debug when you know what the API actually wants.
Check your API token permissions too. I wasted hours debugging this exact issue - deals created but stayed blank because my private app token didn’t have write permissions for the deal properties I was trying to set. Go into your HubSpot developer account and make sure the token has the right scopes. You need crm.objects.deals.write at minimum. Also, use the correct endpoint without the hapikey parameter. The v3 endpoint is https://api.hubapi.com/crm/v3/objects/deals with your bearer token in headers. Sometimes you miss the simple fixes when you’re buried in code.