К содержанию

Сделки

Сделки в воронках: список, карточка, создание и изменение, переход по этапам, контакты сделки.

Список сделок

GET /deals

Сделки в порядке доски, страницами: лимит делится между этапами, чтобы был виден каждый; продолжение этапа — по курсору из stageCursors. Фильтры по воронке, этапам, ответственному, датам, сумме, тегам и собственным полям. status=open, won или lost — только такие сделки, status=deleted — сделки в корзине. Значения собственных полей — только для полей из customFieldIds; описание сделки — в «Получить сделку».

Параметры запроса

  • amountMax string

    шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$

  • amountMin string

    шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$

  • cf string[]

    количество ≤ 20 · длина 1–2100

  • closedFrom string · date-time

  • closedTo string · date-time

  • companyId string · uuid

  • contactId string · uuid

  • createdFrom string · date-time

  • createdTo string · date-time

  • currency string

    шаблон ^[A-Z]{3}$

  • cursor string

    длина 1–512

  • customFieldIds string[] · uuid

    количество ≤ 50

  • excludeStageIds string[] · uuid

    количество ≤ 100

  • expectedCloseFrom string · date

  • expectedCloseTo string · date

  • limit integer

    1–500 · по умолчанию 500

  • noExpectedClose boolean

  • noOwner boolean

  • ownerId string · uuid

  • ownerIds string[] · uuid

    количество ≤ 100

  • payments string[]

    количество ≤ 4

    Значения: instalment_today instalment_overdue partly_paid not_paid

  • pipelineId string · uuid

  • q string

    длина ≤ 200

  • sort string

    Значения: position createdAt -createdAt amount -amount title -title

  • stageEnteredFrom string · date-time

  • stageEnteredTo string · date-time

  • stageIds string[] · uuid

    количество ≤ 100

  • status string

    Значения: open won lost deleted

  • tagIds string[] · uuid

    количество ≤ 50

  • tagMode string

    по умолчанию any

    Значения: any all none

  • taskDueFrom string · date-time

  • taskDueTo string · date-time

  • tasks string[]

    количество ≤ 4

    Значения: none open overdue due

  • updatedFrom string · date-time

  • updatedTo string · date-time

Пример запроса

bash
curl 'https://your-company.altahub.ai/api/v1/deals' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.get(
    "https://your-company.altahub.ai/api/v1/deals",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://your-company.altahub.ai/api/v1/deals', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "items": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
      "number": 1042,
      "title": "Кофемашины для сети кофеен",
      "amount": "12000.00",
      "currency": "UAH",
      "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
      "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000020",
      "status": "open",
      "position": 1,
      "stageEnteredAt": "2026-10-21T12:40:00Z",
      "closedAt": null,
      "expectedCloseDate": "2026-11-15",
      "owner": {
        "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
        "name": "Ирина Мельник"
      },
      "contact": {
        "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
        "fullName": "Елена Коваль",
        "phone": "+380501234567"
      },
      "contacts": [
        {
          "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
          "fullName": "Елена Коваль",
          "phone": "+380501234567",
          "email": "olena.koval@kavova.ua",
          "jobTitle": "Менеджер по закупкам",
          "primary": true
        }
      ],
      "company": {
        "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
        "name": "ООО «Кофейная гильдия»"
      },
      "tags": [
        {
          "id": "0192f3a1-7c2e-7b4d-9a61-000000000028",
          "name": "VIP",
          "color": "purple"
        }
      ],
      "customFields": [
        {
          "fieldId": "0192f3a1-7c2e-7b4d-9a61-000000000032",
          "value": "Киев"
        }
      ],
      "nextTask": {
        "id": "0192f3a1-7c2e-7b4d-9a61-00000000003c",
        "title": "Перезвонить по счёту",
        "kind": "call",
        "dueAt": "2026-10-28T10:00:00Z",
        "overdue": false,
        "type": null
      },
      "deletedAt": null,
      "inTrash": false,
      "deletedBy": null,
      "mergedInto": null,
      "mergedAway": false,
      "createdAt": "2026-10-20T08:15:00Z",
      "updatedAt": "2026-10-24T16:45:00Z",
      "version": 4
    }
  ],
  "nextCursor": null,
  "stageCursors": []
}
Поля ответа
  • items object[]

    Вложенные поля: 30
    • amount string

      шаблон ^[0-9]{1,12}\.[0-9]{2}$

    • closedAt string · date-time | null

    • company object | null

      Вложенные поля: 2
      • id string · uuid

      • name string

    • contact object | null

      Вложенные поля: 3
      • fullName string

      • id string · uuid

      • phone string | null

    • contacts object[]

      Вложенные поля: 6
      • email string | null

      • fullName string

      • id string · uuid

      • jobTitle string | null

        The contact's own job title, as the contact record has it.

      • phone string | null

      • primary boolean

    • createdAt string · date-time

    • currency string

      шаблон ^[A-Z]{3}$

    • customFields object[]

      Вложенные поля: 3
      • fieldId string · uuid

      • value string | boolean | string[] · uuid | object

        Вариант 1 · string

        string

        Вариант 2 · boolean

        boolean

        Вариант 3 · string[] · uuid

        string[] · uuid

        Вариант 4 · object
        • amount string

        • currency string

        Вариант 5 · object
        • city string

        • country string

        • line string

        • postcode string

      • values (string | object)[]

        Вариант 1 · string

        string

        Вариант 2 · object
        • city string

        • country string

        • line string

        • postcode string

    • deletedAt string · date-time | null

    • deletedBy object | null

      Вложенные поля: 2
      • id string · uuid

      • name string

    • expectedCloseDate string · date | null

    • id string · uuid

    • inTrash boolean

      True while the deal is in the trash (deletedAt set), false for a live deal; a deal in the trash keeps its status.

    • mergedAway boolean

      True while a merge keeps this deal in the trash: everything it had is the deal it went into, which `mergedInto` names when your role shows it; such a deal is never restored (409 `merged_deal`). False for every other deal.

    • mergedInto object | null

      The deal this one was merged into, followed through later merges to the one that holds it now (its id and number): set only while the merge keeps this deal in the trash, null for a live deal, for one a person deleted, for one restored since, and when your role does not show that deal.

      Вложенные поля: 2
      • id string · uuid

      • number integer

        ≥ 1

    • nextTask object | null

      Вложенные поля: 7
      • dueAt string · date-time | null

      • id string · uuid

      • kind string

        Значения: task call meeting email reminder chat

      • overdue boolean

      • title string

      • type object | null

        Вложенные поля: 3
        • icon string

        • id string · uuid

        • name string

      • allDay boolean

    • number integer

      ≥ 1

    • owner object | null

      Вложенные поля: 2
      • id string · uuid

      • name string

    • pipelineId string · uuid

    • position number

    • stageEnteredAt string · date-time

    • stageId string · uuid

    • status string

      Значения: open won lost

    • tags object[]

      Вложенные поля: 3
      • color string

        Значения: gray blue teal green yellow orange red purple

      • id string · uuid

      • name string

    • title string

    • updatedAt string · date-time

    • version integer

      ≥ 1

    • amountSource string

      Значения: manual products

    • amountTypeable boolean

    • viewerMay object

      Вложенные поля: 2
      • delete boolean

      • edit boolean

  • nextCursor string | null

  • stageCursors object[]

    Вложенные поля: 2
    • nextCursor string

    • stageId string · uuid

Создать сделку

POST /deals

