# API - Creating a New Deal

**URL:** <https://community.hubspot.com/t/api-creating-a-new-deal/51613>\
**Category:** APIs & Integrations\
**Tags:** python, object, contacts\
**Created:** [February 16, 2022, 1:46am UTC](https://community.hubspot.com/t/api-creating-a-new-deal/51613 "2022-02-16T01:46:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SM6](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sm6/32/48165_2.png) [@SM6](https://community.hubspot.com/u/SM6)\
**Post date:** [February 16, 2022, 1:46am UTC](https://community.hubspot.com/t/api-creating-a-new-deal/51613/1 "2022-02-16T01:46:08Z")

</div>

Hello,

I am trying to use the HubSpot API to create a new deal associated with an existing contact and with a specified dealname, dealstage, and amount.

This is the code that I am using:

```lia-code-sample
HAPI_KEY = 'XXXXXXXXXX'
client = hubspot.Client.create(api_key = HAPI_KEY)

hs_owner_id = 'XXXXXXXXXX'
properties = {
 "amount": 'XXXX',
 "dealname": 'XXXX',
 "dealstage": 'XXXX',
 "hubspot_owner_id": hs_owner_id,
 "pipeline": "default"
}

simple_public_object_input = SimplePublicObjectInput(properties=properties)
try:
 api_response = client.crm.deals.basic_api.create(simple_public_object_input=simple_public_object_input)
 pprint(api_response)
except ApiException as e:
 print("Exception when calling basic_api->create: %s\n" % e)

```

This is what is printed out:

```lia-code-sample
Exception when calling basic_api->create: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict(...)
HTTP response body: {"status":"error","message":"Property values were not valid: [{\"isValid\":false,\"message\":\"XXXXXX was not a valid owner ID\",\"error\":\"INVALID_OWNER_ID\",\"name\":\"hubspot_owner_id\"}]","correlationId":"XXXXXXX","category":"VALIDATION_ERROR"}

```

However, I have checked, using both HubSpot’s website and the API, that the contact does in fact exist and that the contact ID is valid. Does anyone know why this is happening and how a new deal should be created? Thank you in advance!

---

<div class="post-metadata">

**Author:** ![tominal](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tominal/32/73018_2.png) [@tominal](https://community.hubspot.com/u/tominal)\
**Post date:** [February 16, 2022, 2:51am UTC](https://community.hubspot.com/t/api-creating-a-new-deal/51613/2 "2022-02-16T02:51:02Z")

</div>

You may be confusing the HubSpot Owner IDs with Contact IDs. Owner IDs are the users that can log in to your HubSpot portal and can be found using the Owners API. [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/crm/owners)  
I hope this helps!
