Deals
Associate a customer to a deal
Associate a customer to a deal.
You can either:
- associate an existing customer to an existing deal, by
customerId - create a new customer and associate with an existing deal, using
customerfield
Specify either the customerId field or the customer field.
Here is an example when you associate an existing customer by ID:
{
"customerId": 42
}
Here is an example when you create a new customer. The properties field contains the list of custom properties defined on Customers.
{
"customer": {
"properties": {
"name": "John Doe",
"email": "john.doe@customer.com",
"...": "..."
},
"partnerId": 42,
"source": "Deal"
}
}
POST
/
v3
/
deals
/
{id}
/
associate
/
customer
Associate a customer to a deal
curl --request POST \
--url https://api.example.com/v3/deals/{id}/associate/customer \
--header 'Content-Type: application/json-patch+json' \
--data '
{
"customerId": 123,
"customer": {
"properties": {},
"partnerId": 123
}
}
'import requests
url = "https://api.example.com/v3/deals/{id}/associate/customer"
payload = {
"customerId": 123,
"customer": {
"properties": {},
"partnerId": 123
}
}
headers = {"Content-Type": "application/json-patch+json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json-patch+json'},
body: JSON.stringify({customerId: 123, customer: {properties: {}, partnerId: 123}})
};
fetch('https://api.example.com/v3/deals/{id}/associate/customer', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v3/deals/{id}/associate/customer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => 123,
'customer' => [
'properties' => [
],
'partnerId' => 123
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json-patch+json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v3/deals/{id}/associate/customer"
payload := strings.NewReader("{\n \"customerId\": 123,\n \"customer\": {\n \"properties\": {},\n \"partnerId\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json-patch+json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v3/deals/{id}/associate/customer")
.header("Content-Type", "application/json-patch+json")
.body("{\n \"customerId\": 123,\n \"customer\": {\n \"properties\": {},\n \"partnerId\": 123\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v3/deals/{id}/associate/customer")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n \"customerId\": 123,\n \"customer\": {\n \"properties\": {},\n \"partnerId\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"contactId": 123,
"sourcePartnerId": 123,
"stage": "<string>",
"creationDate": "2023-11-07T05:31:56Z",
"totalAmount": 123,
"properties": {},
"sourceLeadId": 123,
"status": "Unknown",
"partners": [
{
"id": 123,
"dealId": 123,
"userPartnerOwnerId": 123,
"userPartnerOwnerName": "<string>",
"userPartnerFirstName": "<string>",
"userPartnerLastName": "<string>",
"userPartnerEmail": "<string>",
"userPartnerJobTitle": "<string>",
"userPartnerPhoneNumber": "<string>",
"userPartnerLinkedInProfileUrl": "<string>",
"partnerId": 123,
"partnerTypeId": 123,
"creationDate": "2023-11-07T05:31:56Z",
"partnerName": "<string>",
"partnerTypeName": "<string>"
}
],
"contractStartDate": "2023-11-07T05:31:56Z",
"contractEndDate": "2023-11-07T05:31:56Z",
"ownerUserId": 123,
"owner": {
"id": 123,
"email": "<string>",
"firstName": "<string>",
"lastName": "<string>"
},
"closeDate": "2023-11-07T05:31:56Z",
"customerId": 123,
"currency": "<string>"
}Body
application/json-patch+jsonapplication/jsontext/jsonapplication/*+json
Response
Customer associated to deal
Associate a customer to a deal
curl --request POST \
--url https://api.example.com/v3/deals/{id}/associate/customer \
--header 'Content-Type: application/json-patch+json' \
--data '
{
"customerId": 123,
"customer": {
"properties": {},
"partnerId": 123
}
}
'import requests
url = "https://api.example.com/v3/deals/{id}/associate/customer"
payload = {
"customerId": 123,
"customer": {
"properties": {},
"partnerId": 123
}
}
headers = {"Content-Type": "application/json-patch+json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json-patch+json'},
body: JSON.stringify({customerId: 123, customer: {properties: {}, partnerId: 123}})
};
fetch('https://api.example.com/v3/deals/{id}/associate/customer', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v3/deals/{id}/associate/customer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => 123,
'customer' => [
'properties' => [
],
'partnerId' => 123
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json-patch+json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v3/deals/{id}/associate/customer"
payload := strings.NewReader("{\n \"customerId\": 123,\n \"customer\": {\n \"properties\": {},\n \"partnerId\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json-patch+json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v3/deals/{id}/associate/customer")
.header("Content-Type", "application/json-patch+json")
.body("{\n \"customerId\": 123,\n \"customer\": {\n \"properties\": {},\n \"partnerId\": 123\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v3/deals/{id}/associate/customer")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json-patch+json'
request.body = "{\n \"customerId\": 123,\n \"customer\": {\n \"properties\": {},\n \"partnerId\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"contactId": 123,
"sourcePartnerId": 123,
"stage": "<string>",
"creationDate": "2023-11-07T05:31:56Z",
"totalAmount": 123,
"properties": {},
"sourceLeadId": 123,
"status": "Unknown",
"partners": [
{
"id": 123,
"dealId": 123,
"userPartnerOwnerId": 123,
"userPartnerOwnerName": "<string>",
"userPartnerFirstName": "<string>",
"userPartnerLastName": "<string>",
"userPartnerEmail": "<string>",
"userPartnerJobTitle": "<string>",
"userPartnerPhoneNumber": "<string>",
"userPartnerLinkedInProfileUrl": "<string>",
"partnerId": 123,
"partnerTypeId": 123,
"creationDate": "2023-11-07T05:31:56Z",
"partnerName": "<string>",
"partnerTypeName": "<string>"
}
],
"contractStartDate": "2023-11-07T05:31:56Z",
"contractEndDate": "2023-11-07T05:31:56Z",
"ownerUserId": 123,
"owner": {
"id": 123,
"email": "<string>",
"firstName": "<string>",
"lastName": "<string>"
},
"closeDate": "2023-11-07T05:31:56Z",
"customerId": 123,
"currency": "<string>"
}