Нужно только название. Без этапа сделка встаёт в первый этап воронки, без ответственного (ownerId) — на того, кто создаёт, для ключа — на его автора (у сделки всегда есть ответственный: ownerId: null — 400 owner_required), без валюты — в валюте организации. Обязательные поля этапа запрос с ключом не останавливают: сделка встаёт на этап и с пустым полем (отказ stage_requires_field:<id поля> получает только человек в Alta). Значение поля «Уникальное значение», которое уже у другой сделки, — 409 VALUE_TAKEN: сделка не создаётся, а error.taken.deal даёт id и номер сделки, которая уже есть, — пишите в неё. Повтор запроса создаст вторую сделку: если ответ не пришёл, сначала поищите сделку по контакту.

Тело запроса

  • title string обязательно

    длина 1–200 · шаблон \S

  • amount string | number

    шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

  • companyId string · uuid | null

  • contactId string · uuid | null

  • currency string

    шаблон ^[A-Z]{3}$

  • customFields object[]

    количество ≤ 100

    Вложенные поля: 3
    • fieldId string · uuid обязательно

    • value string | boolean | string[] · uuid | object | null

      Вариант 1 · string

      string

      Вариант 2 · boolean

      boolean

      Вариант 3 · string[] · uuid

      string[] · uuid

      Вариант 4 · object
      • amount string обязательно

        длина ≤ 40

      • currency string обязательно

        длина ≤ 3

      Вариант 5 · object
      • city string | null

        длина ≤ 200

      • country string | null

        длина ≤ 200

      • line string | null

        длина ≤ 600

      • postcode string | null

        длина ≤ 40

    • values (string | object)[]

      количество ≤ 50

      Вариант 1 · string

      string

      Вариант 2 · object
      • city string | null

        длина ≤ 200

      • country string | null

        длина ≤ 200

      • line string | null

        длина ≤ 600

      • postcode string | null

        длина ≤ 40

  • description string | null

    длина ≤ 5000

  • expectedCloseDate string · date | null

    шаблон ^20[0-9]{2}-

  • ownerId string · uuid | null

  • pipelineId string · uuid

  • position number

    -1000000000000000–1000000000000000

  • stageId string · uuid

  • tagIds string[] · uuid

    количество ≤ 50

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/deals' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "contactId": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-00000000001f"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: 'Кофемашины для сети кофеен',
    amount: '12000.00',
    currency: 'UAH',
    contactId: '0192f3a1-7c2e-7b4d-9a61-00000000000a',
    pipelineId: '0192f3a1-7c2e-7b4d-9a61-00000000001e',
    stageId: '0192f3a1-7c2e-7b4d-9a61-00000000001f',
  }),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/deals",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "title": "Кофемашины для сети кофеен",
        "amount": "12000.00",
        "currency": "UAH",
        "contactId": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
        "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
        "stageId": "0192f3a1-7c2e-7b4d-9a61-00000000001f",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/deals', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'title' => 'Кофемашины для сети кофеен',
        'amount' => '12000.00',
        'currency' => 'UAH',
        'contactId' => '0192f3a1-7c2e-7b4d-9a61-00000000000a',
        'pipelineId' => '0192f3a1-7c2e-7b4d-9a61-00000000001e',
        'stageId' => '0192f3a1-7c2e-7b4d-9a61-00000000001f',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 201

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "number": 1042,
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-00000000001f",
  "status": "open",
  "position": 1,
  "stageEnteredAt": "2026-10-20T08:15:00Z",
  "closedAt": null,
  "expectedCloseDate": null,
  "description": null,
  "owner": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000001",
    "name": "Андрей Шевченко"
  },
  "contact": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
    "fullName": "Елена Коваль",
    "phone": "+380501234567"
  },
  "contacts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
      "fullName": "Елена Коваль",
      "phone": "+380501234567",
      "email": "olena.koval@kavova.ua",
      "jobTitle": "Менеджер по закупкам",
      "primary": true
    }
  ],
  "company": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
    "name": "ООО «Кофейная гильдия»"
  },
  "tags": [],
  "customFields": [],
  "nextTask": null,
  "deletedAt": null,
  "inTrash": false,
  "deletedBy": null,
  "mergedInto": null,
  "mergedAway": false,
  "createdAt": "2026-10-20T08:15:00Z",
  "updatedAt": "2026-10-20T08:15:00Z",
  "version": 1
}
Поля ответа
  • amount string

    шаблон ^[0-9]{1,12}\.[0-9]{2}$

  • closedAt string · date-time | null

  • company object | null

    Вложенные поля: 2
    • id string · uuid

    • name string

  • contact object | null

    Вложенные поля: 3
    • fullName string

    • id string · uuid

    • phone string | null

  • contacts object[]

    Вложенные поля: 6
    • email string | null

    • fullName string

    • id string · uuid

    • jobTitle string | null

      The contact's own job title, as the contact record has it.

    • phone string | null

    • primary boolean

  • createdAt string · date-time

  • currency string

    шаблон ^[A-Z]{3}$

  • customFields object[]

    Вложенные поля: 3
    • fieldId string · uuid

    • value string | boolean | string[] · uuid | object

      Вариант 1 · string

      string

      Вариант 2 · boolean

      boolean

      Вариант 3 · string[] · uuid

      string[] · uuid

      Вариант 4 · object
      • amount string

      • currency string

      Вариант 5 · object
      • city string

      • country string

      • line string

      • postcode string

    • values (string | object)[]

      Вариант 1 · string

      string

      Вариант 2 · object
      • city string

      • country string

      • line string

      • postcode string

  • deletedAt string · date-time | null

  • deletedBy object | null

    Вложенные поля: 2
    • id string · uuid

    • name string

  • description string | null

  • expectedCloseDate string · date | null

  • id string · uuid

  • inTrash boolean

    True while the deal is in the trash (deletedAt set), false for a live deal; a deal in the trash keeps its status.

  • mergedAway boolean

    True while a merge keeps this deal in the trash: everything it had is the deal it went into, which `mergedInto` names when your role shows it; such a deal is never restored (409 `merged_deal`). False for every other deal.

  • mergedInto object | null

    The deal this one was merged into, followed through later merges to the one that holds it now (its id and number): set only while the merge keeps this deal in the trash, null for a live deal, for one a person deleted, for one restored since, and when your role does not show that deal.

    Вложенные поля: 2
    • id string · uuid

    • number integer

      ≥ 1

  • nextTask object | null

    Вложенные поля: 7
    • dueAt string · date-time | null

    • id string · uuid

    • kind string

      Значения: task call meeting email reminder chat

    • overdue boolean

    • title string

    • type object | null

      Вложенные поля: 3
      • icon string

      • id string · uuid

      • name string

    • allDay boolean

  • number integer

    ≥ 1

  • owner object | null

    Вложенные поля: 2
    • id string · uuid

    • name string

  • pipelineId string · uuid

  • position number

  • stageEnteredAt string · date-time

  • stageId string · uuid

  • status string

    Значения: open won lost

  • tags object[]

    Вложенные поля: 3
    • color string

      Значения: gray blue teal green yellow orange red purple

    • id string · uuid

    • name string

  • title string

  • updatedAt string · date-time

  • version integer

    ≥ 1

  • amountSource string

    Значения: manual products

  • amountTypeable boolean

  • viewerMay object

    Вложенные поля: 2
    • delete boolean

    • edit boolean

Получить сделку

GET /deals/{dealId}

Одна сделка по id. Сделка в корзине тоже отвечает — с inTrash: true, deletedAt и deletedBy; удалённая навсегда — 404. Сделка, которую объединили с другой, лежит в корзине со своим статусом, а mergedInto называет id и номер сделки, в которой она теперь.

Параметры пути

  • dealId string · uuid обязательно

Пример запроса

