# Шаблоны

> REST API раздела «Шаблоны»: 78 операций.

Базовый адрес: `https://api.legalstack.ru`. Спецификация: [openapi/smartdoc.json](https://docs.legalstack.ru/openapi/smartdoc.json).

- [AI-инструменты](https://docs.legalstack.ru/api/smartdoc/smartdoc-ai): AI-функции при работе с текстом шаблона.
- [Совместное редактирование](https://docs.legalstack.ru/api/smartdoc/smartdoc-collaboration): Совместное редактирование шаблонов в реальном времени.
- [Шаблоны и блоки](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents): Создание шаблонов и управление их блоками.
- [Папки](https://docs.legalstack.ru/api/smartdoc/smartdoc-folders): Папки шаблонов.
- [Импорт и экспорт](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export): Импорт шаблонов из DOCX, PDF и HTML, экспорт в DOCX и PDF.
- [Связи с реестрами](https://docs.legalstack.ru/api/smartdoc/smartdoc-links): Связи шаблонов с записями реестров.
- [Типы блоков и роли сторон](https://docs.legalstack.ru/api/smartdoc/smartdoc-schemas): Типы блоков и роли сторон по типам договоров.
- [Доступ и приглашения](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares): Доступ к шаблонам и приглашения.

## Операции

Всего операций: 78. У каждой операции своя страница со схемами запроса и ответа и примерами вызова.

### [AI-инструменты](https://docs.legalstack.ru/api/smartdoc/smartdoc-ai)

| Метод | Путь | Операция |
| --- | --- | --- |
| `POST` | `/api/v1/smartdoc/ai/transform` | [ИИ-обработка текста](https://docs.legalstack.ru/api/smartdoc/smartdoc-ai/post-smartdoc-ai-transform) |

### [Совместное редактирование](https://docs.legalstack.ru/api/smartdoc/smartdoc-collaboration)

| Метод | Путь | Операция |
| --- | --- | --- |
| `POST` | `/api/v1/smartdoc/documents/{id}/comments/notify` | [Уведомить участников о новом комментарии к шаблону](https://docs.legalstack.ru/api/smartdoc/smartdoc-collaboration/post-smartdoc-documents-id-comments-notify) |
| `GET` | `/api/v1/smartdoc/documents/{id}/yjs` | [Получить состояние шаблона для совместного редактирования (Yjs CRDT, бинарный формат)](https://docs.legalstack.ru/api/smartdoc/smartdoc-collaboration/get-smartdoc-documents-id-yjs) |

### [Шаблоны и блоки](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents)

| Метод | Путь | Операция |
| --- | --- | --- |
| `POST` | `/api/v1/smartdoc/blocks/batch` | [Получить блоки по списку id](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-blocks-batch) |
| `POST` | `/api/v1/smartdoc/blocks/parent-documents` | [Родительские шаблоны для блоков](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-blocks-parent-documents) |
| `GET` | `/api/v1/smartdoc/blocks/{blockId}` | [Получить блок по id](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-blocks-blockid) |
| `GET` | `/api/v1/smartdoc/blocks/{blockId}/references` | [Ссылки на блок из других шаблонов](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-blocks-blockid-references) |
| `POST` | `/api/v1/smartdoc/decline-name` | [Просклонять ФИО по падежам](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-decline-name) |
| `POST` | `/api/v1/smartdoc/decline-role` | [Просклонять роль стороны по падежам](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-decline-role) |
| `GET` | `/api/v1/smartdoc/documents` | [Список шаблонов](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-documents) |
| `POST` | `/api/v1/smartdoc/documents` | [Создать шаблон](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents) |
| `POST` | `/api/v1/smartdoc/documents/from-template` | [Создать шаблон из библиотеки](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-from-template) |
| `DELETE` | `/api/v1/smartdoc/documents/{id}` | [Удалить шаблон](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/delete-smartdoc-documents-id) |
| `GET` | `/api/v1/smartdoc/documents/{id}` | [Получить шаблон](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-documents-id) |
| `PUT` | `/api/v1/smartdoc/documents/{id}` | [Обновить шаблон](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/put-smartdoc-documents-id) |
| `POST` | `/api/v1/smartdoc/documents/{id}/blocks` | [Добавить блок в шаблон](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-blocks) |
| `DELETE` | `/api/v1/smartdoc/documents/{id}/blocks/{blockId}` | [Удалить блок шаблона](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/delete-smartdoc-documents-id-blocks-blockid) |
| `PATCH` | `/api/v1/smartdoc/documents/{id}/blocks/{blockId}` | [Обновить блок шаблона](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/patch-smartdoc-documents-id-blocks-blockid) |
| `POST` | `/api/v1/smartdoc/documents/{id}/copy` | [Копировать шаблон](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-copy) |
| `POST` | `/api/v1/smartdoc/documents/{id}/link` | [Связать дочерний шаблон](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-link) |
| `PATCH` | `/api/v1/smartdoc/documents/{id}/move` | [Переместить шаблон в папку](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/patch-smartdoc-documents-id-move) |
| `POST` | `/api/v1/smartdoc/documents/{id}/project-now` | [Применить накопленные правки совместного редактирования к блокам](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-project-now) |
| `POST` | `/api/v1/smartdoc/documents/{id}/restore/{versionId}` | [Восстановить шаблон из версии](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-restore-versionid) |
| `POST` | `/api/v1/smartdoc/documents/{id}/save` | [Сохранить шаблон целиком](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-save) |
| `GET` | `/api/v1/smartdoc/documents/{id}/suggestions` | [Нерассмотренные предложения агента](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-documents-id-suggestions) |
| `POST` | `/api/v1/smartdoc/documents/{id}/suggestions/resolve-all` | [Принять или отклонить все предложения агента](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-suggestions-resolve-all) |
| `POST` | `/api/v1/smartdoc/documents/{id}/suggestions/{suggestionId}/accept` | [Принять предложение агента](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-suggestions-suggestionid-accept) |
| `POST` | `/api/v1/smartdoc/documents/{id}/suggestions/{suggestionId}/reject` | [Отклонить предложение агента](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-suggestions-suggestionid-reject) |
| `POST` | `/api/v1/smartdoc/documents/{id}/unlink` | [Отвязать дочерний шаблон](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-unlink) |
| `GET` | `/api/v1/smartdoc/documents/{id}/versions` | [Версии шаблона](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-documents-id-versions) |
| `POST` | `/api/v1/smartdoc/documents/{id}/versions` | [Создать версию шаблона](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-documents-id-versions) |
| `GET` | `/api/v1/smartdoc/documents/{id}/versions/compare` | [Сравнить две версии шаблона](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-documents-id-versions-compare) |
| `GET` | `/api/v1/smartdoc/documents/{id}/versions/{versionId}` | [Получить версию шаблона](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-documents-id-versions-versionid) |
| `GET` | `/api/v1/smartdoc/documents/{id}/versions/{versionId}/compare-current` | [Сравнить версию с текущим состоянием](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-documents-id-versions-versionid-compare-current) |
| `GET` | `/api/v1/smartdoc/parties/{recordId}/documents` | [Шаблоны с участием контрагента](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/get-smartdoc-parties-recordid-documents) |
| `POST` | `/api/v1/smartdoc/resync` | [Пересинхронизировать шаблоны команды](https://docs.legalstack.ru/api/smartdoc/smartdoc-documents/post-smartdoc-resync) |

### [Папки](https://docs.legalstack.ru/api/smartdoc/smartdoc-folders)

| Метод | Путь | Операция |
| --- | --- | --- |
| `GET` | `/api/v1/smartdoc/folders` | [Список папок](https://docs.legalstack.ru/api/smartdoc/smartdoc-folders/get-smartdoc-folders) |
| `POST` | `/api/v1/smartdoc/folders` | [Создать папку](https://docs.legalstack.ru/api/smartdoc/smartdoc-folders/post-smartdoc-folders) |
| `DELETE` | `/api/v1/smartdoc/folders/{id}` | [Удалить папку](https://docs.legalstack.ru/api/smartdoc/smartdoc-folders/delete-smartdoc-folders-id) |
| `GET` | `/api/v1/smartdoc/folders/{id}` | [Получить папку](https://docs.legalstack.ru/api/smartdoc/smartdoc-folders/get-smartdoc-folders-id) |
| `PUT` | `/api/v1/smartdoc/folders/{id}` | [Обновить папку](https://docs.legalstack.ru/api/smartdoc/smartdoc-folders/put-smartdoc-folders-id) |
| `PATCH` | `/api/v1/smartdoc/folders/{id}/move` | [Переместить папку](https://docs.legalstack.ru/api/smartdoc/smartdoc-folders/patch-smartdoc-folders-id-move) |

### [Импорт и экспорт](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export)

| Метод | Путь | Операция |
| --- | --- | --- |
| `POST` | `/api/v1/smartdoc/analyze-file` | [Проанализировать файл перед импортом](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export/post-smartdoc-analyze-file) |
| `GET` | `/api/v1/smartdoc/documents/{id}/export/docx` | [Экспорт шаблона в DOCX](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export/get-smartdoc-documents-id-export-docx) |
| `GET` | `/api/v1/smartdoc/documents/{id}/export/pdf` | [Экспорт шаблона в PDF (скачивание)](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export/get-smartdoc-documents-id-export-pdf) |
| `POST` | `/api/v1/smartdoc/documents/{id}/export/pdf` | [Экспорт шаблона в PDF (просмотр, с фирменным бланком)](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export/post-smartdoc-documents-id-export-pdf) |
| `POST` | `/api/v1/smartdoc/extraction/warm` | [Подготовить извлечение текста, пока пользователь выбирает файл для импорта](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export/post-smartdoc-extraction-warm) |
| `POST` | `/api/v1/smartdoc/import` | [Импортировать шаблон из файла (PDF/DOCX)](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export/post-smartdoc-import) |
| `POST` | `/api/v1/smartdoc/import/html` | [Импортировать шаблон из HTML](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export/post-smartdoc-import-html) |
| `POST` | `/api/v1/smartdoc/import/{jobId}/cancel` | [Остановить импорт](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export/post-smartdoc-import-jobid-cancel) |
| `GET` | `/api/v1/smartdoc/import/{jobId}/status` | [Статус задачи импорта](https://docs.legalstack.ru/api/smartdoc/smartdoc-import-export/get-smartdoc-import-jobid-status) |

### [Связи с реестрами](https://docs.legalstack.ru/api/smartdoc/smartdoc-links)

| Метод | Путь | Операция |
| --- | --- | --- |
| `GET` | `/api/v1/smartdoc/documents/{documentId}/links` | [Связи шаблона с записями реестров](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/get-smartdoc-documents-documentid-links) |
| `POST` | `/api/v1/smartdoc/documents/{documentId}/links` | [Привязать запись реестра к шаблону](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/post-smartdoc-documents-documentid-links) |
| `DELETE` | `/api/v1/smartdoc/documents/{documentId}/links/{linkId}` | [Удалить связь шаблона](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/delete-smartdoc-documents-documentid-links-linkid) |
| `GET` | `/api/v1/smartdoc/documents/{documentId}/sources` | [Разрешённые источники документа](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/get-smartdoc-documents-documentid-sources) |
| `GET` | `/api/v1/smartdoc/documents/{documentId}/sources/content` | [Разрешённые данные источников для редактора](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/get-smartdoc-documents-documentid-sources-content) |
| `PATCH` | `/api/v1/smartdoc/documents/{documentId}/sources/variables` | [Изменить поля используемого источника](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/patch-smartdoc-documents-documentid-sources-variables) |
| `PUT` | `/api/v1/smartdoc/documents/{documentId}/sources/{id}` | [Разрешить использование источника в документе](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/put-smartdoc-documents-documentid-sources-id) |
| `POST` | `/api/v1/smartdoc/documents/{documentId}/sources/{id}/revoke` | [Отозвать конкретное разрешение на источник](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/post-smartdoc-documents-documentid-sources-id-revoke) |
| `GET` | `/api/v1/smartdoc/registry/{typeId}/records/{recordId}/documents` | [Шаблоны, привязанные к записи реестра](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/get-smartdoc-registry-typeid-records-recordid-documents) |
| `GET` | `/api/v1/smartdoc/sources/{kind}/{id}/grants` | [Документы, которым разрешён источник](https://docs.legalstack.ru/api/smartdoc/smartdoc-links/get-smartdoc-sources-kind-id-grants) |

### [Типы блоков и роли сторон](https://docs.legalstack.ru/api/smartdoc/smartdoc-schemas)

| Метод | Путь | Операция |
| --- | --- | --- |
| `GET` | `/api/v1/smartdoc/schemas/blocks` | [Типы блоков шаблона](https://docs.legalstack.ru/api/smartdoc/smartdoc-schemas/get-smartdoc-schemas-blocks) |
| `GET` | `/api/v1/smartdoc/schemas/blocks/{type}` | [Детали типа блока](https://docs.legalstack.ru/api/smartdoc/smartdoc-schemas/get-smartdoc-schemas-blocks-type) |
| `GET` | `/api/v1/smartdoc/schemas/contract-roles` | [Карта ролей сторон по типам договоров](https://docs.legalstack.ru/api/smartdoc/smartdoc-schemas/get-smartdoc-schemas-contract-roles) |
| `GET` | `/api/v1/smartdoc/schemas/contract-roles/{contractType}` | [Роли сторон для типа договора](https://docs.legalstack.ru/api/smartdoc/smartdoc-schemas/get-smartdoc-schemas-contract-roles-contracttype) |

### [Доступ и приглашения](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares)

| Метод | Путь | Операция |
| --- | --- | --- |
| `DELETE` | `/api/v1/smartdoc/documents/{id}/share-invites/{inviteId}` | [Отменить приглашение к шаблону](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/delete-smartdoc-documents-id-share-invites-inviteid) |
| `GET` | `/api/v1/smartdoc/documents/{id}/shares` | [Доступы к шаблону](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/get-smartdoc-documents-id-shares) |
| `POST` | `/api/v1/smartdoc/documents/{id}/shares` | [Выдать доступ к шаблону](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/post-smartdoc-documents-id-shares) |
| `POST` | `/api/v1/smartdoc/documents/{id}/shares/by-email` | [Открыть доступ к шаблону по email](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/post-smartdoc-documents-id-shares-by-email) |
| `DELETE` | `/api/v1/smartdoc/documents/{id}/shares/{shareId}` | [Отозвать доступ к шаблону](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/delete-smartdoc-documents-id-shares-shareid) |
| `PATCH` | `/api/v1/smartdoc/documents/{id}/shares/{shareId}` | [Изменить доступ к шаблону](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/patch-smartdoc-documents-id-shares-shareid) |
| `DELETE` | `/api/v1/smartdoc/folders/{id}/share-invites/{inviteId}` | [Отменить приглашение к папке](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/delete-smartdoc-folders-id-share-invites-inviteid) |
| `GET` | `/api/v1/smartdoc/folders/{id}/shares` | [Доступы к папке](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/get-smartdoc-folders-id-shares) |
| `POST` | `/api/v1/smartdoc/folders/{id}/shares` | [Выдать доступ к папке](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/post-smartdoc-folders-id-shares) |
| `POST` | `/api/v1/smartdoc/folders/{id}/shares/by-email` | [Расшарить папку по email](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/post-smartdoc-folders-id-shares-by-email) |
| `DELETE` | `/api/v1/smartdoc/folders/{id}/shares/{shareId}` | [Отозвать доступ к папке](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/delete-smartdoc-folders-id-shares-shareid) |
| `PATCH` | `/api/v1/smartdoc/folders/{id}/shares/{shareId}` | [Изменить доступ к папке](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/patch-smartdoc-folders-id-shares-shareid) |
| `GET` | `/api/v1/smartdoc/shared-with-me` | [Шаблоны и папки, к которым открыт доступ текущему пользователю](https://docs.legalstack.ru/api/smartdoc/smartdoc-shares/get-smartdoc-shared-with-me) |
