# API reference

Every endpoint of API v2, generated from the OpenAPI document (/v2/openapi.json).

Base URL `https://api.monoclan.ru`. Authenticate with `Authorization: Bearer sk_test_…` (or `sk_live_…`); browser routes under `/v2/client` take a session secret instead. Fields marked * are required.

<h2 id="documents"><a class="anchor" href="#documents" aria-hidden="true">#</a>Documents</h2>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents</code></p>

**Create a document**

From an uploaded DOCX or PDF (`file`), from Markdown, from a template, or empty. Word documents keep their layout one to one. Pass `send: true` to send at once.

| Field | Type | Description |
| --- | --- | --- |
| `name` | string |  |
| `file` | string | A file_ id (DOCX or PDF) uploaded with purpose "document". |
| `markdown` | string | The document as Markdown; {{markers}} become fields. |
| `template` | string |  |
| `template_version` | integer |  |
| `locale` | string |  |
| `message` | string | null |  |
| `signing_order` | string |  |
| `expires_at` | string | null |  |
| `reminders` | object | null |  |
| `parties` | array |  |
| `fields` | array |  |
| `data` | object | Field values by key. |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |
| `send` | boolean | Send right after creating. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents</code></p>

**List documents**

Filter by stage, template, counterparty, dates, words (`q`) and any field value (`field.<key>…`); sort by any column or field (`sort`); show field values as columns (`columns`). A sorted list pages with `cursor` = `next_cursor`.

| Parameter | In | Description |
| --- | --- | --- |
| `limit` | query |  |
| `starting_after` | query |  |
| `ending_before` | query |  |
| `status` | query |  |
| `stage` | query | Stages, comma-separated: draft, approval (a draft with its approvers), signing, completed, declined, voided, expired |
| `template` | query |  |
| `waiting` | query | Only documents waiting for the signed-in member to sign or approve |
| `q` | query | Words to find anywhere: name, text, field values, recipients, counterparty (prefix match, all words; "quoted" for a phrase, -word to exclude) |
| `counterparty` | query | Documents with this counterparty (case-insensitive), or `none` for those without one |
| `created_from` | query | YYYY-MM-DD |
| `created_to` | query | YYYY-MM-DD, inclusive |
| `updated_from` | query | YYYY-MM-DD |
| `updated_to` | query | YYYY-MM-DD, inclusive |
| `archived` | query | Archived documents are left out unless asked: `only` or `include` |
| `field.{key}` | query | A field value condition, any number of them: `field.city=Moscow,Kazan` (any of, case-insensitive), `field.city.contains=mos`, `field.amount.gte=100000`, `field.end_date.lte=2027-01-01`, `field.inn.empty=true`, `field.inn.filled=true` |
| `sort` | query | updated, created (default, newest first), name, status, counterparty or field.<key>; a leading - sorts descending: `-updated`, `field.amount` |
| `columns` | query | Field keys, comma-separated: each row then carries `columns` with their values as shown |
| `cursor` | query | next_cursor from the previous page |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/groups</code></p>

**Count documents by group**

How many documents fall into each counterparty, template, stage, status or value of a field (`by=field.<key>`), largest first, the empty group last; the same filters as the list. Pass a group's `value` back as the list's filter to open it.

| Parameter | In | Description |
| --- | --- | --- |
| `by` * | query | counterparty, template, stage, status or field.<key> |
| `status` | query |  |
| `stage` | query | Stages, comma-separated: draft, approval (a draft with its approvers), signing, completed, declined, voided, expired |
| `template` | query |  |
| `waiting` | query | Only documents waiting for the signed-in member to sign or approve |
| `q` | query | Words to find anywhere: name, text, field values, recipients, counterparty (prefix match, all words; "quoted" for a phrase, -word to exclude) |
| `counterparty` | query | Documents with this counterparty (case-insensitive), or `none` for those without one |
| `created_from` | query | YYYY-MM-DD |
| `created_to` | query | YYYY-MM-DD, inclusive |
| `updated_from` | query | YYYY-MM-DD |
| `updated_to` | query | YYYY-MM-DD, inclusive |
| `archived` | query | Archived documents are left out unless asked: `only` or `include` |
| `field.{key}` | query | A field value condition, any number of them: `field.city=Moscow,Kazan` (any of, case-insensitive), `field.city.contains=mos`, `field.amount.gte=100000`, `field.end_date.lte=2027-01-01`, `field.inn.empty=true`, `field.inn.filled=true` |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/columns</code></p>