bash
curl 'https://your-company.altahub.ai/api/v1/deals/{dealId}' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.get(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://your-company.altahub.ai/api/v1/deals/{dealId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "number": 1042,
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000020",
  "status": "open",
  "position": 1,
  "stageEnteredAt": "2026-10-21T12:40:00Z",
  "closedAt": null,
  "expectedCloseDate": "2026-11-15",
  "description": "Три кофемашины и сервис на год",
  "owner": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "contact": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
    "fullName": "Елена Коваль",
    "phone": "+380501234567"
  },
  "contacts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
      "fullName": "Елена Коваль",
      "phone": "+380501234567",
      "email": "olena.koval@kavova.ua",
      "jobTitle": "Менеджер по закупкам",
      "primary": true
    }
  ],
  "company": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
    "name": "ООО «Кофейная гильдия»"
  },
  "tags": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000028",
      "name": "VIP",
      "color": "purple"
    }
  ],
  "customFields": [
    {
      "fieldId": "0192f3a1-7c2e-7b4d-9a61-000000000032",
      "value": "Киев"
    }
  ],
  "nextTask": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000003c",
    "title": "Перезвонить по счёту",
    "kind": "call",
    "dueAt": "2026-10-28T10:00:00Z",
    "overdue": false,
    "type": null
  },
  "deletedAt": null,
  "inTrash": false,
  "deletedBy": null,
  "mergedInto": null,
  "mergedAway": false,
  "createdAt": "2026-10-20T08:15:00Z",
  "updatedAt": "2026-10-24T16:45:00Z",
  "version": 4
}

Поля — как в ответе Создать сделку

Изменить сделку

PATCH /deals/{dealId}

Меняет поля сделки или переносит её на другой этап: этап успеха или отказа закрывает сделку, открытый этап снова её открывает. Передайте только то, что меняется; version необязателен: с ним изменение пройдёт, только если запись не меняли после вашего чтения (иначе 409 CONFLICT). Переход на этап с пустым обязательным полем запрос с ключом не останавливает (отказ stage_requires_field:<id поля> получает только человек в Alta). Значение уникального поля, которое уже у другой сделки, — 409 VALUE_TAKEN (error.taken). Сделку в корзине сначала восстановите. ownerId передаёт сделку другому сотруднику; убрать ответственного нельзя: ownerId: null — 400 owner_required (без ownerId ответственный остаётся прежним). У сделки со своими товарами сумма — из них: другая amount — 409 amount_from_products, пока сумма считается из товаров, и 409 amount_has_lines, пока у сделки ещё сумма, введённая до этого правила (PUT /deals/{dealId}/amount-source products считает её по товарам); та же сумма проходит.

Параметры пути

  • dealId string · uuid обязательно

Тело запроса

  • amount string | number

    шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

  • companyId string · uuid | null

  • contactId string · uuid | null

  • currency string

    шаблон ^[A-Z]{3}$

  • customFields object[]

    количество ≤ 100

    Вложенные поля: 3
    • fieldId string · uuid обязательно

    • value string | boolean | string[] · uuid | object | null

      Вариант 1 · string

      string

      Вариант 2 · boolean

      boolean

      Вариант 3 · string[] · uuid

      string[] · uuid

      Вариант 4 · object
      • amount string обязательно

        длина ≤ 40

      • currency string обязательно

        длина ≤ 3

      Вариант 5 · object
      • city string | null

        длина ≤ 200

      • country string | null

        длина ≤ 200

      • line string | null

        длина ≤ 600

      • postcode string | null

        длина ≤ 40

    • values (string | object)[]

      количество ≤ 50

      Вариант 1 · string

      string

      Вариант 2 · object
      • city string | null

        длина ≤ 200

      • country string | null

        длина ≤ 200

      • line string | null

        длина ≤ 600

      • postcode string | null

        длина ≤ 40

  • description string | null

    длина ≤ 5000

  • expectedCloseDate string · date | null

    шаблон ^20[0-9]{2}-

  • ownerId string · uuid | null

  • position number

    -1000000000000000–1000000000000000

  • stageId string · uuid

  • status string

    Значения: open won lost

  • tagIds string[] · uuid

    количество ≤ 50

  • title string

    длина 1–200 · шаблон \S

  • version integer

    ≥ 1

Пример запроса

bash
curl -X PATCH 'https://your-company.altahub.ai/api/v1/deals/{dealId}' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000021"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}', {
  method: 'PATCH',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    stageId: '0192f3a1-7c2e-7b4d-9a61-000000000021',
  }),
});
const data = await response.json();
python
import requests

response = requests.patch(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000021",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://your-company.altahub.ai/api/v1/deals/{dealId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'stageId' => '0192f3a1-7c2e-7b4d-9a61-000000000021',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "number": 1042,
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000021",
  "status": "open",
  "position": 1,
  "stageEnteredAt": "2026-10-24T16:45:00Z",
  "closedAt": null,
  "expectedCloseDate": "2026-11-15",
  "description": "Три кофемашины и сервис на год",
  "owner": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "contact": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
    "fullName": "Елена Коваль",
    "phone": "+380501234567"
  },
  "contacts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
      "fullName": "Елена Коваль",
      "phone": "+380501234567",
      "email": "olena.koval@kavova.ua",
      "jobTitle": "Менеджер по закупкам",
      "primary": true
    }
  ],
  "company": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
    "name": "ООО «Кофейная гильдия»"
  },
  "tags": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000028",
      "name": "VIP",
      "color": "purple"
    }
  ],
  "customFields": [
    {
      "fieldId": "0192f3a1-7c2e-7b4d-9a61-000000000032",
      "value": "Киев"
    }
  ],
  "nextTask": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000003c",
    "title": "Перезвонить по счёту",
    "kind": "call",
    "dueAt": "2026-10-28T10:00:00Z",
    "overdue": false,
    "type": null
  },
  "deletedAt": null,
  "inTrash": false,
  "deletedBy": null,
  "mergedInto": null,
  "mergedAway": false,
  "createdAt": "2026-10-20T08:15:00Z",
  "updatedAt": "2026-10-24T16:45:00Z",
  "version": 5
}

Поля — как в ответе Создать сделку

Удалить сделку

DELETE /deals/{dealId}

Переносит сделку в корзину вместе с задачами: она пропадает с доски, из списков и поиска, а через 30 дней удаляется навсегда. Повтор ничего не меняет.

Параметры пути

  • dealId string · uuid обязательно

Параметры запроса

  • version integer

    ≥ 1

Пример запроса

bash
curl -X DELETE 'https://your-company.altahub.ai/api/v1/deals/{dealId}' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}', {
  method: 'DELETE',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.delete(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://your-company.altahub.ai/api/v1/deals/{dealId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "number": 1042,
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000020",
  "status": "open",
  "position": 1,
  "stageEnteredAt": "2026-10-21T12:40:00Z",
  "closedAt": null,
  "expectedCloseDate": "2026-11-15",
  "description": "Три кофемашины и сервис на год",
  "owner": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "contact": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
    "fullName": "Елена Коваль",
    "phone": "+380501234567"
  },
  "contacts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
      "fullName": "Елена Коваль",
      "phone": "+380501234567",
      "email": "olena.koval@kavova.ua",
      "jobTitle": "Менеджер по закупкам",
      "primary": true
    }
  ],
  "company": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
    "name": "ООО «Кофейная гильдия»"
  },
  "tags": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000028",
      "name": "VIP",
      "color": "purple"
    }
  ],
  "customFields": [
    {
      "fieldId": "0192f3a1-7c2e-7b4d-9a61-000000000032",
      "value": "Киев"
    }
  ],
  "nextTask": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000003c",
    "title": "Перезвонить по счёту",
    "kind": "call",
    "dueAt": "2026-10-28T10:00:00Z",
    "overdue": false,
    "type": null
  },
  "deletedAt": "2026-10-24T16:45:00Z",
  "inTrash": true,
  "deletedBy": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "mergedInto": null,
  "mergedAway": false,
  "createdAt": "2026-10-20T08:15:00Z",
  "updatedAt": "2026-10-24T16:45:00Z",
  "version": 5
}

