---
title: "Deals | Docs | CRM by R&D Copilot"
description: "Create deals, move them through the stages, win or lose them, reopen them, create their order in ERP and merge duplicates."
canonical: "https://crm.rdcopilot.com/docs/api-reference/deals/"
language: en
updated: 2026-11-22
---

# Deals

Create deals, move them through the stages, win or lose them, reopen them, create their order in ERP and merge duplicates.

## List deals

GET `/crm/v1/deals`

Returns deals in pages, newest first.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `stage` | query | `string` | Nooptional | Only deals in this stage. One of `lead`, `qualified`, `offer`, `negotiation`, `won`, `lost` |
| `owner` | query | `string` | Nooptional | Only the records of this owner. |
| `companyId` | query | `string (uuid)` | Nooptional | Only the records of this company. |
| `externalId` | query | `string` | Nooptional | The record that carries this `externalId`. |
| `limit` | query | `integer` | Nooptional | Records per page. Default `100` Range `1` – `500` |
| `cursor` | query | `string` | Nooptional | The `nextCursor` of the previous page. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | A page of records. | `DealPage` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/crm/v1/deals?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals?limit=20`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals?limit=20');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals?limit=20");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `200`

JSON

```json
{
  "items": [
    {
      "id": "d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44",
      "number": "DL-1044",
      "companyId": "ffc05e95-9bb4-41f8-8389-0047121e711a",
      "company": "Market Trei Brazi SRL",
      "name": "Frozen goods, request from the form",
      "owner": "ana-rusu",
      "value": "45000.00",
      "currency": "RON",
      "stage": "lead",
      "reason": null,
      "expectedClose": "2026-12-15",
      "order": null,
      "externalId": null,
      "customFields": {},
      "revision": 1
    },
    {
      "id": "92b6d0f5-1c48-4a3e-8d27-e5f9a4c0b742",
      "number": "DL-1042",
      "companyId": "ffc05e95-9bb4-41f8-8389-0047121e711a",
      "company": "Market Trei Brazi SRL",
      "name": "Frozen goods trial",
      "owner": "ana-rusu",
      "value": "47600.00",
      "currency": "RON",
      "stage": "lead",
      "reason": null,
      "expectedClose": "2026-12-15",
      "order": null,
      "externalId": null,
      "customFields": {},
      "revision": 2
    }
  ],
  "nextCursor": null
}
```

## Create a deal

POST `/crm/v1/deals`

Records a new deal as a lead. The answer is the operation result; read the deal with `getDeal` once `status` is `completed`.

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `companyId` | `string (uuid)` | Yesrequired | The company of the deal. |
| `name` | `string` | Yesrequired | Name of the deal. |
| `owner` | `string` | Nooptional | Identifier of the owner. The owner of the company by default. |
| `value` | `string` | Yesrequired | Net value as a decimal string, in RON, greater than zero. |
| `expectedClose` | `string (date)` | Yesrequired | The day the deal is expected to close, today or later. |
| `externalId` | `string` | Nooptional | Your own identifier for the deal. It is unique among the deals of your account. |
| `customFields` | `object` | Nooptional | Values of your custom fields, by field `key`. A decimal is a decimal string, a date is `YYYY-MM-DD`. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `company_not_found` or `owner_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `operation_reused` or `external_id_taken`. | `Error` |
| `422` | The request was refused. The `code` is `name_required`, `value_not_valid`, `date_not_valid`, `custom_field_unknown` or `custom_field_invalid`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/crm/v1/deals" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "3c9d2f6a-5b1e-4d7a-8f20-6a1b9c0e4d12",
  "companyId": "61d54dde-e1f3-43da-b2fc-a4a21540e5f3",
  "name": "First order for the kitchen",
  "owner": "andrei-pop",
  "value": "2818.41",
  "expectedClose": "2026-12-18",
  "externalId": "cust-0231-first-order"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "3c9d2f6a-5b1e-4d7a-8f20-6a1b9c0e4d12",
    "companyId": "61d54dde-e1f3-43da-b2fc-a4a21540e5f3",
    "name": "First order for the kitchen",
    "owner": "andrei-pop",
    "value": "2818.41",
    "expectedClose": "2026-12-18",
    "externalId": "cust-0231-first-order"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '3c9d2f6a-5b1e-4d7a-8f20-6a1b9c0e4d12',
        'companyId': '61d54dde-e1f3-43da-b2fc-a4a21540e5f3',
        'name': 'First order for the kitchen',
        'owner': 'andrei-pop',
        'value': '2818.41',
        'expectedClose': '2026-12-18',
        'externalId': 'cust-0231-first-order',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "3c9d2f6a-5b1e-4d7a-8f20-6a1b9c0e4d12",
  "companyId": "61d54dde-e1f3-43da-b2fc-a4a21540e5f3",
  "name": "First order for the kitchen",
  "owner": "andrei-pop",
  "value": "2818.41",
  "expectedClose": "2026-12-18",
  "externalId": "cust-0231-first-order"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "3c9d2f6a-5b1e-4d7a-8f20-6a1b9c0e4d12",
  "companyId": "61d54dde-e1f3-43da-b2fc-a4a21540e5f3",
  "name": "First order for the kitchen",
  "owner": "andrei-pop",
  "value": "2818.41",
  "expectedClose": "2026-12-18",
  "externalId": "cust-0231-first-order"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "3c9d2f6a-5b1e-4d7a-8f20-6a1b9c0e4d12",
  "status": "accepted",
  "aggregateRevision": 1
}
```

## Get a deal

GET `/crm/v1/deals/{dealId}`

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `dealId` | path | `string (uuid)` | Yesrequired | The deal. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | The record at its current revision. | `Deal` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `deal_not_found`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/crm/v1/deals/4b1c7a52-9e03-4d6f-8a17-c05e2d9b6f31" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals/4b1c7a52-9e03-4d6f-8a17-c05e2d9b6f31`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals/4b1c7a52-9e03-4d6f-8a17-c05e2d9b6f31',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals/4b1c7a52-9e03-4d6f-8a17-c05e2d9b6f31');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals/4b1c7a52-9e03-4d6f-8a17-c05e2d9b6f31");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `200`

