Update or create deal
You can update an existing deal or create a new one in case a deal with a specific identifier doesn't exist. You can also set up any custom attribute of your choice. If a specified custom attribute doesn't exist yet it will be created.
| Attributes | Type | Required | Description |
|---|---|---|---|
| custom_id | string | no | The unique identifier for the deal which is provided by the client. |
| activities_status | string | no | A status of an activity assigned to the user. |
| assigned_to | integer | no | A unique identifier for the agent which is given by User automatically. |
| company_id | integer | no | A unique identifier for the company which is given by User automatically. |
| currency | ISO 4217 code | no | A currency of a deal. |
| expected_close_date | date | no | A date when the deal is expected to be closed. |
| loss_reason | integer | no | A reason for a lost deal. |
| lost_at | datetime | no | A date when the deal has been marked as lost. |
| name | string | yes | A deal name. |
| participants | integer(list) | no | A list of user_ids assigned to a deal. |
| pipeline | integer | no | An id of a pipeline where the deal is assigned to. |
| products | integer(list) | no | A list of product IDs. |
| products_custom_id | string(list) | no | A list of product custom IDs. |
| stage | integer | no | An id of a stage of the pipeline the deal is currently at. |
| status | integer | no | A status of your deal (0 - abandoned, 1 - in progress, 2 - won, 3 - lost, 4 - archived) |
| user_id | integer | no | A unique identifier for the user which is given by User automatically. |
| value | number | no | A value of a deal. |
| won_at | datetime | no | A date when the deal has been marked as won. |
| user_custom_id | string | no | The unique identifier for the user which is provided by the client. |
| company_custom_id | string | no | The unique identifier for the company which is provided by the client. |
| order_products | list | no | A list of basic information per each ordered product which is
provided by the client.
|
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/deals/update_or_create/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"custom_id": "annual-plan",
"name": "Annual plan for Acme Inc",
"value": 2000
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/deals/update_or_create/",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
custom_id: "annual-plan",
name: "Annual plan for Acme Inc",
value: 2000,
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/deals/update_or_create/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"custom_id" => "annual-plan",
"name" => "Annual plan for Acme Inc",
"value" => 2000,
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/deals/update_or_create/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"custom_id": "annual-plan",
"name": "Annual plan for Acme Inc",
"value": 2000,
},
)
print(response.json())
Response examples
- 200 OK
- 201 Created
{
"id": 387,
"created": false
}
{
"id": 388,
"created": true
}
Response fields · 200 OK
Fields returned in the 200 OK response body.
- id
- A unique identifier for the deal which is given by User automatically.
- created
trueif the tag didn't exist and was created,falseif an existing tag was used.
Response fields · 201 Created
Fields returned in the 201 Created response body.
- id
- A unique identifier for the deal which is given by User automatically.
- created
trueif the tag didn't exist and was created,falseif an existing tag was used.
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.