**Fields the list can show**

The account's field keys, most used first, with label, type and how many documents carry and fill them.

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/bulk</code></p>

**One action on many documents**

delete (drafts), archive (off the list; a document out for signature must be withdrawn first) or unarchive, up to 200 documents; each succeeds or fails on its own.

| Field | Type | Description |
| --- | --- | --- |
| `action` * | string |  |
| `ids` * | array |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/archive/empty</code></p>

**Empty the archive**

Deletes every archived document for good. A person only: agents archive, they never delete.

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}</code></p>

**Retrieve a document**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-patch">PATCH</span> <code>/v2/documents/{id}</code></p>

**Update a document**

Drafts can change everything; after sending only metadata changes.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `name` | string |  |
| `locale` | string |  |
| `message` | string | null |  |
| `signing_order` | string |  |
| `expires_at` | string | null |  |
| `reminders` | object | null |  |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |
| `fields` | array |  |
| `remove_fields` | array | Keys of fields to remove. Only fields that are not part of the text: a PDF's boxes, form questions. |
| `data` | object |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-delete">DELETE</span> <code>/v2/documents/{id}</code></p>

**Delete a draft**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/archive</code></p>

**Archive a document**

Takes it off the list (`archived=only` shows it); nothing is deleted. A document out for signature is withdrawn first.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/unarchive</code></p>

**Bring a document back from the archive**

Puts it back on the list.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-put">PUT</span> <code>/v2/documents/{id}/counterparty</code></p>

**Set the counterparty**

Who the contract is with, as the list shows and groups it. `name` sets it by hand (null: found again automatically); `field` names the field (by key) that holds it.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `name` | string | null |  |
| `field` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/copy</code></p>

**Start again from a document**

A new draft with the text as it stands, the same fields (the sender’s values kept) and the same people in the same steps, all waiting: to change and send again after voiding, a decline or expiry. `metadata.copied_from` names the original.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/send</code></p>

**Send for signature**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/void</code></p>

**Void (withdraw) a sent document**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `reason` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/unsend</code></p>

**Back to a draft (nobody has signed, approved or declined yet)**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/remind</code></p>

**Remind waiting signers**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `party` | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/content</code></p>

**Read the content**

`markdown` for agents (fields as values or `{{key}}`), `html` to display, `blocks` with ids for targeted edits, `json` for editors.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `format` | query |  |
| `values` | query |  |
| `revision` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-patch">PATCH</span> <code>/v2/documents/{id}/content</code></p>

**Edit the content by block id**

Replace, insert or delete blocks, or replace exact text. Formatting and numbering of the surrounding clauses stay.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `revision` * | integer | The revision you edited; a newer one is a conflict. |
| `operations` * | array |  |
| `note` | string | null | What this edit is and why, kept with the revision: the change log people and agents read. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/revisions</code></p>

**List revisions**

Every edit is a revision, kept whole. By default saves made in one sitting (one person, pauses under 5 minutes, at most 30 minutes) come as one entry: `revision` is its last save, `from_revision` its first, `edits` how many; compare from_revision-1 to revision to see the whole sitting. `group=none` lists every save. Newest first. Read one with GET /content?revision=N.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `limit` | query |  |
| `before` | query |  |
| `group` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/blocks/{block}/history</code></p>

**A paragraph’s history**

Each version where the block appeared, changed (with the words that went and came) or went away, newest first: who, when, with what note.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `block` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/changes</code></p>

**Changes since a version, with who made them**

Blocks changed since `since` (default: the version the draft went out for approval with), each with the people who changed it.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `since` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/revisions/compare</code></p>

**Compare two revisions**

Blocks added, removed, changed (with the words that went and came) and reformatted, and fields added, removed or changed. Defaults: `to` = current, `from` = the one before.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `from` | query |  |
| `to` | query |  |
| `rows` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/revisions/{target}/restore</code></p>

**Restore an earlier revision**

Drafts only. The earlier text becomes a new revision; the ones in between stay readable. Pass the current `revision` you saw.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `target` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `revision` * | integer |  |
| `note` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/versions/preview</code></p>

**Compare a Word file with the current version**