Поля — как в ответе Создать сделку

Откуда берётся сумма сделки

PUT /deals/{dealId}/amount-source

manual — сумму вводят вручную; products — сумма считается из строк самой сделки (у сделки без строк — 409 no_lines; у сделки, сумму которой пишет импорт другой системы, — 409 amount_kept_by_sync: её строки сумму не меняют, amountKeptBySync в списке товаров). У сделки со своими строками сумма — из них: manual — 409 amount_has_lines, другая сумма получается своей ценой строки или скидкой. Сделка, у которой строки и сумма, введённая до этого правила, сохраняет её, пока не выбрано products — в одну сторону. Пока сумма из товаров, изменить amount через PATCH /deals/{dealId} нельзя: 409 amount_from_products. Тот же источник ещё раз ничего не меняет.

Параметры пути

  • dealId string · uuid обязательно

Тело запроса

  • source string обязательно

    Where the deal's amount comes from: typed (`manual`) or the sum of its own product lines (`products`)

    Значения: manual products

Пример запроса

bash
curl -X PUT 'https://your-company.altahub.ai/api/v1/deals/{dealId}/amount-source' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "source": "manual"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/amount-source', {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    source: 'manual',
  }),
});
const data = await response.json();
python
import requests

response = requests.put(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/amount-source",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "source": "manual",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/amount-source', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'source' => 'manual',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "amount": "84000.00",
  "currency": "UAH",
  "amountSource": "manual",
  "version": 8
}
Поля ответа
  • amount string

    шаблон ^[0-9]+\.[0-9]{2}$

  • amountSource string

    Where the deal's amount comes from: typed (`manual`) or the sum of its own product lines (`products`)

    Значения: manual products

  • currency string

    шаблон ^[A-Z]{3}$

  • version integer

    ≥ 1

Добавить контакт в сделку

POST /deals/{dealId}/contacts

Первый контакт сделки становится основным, следующие — после него. Не больше 20 контактов у сделки (409); повтор ничего не меняет.

Параметры пути

  • dealId string · uuid обязательно

Тело запроса

  • contactId string · uuid обязательно

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "contactId": "0192f3a1-7c2e-7b4d-9a61-00000000000a"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    contactId: '0192f3a1-7c2e-7b4d-9a61-00000000000a',
  }),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "contactId": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'contactId' => '0192f3a1-7c2e-7b4d-9a61-00000000000a',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "number": 1042,
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000020",
  "status": "open",
  "position": 1,
  "stageEnteredAt": "2026-10-21T12:40:00Z",
  "closedAt": null,
  "expectedCloseDate": "2026-11-15",
  "description": "Три кофемашины и сервис на год",
  "owner": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "contact": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
    "fullName": "Елена Коваль",
    "phone": "+380501234567"
  },
  "contacts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
      "fullName": "Елена Коваль",
      "phone": "+380501234567",
      "email": "olena.koval@kavova.ua",
      "jobTitle": "Менеджер по закупкам",
      "primary": true
    }
  ],
  "company": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
    "name": "ООО «Кофейная гильдия»"
  },
  "tags": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000028",
      "name": "VIP",
      "color": "purple"
    }
  ],
  "customFields": [
    {
      "fieldId": "0192f3a1-7c2e-7b4d-9a61-000000000032",
      "value": "Киев"
    }
  ],
  "nextTask": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000003c",
    "title": "Перезвонить по счёту",
    "kind": "call",
    "dueAt": "2026-10-28T10:00:00Z",
    "overdue": false,
    "type": null
  },
  "deletedAt": null,
  "inTrash": false,
  "deletedBy": null,
  "mergedInto": null,
  "mergedAway": false,
  "createdAt": "2026-10-20T08:15:00Z",
  "updatedAt": "2026-10-24T16:45:00Z",
  "version": 4
}

Поля — как в ответе Создать сделку

Убрать контакт из сделки

DELETE /deals/{dealId}/contacts/{contactId}

Если контакт был основным, основным становится добавленный раньше остальных. Повтор ничего не меняет.

Параметры пути

  • contactId string · uuid обязательно

  • dealId string · uuid обязательно

Пример запроса

bash
curl -X DELETE 'https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts/{contactId}' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts/{contactId}', {
  method: 'DELETE',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.delete(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts/{contactId}",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts/{contactId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "number": 1042,
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000020",
  "status": "open",
  "position": 1,
  "stageEnteredAt": "2026-10-21T12:40:00Z",
  "closedAt": null,
  "expectedCloseDate": "2026-11-15",
  "description": "Три кофемашины и сервис на год",
  "owner": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "contact": null,
  "contacts": [],
  "company": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
    "name": "ООО «Кофейная гильдия»"
  },
  "tags": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000028",
      "name": "VIP",
      "color": "purple"
    }
  ],
  "customFields": [
    {
      "fieldId": "0192f3a1-7c2e-7b4d-9a61-000000000032",
      "value": "Киев"
    }
  ],
  "nextTask": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000003c",
    "title": "Перезвонить по счёту",
    "kind": "call",
    "dueAt": "2026-10-28T10:00:00Z",
    "overdue": false,
    "type": null
  },
  "deletedAt": null,
  "inTrash": false,
  "deletedBy": null,
  "mergedInto": null,
  "mergedAway": false,
  "createdAt": "2026-10-20T08:15:00Z",
  "updatedAt": "2026-10-24T16:45:00Z",
  "version": 5
}

Поля — как в ответе Создать сделку

Сделать контакт основным

POST /deals/{dealId}/contacts/{contactId}/primary

Прежний основной контакт остаётся в сделке; контакт, которого в сделке нет, добавляется сразу основным.

Параметры пути

  • contactId string · uuid обязательно

  • dealId string · uuid обязательно

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts/{contactId}/primary' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts/{contactId}/primary', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({}),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts/{contactId}/primary",
    headers={"Authorization": "Bearer alta_…"},
    json={},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/contacts/{contactId}/primary', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => new \stdClass(),
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "number": 1042,
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000020",
  "status": "open",
  "position": 1,
  "stageEnteredAt": "2026-10-21T12:40:00Z",
  "closedAt": null,
  "expectedCloseDate": "2026-11-15",
  "description": "Три кофемашины и сервис на год",
  "owner": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "contact": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
    "fullName": "Елена Коваль",
    "phone": "+380501234567"
  },
  "contacts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
      "fullName": "Елена Коваль",
      "phone": "+380501234567",
      "email": "olena.koval@kavova.ua",
      "jobTitle": "Менеджер по закупкам",
      "primary": true
    }
  ],
  "company": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
    "name": "ООО «Кофейная гильдия»"
  },
  "tags": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000028",
      "name": "VIP",
      "color": "purple"
    }
  ],
  "customFields": [
    {
      "fieldId": "0192f3a1-7c2e-7b4d-9a61-000000000032",
      "value": "Киев"
    }
  ],
  "nextTask": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000003c",
    "title": "Перезвонить по счёту",
    "kind": "call",
    "dueAt": "2026-10-28T10:00:00Z",
    "overdue": false,
    "type": null
  },
  "deletedAt": null,
  "inTrash": false,
  "deletedBy": null,
  "mergedInto": null,
  "mergedAway": false,
  "createdAt": "2026-10-20T08:15:00Z",
  "updatedAt": "2026-10-24T16:45:00Z",
  "version": 4
}

Поля — как в ответе Создать сделку

Применить купон к сделке

PUT /deals/{dealId}/discounts/coupons/{couponId}