JSON

```json
{
  "id": "4b1c7a52-9e03-4d6f-8a17-c05e2d9b6f31",
  "number": "DL-1031",
  "companyId": "61d54dde-e1f3-43da-b2fc-a4a21540e5f3",
  "company": "Hanul Ozana SRL",
  "name": "First order for the kitchen",
  "owner": "andrei-pop",
  "value": "2818.41",
  "currency": "RON",
  "stage": "won",
  "reason": "range",
  "expectedClose": "2026-11-17",
  "order": "CV-1042",
  "externalId": "cust-0231-first-order",
  "customFields": {},
  "revision": 6
}
```

## Move a deal

POST `/crm/v1/deals/{dealId}/move`

Moves an open deal to another open stage, forwards or back. A deal is won or lost with its own operations, because both need a reason.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `dealId` | path | `string (uuid)` | Yesrequired | The deal. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the deal you read. |
| `to` | `string` | Yesrequired | The stage to move to: `lead`, `qualified`, `offer` or `negotiation`. One of `lead`, `qualified`, `offer`, `negotiation` |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `deal_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict`, `operation_reused` or `deal_closed`. | `Error` |
| `422` | The request was refused. The `code` is `not_a_move`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/crm/v1/deals/7f2c8e49-5a01-4d73-b9e6-0c3d1a8f5b37/move" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "f9208bca-cb01-4c7e-a6d4-01c5fc0c08c0",
  "expectedRevision": 2,
  "to": "offer"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals/7f2c8e49-5a01-4d73-b9e6-0c3d1a8f5b37/move`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "f9208bca-cb01-4c7e-a6d4-01c5fc0c08c0",
    "expectedRevision": 2,
    "to": "offer"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals/7f2c8e49-5a01-4d73-b9e6-0c3d1a8f5b37/move',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'f9208bca-cb01-4c7e-a6d4-01c5fc0c08c0',
        'expectedRevision': 2,
        'to': 'offer',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "f9208bca-cb01-4c7e-a6d4-01c5fc0c08c0",
  "expectedRevision": 2,
  "to": "offer"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals/7f2c8e49-5a01-4d73-b9e6-0c3d1a8f5b37/move');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals/7f2c8e49-5a01-4d73-b9e6-0c3d1a8f5b37/move");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "f9208bca-cb01-4c7e-a6d4-01c5fc0c08c0",
  "expectedRevision": 2,
  "to": "offer"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "f9208bca-cb01-4c7e-a6d4-01c5fc0c08c0",
  "status": "accepted",
  "aggregateRevision": 3
}
```