A .docx (uploaded as a file with purpose "document") that should become the next version: every changed, added and removed paragraph with both texts side by side (`rows`), values typed over fields, and what the document cannot take from the file (`notes`). Nothing changes; apply it with `POST /v2/documents/{id}/versions`.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `file` * | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/versions</code></p>

**Make a Word file the next version**

Drafts only. The file becomes a new revision in one step, with every change it brings except those in `rejected` (change ids from the preview; `field:<key>` for a value typed over a field). Fields stay fields; the document keeps its own Word package. Pass the `revision` you compared against.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `file` * | string |  |
| `revision` * | integer |  |
| `rejected` | array | null |  |
| `note` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/docx</code></p>

**Download as DOCX**

A draft by default keeps every conditional variant and its fields as Word content controls, so the file can come back as the next version (upload_version). `view=final` gives the text as it will be signed: conditions applied, values as plain text (what the PDF shows).

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `view` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/pdf</code></p>

**Download the PDF**

The signed PDF with its certificate once completed; before that, a preview with the current values.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/audit_trail</code></p>

**Audit trail**

Every event of the document with its hash chain, and whether the chain verifies.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/parties</code></p>

**Add a party**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `role` | string |  |
| `kind` | string | `signer` signs, `approver` approves or returns the document (before signatures it goes back to draft), `cc` gets the result. |
| `member` | string | null | A member of the workspace (from /v2/directory). They act in their own workspace; no link or email is needed. |
| `name` | string | null |  |
| `email` | string | null |  |
| `locale` | string | null |  |
| `delivery` | string | `email`: we send the link. `link`: you get `signing_url`. `embedded`: you open a signing session. |
| `can` | string | null | What they may do with the text besides their step: `view` reads, `comment` comments on it, `suggest` also suggests edits (sending it back to the author before anyone signed). Default: approvers suggest, signers comment, copies view. Set on a draft only. |
| `order` | integer |  |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-patch">PATCH</span> <code>/v2/documents/{id}/parties/{party}</code></p>

**Update a party**

After sending, only the details of a party who has not acted yet can change.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `party` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `role` | string |  |
| `kind` | string | `signer` signs, `approver` approves or returns the document (before signatures it goes back to draft), `cc` gets the result. |
| `member` | string | null | A member of the workspace (from /v2/directory). They act in their own workspace; no link or email is needed. |
| `name` | string | null |  |
| `email` | string | null |  |
| `locale` | string | null |  |
| `delivery` | string | `email`: we send the link. `link`: you get `signing_url`. `embedded`: you open a signing session. |
| `can` | string | null | What they may do with the text besides their step: `view` reads, `comment` comments on it, `suggest` also suggests edits (sending it back to the author before anyone signed). Default: approvers suggest, signers comment, copies view. Set on a draft only. |
| `order` | integer |  |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-delete">DELETE</span> <code>/v2/documents/{id}/parties/{party}</code></p>

**Remove a party from a draft**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `party` * | path |  |

</section>

<h2 id="files"><a class="anchor" href="#files" aria-hidden="true">#</a>Files</h2>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/files</code></p>

**Upload a file**

Multipart form with `file` and `purpose` (`document` for DOCX or PDF to sign, `image`, `attachment`); or JSON with `content_base64`, `filename` and `purpose`, which is easier for agents.

| Field | Type | Description |
| --- | --- | --- |
| `content_base64` * | string |  |
| `filename` | string |  |
| `purpose` * | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/files</code></p>

**List files**

| Parameter | In | Description |
| --- | --- | --- |
| `limit` | query |  |
| `starting_after` | query |  |
| `ending_before` | query |  |
| `purpose` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/files/upload_links</code></p>

**A one-time address to upload a file to**

For agents with a terminal: send the file there with `curl -X PUT --data-binary @file <url>` (15 minutes, once), so it never passes through the model as base64. The answer of that PUT is the file.

| Field | Type | Description |
| --- | --- | --- |
| `filename` | string |  |
| `purpose` | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/files/{id}</code></p>

**Retrieve a file**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-delete">DELETE</span> <code>/v2/files/{id}</code></p>

**Delete a file**

Deletes an upload nothing uses yet. Signatures, signed documents and files a document or template uses stay.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/files/{id}/content</code></p>

**Download a file**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<h2 id="templates"><a class="anchor" href="#templates" aria-hidden="true">#</a>Templates</h2>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/templates</code></p>

