---
title: "Привязка продажи к шаблону — предпросмотр"
method: GET
path: "/api/v1/docflow/sales/{id}/template-bind"
tags: ["Docflow flow"]
---

# Привязка продажи к шаблону — предпросмотр

`GET /api/v1/docflow/sales/{id}/template-bind`

## Request

- Base URL: `https://erp.akeda.ru`
- URL: `https://erp.akeda.ru/api/v1/docflow/sales/{id}/template-bind`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-Api-Key`
  - OAuth 2
    - Authorization code: `https://erp.akeda.ru/oauth2/authorize`
    - Token URL: `https://erp.akeda.ru/oauth2/token` scopes: `akeda:delegate`

Подходящие шаблоны и свободные периоды, какие выпущенные документы засчитаются, что и когда будет выпущено и чем отличается сумма. Ничего не пишет.

## Path parameters

- `id` string, uuid, required

## Query parameters

- `template_id` string, uuid
- `key` string

## Headers

- `X-Tenant` string, required

## Response `200`

Что будет после привязки

- DocflowSaleTemplateBindPreview
  - `templates` object[], required
    - `id` string, uuid, required
    - `title` string, required
    - `state` string, required
  - `template_id` string, uuid
  - `key` string
  - `periods` object[], required
    - `run` CoreOrderTemplateRun, required
      - `key` string, required
      - `date` string, date, required
      - `invoice_date` string, date
      - `closing_date` string, date
      - `amount` string: Period sale amount by template lines and dated prices.
      - `service_from` string, date: Service period start (prorated and rolling modes).
      - `service_until` string, date: Service period end, inclusive.
      - `days` integer: Partial first month: billed days.
      - `period_days` integer: Partial first month: days in the month.
      - `papers` CoreOrderTemplateRunPaper[]
        - `kind` 'invoice' | 'closing', required
        - `index` integer, required
        - `title` string
        - `mode` string
        - `date` string, date, required
        - `due_date` string, date
        - `amount` string
    - `suggested` boolean, required
  - `counted` object[], required
    - `row` DocflowSalePaperRow, required
      - `kind` 'invoice' | 'closing', required: Счёт или закрывающий
      - `index` integer, required: Номер строки своего вида; у новой строки не передаётся; −1 — одиночный документ прежнего шаблона
      - `title` string: Название счёта
      - `mode` 'issue' | 'draft' | 'upd' | 'act' | 'business_act', required: Счёт: issue — выставить, draft — черновиком; закрывающий: upd, act или business_act
      - `date` string, date, required: Дата документа
      - `due_date` string, date: Оплатить до — не раньше даты счёта
      - `amount` string: Сумма счёта
      - `payment_term_id` string, uuid: Строка условий оплаты продажи
      - `delivery` CoreOrderTemplateDelivery: Independent delivery policy for newly issued template documents. Email uses the shared idempotent queue; EDI awaits manual signing and sending.
        - `channel` 'mail' | 'edo', required
        - `account_id` string, uuid: Mailbox visible to the template author; required for mail.
        - `connection_id` string, uuid: EDI connection; required for edo.
        - `to` string[]
        - `subject` string: Email subject; supports {kind}, {number}, {date} and {client}.
        - `body` string: Email plain text; supports {kind}, {number}, {date} and {client}.
        - `with_xml` boolean: Attach XML in the FTS format to the letter (UTD only). Off by default.
        - `since` string, date-time: Server managed first activation timestamp. Historical documents are excluded.
      - `delivery_alt` CoreOrderTemplateDelivery: Independent delivery policy for newly issued template documents. Email uses the shared idempotent queue; EDI awaits manual signing and sending.
        - `channel` 'mail' | 'edo', required
        - `account_id` string, uuid: Mailbox visible to the template author; required for mail.
        - `connection_id` string, uuid: EDI connection; required for edo.
        - `to` string[]
        - `subject` string: Email subject; supports {kind}, {number}, {date} and {client}.
        - `body` string: Email plain text; supports {kind}, {number}, {date} and {client}.
        - `with_xml` boolean: Attach XML in the FTS format to the letter (UTD only). Off by default.
        - `since` string, date-time: Server managed first activation timestamp. Historical documents are excluded.
      - `manual` boolean: Дата прошла — сам документ не выпускается
      - `removed` boolean
      - `from_template` boolean: Строка пришла из шаблона
      - `edited` boolean: Строку изменили в продаже
      - `state` 'planned' | 'issued' | 'missed' | 'stopped' | 'failed'
      - `reason` string: Код причины остановки или отказа
      - `document_id` string, uuid: Выпущенный документ
      - `document_number` string
    - `document` object, required
      - `id` string, uuid, required
      - `kind` string, required
      - `number` string, required
      - `date` string, required
      - `amount` string, required
    - `amount_differs` boolean, required
  - `planned` DocflowSalePaperRow[], required
    - `kind` 'invoice' | 'closing', required: Счёт или закрывающий
    - `index` integer, required: Номер строки своего вида; у новой строки не передаётся; −1 — одиночный документ прежнего шаблона
    - `title` string: Название счёта
    - `mode` 'issue' | 'draft' | 'upd' | 'act' | 'business_act', required: Счёт: issue — выставить, draft — черновиком; закрывающий: upd, act или business_act
    - `date` string, date, required: Дата документа
    - `due_date` string, date: Оплатить до — не раньше даты счёта
    - `amount` string: Сумма счёта
    - `payment_term_id` string, uuid: Строка условий оплаты продажи
    - `delivery` CoreOrderTemplateDelivery: Independent delivery policy for newly issued template documents. Email uses the shared idempotent queue; EDI awaits manual signing and sending.
      - `channel` 'mail' | 'edo', required
      - `account_id` string, uuid: Mailbox visible to the template author; required for mail.
      - `connection_id` string, uuid: EDI connection; required for edo.
      - `to` string[]
      - `subject` string: Email subject; supports {kind}, {number}, {date} and {client}.
      - `body` string: Email plain text; supports {kind}, {number}, {date} and {client}.
      - `with_xml` boolean: Attach XML in the FTS format to the letter (UTD only). Off by default.
      - `since` string, date-time: Server managed first activation timestamp. Historical documents are excluded.
    - `delivery_alt` CoreOrderTemplateDelivery: Independent delivery policy for newly issued template documents. Email uses the shared idempotent queue; EDI awaits manual signing and sending.
      - `channel` 'mail' | 'edo', required
      - `account_id` string, uuid: Mailbox visible to the template author; required for mail.
      - `connection_id` string, uuid: EDI connection; required for edo.
      - `to` string[]
      - `subject` string: Email subject; supports {kind}, {number}, {date} and {client}.
      - `body` string: Email plain text; supports {kind}, {number}, {date} and {client}.
      - `with_xml` boolean: Attach XML in the FTS format to the letter (UTD only). Off by default.
      - `since` string, date-time: Server managed first activation timestamp. Historical documents are excluded.
    - `manual` boolean: Дата прошла — сам документ не выпускается
    - `removed` boolean
    - `from_template` boolean: Строка пришла из шаблона
    - `edited` boolean: Строку изменили в продаже
    - `state` 'planned' | 'issued' | 'missed' | 'stopped' | 'failed'
    - `reason` string: Код причины остановки или отказа
    - `document_id` string, uuid: Выпущенный документ
    - `document_number` string
  - `order_amount` string, required
  - `template_amount` string, required
  - `amount_differs` boolean, required

## Other responses

- `400`: Некорректный запрос или нарушение бизнес-правила
- `401`: Сессия, ключ или кабинет не подтверждены
- `403`: Текущая роль не имеет требуемого права
- `404`: Запись не найдена или не видима текущему пользователю
- `409`: Конфликт версии, идемпотентности или бизнес-состояния
- `503`: Внешний банк, справочник или контур подключений временно недоступен

## Changes

- **2026-12-04** `5fafde39edb6`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/akeda/apis/akeda-erp-client-api/changes/api/v1/docflow/sales/:id/template-bind/get.md)

---

[API](https://skmtc.dev/akeda/apis/akeda-erp-client-api.md) - [All operations](https://skmtc.dev/akeda/apis/akeda-erp-client-api/llms.txt) - [OpenAPI document](https://skmtc.dev/akeda/apis/akeda-erp-client-api/revisions/084f7bbc939c?raw)
