Example URL to POST to:
https://api.hubapi.com/deals/v1/deal
Example request JSON:
{
"associations": {
"associatedCompanyIds": [
8954037
],
"associatedVids": [
27136
]
},
"properties": [
{
"value": "Tim's Newer Deal",
"name": "dealname"
},
{
"value": "appointmentscheduled",
"name": "dealstage"
},
{
"value": "default",
"name": "pipeline"
},
{
"value": "24",
"name": "hubspot_owner_id"
},
{
"value": 1409443200000,
"name": "closedate"
},
{
"value": "60000",
"name": "amount"
},
{
"value": "newbusiness",
"name": "dealtype"
}
]
}
Returns a 200 on success with the data for
the newly created deal in the response:
{
"portalId": 62515,
"dealId": 151088,
"isDeleted": false,
"associations": {
"associatedVids": [
27136
],
"associatedCompanyIds": [
8954037
],
"associatedDealIds": [
]
},
"properties": {
"amount": {
"value": "60000",
"timestamp": 1410381338943,
"source": "API",
"sourceId": null,
"versions": [
{
"name": "amount",
"value": "60000",
"timestamp": 1410381338943,
"source": "API",
"sourceVid": [
]
}
]
},
"dealstage": {
"value": "appointmentscheduled",
"timestamp": 1410381338943,
"source": "API",
"sourceId": null,
"versions": [
{
"name": "dealstage",
"value": "appointmentscheduled",
"timestamp": 1410381338943,
"source": "API",
"sourceVid": [
]
}
]
},
"pipeline": {
"value": "default",
"timestamp": 1410381338943,
"source": "API",
"sourceId": null,
"versions": [
{
"name": "pipeline",
"value": "default",
"timestamp": 1410381338943,
"source": "API",
"sourceVid": [
]
}
]
},
"closedate": {
"value": "1409443200000",
"timestamp": 1410381338943,
"source": "API",
"sourceId": null,
"versions": [
{
"name": "closedate",
"value": "1409443200000",
"timestamp": 1410381338943,
"source": "API",
"sourceVid": [
]
}
]
},
"createdate": {
"value": "1410381339020",
"timestamp": 1410381339020,
"source": null,
"sourceId": null,
"versions": [
{
"name": "createdate",
"value": "1410381339020",
"timestamp": 1410381339020,
"sourceVid": [
]
}
]
},
"hubspot_owner_id": {
"value": "24",
"timestamp": 1410381338943,
"source": "API",
"sourceId": null,
"versions": [
{
"name": "hubspot_owner_id",
"value": "24",
"timestamp": 1410381338943,
"source": "API",
"sourceVid": [
]
}
]
},
"hs_createdate": {
"value": "1410381339020",
"timestamp": 1410381339020,
"source": null,
"sourceId": null,
"versions": [
{
"name": "hs_createdate",
"value": "1410381339020",
"timestamp": 1410381339020,
"sourceVid": [
]
}
]
},
"dealtype": {
"value": "newbusiness",
"timestamp": 1410381338943,
"source": "API",
"sourceId": null,
"versions": [
{
"name": "dealtype",
"value": "newbusiness",
"timestamp": 1410381338943,
"source": "API",
"sourceVid": [
]
}
]
},
"dealname": {
"value": "A new Deal",
"timestamp": 1410381338943,
"source": "API",
"sourceId": null,
"versions": [
{
"name": "dealname",
"value": "A new Deal",
"timestamp": 1410381338943,
"source": "API",
"sourceVid": [
]
}
]
}
}
}
If there are any issues with the association, you
will still create a deal, and still get a 200 response,
but the response will include an additional 'associationCreateFailures` field
with details about the associations.
"associationCreateFailures": [
{
"association": {
"fromObjectId": 1,
"associationType": "COMPANY_TO_DEAL",
"toObjectId": 5464192,
"timestamp": 1508187481409
},
"failReason": "INVALID_OBJECT_IDS",
"message": "COMPANY=1 is not valid"
}
],
import requests
import json
url= 'https://api.hubapi.com/deals/v1/deal?hapikey=demo'
headers={}
headers["Content-Type"]="application/json"
data = json.dumps({
"associations": {
"associatedCompanyIds": [
8954037
],
"associatedVids": [
27136
]
},
"properties": [
{
"value": "Tim's Newer Deal",
"name": "dealname"
},
{
"value": "appointmentscheduled",
"name": "dealstage"
},
{
"value": "default",
"name": "pipeline"
},
{
"value": "24",
"name": "hubspot_owner_id"
},
{
"value": 1409443200000,
"name": "closedate"
},
{
"value": "60000",
"name": "amount"
},
{
"value": "newbusiness",
"name": "dealtype"
}
]
})
r=requests.post(url, headers = headers, data = data)
print(r.status_code)
var request = require("request");
var options = { method: 'POST',
url: 'https://api.hubapi.com/deals/v1/deal',
qs: { hapikey: 'demo' },
headers:
{ 'Content-Type': 'application/json' },
body:
{ associations: { associatedCompanyIds: [ 8954037 ], associatedVids: [ 27136 ] },
properties:
[ { value: 'Tim\'s Newer Deal', name: 'dealname' },
{ value: 'appointmentscheduled', name: 'dealstage' },
{ value: 'default', name: 'pipeline' },
{ value: '24', name: 'hubspot_owner_id' },
{ value: 1409443200000, name: 'closedate' },
{ value: '60000', name: 'amount' },
{ value: 'newbusiness', name: 'dealtype' } ] },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});