**Create a template**

| Field | Type | Description |
| --- | --- | --- |
| `file` | string | A file_ id: DOCX keeps its layout, PDF gets placed fields. |
| `markdown` | string |  |
| `document` | string | Turn an existing document into a template. |
| `fields` | array |  |
| `roles` | array |  |
| `note` | string | null | What changed in this version and why. |
| `name` | string |  |
| `description` | string | null |  |
| `locale` | string | null |  |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |
| `status` | string | draft (the default): not offered yet; published: offered when a document is created. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/templates</code></p>

**List templates**

| Parameter | In | Description |
| --- | --- | --- |
| `limit` | query |  |
| `starting_after` | query |  |
| `ending_before` | query |  |
| `status` | query | Only templates in this state. Without it: all but archived. |
| `archived` | query | The archive: `only` archived templates, or `include` them |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/templates/bulk</code></p>

**One action on many templates**

archive, unarchive, duplicate, or delete (archived templates, for good: a person only), up to 200; each succeeds or fails on its own.

| Field | Type | Description |
| --- | --- | --- |
| `action` * | string |  |
| `ids` * | array |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/templates/{id}</code></p>

**Retrieve a template**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `version` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-patch">PATCH</span> <code>/v2/templates/{id}</code></p>

**Update a template**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `name` | string |  |
| `description` | string | null |  |
| `locale` | string | null |  |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |
| `status` | string | published: offered when a document is created; unpublished: taken off the list. |
| `counterparty_field` | string | null | The field (by key) holding the counterparty in documents made from it; they show and group by it |

</section>

<section class="endpoint"><p class="ep"><span class="method m-delete">DELETE</span> <code>/v2/templates/{id}</code></p>

**Archive a template, or delete an archived one for good**

Moves the template to the archive (`archived=only` lists it; documents made from it are not touched). With `forever=true` an archived template is deleted for good: a person only, never an agent.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `forever` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/templates/{id}/versions</code></p>

**Publish a new version**

Documents created before keep the version they were made from.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `file` | string | A file_ id: DOCX keeps its layout, PDF gets placed fields. |
| `markdown` | string |  |
| `document` | string | Turn an existing document into a template. |
| `fields` | array |  |
| `roles` | array |  |
| `note` | string | null | What changed in this version and why. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/templates/{id}/versions</code></p>

**List versions**

Every version, newest first: when it was published, by whom, with what note.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/templates/{id}/content</code></p>

**Read a version’s text**

Markdown with field markers and conditions (default), or HTML with its CSS to show it.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `version` | query |  |
| `format` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/templates/{id}/draft</code></p>

**Open the working draft**

The template’s current version as a draft document to edit with every document tool (fields, conditions, co-editing). One per template, shared; it is never sent. Publish it to make the next version; until then the template does not change.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/templates/{id}/publish</code></p>

**Publish the working draft as a version**

Makes the template’s next version from its working draft, and removes the draft. Documents made earlier keep their version.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `document` * | string |  |
| `note` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/templates/{id}/duplicate</code></p>

**Duplicate a template**

A copy to change apart from it: its current version, parties and settings; the copy starts as a draft.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `name` | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/templates/{id}/unarchive</code></p>

**Bring a template back from the archive**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<h2 id="sessions"><a class="anchor" href="#sessions" aria-hidden="true">#</a>Sessions</h2>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/sessions</code></p>

**Create a session for an embedded component**

Returns a short-lived `client_secret` for the browser. `signing` needs a party and is refused for agent keys; `viewing` shows a document; `editing` opens a draft in the editor.

| Field | Type | Description |
| --- | --- | --- |
| `kind` * | string |  |
| `document` * | string |  |
| `party` | string | null |  |
| `expires_in` | integer |  |
| `return_url` | string | null |  |
| `features` | array |  |

</section>

<h2 id="webhooks"><a class="anchor" href="#webhooks" aria-hidden="true">#</a>Webhooks</h2>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/webhook_endpoints</code></p>

**Create a webhook endpoint**

The response holds the signing secret; it is shown only here.

| Field | Type | Description |
| --- | --- | --- |
| `url` * | string |  |
| `enabled_events` * | array |  |
| `description` | string | null |  |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/webhook_endpoints</code></p>

**List webhook endpoints**

