HubSpot Deal Creation API Returns Empty Object

I’m having trouble with the HubSpot CRM API when trying to create new deals. Even though I’m sending all the required data in my POST request, the API keeps creating completely empty deals with no properties set.

Here’s my current implementation:

import json
import requests

api_token = "YOUR_API_TOKEN"
endpoint = 'https://api.hubapi.com/crm/v3/objects/deals?hapikey={}'.format(api_token)

request_headers = {"Content-Type": "application/json"}
deal_data = {
    'deal_amount': "2500.00",
    'close_date': '2021-06-15T10:30:00.000Z',
    'deal_title': 'Website redesign project',
    'stage': 'negotiation',
    'owner_id': "1234567890",
    'deal_pipeline': 'sales'
}

api_response = requests.post(endpoint, headers=request_headers, data=json.dumps(deal_data))
print(api_response.text)

The API call executes successfully and returns a 200 status code, but when I check the created deal in HubSpot, all the fields are blank. What could be causing this issue with the data not being properly saved?

Your data structure’s wrong. HubSpot’s CRM API needs deal properties nested under a ‘properties’ key - you can’t just pass them as a flat object. I hit this same issue when I started with their API last year. Here’s how your deal_data should look:

deal_data = {
    'properties': {
        'amount': "2500.00",
        'closedate': '2021-06-15T10:30:00.000Z',
        'dealname': 'Website redesign project',
        'dealstage': 'negotiation',
        'hubspot_owner_id': "1234567890",
        'pipeline': 'sales'
    }
}

I also fixed the property names - HubSpot uses specific internal names like ‘dealname’ not ‘deal_title’ and ‘amount’ not ‘deal_amount’. Check your HubSpot property settings to get the exact internal names for any custom properties.