# API Create Deal Call failing when calling from application.

**URL:** <https://community.hubspot.com/t/api-create-deal-call-failing-when-calling-from-application/18597>\
**Category:** APIs & Integrations\
**Tags:** object\
**Created:** [February 6, 2020, 8:24am UTC](https://community.hubspot.com/t/api-create-deal-call-failing-when-calling-from-application/18597 "2020-02-06T08:24:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![siddharth-cm](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/siddharth-cm/32/58551_2.png) [@siddharth-cm](https://community.hubspot.com/u/siddharth-cm)\
**Post date:** [February 6, 2020, 8:24am UTC](https://community.hubspot.com/t/api-create-deal-call-failing-when-calling-from-application/18597/1 "2020-02-06T08:24:13Z")

</div>

I am calling hubspot api POST [https://api.hubapi.com/deals/v1/deal?hapikey=demo](https://api.hubapi.com/deals/v1/deal?hapikey=demo)

to create a deal from a api client insomnia with following as the body of json

```auto
{
	"properties": [
		{
			"value": "John Doe Test Deal",
			"name": "dealname"
		},
		{
			"value": "1294558",
			"name": "pipeline"
		},
		{
			"value": "2500000",
			"name": "amount"
		},
		{
			"value": "1294560",
			"name": "dealstage"
		}
	]
}

```

but when i do the same with a firebase cloud function to the hubspot api i get an error saying that

`[{"isValid":false,"message":"1294559 is not a valid pipeline stage ID. Valid options are: pipelineId=default : [appointmentscheduled, qualifiedtobuy, presentationscheduled, decisionmakerboughtin, contractsent]","error":"INVALID_OPTION","name":"dealstage"}],"status":"error","message":"Property values were not valid"`

---

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [February 6, 2020, 8:31am UTC](https://community.hubspot.com/t/api-create-deal-call-failing-when-calling-from-application/18597/2 "2020-02-06T08:31:27Z")

</div>

Hi @siddharth-cm,

It looks like the issue lies with the values you are passing in for the `pipeline` and `dealstage` attributes. I would recommend making a GET request to the [CRM pipelines endpoint](https://developers.hubspot.com/docs/methods/pipelines/get_pipelines_for_object_type) to pull down the data for the deal pipeline in that portal. The response will contain the “pipelineId” and the “stageId” values which you can use in your POST request to [create a deal](https://developers.hubspot.com/docs/methods/deals/create_deal). For example when I run:

```auto
GET https://api.hubapi.com/crm-pipelines/v1/pipelines/deals?hapikey={{apikey}}

```

It returns the following payload. Look at the values for “pipelineId” and “stageId”. These should be used in your POST request to [create the deal](https://developers.hubspot.com/docs/methods/deals/create_deal).

```auto
{
 "results": [
 {
 "pipelineId": "default",
 "objectType": "DEAL",
 "label": "Sales Pipeline",
 "active": true,
 "stages": [
 {
 "stageId": "presentationscheduled"
 },
 {
 "stageId": "decisionmakerboughtin"
 },
 {
 "stageId": "appointmentscheduled"
 },
 {
 "stageId": "contractsent"
 },
 {
 "stageId": "qualifiedtobuy"
 },
 {
 "stageId": "closedwon"
 },
 {
 "stageId": "closedlost"
 }
 ],
 "default": true
 }
 ]
}

```

With the data above I can [create a deal](https://developers.hubspot.com/docs/methods/deals/create_deal) using the following endpoint:

`POST https://api.hubapi.com/deals/v1/deal?hapikey={{apikey}}`

```auto
{
	"properties": [
		{
			"value": "John Doe Test Deal",
			"name": "dealname"
		},
		{
			"value": "default",
			"name": "pipeline"
		},
		{
			"value": "2500000",
			"name": "amount"
		},
		{
			"value": "presentationscheduled",
			"name": "dealstage"
		}
	]
}

```

I hope this helps.

Jack

---

<div class="post-metadata">

**Author:** ![siddharth-cm](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/siddharth-cm/32/58551_2.png) [@siddharth-cm](https://community.hubspot.com/u/siddharth-cm)\
**Post date:** [February 6, 2020, 9:49am UTC](https://community.hubspot.com/t/api-create-deal-call-failing-when-calling-from-application/18597/3 "2020-02-06T09:49:23Z")

</div>

Thank you @jackcoldrick ,

Just asking,

In my case I am getting unique numbers as pipeline stage id.Is it a special case or exception in one way or another.

Thanks again.

---

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [February 6, 2020, 9:51am UTC](https://community.hubspot.com/t/api-create-deal-call-failing-when-calling-from-application/18597/4 "2020-02-06T09:51:27Z")

</div>

Hi @siddharth-cm,

If you are using the “default” pipeline included with the portal the deal stages will be returned as string values as shown in my example. However if it’s an additional pipeline you created then it’s expected the “stageId” would be a random string of numbers.

Does this help?

Regards,

Jack

---

<div class="post-metadata">

**Author:** ![siddharth-cm](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/siddharth-cm/32/58551_2.png) [@siddharth-cm](https://community.hubspot.com/u/siddharth-cm)\
**Post date:** [February 27, 2020, 6:05am UTC](https://community.hubspot.com/t/api-create-deal-call-failing-when-calling-from-application/18597/5 "2020-02-27T06:05:56Z")

</div>

Thanks

This was helpful  
 ![16x16_smiley-happy.png.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/2/22d5e40d253def47f5f4ea7f0e3e70be19010689.png)

---

<div class="post-metadata">

**Author:** ![FRichard1rhudd](https://avatars.discourse-cdn.com/v4/letter/f/3bc359/32.png) [@FRichard1rhudd](https://community.hubspot.com/u/FRichard1rhudd)\
**Post date:** [April 8, 2022, 1:43pm UTC](https://community.hubspot.com/t/api-create-deal-call-failing-when-calling-from-application/18597/6 "2022-04-08T13:43:07Z")

</div>

Hi

I am having the same problem. When I try to call the API to create a ticket from the python sample on [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/crm/tickets) with the following code

{  
“hs\_pipeline”: “default”,  
“hs\_pipeline\_stage”: “decisionmakerboughtin”,

“hs\_ticket\_priority”: “HIGH”,  
“hubspot\_owner\_id”: “284345313”,  
“subject”: “troubleshoot report”  
}

I am getting this error

HTTP 400

{  
“status”: “error”,  
“message”: “Property values were not valid: [{\“isValid\”:false,\“message\”:\“decisionmakerboughtin is not a valid pipeline stage ID. Valid options are: pipelineId=0 : [1, 2, 3, 4]\”,\“error\”:\“INVALID\_OPTION\”,\“name\”:\“hs\_pipeline\_stage\”}]”,  
“correlationId”: “1e6fe089-8c07-410c-a168-480a453bdf9c”,  
“category”: “VALIDATION\_ERROR”  
}

I have called [https://api.hubapi.com/crm-pipelines/v1/pipelines/deals?hapikey=xxxxx](https://api.hubapi.com/crm-pipelines/v1/pipelines/deals?hapikey=eu1-4a78-c4a6-4e75-a1ed-7fdf4588c13d)and I am getting this respose which shows that the stage does exist. Another thing is that I have edited that pipeline and on the web it shows what I have enterd but the API returns the original codes