| Parameter | In | Description |
| --- | --- | --- |
| `limit` | query |  |
| `starting_after` | query |  |
| `ending_before` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/webhook_endpoints/{id}</code></p>

**Retrieve a webhook endpoint**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-patch">PATCH</span> <code>/v2/webhook_endpoints/{id}</code></p>

**Update a webhook endpoint**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `url` | string |  |
| `enabled_events` | array |  |
| `description` | string | null |  |
| `status` | string |  |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-delete">DELETE</span> <code>/v2/webhook_endpoints/{id}</code></p>

**Delete a webhook endpoint**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/webhook_endpoints/{id}/deliveries</code></p>

**Delivery log**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `limit` | query |  |
| `starting_after` | query |  |
| `ending_before` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/webhook_endpoints/{id}/deliveries/{delivery}/retry</code></p>

**Retry a delivery now**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `delivery` * | path |  |

</section>

<h2 id="events"><a class="anchor" href="#events" aria-hidden="true">#</a>Events</h2>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/events</code></p>

**List events**

The last 30 days, newest first.

| Parameter | In | Description |
| --- | --- | --- |
| `limit` | query |  |
| `starting_after` | query |  |
| `ending_before` | query |  |
| `type` | query |  |
| `document` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/events/{id}</code></p>

**Retrieve an event**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<h2 id="account"><a class="anchor" href="#account" aria-hidden="true">#</a>Account</h2>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/account</code></p>

**The account and key in use**

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/usage</code></p>

**Usage by month**

| Parameter | In | Description |
| --- | --- | --- |
| `months` | query |  |

</section>

<h2 id="api-keys"><a class="anchor" href="#api-keys" aria-hidden="true">#</a>API keys</h2>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/api_keys</code></p>

**Create an API key**

Restricted keys carry permissions; `agent: true` keys can do everything their permissions allow except sign, and every key they create is an agent key too. The secret is shown only here.

| Field | Type | Description |
| --- | --- | --- |
| `kind` | string |  |
| `name` | string | null |  |
| `permissions` | array |  |
| `tenant` | string | null |  |
| `agent` | boolean |  |
| `allowed_recipient_domains` | array | null |  |
| `expires_at` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/api_keys</code></p>

**List API keys**

| Parameter | In | Description |
| --- | --- | --- |
| `limit` | query |  |
| `starting_after` | query |  |
| `ending_before` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/api_keys/{id}/revoke</code></p>

**Revoke an API key**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<h2 id="tenants"><a class="anchor" href="#tenants" aria-hidden="true">#</a>Tenants</h2>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/tenants</code></p>

**Create a tenant**

A customer of your platform with its own brand, sender name and documents. Act for it with the Monoclan-Tenant header.

| Field | Type | Description |
| --- | --- | --- |
| `name` * | string |  |
| `email` | string | null |  |
| `locale` | string | null |  |
| `branding` | object |  |
| `sender` | object |  |
| `external_id` | string | null |  |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/tenants</code></p>

**List tenants**

| Parameter | In | Description |
| --- | --- | --- |
| `limit` | query |  |
| `starting_after` | query |  |
| `ending_before` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/tenants/{id}</code></p>

**Retrieve a tenant**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-patch">PATCH</span> <code>/v2/tenants/{id}</code></p>

**Update a tenant**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `name` | string |  |
| `email` | string | null |  |
| `locale` | string | null |  |
| `branding` | object |  |
| `sender` | object |  |
| `external_id` | string | null |  |
| `metadata` | object | Up to 50 keys of your own data. An empty string removes a key. |

</section>

<h2 id="client"><a class="anchor" href="#client" aria-hidden="true">#</a>Client</h2>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/client/session</code></p>

**What the session’s browser sees**

Signing sessions get the signing view. Viewing and editing sessions get the document view: status, parties, history, content, readiness and the actions the session allows.

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/values</code></p>

**Save field values**

A signer saves their own fields; an editing session with "values" fills the sender’s fields of a draft.

| Field | Type | Description |
| --- | --- | --- |
| `data` * | object |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/sign</code></p>

**Sign**

The signature is a PNG (drawn, or a typed name drawn in a script face by the component). Consent must be true.

| Field | Type | Description |
| --- | --- | --- |
| `data` | object |  |
| `name` | string |  |
| `signature` * | object |  |
| `initials` | object |  |
| `consent` * | boolean |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/decline</code></p>