Любой, кто может менять сделку; купон встаёт после остальных скидок сделки, тот же купон ещё раз ничего не меняет. База раскладывает его по строкам самой сделки в порядке Lago (сначала купоны на товары и группы, потом остальные, каждый — от того, что осталось после предыдущих) и пересчитывает при каждом изменении строк; сумма сделки — сумма строк после долей. Пока купон стоит на живой сделке, он занимает одно из использований. 409: coupon_archived, coupon_expired, coupon_needs_client (купон «один раз на клиента», у сделки нет контакта), coupon_other_currency, coupon_used_up, coupon_used_by_client, coupon_no_matching_products, coupon_below_minimum, imported_lines, amount_kept_by_sync, amount_not_from_products (сумма сделки введена вручную). Купон другой организации — 404.

Параметры пути

  • couponId string · uuid обязательно

  • dealId string · uuid обязательно

Пример запроса

bash
curl -X PUT 'https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/coupons/{couponId}' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/coupons/{couponId}', {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({}),
});
const data = await response.json();
python
import requests

response = requests.put(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/coupons/{couponId}",
    headers={"Authorization": "Bearer alta_…"},
    json={},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/coupons/{couponId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => new \stdClass(),
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "deal": {
    "amount": "88400.00",
    "currency": "UAH",
    "amountSource": "products",
    "version": 9
  },
  "discounts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000a03",
      "kind": "coupon",
      "couponId": "0192f3a1-7c2e-7b4d-9a61-000000000a01",
      "name": "Black Friday",
      "discount": {
        "type": "amount",
        "value": "1000.00"
      },
      "currency": "UAH",
      "minimumAmount": "20000.00",
      "targeted": false,
      "position": 1,
      "amount": "1000.00",
      "lineIds": [
        "0192f3a1-7c2e-7b4d-9a61-000000000901",
        "0192f3a1-7c2e-7b4d-9a61-000000000902"
      ],
      "inactiveReason": null,
      "capPercent": null,
      "targets": null
    }
  ]
}
Поля ответа
  • deal object

    Вложенные поля: 4
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • amountSource string

      Значения: manual products

    • currency string

      шаблон ^[A-Z]{3}$

    • version integer

      ≥ 1

  • discounts object[]

    Вложенные поля: 14
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • capPercent string | null

      шаблон ^[0-9]{1,3}\.[0-9]{2}$

    • couponId string · uuid | null

    • currency string | null

      шаблон ^[A-Z]{3}$

    • discount object

      Вложенные поля: 2
      • type string

        Значения: percent amount

      • value string

        шаблон ^[0-9]+\.[0-9]{2}$

    • id string · uuid

    • inactiveReason string | null

      Значения: amount_typed used_up used_by_client other_currency no_matching_products below_minimum

    • kind string

      Значения: coupon manual

    • lineIds string[] · uuid

    • minimumAmount string | null

      шаблон ^[0-9]+\.[0-9]{2}$

    • name string | null

    • position integer

      ≥ 1

    • targeted boolean

    • targets object | null

      Вложенные поля: 2
      • categoryIds string[] · uuid

      • productIds string[] · uuid

Убрать купон со сделки

DELETE /deals/{dealId}/discounts/coupons/{couponId}

Использование купона возвращается, остальные скидки сделки раскладываются заново. Купона на сделке нет — ничего не меняется.

Параметры пути

  • couponId string · uuid обязательно

  • dealId string · uuid обязательно

Пример запроса

bash
curl -X DELETE 'https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/coupons/{couponId}' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/coupons/{couponId}', {
  method: 'DELETE',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.delete(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/coupons/{couponId}",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/coupons/{couponId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "deal": {
    "amount": "89400.00",
    "currency": "UAH",
    "amountSource": "products",
    "version": 10
  },
  "discounts": []
}

Поля — как в ответе Применить купон к сделке

Скидка на всю сделку

PUT /deals/{dealId}/discounts/manual

Скидка сделки без купона (право «Менять цену в сделке», иначе 403): percent — процент от того, что осталось от сделки к её очереди (больше 0, не больше 100), или amount — сумма в валюте сделки (не больше того, что осталось). Одна на сделку; изменённая остаётся на своём месте среди скидок и раскладывается по строкам, как купон. Не больше «Максимальной скидки» роли (403 discount_above_role_cap). Та же скидка ещё раз ничего не меняет. 409 imported_lines, amount_kept_by_sync, amount_not_from_products. Предел роли того, кто дал скидку, остаётся с ней (capPercent): она никогда не берёт больше этой доли того, что осталось, как бы ни менялись строки потом.

Параметры пути

  • dealId string · uuid обязательно

Тело запроса

  • type string обязательно

    A percentage of the price before the discount (`percent`) or an amount of the line's currency (`amount`), per unit

    Значения: percent amount

  • value string | number обязательно

    шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

Пример запроса

bash
curl -X PUT 'https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/manual' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "type": "percent",
  "value": "5"
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/manual', {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    type: 'percent',
    value: '5',
  }),
});
const data = await response.json();
python
import requests

response = requests.put(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/manual",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "type": "percent",
        "value": "5",
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/manual', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'type' => 'percent',
        'value' => '5',
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "deal": {
    "amount": "84930.00",
    "currency": "UAH",
    "amountSource": "products",
    "version": 11
  },
  "discounts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000a04",
      "kind": "manual",
      "couponId": null,
      "name": null,
      "discount": {
        "type": "percent",
        "value": "5.00"
      },
      "currency": null,
      "minimumAmount": null,
      "targeted": false,
      "position": 1,
      "amount": "4470.00",
      "lineIds": [
        "0192f3a1-7c2e-7b4d-9a61-000000000901",
        "0192f3a1-7c2e-7b4d-9a61-000000000902"
      ],
      "inactiveReason": null,
      "capPercent": "10.00",
      "targets": null
    }
  ]
}

Поля — как в ответе Применить купон к сделке

Убрать скидку на сделку

DELETE /deals/{dealId}/discounts/manual

Право «Менять цену в сделке», иначе 403; остальные скидки раскладываются заново. Скидки нет — ничего не меняется.

Параметры пути

  • dealId string · uuid обязательно

Пример запроса

bash
curl -X DELETE 'https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/manual' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/manual', {
  method: 'DELETE',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.delete(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/manual",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/discounts/manual', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "deal": {
    "amount": "89400.00",
    "currency": "UAH",
    "amountSource": "products",
    "version": 12
  },
  "discounts": []
}

Поля — как в ответе Применить купон к сделке

Товары сделки

GET /deals/{dealId}/products

Строки сделки по порядку: товар каталога и цена, по которой его взяли; название, артикул и единица — какими были в момент добавления; количество, цена за единицу, по которой строка продаётся (price), своя цена строки до скидки (priceBeforeDiscount) и скидка (discount, null — без скидки), цена каталога в тот момент (listPrice) и сумма строки: количество × price. Строки другой системы (imported) только для чтения. amountSource: сумма сделки введена вручную (manual) или считается из её товаров (products).

Параметры пути

  • dealId string · uuid обязательно

Пример запроса