## Win a deal

POST `/crm/v1/deals/{dealId}/win`

Marks a deal won, with its reason. Only a deal in `offer` or `negotiation` can be won. The request is refused with 409 when `expectedRevision` is not the current revision.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `dealId` | path | `string (uuid)` | Yesrequired | The deal. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the deal you read. |
| `reason` | `string` | Yesrequired | Why the deal was won: `price`, `range`, `delivery` or `relationship`. One of `price`, `range`, `delivery`, `relationship` |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `deal_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict`, `operation_reused`, `deal_closed` or `offer_required`. | `Error` |
| `422` | The request was refused. The `code` is `reason_not_valid`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/crm/v1/deals/0d7e2b85-f1a3-4c69-b2d4-93a8e5c61d38/win" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25",
  "expectedRevision": 5,
  "reason": "delivery"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals/0d7e2b85-f1a3-4c69-b2d4-93a8e5c61d38/win`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25",
    "expectedRevision": 5,
    "reason": "delivery"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals/0d7e2b85-f1a3-4c69-b2d4-93a8e5c61d38/win',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25',
        'expectedRevision': 5,
        'reason': 'delivery',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25",
  "expectedRevision": 5,
  "reason": "delivery"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals/0d7e2b85-f1a3-4c69-b2d4-93a8e5c61d38/win');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals/0d7e2b85-f1a3-4c69-b2d4-93a8e5c61d38/win");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25",
  "expectedRevision": 5,
  "reason": "delivery"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "9a4e7b10-2c6d-4f38-b5a1-0d3e8c7f6b25",
  "status": "accepted",
  "aggregateRevision": 6
}
```

## Lose a deal

POST `/crm/v1/deals/{dealId}/lose`

Marks an open deal lost, with its reason. A lost deal leaves the board and keeps its reason.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `dealId` | path | `string (uuid)` | Yesrequired | The deal. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the deal you read. |
| `reason` | `string` | Yesrequired | Why the deal was lost: `price`, `competitor`, `no-budget`, `no-decision` or `not-a-fit`. One of `price`, `competitor`, `no-budget`, `no-decision`, `not-a-fit` |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `deal_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict`, `operation_reused` or `deal_closed`. | `Error` |
| `422` | The request was refused. The `code` is `reason_not_valid`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/crm/v1/deals/58e3b2a9-c704-4f1d-9b68-3a0d7e1c4f39/lose" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "400d2326-b0df-4266-a9bc-a8fa6be8ea86",
  "expectedRevision": 4,
  "reason": "price"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals/58e3b2a9-c704-4f1d-9b68-3a0d7e1c4f39/lose`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "400d2326-b0df-4266-a9bc-a8fa6be8ea86",
    "expectedRevision": 4,
    "reason": "price"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals/58e3b2a9-c704-4f1d-9b68-3a0d7e1c4f39/lose',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '400d2326-b0df-4266-a9bc-a8fa6be8ea86',
        'expectedRevision': 4,
        'reason': 'price',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "400d2326-b0df-4266-a9bc-a8fa6be8ea86",
  "expectedRevision": 4,
  "reason": "price"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals/58e3b2a9-c704-4f1d-9b68-3a0d7e1c4f39/lose');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals/58e3b2a9-c704-4f1d-9b68-3a0d7e1c4f39/lose");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "400d2326-b0df-4266-a9bc-a8fa6be8ea86",
  "expectedRevision": 4,
  "reason": "price"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "400d2326-b0df-4266-a9bc-a8fa6be8ea86",
  "status": "accepted",
  "aggregateRevision": 5
}
```

## Reopen a deal

POST `/crm/v1/deals/{dealId}/reopen`