**Decline to sign**

| Field | Type | Description |
| --- | --- | --- |
| `reason` | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/decision</code></p>

**Approve or return a draft (an approver’s turn)**

In the editing session opened for an approver’s turn on a draft out for approval: `approve` (with a comment) or `return` (with the reason).

| Field | Type | Description |
| --- | --- | --- |
| `decision` * | string |  |
| `text` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/approve</code></p>

**Approve the document (an approver in the workflow)**

| Field | Type | Description |
| --- | --- | --- |
| `comment` | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/return</code></p>

**Send the document back with what has to change (an approver)**

| Field | Type | Description |
| --- | --- | --- |
| `reason` | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/client/session/source.pdf</code></p>

**The PDF being signed (PDF documents)**

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/client/session/signed.pdf</code></p>

**The signed PDF, once everyone signed**

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/send</code></p>

**Send for signature**

Editing sessions with "send". Fails with the first readiness issue.

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/remind</code></p>

**Remind waiting signers**

Sessions with "remind". Without a party, every signer whose turn it is gets a reminder.

| Field | Type | Description |
| --- | --- | --- |
| `party` | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/void</code></p>

**Withdraw the document**

Sessions with "void". Signers can no longer open it.

| Field | Type | Description |
| --- | --- | --- |
| `reason` | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/unsend</code></p>

**Back to a draft**

Sessions with "void", while nobody has signed, approved or declined: the document becomes a draft again and its links stop working.

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/parties</code></p>

**Change the parties of a draft**

Editing sessions with "parties". Removals run first, then updates, then additions.

| Field | Type | Description |
| --- | --- | --- |
| `add` | array |  |
| `update` | array |  |
| `remove` | array |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/settings</code></p>

**Change the draft’s name, message or signing order**

Editing sessions with "values". The message is what signers read above the document.

| Field | Type | Description |
| --- | --- | --- |
| `name` | string |  |
| `message` | string | null |  |
| `signing_order` | string |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/content</code></p>

**Edit the text of a draft**

Editing sessions with "content". Operations address blocks by id; revision guards against lost updates.

| Field | Type | Description |
| --- | --- | --- |
| `revision` * | integer |  |
| `operations` * | array |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/client/session/revisions</code></p>

**The document’s revisions**

Viewing and editing sessions. Newest first, saves made in one sitting as one entry; `group=none` lists every save; `before` pages back.

| Parameter | In | Description |
| --- | --- | --- |
| `before` | query |  |
| `limit` | query |  |
| `group` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/client/session/blocks/{block}/history</code></p>

**A paragraph’s history**

| Parameter | In | Description |
| --- | --- | --- |
| `block` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/client/session/changes</code></p>

**Changes since a version, with who made them**

| Parameter | In | Description |
| --- | --- | --- |
| `since` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/client/session/revisions/compare</code></p>

**Compare two revisions**

Viewing and editing sessions. Defaults: `to` = current, `from` = the one before.

| Parameter | In | Description |
| --- | --- | --- |
| `from` | query |  |
| `to` | query |  |
| `rows` | query |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/revisions/restore</code></p>

**Restore an earlier revision**

Editing sessions with "content". `target` becomes current again as a new revision; `revision` is the current one you saw.

| Field | Type | Description |
| --- | --- | --- |
| `target` * | integer |  |
| `revision` * | integer |  |
| `note` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/client/session/fields</code></p>

**Place and change the fields of a draft**

Editing sessions with "content". For a PDF, a field's placements are its boxes on the pages, in points from the top-left corner.

| Field | Type | Description |
| --- | --- | --- |
| `upsert` | array |  |
| `remove` | array |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/client/session/document</code></p>

**The draft in the Monoclan model, for an editor**

Editing sessions with "content". Send it back changed with a replace_body operation to /v2/client/session/content.

</section>

<h2 id="agents"><a class="anchor" href="#agents" aria-hidden="true">#</a>Agents</h2>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/me/agent-inbox</code></p>

**My agent inbox**

Where Monoclan tells your own agent about your documents, or null.

</section>

<section class="endpoint"><p class="ep"><span class="method m-put">PUT</span> <code>/v2/me/agent-inbox</code></p>

**Connect my agent**

Your agent hears when a document waits for you to approve or sign, and what happens to the documents you sent (approved, returned with edits, signed, declined, completed). Replaces the earlier one. A webhook’s signing secret is shown once.