bash
curl 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/products', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.get(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/products",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "items": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000901",
      "productId": "0192f3a1-7c2e-7b4d-9a61-000000000066",
      "priceId": "0192f3a1-7c2e-7b4d-9a61-000000000068",
      "rateId": "0192f3a1-7c2e-7b4d-9a61-00000000006b",
      "name": "Кофемашина Jura E8",
      "sku": "JE8-01",
      "unit": "шт",
      "quantity": "2",
      "price": "42000.00",
      "priceBeforeDiscount": "42000.00",
      "discount": null,
      "listPrice": "45000.00",
      "amount": "84000.00",
      "discounts": [],
      "total": "84000.00",
      "currency": "UAH",
      "position": 1,
      "version": 2,
      "imported": false
    },
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000902",
      "productId": "0192f3a1-7c2e-7b4d-9a61-000000000067",
      "priceId": "0192f3a1-7c2e-7b4d-9a61-00000000006a",
      "rateId": "0192f3a1-7c2e-7b4d-9a61-00000000006d",
      "name": "Сервис кофемашины на год",
      "sku": null,
      "unit": "год",
      "quantity": "1",
      "price": "5400.00",
      "priceBeforeDiscount": "6000.00",
      "discount": {
        "type": "percent",
        "value": "10.00"
      },
      "listPrice": "6000.00",
      "amount": "5400.00",
      "discounts": [],
      "total": "5400.00",
      "currency": "UAH",
      "position": 2,
      "version": 1,
      "imported": false
    }
  ],
  "totals": [
    {
      "currency": "UAH",
      "amount": "89400.00"
    }
  ],
  "amountSource": "products",
  "amountKeptBySync": false,
  "discounts": []
}
Поля ответа
  • amountSource string

    Where the deal's amount comes from: typed (`manual`) or the sum of its own product lines (`products`)

    Значения: manual products

  • discounts object[]

    Вложенные поля: 14
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • capPercent string | null

      шаблон ^[0-9]{1,3}\.[0-9]{2}$

    • couponId string · uuid | null

    • currency string | null

      шаблон ^[A-Z]{3}$

    • discount object

      Вложенные поля: 2
      • type string

        Значения: percent amount

      • value string

        шаблон ^[0-9]+\.[0-9]{2}$

    • id string · uuid

    • inactiveReason string | null

      Значения: amount_typed used_up used_by_client other_currency no_matching_products below_minimum

    • kind string

      Значения: coupon manual

    • lineIds string[] · uuid

    • minimumAmount string | null

      шаблон ^[0-9]+\.[0-9]{2}$

    • name string | null

    • position integer

      ≥ 1

    • targeted boolean

    • targets object | null

      Вложенные поля: 2
      • categoryIds string[] · uuid

      • productIds string[] · uuid

  • items object[]

    Вложенные поля: 20
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • currency string

      шаблон ^[A-Z]{3}$

    • discount object | null

      Вложенные поля: 2
      • type string

        A percentage of the price before the discount (`percent`) or an amount of the line's currency (`amount`), per unit

        Значения: percent amount

      • value string

        шаблон ^[0-9]+\.[0-9]{2}$

    • discounts object[]

      Вложенные поля: 2
      • amount string

        шаблон ^[0-9]+\.[0-9]{2}$

      • discountId string · uuid

    • id string · uuid

    • imported boolean

    • listPrice string | null

      шаблон ^[0-9]+\.[0-9]{2}$

    • name string

    • position integer

    • price string

      шаблон ^[0-9]+\.[0-9]{2}$

    • priceBeforeDiscount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • priceId string · uuid | null

    • productId string · uuid | null

    • quantity string

    • rateId string · uuid | null

    • sku string | null

    • total string

      шаблон ^[0-9]+\.[0-9]{2}$

    • unit string | null

    • version integer

      ≥ 1

    • tax object | null

      Вложенные поля: 6
      • amount string

        шаблон ^[0-9]+\.[0-9]{2}$

      • base string

        шаблон ^[0-9]+\.[0-9]{2}$

      • inclusive boolean

      • name string

      • rate string

        шаблон ^[0-9]{1,3}\.[0-9]{2}$

      • taxRateId string · uuid

  • totals object[]

    Вложенные поля: 2
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • currency string

      шаблон ^[A-Z]{3}$

  • amountKeptBySync boolean

    True while another system's import writes the deal's amount: its own lines are kept but never make the amount, and amount-source stays `manual`

  • taxes object[]

    Вложенные поля: 6
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • base string

      шаблон ^[0-9]+\.[0-9]{2}$

    • inclusive boolean

    • name string

    • rate string

      шаблон ^[0-9]{1,3}\.[0-9]{2}$

    • taxRateId string · uuid

Добавить товар в сделку

POST /deals/{dealId}/products

Товар каталога встаёт в конец, в валюте сделки: priceId — одна из его цен в этой валюте (без него — основная, иначе самая ранняя из них), или price — своя цена за единицу (нужно право «Менять цену в сделке», иначе 403). Первый товар сделки с суммой «вручную» переключает её на сумму товаров (amountSourceChanged). Без цены в валюте сделки и без своей — 409 no_price_in_currency; товар в архиве — 409 product_archived; у сделки есть строки другой системы — 409 imported_lines; больше 200 строк — 409 too_many_lines. discount — скидка на единицу (право «Менять цену в сделке», иначе 403): percent — процент от цены строки (больше 0, не больше 100) или amount — сумма в валюте сделки (больше 0); цена за единицу — цена строки минус скидка, округлённая до копейки (половина — вверх), не ниже 0. Сделка, сумму которой пишет импорт другой системы, скидку не принимает: 409 amount_kept_by_sync. Повтор с тем же idempotencyKey после потерянного ответа вернёт ту же строку.

Параметры пути

  • dealId string · uuid обязательно

Тело запроса

  • productId string · uuid обязательно

  • discount object

    Вложенные поля: 2
    • type string обязательно

      A percentage of the price before the discount (`percent`) or an amount of the line's currency (`amount`), per unit

      Значения: percent amount

    • value string | number обязательно

      шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

  • idempotencyKey string

    шаблон ^[\x21-\x7e]{1,255}$

  • price string | number

    шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

  • priceId string · uuid

  • quantity string | number

    шаблон ^[0-9]{1,8}(\.[0-9]{1,3})?$ · > 0, ≤ 99999999.999

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "productId": "0192f3a1-7c2e-7b4d-9a61-000000000067",
  "priceId": "0192f3a1-7c2e-7b4d-9a61-00000000006a",
  "quantity": "1",
  "discount": {
    "type": "percent",
    "value": "10"
  }
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/products', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    productId: '0192f3a1-7c2e-7b4d-9a61-000000000067',
    priceId: '0192f3a1-7c2e-7b4d-9a61-00000000006a',
    quantity: '1',
    discount: {
      type: 'percent',
      value: '10',
    },
  }),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/products",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "productId": "0192f3a1-7c2e-7b4d-9a61-000000000067",
        "priceId": "0192f3a1-7c2e-7b4d-9a61-00000000006a",
        "quantity": "1",
        "discount": {
            "type": "percent",
            "value": "10",
        },
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'productId' => '0192f3a1-7c2e-7b4d-9a61-000000000067',
        'priceId' => '0192f3a1-7c2e-7b4d-9a61-00000000006a',
        'quantity' => '1',
        'discount' => [
            'type' => 'percent',
            'value' => '10',
        ],
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 201

Успешный ответ.

