До змісту
Скачати OpenAPI

Угоди

Угоди у воронках: список, картка, створення і зміна, перехід етапами, контакти угоди.

Список угод

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
}

Поля — як у відповіді Створити угоду