| Field | Type | Description |
| --- | --- | --- |
| `kind` * | string | `eggent`: a turn through Eggent’s external API. `webhook`: a signed JSON for any other harness. |
| `url` * | string | Eggent: the workspace address (https://name.cloud.eggent.ai). Webhook: the full address to post to. |
| `token` | string | null | Eggent: the external API token from Settings → API. Kept sealed. |
| `project` | string | null | Eggent: the project the turns run in (id or exact name); empty for the orchestrator. |

</section>

<section class="endpoint"><p class="ep"><span class="method m-delete">DELETE</span> <code>/v2/me/agent-inbox</code></p>

**Disconnect my agent**

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/me/agent-inbox/test</code></p>

**Send a test message**

Sends a short check to your agent now and says whether it got through.

</section>

<h2 id="review"><a class="anchor" href="#review" aria-hidden="true">#</a>Review</h2>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/review</code></p>

**Review state**

Rounds of approval (newest first) with each reviewer’s status, decision, comment and review link; comments with threads; suggested edits.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/reviews</code></p>

**Start a review round**

Asks named people to approve the draft as it is now, in order or all at once. Each gets a review link (`review_url`) to pass on. Any later change to the text makes the round outdated. Sending waits for an approved round (or a cancelled one).

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `name` | string | null | The circle's name: "Team", "Client" |
| `reviewers` | array | People to ask by name; none: whoever the circle's shared link is passed to joins |
| `order` | string | Default: all at once |
| `message` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/reviews/{review}/cancel</code></p>

**Cancel a review round**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `review` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/reviews/word</code></p>

**Bring in a Word file that came back from review**

The .docx reviewers sent back (uploaded as a file with purpose "document"): tracked changes, edits made without tracking and Word comments become suggestions and comments in a review circle, under each Word author. The text does not change; `revision` is the version it stood at.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `file` * | string |  |
| `review` | string | null | An open circle to add to; default a new one |
| `name` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/reviews/{review}/reviewers</code></p>

**Add people to an open circle**

More reviewers in a circle that is open; each gets their own `review_url`.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `review` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `reviewers` * | array |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/reviews/{review}/close</code></p>

**Close a circle**

The circle takes no more comments or decisions; its discussion stays. Sending waits for open circles.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `review` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/comments</code></p>

**Comment on the text**

On a block and the exact words (`quote`), or a reply in a thread.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `body` * | string |  |
| `whole` | boolean | null | About the whole document, not particular words |
| `block` | string | null | The block it is about (from content?format=blocks) |
| `quote` | string | null | The exact words it is about |
| `thread` | string | null | Reply to this comment |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/comments/{comment}/resolve</code></p>

**Resolve a comment thread (or reopen it)**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `comment` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `resolved` | boolean |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/suggestions</code></p>

**Suggest an edit**

Exact text in a block and what to put instead. The sender’s side accepts it (it becomes a new version) or rejects it.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `block` * | string |  |
| `find` * | string | Exact text in the block to change |
| `replace` * | string | What to put instead (empty to delete) |
| `note` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/return</code></p>

**Return to the author with proposed edits**

For the workspace member whose approval step it is (directly or through their agent): the document, signed by no one yet, goes back to its author as a draft, with the reason as a comment and each proposed edit as a suggestion to accept or reject. Approving is done by the person in their workspace.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `reason` | string | null | What has to change and why |
| `edits` | array | Exact edits to propose |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/approve</code></p>

**Approve a draft on your turn**

For the workspace member whose turn it is on a draft out for approval, signed in as themselves (never an agent): `approve`, or `return` with the reason. The approver may have changed the draft first; every change is a version under their name.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `decision` * | string |  |
| `text` | string | null | A comment, or the reason to return |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/suggestions/{suggestion}/accept</code></p>

**Accept a suggested edit**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `suggestion` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/suggestions/{suggestion}/reject</code></p>

**Reject a suggested edit**

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `suggestion` * | path |  |

</section>

<h2 id="negotiation"><a class="anchor" href="#negotiation" aria-hidden="true">#</a>Negotiation</h2>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/negotiation</code></p>

**Negotiation state**

The latest negotiation on the document: whose move it is, the points of both sides (yours including drafts not yet sent), what the other side answered on its last turn, and the link for the other side. `from` adds your view of the text as blocks with ids, to propose edits by.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `words` | query | Each point’s words, went and came |
| `from` | query | Include your view’s text from this block number |
| `blocks` | query | How many blocks of text (default 200), at most 2000 |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/negotiation</code></p>

**Start a negotiation**

Opens a negotiation with the other side on the draft as it is now and gives a link (`link`) for them: they read, propose changes and decide on yours there, or through their own agent. The first move is theirs. While it is open the text changes only by accepted points.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `name` * | string | Who negotiates for the other side |
| `email` | string | null |  |
| `company` | string | null | The other side as a company |
| `message` | string | null | A note to the other side |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/negotiation/edits</code></p>

**Propose changes**

Changes your view of the text; each changed paragraph or table becomes a point (a draft until you pass the turn). An edit that undoes another removes the point.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `operations` * | array | The same operations a draft is edited with, by block id from the negotiation’s `text`: replace_text, replace, insert_after, insert_before, append, delete. They change your view, not the agreed text. |
| `reason` | string | null | Why: the other side reads it beside each point |

</section>

<section class="endpoint"><p class="ep"><span class="method m-put">PUT</span> <code>/v2/documents/{id}/negotiation/view</code></p>

**Save your whole view**

An editor’s save: your view of the text as a whole; the points are what it differs from the agreed text by.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `content` * | object | Your whole view as the editor saves it (JSON content) |
| `reason` | string | null |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/negotiation/view</code></p>

**Your view of the text**

The agreed text with your drafts, as JSON content an editor opens.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/negotiation/proposals/{proposal}/decision</code></p>

**Decide on a point**

On your move: accept, reject or counter one point of the other side. Accepting changes the agreed text (a new revision).

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `proposal` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `decision` * | string | accept: the point goes into the agreed text. reject: it does not. counter: it does not, and you propose your own wording of that place (edit it before passing the turn). |
| `note` | string | null | Why, for the other side |

</section>

<section class="endpoint"><p class="ep"><span class="method m-delete">DELETE</span> <code>/v2/documents/{id}/negotiation/proposals/{proposal}</code></p>

**Take back a draft**

Removes one of your points not yet sent.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |
| `proposal` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/negotiation/pass</code></p>

**Pass the turn**

Sends your drafts to the other side and gives them the move. Every point of theirs must be decided first.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | null | A note to the other side with this turn |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/negotiation/agree</code></p>

**Agree to the text**

You agree to the text as it is now (nothing of theirs waiting, no drafts of yours). When the other side agrees to the same version the negotiation closes as agreed and the document can be sent.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/negotiation/stop</code></p>

**Stop the negotiation**

Ends it: points not decided go, the text stays as agreed so far and can be edited again.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/negotiation/word</code></p>

**Your view as a Word file**

The agreed text with your drafts as a .docx, each paragraph marked so the file maps back exactly. Edit it in Word (plainly or with tracked changes) and upload it back: what it changes becomes your drafts.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-post">POST</span> <code>/v2/documents/{id}/negotiation/word</code></p>

**Upload your Word file back**

Your view edited in Word: the body is the .docx (raw bytes, or JSON `{ "base64": "…", "reason": "…" }`). What it changes against your view becomes your drafts, replacing those you had.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/documents/{id}/negotiation/protocol</code></p>

**Protocol of disagreements**

A Word table of every point put forward: each side’s wording, the reason and the outcome.

| Parameter | In | Description |
| --- | --- | --- |
| `id` * | path |  |

</section>

<h2 id="search"><a class="anchor" href="#search" aria-hidden="true">#</a>Search</h2>

<section class="endpoint"><p class="ep"><span class="method m-get">GET</span> <code>/v2/search</code></p>

**Search documents and templates**

Finds documents and templates by their name, text, field values, recipients (names, emails) and counterparty, best matches first. Every word must match, as the start of a word (`договор` finds `договора`); `"quoted words"` in that order; `-word` excludes; `a | b` either. Each hit says where it matched (`name`, `details`, `text`) and shows the words in context. Changes made a moment ago are found: the account's index is brought up to date before the search.

| Parameter | In | Description |
| --- | --- | --- |
| `q` * | query |  |
| `kind` | query | document, template, or both (default) |
| `limit` | query |  |
| `offset` | query |  |

</section>