json
{
  "line": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000902",
    "productId": "0192f3a1-7c2e-7b4d-9a61-000000000067",
    "priceId": "0192f3a1-7c2e-7b4d-9a61-00000000006a",
    "rateId": "0192f3a1-7c2e-7b4d-9a61-00000000006d",
    "name": "Сервис кофемашины на год",
    "sku": null,
    "unit": "год",
    "quantity": "1",
    "price": "5400.00",
    "priceBeforeDiscount": "6000.00",
    "discount": {
      "type": "percent",
      "value": "10.00"
    },
    "listPrice": "6000.00",
    "amount": "5400.00",
    "discounts": [],
    "total": "5400.00",
    "currency": "UAH",
    "position": 2,
    "version": 1,
    "imported": false
  },
  "deal": {
    "amount": "89400.00",
    "currency": "UAH",
    "amountSource": "products",
    "version": 5
  }
}
Поля ответа
  • deal object

    Вложенные поля: 4
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • amountSource string

      Where the deal's amount comes from: typed (`manual`) or the sum of its own product lines (`products`)

      Значения: manual products

    • currency string

      шаблон ^[A-Z]{3}$

    • version integer

      ≥ 1

  • line object

    Вложенные поля: 20
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • currency string

      шаблон ^[A-Z]{3}$

    • discount object | null

      Вложенные поля: 2
      • type string

        A percentage of the price before the discount (`percent`) or an amount of the line's currency (`amount`), per unit

        Значения: percent amount

      • value string

        шаблон ^[0-9]+\.[0-9]{2}$

    • discounts object[]

      Вложенные поля: 2
      • amount string

        шаблон ^[0-9]+\.[0-9]{2}$

      • discountId string · uuid

    • id string · uuid

    • imported boolean

    • listPrice string | null

      шаблон ^[0-9]+\.[0-9]{2}$

    • name string

    • position integer

    • price string

      шаблон ^[0-9]+\.[0-9]{2}$

    • priceBeforeDiscount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • priceId string · uuid | null

    • productId string · uuid | null

    • quantity string

    • rateId string · uuid | null

    • sku string | null

    • total string

      шаблон ^[0-9]+\.[0-9]{2}$

    • unit string | null

    • version integer

      ≥ 1

    • tax object | null

      Вложенные поля: 6
      • amount string

        шаблон ^[0-9]+\.[0-9]{2}$

      • base string

        шаблон ^[0-9]+\.[0-9]{2}$

      • inclusive boolean

      • name string

      • rate string

        шаблон ^[0-9]{1,3}\.[0-9]{2}$

      • taxRateId string · uuid

  • amountSourceChanged boolean

Изменить товар сделки

PATCH /deals/{dealId}/products/{lineId}

Количество, другая цена товара в валюте сделки (priceId: её сумма становится ценой строки) или своя цена (price, право «Менять цену в сделке»). Без discount price и priceId — цена, по которой строка продаётся, как до скидок: та же, что сейчас (прочитанная строка, отправленная обратно), ничего не меняет, скидка остаётся; другая — строка продаётся ровно по ней, скидка снимается. С discount (то же право, если скидка меняется) price и priceId — цена до скидки, а discount — скидка строки на единицу (null — без скидки); но price, равная цене продажи, вместе с той же скидкой (прочитанная строка, отправленная целиком) ничего не меняет — скидка не применяется дважды. Изменение одного количества скидку сохраняет. С version строки, которую вы прочитали: её успели изменить — 409. Строка другой системы — 409 imported_line. Пока сумма сделки из товаров, она пересчитывается.

Параметры пути

  • dealId string · uuid обязательно

  • lineId string · uuid обязательно

Тело запроса

  • discount object | null

    Вложенные поля: 2
    • type string обязательно

      A percentage of the price before the discount (`percent`) or an amount of the line's currency (`amount`), per unit

      Значения: percent amount

    • value string | number обязательно

      шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

  • price string | number

    шаблон ^[0-9]{1,12}(\.[0-9]{1,2})?$ · 0–999999999999.99

  • priceId string · uuid

  • quantity string | number

    шаблон ^[0-9]{1,8}(\.[0-9]{1,3})?$ · > 0, ≤ 99999999.999

  • version integer

    ≥ 1

Пример запроса

bash
curl -X PATCH 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products/{lineId}' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "quantity": "2",
  "price": "42000",
  "version": 1
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/products/{lineId}', {
  method: 'PATCH',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    quantity: '2',
    price: '42000',
    version: 1,
  }),
});
const data = await response.json();
python
import requests

response = requests.patch(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/products/{lineId}",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "quantity": "2",
        "price": "42000",
        "version": 1,
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products/{lineId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'quantity' => '2',
        'price' => '42000',
        'version' => 1,
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "line": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000901",
    "productId": "0192f3a1-7c2e-7b4d-9a61-000000000066",
    "priceId": "0192f3a1-7c2e-7b4d-9a61-000000000068",
    "rateId": "0192f3a1-7c2e-7b4d-9a61-00000000006b",
    "name": "Кофемашина Jura E8",
    "sku": "JE8-01",
    "unit": "шт",
    "quantity": "2",
    "price": "42000.00",
    "priceBeforeDiscount": "42000.00",
    "discount": null,
    "listPrice": "45000.00",
    "amount": "84000.00",
    "discounts": [],
    "total": "84000.00",
    "currency": "UAH",
    "position": 1,
    "version": 2,
    "imported": false
  },
  "deal": {
    "amount": "89400.00",
    "currency": "UAH",
    "amountSource": "products",
    "version": 6
  }
}

Поля — как в ответе Добавить товар в сделку

Убрать товар из сделки

DELETE /deals/{dealId}/products/{lineId}

Строку другой системы не убрать (409 imported_line). Пока сумма сделки из товаров, она пересчитывается; в ответе — новая сумма сделки. Когда убрана последняя своя строка, сумма снова вводится вручную (amountSource manual) и остаётся такой, какой была с этой строкой.

Параметры пути

  • dealId string · uuid обязательно

  • lineId string · uuid обязательно

Пример запроса

bash
curl -X DELETE 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products/{lineId}' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/products/{lineId}', {
  method: 'DELETE',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.delete(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/products/{lineId}",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products/{lineId}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "deal": {
    "amount": "84000.00",
    "currency": "UAH",
    "amountSource": "products",
    "version": 7
  }
}
Поля ответа
  • deal object

    Вложенные поля: 4
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • amountSource string

      Where the deal's amount comes from: typed (`manual`) or the sum of its own product lines (`products`)

      Значения: manual products

    • currency string

      шаблон ^[A-Z]{3}$

    • version integer

      ≥ 1

Порядок товаров сделки

PUT /deals/{dealId}/products/order

lineIds — все строки самой сделки ровно по разу, в новом порядке (иначе 409 order_mismatch); строки другой системы стоят на своих местах. В истории сделки не отмечается.

Параметры пути

  • dealId string · uuid обязательно

Тело запроса

  • lineIds string[] · uuid обязательно

    количество ≤ 400 · без повторов

Пример запроса

bash
curl -X PUT 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products/order' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "lineIds": [
    "0192f3a1-7c2e-7b4d-9a61-000000000902",
    "0192f3a1-7c2e-7b4d-9a61-000000000901"
  ]
}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/products/order', {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    lineIds: [
      '0192f3a1-7c2e-7b4d-9a61-000000000902',
      '0192f3a1-7c2e-7b4d-9a61-000000000901',
    ],
  }),
});
const data = await response.json();
python
import requests