Opens a won or lost deal again, in the stage it was closed from or in the stage you name. The reopening is recorded. A won deal that has its order in ERP cannot be reopened.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `dealId` | path | `string (uuid)` | Yesrequired | The deal. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the deal you read. |
| `to` | `string` | Nooptional | The stage to reopen in. The stage the deal was closed from by default. One of `lead`, `qualified`, `offer`, `negotiation` |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `deal_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict`, `operation_reused`, `deal_not_closed` or `order_exists`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/crm/v1/deals/6c4a1e97-d2b8-4f30-8e59-a1d7b3c20f36/reopen" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "99fd1efb-a400-4796-a5bc-b3fd231d49f9",
  "expectedRevision": 3,
  "to": "qualified"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals/6c4a1e97-d2b8-4f30-8e59-a1d7b3c20f36/reopen`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "99fd1efb-a400-4796-a5bc-b3fd231d49f9",
    "expectedRevision": 3,
    "to": "qualified"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals/6c4a1e97-d2b8-4f30-8e59-a1d7b3c20f36/reopen',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '99fd1efb-a400-4796-a5bc-b3fd231d49f9',
        'expectedRevision': 3,
        'to': 'qualified',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "99fd1efb-a400-4796-a5bc-b3fd231d49f9",
  "expectedRevision": 3,
  "to": "qualified"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals/6c4a1e97-d2b8-4f30-8e59-a1d7b3c20f36/reopen');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals/6c4a1e97-d2b8-4f30-8e59-a1d7b3c20f36/reopen");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "99fd1efb-a400-4796-a5bc-b3fd231d49f9",
  "expectedRevision": 3,
  "to": "qualified"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "99fd1efb-a400-4796-a5bc-b3fd231d49f9",
  "status": "accepted",
  "aggregateRevision": 4
}
```

## Create the order in ERP

POST `/crm/v1/deals/{dealId}/erp-order`

Creates the order of a won deal in ERP and links it to the deal: `order` of the deal then holds its number, `CV-` and digits. A deal has one order.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `dealId` | path | `string (uuid)` | Yesrequired | The deal. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the deal you read. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `deal_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict`, `operation_reused`, `deal_not_won` or `order_already_created`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/crm/v1/deals/17f8c3b4-62d9-4e05-9a3c-b8e4d1f70a34/erp-order" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "016522fb-835b-4235-83d0-a790eb0a074a",
  "expectedRevision": 5
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals/17f8c3b4-62d9-4e05-9a3c-b8e4d1f70a34/erp-order`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "016522fb-835b-4235-83d0-a790eb0a074a",
    "expectedRevision": 5
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals/17f8c3b4-62d9-4e05-9a3c-b8e4d1f70a34/erp-order',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': '016522fb-835b-4235-83d0-a790eb0a074a',
        'expectedRevision': 5,
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "016522fb-835b-4235-83d0-a790eb0a074a",
  "expectedRevision": 5
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals/17f8c3b4-62d9-4e05-9a3c-b8e4d1f70a34/erp-order');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals/17f8c3b4-62d9-4e05-9a3c-b8e4d1f70a34/erp-order");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "016522fb-835b-4235-83d0-a790eb0a074a",
  "expectedRevision": 5
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "016522fb-835b-4235-83d0-a790eb0a074a",
  "status": "accepted",
  "aggregateRevision": 6
}
```

## List the duplicates of a deal

GET `/crm/v1/deals/{dealId}/duplicates`

Returns the earlier leads of the same company that this lead repeats, the oldest first. The first one is the lead to keep.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `dealId` | path | `string (uuid)` | Yesrequired | The deal. |
| `limit` | query | `integer` | Nooptional | Records per page. Default `100` Range `1` – `500` |
| `cursor` | query | `string` | Nooptional | The `nextCursor` of the previous page. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `200` | A page of records. | `DealPage` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `deal_not_found`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl "$RDC_BASE_URL/crm/v1/deals/d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44/duplicates?limit=20" \
  -H "Authorization: Bearer $RDC_TOKEN"
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals/d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44/duplicates?limit=20`, {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
  },
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'GET',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals/d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44/duplicates?limit=20',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
)
result = response.json()
```

PHP