response = requests.put(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/products/order",
    headers={"Authorization": "Bearer alta_…"},
    json={
        "lineIds": [
            "0192f3a1-7c2e-7b4d-9a61-000000000902",
            "0192f3a1-7c2e-7b4d-9a61-000000000901",
        ],
    },
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/products/order', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => [
        'lineIds' => [
            '0192f3a1-7c2e-7b4d-9a61-000000000902',
            '0192f3a1-7c2e-7b4d-9a61-000000000901',
        ],
    ],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "items": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000902",
      "productId": "0192f3a1-7c2e-7b4d-9a61-000000000067",
      "priceId": "0192f3a1-7c2e-7b4d-9a61-00000000006a",
      "rateId": "0192f3a1-7c2e-7b4d-9a61-00000000006d",
      "name": "Сервис кофемашины на год",
      "sku": null,
      "unit": "год",
      "quantity": "1",
      "price": "5400.00",
      "priceBeforeDiscount": "6000.00",
      "discount": {
        "type": "percent",
        "value": "10.00"
      },
      "listPrice": "6000.00",
      "amount": "5400.00",
      "discounts": [],
      "total": "5400.00",
      "currency": "UAH",
      "position": 1,
      "version": 1,
      "imported": false
    },
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000901",
      "productId": "0192f3a1-7c2e-7b4d-9a61-000000000066",
      "priceId": "0192f3a1-7c2e-7b4d-9a61-000000000068",
      "rateId": "0192f3a1-7c2e-7b4d-9a61-00000000006b",
      "name": "Кофемашина Jura E8",
      "sku": "JE8-01",
      "unit": "шт",
      "quantity": "2",
      "price": "42000.00",
      "priceBeforeDiscount": "42000.00",
      "discount": null,
      "listPrice": "45000.00",
      "amount": "84000.00",
      "discounts": [],
      "total": "84000.00",
      "currency": "UAH",
      "position": 2,
      "version": 2,
      "imported": false
    }
  ]
}
Поля ответа
  • items object[]

    Вложенные поля: 20
    • amount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • currency string

      шаблон ^[A-Z]{3}$

    • discount object | null

      Вложенные поля: 2
      • type string

        A percentage of the price before the discount (`percent`) or an amount of the line's currency (`amount`), per unit

        Значения: percent amount

      • value string

        шаблон ^[0-9]+\.[0-9]{2}$

    • discounts object[]

      Вложенные поля: 2
      • amount string

        шаблон ^[0-9]+\.[0-9]{2}$

      • discountId string · uuid

    • id string · uuid

    • imported boolean

    • listPrice string | null

      шаблон ^[0-9]+\.[0-9]{2}$

    • name string

    • position integer

    • price string

      шаблон ^[0-9]+\.[0-9]{2}$

    • priceBeforeDiscount string

      шаблон ^[0-9]+\.[0-9]{2}$

    • priceId string · uuid | null

    • productId string · uuid | null

    • quantity string

    • rateId string · uuid | null

    • sku string | null

    • total string

      шаблон ^[0-9]+\.[0-9]{2}$

    • unit string | null

    • version integer

      ≥ 1

    • tax object | null

      Вложенные поля: 6
      • amount string

        шаблон ^[0-9]+\.[0-9]{2}$

      • base string

        шаблон ^[0-9]+\.[0-9]{2}$

      • inclusive boolean

      • name string

      • rate string

        шаблон ^[0-9]{1,3}\.[0-9]{2}$

      • taxRateId string · uuid

Восстановить сделку

POST /deals/{dealId}/restore

Возвращает сделку из корзины такой, какой она была, вместе с задачами. Удалённая навсегда — 404. Сделка в корзине не держит значений уникальных полей: если одно из них тем временем взяла другая сделка — 409 VALUE_TAKEN (error.taken).

Параметры пути

  • dealId string · uuid обязательно

Пример запроса

bash
curl -X POST 'https://your-company.altahub.ai/api/v1/deals/{dealId}/restore' \
  -H 'Authorization: Bearer alta_…' \
  -H 'Content-Type: application/json' \
  -d '{}'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/{dealId}/restore', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer alta_…',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({}),
});
const data = await response.json();
python
import requests

response = requests.post(
    "https://your-company.altahub.ai/api/v1/deals/{dealId}/restore",
    headers={"Authorization": "Bearer alta_…"},
    json={},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://your-company.altahub.ai/api/v1/deals/{dealId}/restore', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
    'json' => new \stdClass(),
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "number": 1042,
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000020",
  "status": "open",
  "position": 1,
  "stageEnteredAt": "2026-10-21T12:40:00Z",
  "closedAt": null,
  "expectedCloseDate": "2026-11-15",
  "description": "Три кофемашины и сервис на год",
  "owner": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "contact": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
    "fullName": "Елена Коваль",
    "phone": "+380501234567"
  },
  "contacts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
      "fullName": "Елена Коваль",
      "phone": "+380501234567",
      "email": "olena.koval@kavova.ua",
      "jobTitle": "Менеджер по закупкам",
      "primary": true
    }
  ],
  "company": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
    "name": "ООО «Кофейная гильдия»"
  },
  "tags": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000028",
      "name": "VIP",
      "color": "purple"
    }
  ],
  "customFields": [
    {
      "fieldId": "0192f3a1-7c2e-7b4d-9a61-000000000032",
      "value": "Киев"
    }
  ],
  "nextTask": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000003c",
    "title": "Перезвонить по счёту",
    "kind": "call",
    "dueAt": "2026-10-28T10:00:00Z",
    "overdue": false,
    "type": null
  },
  "deletedAt": null,
  "inTrash": false,
  "deletedBy": null,
  "mergedInto": null,
  "mergedAway": false,
  "createdAt": "2026-10-20T08:15:00Z",
  "updatedAt": "2026-10-24T16:45:00Z",
  "version": 6
}

Поля — как в ответе Создать сделку

Сделка по номеру

GET /deals/by-number/{number}

Сделка по её номеру в организации, а импортированная — ещё и по id в прежней системе.

Параметры пути

  • number string обязательно

    шаблон ^[1-9][0-9]{0,8}$

Пример запроса

bash
curl 'https://your-company.altahub.ai/api/v1/deals/by-number/{number}' \
  -H 'Authorization: Bearer alta_…'
js
const response = await fetch('https://your-company.altahub.ai/api/v1/deals/by-number/{number}', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer alta_…',
  },
});
const data = await response.json();
python
import requests

response = requests.get(
    "https://your-company.altahub.ai/api/v1/deals/by-number/{number}",
    headers={"Authorization": "Bearer alta_…"},
)
data = response.json()
php
<?php
$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://your-company.altahub.ai/api/v1/deals/by-number/{number}', [
    'headers' => ['Authorization' => 'Bearer alta_…'],
]);
$data = json_decode((string) $response->getBody(), true);

Ответ 200

Успешный ответ.

json
{
  "id": "0192f3a1-7c2e-7b4d-9a61-000000000014",
  "number": 1042,
  "title": "Кофемашины для сети кофеен",
  "amount": "12000.00",
  "currency": "UAH",
  "pipelineId": "0192f3a1-7c2e-7b4d-9a61-00000000001e",
  "stageId": "0192f3a1-7c2e-7b4d-9a61-000000000020",
  "status": "open",
  "position": 1,
  "stageEnteredAt": "2026-10-21T12:40:00Z",
  "closedAt": null,
  "expectedCloseDate": "2026-11-15",
  "description": "Три кофемашины и сервис на год",
  "owner": {
    "id": "0192f3a1-7c2e-7b4d-9a61-000000000002",
    "name": "Ирина Мельник"
  },
  "contact": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
    "fullName": "Елена Коваль",
    "phone": "+380501234567"
  },
  "contacts": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-00000000000a",
      "fullName": "Елена Коваль",
      "phone": "+380501234567",
      "email": "olena.koval@kavova.ua",
      "jobTitle": "Менеджер по закупкам",
      "primary": true
    }
  ],
  "company": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000000b",
    "name": "ООО «Кофейная гильдия»"
  },
  "tags": [
    {
      "id": "0192f3a1-7c2e-7b4d-9a61-000000000028",
      "name": "VIP",
      "color": "purple"
    }
  ],
  "customFields": [
    {
      "fieldId": "0192f3a1-7c2e-7b4d-9a61-000000000032",
      "value": "Киев"
    }
  ],
  "nextTask": {
    "id": "0192f3a1-7c2e-7b4d-9a61-00000000003c",
    "title": "Перезвонить по счёту",
    "kind": "call",
    "dueAt": "2026-10-28T10:00:00Z",
    "overdue": false,
    "type": null
  },
  "deletedAt": null,
  "inTrash": false,
  "deletedBy": null,
  "mergedInto": null,
  "mergedAway": false,
  "createdAt": "2026-10-20T08:15:00Z",
  "updatedAt": "2026-10-24T16:45:00Z",
  "version": 4
}

Поля — как в ответе Создать сделку