```php
<?php

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals/d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44/duplicates?limit=20');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
    ],
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals/d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44/duplicates?limit=20");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `200`

JSON

```json
{
  "items": [
    {
      "id": "92b6d0f5-1c48-4a3e-8d27-e5f9a4c0b742",
      "number": "DL-1042",
      "companyId": "ffc05e95-9bb4-41f8-8389-0047121e711a",
      "company": "Market Trei Brazi SRL",
      "name": "Frozen goods trial",
      "owner": "ana-rusu",
      "value": "47600.00",
      "currency": "RON",
      "stage": "lead",
      "reason": null,
      "expectedClose": "2026-12-15",
      "order": null,
      "externalId": null,
      "customFields": {},
      "revision": 2
    }
  ],
  "nextCursor": null
}
```

## Merge a duplicate into a deal

POST `/crm/v1/deals/{dealId}/merge`

Merges a lead of the same company into the lead named in the path, which stays. The duplicate is removed and its activities and tasks move to the lead that stays.

### Parameters

| Name | In | Type | Required | Meaning |
| --- | --- | --- | --- | --- |
| `dealId` | path | `string (uuid)` | Yesrequired | The deal. |

### Request body

| Field | Type | Required | Meaning |
| --- | --- | --- | --- |
| `operationId` | `string (uuid)` | Yesrequired | A UUID you choose for this change. Send it again to repeat the request. |
| `expectedRevision` | `integer` | Yesrequired | The revision of the deal that stays, the one in the path. |
| `duplicateDealId` | `string (uuid)` | Yesrequired | The lead to merge into the deal in the path. It is removed. |

### Responses

| Status | Meaning | Body |
| --- | --- | --- |
| `202` | The change was accepted. The body is the operation result. | `OperationResult` |
| `400` | The request cannot be read or breaks the contract: malformed JSON, a missing or unknown field, a wrong type. `fields` names each one. | `Error` |
| `401` | The token is missing, expired or not ours. | `Error` |
| `403` | The token does not give access to this company or operation. | `Error` |
| `404` | The request was refused. The `code` is `deal_not_found`. | `Error` |
| `409` | The request was refused. The `code` is `revision_conflict`, `operation_reused`, `other_company` or `not_a_lead`. | `Error` |
| `422` | The request was refused. The `code` is `same_deal`. | `Error` |
| `429` | The request was refused and not processed: the `code` is `rate_limited`. Wait the seconds in the header `Retry-After`, then send it again with the same `operationId`. | `Error` |
| `503` | The service cannot answer now: the `code` is `unavailable`. Send the request again with the same `operationId`. | `Error` |

### Request

curl

```bash
curl -X POST "$RDC_BASE_URL/crm/v1/deals/92b6d0f5-1c48-4a3e-8d27-e5f9a4c0b742/merge" \
  -H "Authorization: Bearer $RDC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "operationId": "f11c6469-c5bf-4ecc-a73e-d73a674eeaf4",
  "expectedRevision": 2,
  "duplicateDealId": "d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44"
}'
```

JavaScript

```javascript
const response = await fetch(`${process.env.RDC_BASE_URL}/crm/v1/deals/92b6d0f5-1c48-4a3e-8d27-e5f9a4c0b742/merge`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.RDC_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operationId": "f11c6469-c5bf-4ecc-a73e-d73a674eeaf4",
    "expectedRevision": 2,
    "duplicateDealId": "d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44"
  }),
});
const result = await response.json();
```

Python

```python
import os
import requests

response = requests.request(
    'POST',
    f'{os.environ["RDC_BASE_URL"]}/crm/v1/deals/92b6d0f5-1c48-4a3e-8d27-e5f9a4c0b742/merge',
    headers={
        'Authorization': f'Bearer {os.environ["RDC_TOKEN"]}',
    },
    json={
        'operationId': 'f11c6469-c5bf-4ecc-a73e-d73a674eeaf4',
        'expectedRevision': 2,
        'duplicateDealId': 'd4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44',
    },
)
result = response.json()
```

PHP

```php
<?php

$body = <<<'JSON'
{
  "operationId": "f11c6469-c5bf-4ecc-a73e-d73a674eeaf4",
  "expectedRevision": 2,
  "duplicateDealId": "d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44"
}
JSON;

$curl = curl_init(getenv('RDC_BASE_URL') . '/crm/v1/deals/92b6d0f5-1c48-4a3e-8d27-e5f9a4c0b742/merge');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('RDC_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
```

C#

```csharp
using System.Net.Http.Headers;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, $"{Environment.GetEnvironmentVariable("RDC_BASE_URL")}/crm/v1/deals/92b6d0f5-1c48-4a3e-8d27-e5f9a4c0b742/merge");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("RDC_TOKEN"));
request.Content = new StringContent("""
{
  "operationId": "f11c6469-c5bf-4ecc-a73e-d73a674eeaf4",
  "expectedRevision": 2,
  "duplicateDealId": "d4a1f7c8-3e90-4b56-a2d1-8c7e0b9f6a44"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
```

### Response `202`

JSON

```json
{
  "operationId": "f11c6469-c5bf-4ecc-a73e-d73a674eeaf4",
  "status": "accepted",
  "aggregateRevision": 3
}
```
