@assinafy/cli 2.6.1 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.en.md +50 -20
  3. package/README.md +38 -10
  4. package/THIRD_PARTY_NOTICES.md +1 -1
  5. package/dist/api.cjs +214 -33
  6. package/dist/api.cjs.map +1 -1
  7. package/dist/api.js +213 -33
  8. package/dist/api.js.map +1 -1
  9. package/dist/cli.cjs +344 -67
  10. package/dist/types/api/client.d.ts +2 -0
  11. package/dist/types/api/client.d.ts.map +1 -1
  12. package/dist/types/api/contract-types.d.ts +110 -0
  13. package/dist/types/api/contract-types.d.ts.map +1 -0
  14. package/dist/types/api/index.d.ts +2 -0
  15. package/dist/types/api/index.d.ts.map +1 -1
  16. package/dist/types/api/resources/assignments.d.ts +2 -2
  17. package/dist/types/api/resources/assignments.d.ts.map +1 -1
  18. package/dist/types/api/resources/authentication.d.ts +3 -3
  19. package/dist/types/api/resources/authentication.d.ts.map +1 -1
  20. package/dist/types/api/resources/contracts.d.ts +19 -0
  21. package/dist/types/api/resources/contracts.d.ts.map +1 -0
  22. package/dist/types/api/resources/documents.d.ts +3 -3
  23. package/dist/types/api/resources/documents.d.ts.map +1 -1
  24. package/dist/types/api/resources/webhooks.d.ts +4 -3
  25. package/dist/types/api/resources/webhooks.d.ts.map +1 -1
  26. package/dist/types/api/types.d.ts +69 -18
  27. package/dist/types/api/types.d.ts.map +1 -1
  28. package/dist/types/api/utils.d.ts +3 -1
  29. package/dist/types/api/utils.d.ts.map +1 -1
  30. package/docs/README.md +2 -1
  31. package/docs/api-operations.json +49 -1
  32. package/docs/api-reference.md +1446 -295
  33. package/docs/contracts.md +128 -0
  34. package/docs/documents.md +7 -4
  35. package/docs/oauth-guide.md +5 -5
  36. package/docs/sdk-reference.md +154 -13
  37. package/package.json +2 -2
@@ -0,0 +1,128 @@
1
+ # `assinafy contracts`
2
+
3
+ ## `assinafy contracts`
4
+
5
+ ```text
6
+ Usage: assinafy contracts [options] [command]
7
+
8
+ Track contract terms, amendments, renewals and terminations (CLM)
9
+
10
+ Options:
11
+ -h, --help display help for command
12
+
13
+ Commands:
14
+ list [options] List workspace contract terms
15
+ get <documentId> Read a document’s contract terms or
16
+ amendment link
17
+ set [options] <documentId> Set terms or link an amendment; null clears,
18
+ omitted fields stay unchanged
19
+ related <documentId> Read the root contract and every linked
20
+ instrument
21
+ renew [options] <documentId> Start the next term using the current term
22
+ or a later end_date
23
+ terminate [options] <documentId> Terminate tracked terms and stop lifecycle
24
+ alerts
25
+ help [command] display help for command
26
+ ```
27
+
28
+ ### `assinafy contracts list`
29
+
30
+ ```text
31
+ Usage: assinafy contracts list [options]
32
+
33
+ List workspace contract terms
34
+
35
+ Options:
36
+ --page <n> Page number to fetch
37
+ --per-page <n> Items per page
38
+ --search <query> Filter by a search query
39
+ --sort <field> end_date or updated_at; prefix with - for
40
+ descending
41
+ --status <csv> draft, active, expired, terminated
42
+ (comma-separated)
43
+ --counterparty <query> Counterparty name or exact CPF/CNPJ
44
+ --end-date-from <date> Earliest end date (YYYY-MM-DD)
45
+ --end-date-to <date> Latest end date (YYYY-MM-DD)
46
+ --ending-within-days <n> Ends within 0–3650 days; 0 includes today in
47
+ Brasília
48
+ --external-system <system> External reference system
49
+ --external-id <id> External reference ID
50
+ --expand <relation> Embed document
51
+ -h, --help display help for command
52
+ ```
53
+
54
+ ### `assinafy contracts get`
55
+
56
+ ```text
57
+ Usage: assinafy contracts get [options] <documentId>
58
+
59
+ Read a document’s contract terms or amendment link
60
+
61
+ Arguments:
62
+ documentId Document ID
63
+
64
+ Options:
65
+ -h, --help display help for command
66
+ ```
67
+
68
+ ### `assinafy contracts set`
69
+
70
+ ```text
71
+ Usage: assinafy contracts set [options] <documentId>
72
+
73
+ Set terms or link an amendment; null clears, omitted fields stay unchanged
74
+
75
+ Arguments:
76
+ documentId Document ID
77
+
78
+ Options:
79
+ --data <json> JSON terms or amendment link; include updated_at for conflict
80
+ detection
81
+ -h, --help display help for command
82
+ ```
83
+
84
+ ### `assinafy contracts related`
85
+
86
+ ```text
87
+ Usage: assinafy contracts related [options] <documentId>
88
+
89
+ Read the root contract and every linked instrument
90
+
91
+ Arguments:
92
+ documentId Contract or amendment document ID
93
+
94
+ Options:
95
+ -h, --help display help for command
96
+ ```
97
+
98
+ ### `assinafy contracts renew`
99
+
100
+ ```text
101
+ Usage: assinafy contracts renew [options] <documentId>
102
+
103
+ Start the next term using the current term or a later end_date
104
+
105
+ Arguments:
106
+ documentId Document ID
107
+
108
+ Options:
109
+ --data <json> JSON with term or end_date, optional value and updated_at
110
+ -y, --yes Skip confirmation
111
+ -h, --help display help for command
112
+ ```
113
+
114
+ ### `assinafy contracts terminate`
115
+
116
+ ```text
117
+ Usage: assinafy contracts terminate [options] <documentId>
118
+
119
+ Terminate tracked terms and stop lifecycle alerts
120
+
121
+ Arguments:
122
+ documentId Document ID
123
+
124
+ Options:
125
+ --data <json> JSON with optional reason and updated_at
126
+ -y, --yes Skip confirmation
127
+ -h, --help display help for command
128
+ ```
package/docs/documents.md CHANGED
@@ -19,7 +19,7 @@ Commands:
19
19
  download [options] <id> Download a document artifact
20
20
  thumbnail [options] <id> Download the document thumbnail (JPEG)
21
21
  download-page [options] <id> <pageId> Download a single document page (JPEG)
22
- activities <id> Show the activity log for a document
22
+ activities [options] <id> Show one page of the activity log for a document
23
23
  delete|rm [options] <id> Delete a document
24
24
  tags <id> List the tags attached to a document
25
25
  tags-set <id> [tags...] Replace a document tag set by name
@@ -176,13 +176,16 @@ Options:
176
176
  ```text
177
177
  Usage: assinafy documents activities [options] <id>
178
178
 
179
- Show the activity log for a document
179
+ Show one page of the activity log for a document
180
180
 
181
181
  Arguments:
182
- id Document ID
182
+ id Document ID
183
183
 
184
184
  Options:
185
- -h, --help display help for command
185
+ --page <n> Page number to fetch
186
+ --per-page <n> Items per page
187
+ --sort <field> Sort by id or -id (default: -id, newest first)
188
+ -h, --help display help for command
186
189
  ```
187
190
 
188
191
  ### `assinafy documents delete`
@@ -4,7 +4,7 @@ Assinafy uses OAuth 2.1 authorization code with mandatory S256 PKCE for public a
4
4
 
5
5
  Use a separate connection for each customer workspace. An OAuth access token carries the consenting user's permissions, the granted scopes, and exactly one workspace. It never grants billing, workspace creation/deletion, API-key management, or other platform administration. An API key remains available for direct owner integrations. Signer access codes remain a separate authentication mechanism.
6
6
 
7
- Use `oauth.userinfo()` for the consenting user's profile. Production rejects OAuth application tokens for `users.self`, user statistics and notification preferences, workspace statistics, and API-key lookup. These operations require the owner or first-party credential supported by their endpoint. Per the live OAuth guide, `documents:read` covers webhook event types, webhook delivery history and the WhatsApp notifications sent for an assignment, and `account:read` covers reading the workspace's webhook subscription. Requesting additional OAuth scopes does not grant access to them.
7
+ Use `oauth.userinfo()` for the consenting user's profile. Production rejects OAuth application tokens for `users.self`, user statistics and notification preferences, and API-key lookup. These operations require the owner or first-party credential supported by their endpoint. Per the live OAuth guide, `documents:read` covers webhook event types, webhook delivery history and the WhatsApp notifications sent for an assignment, and `account:read` covers workspace KPIs and reading the workspace's webhook subscription and endpoints. `webhooks:write` permits endpoint management, enabling signing, secret rotation and delivery retries; reading an existing secret remains unavailable. Additional scopes do not grant access to restricted user or administrative operations.
8
8
 
9
9
  ## Register the application
10
10
 
@@ -29,12 +29,12 @@ The resource indicator is an origin, distinct from the SDK `baseUrl`, which incl
29
29
 
30
30
  | Scope | Purpose |
31
31
  | --- | --- |
32
- | `documents:read` | Read documents and signing state. |
33
- | `documents:write` | Upload and manage documents and request signatures. |
32
+ | `documents:read` | Read documents, signing state and contract tracking. |
33
+ | `documents:write` | Upload/manage documents, request signatures and write contract terms. |
34
34
  | `templates:read` | Read templates. |
35
35
  | `templates:write` | Permitted template operations. |
36
- | `account:read` | Read the selected workspace. |
37
- | `webhooks:write` | Change webhook delivery and deactivate the subscription. Requested by `oauth connect` by default. |
36
+ | `account:read` | Read the selected workspace, KPIs, webhook subscription and endpoints. |
37
+ | `webhooks:write` | Manage endpoints, delivery, signing enablement, secret rotation and retries. Requested by `oauth connect` by default. |
38
38
  | `openid` | Request OpenID Connect identity and UserInfo. |
39
39
  | `profile` | Include permitted profile claims. |
40
40
  | `email` | Include permitted email claims. |
@@ -1,6 +1,6 @@
1
1
  # TypeScript SDK reference
2
2
 
3
- The Node.js SDK is published with the CLI and requires Node.js `>=22.12.0` (Node.js 24 LTS is recommended). Responses containing Assinafy's `{ status, message, data }` envelope resolve to `data`; operations with empty result data resolve to `IEmptyResult` (`unknown[]`). Responses without `data` remain unchanged, including direct `IStatusResponse` (`{ status, message }`) bodies. `sendToken` resolves to `{ document, channel, recipient }`.
3
+ The Node.js SDK is published with the CLI and requires Node.js `>=22.12.0` (Node.js 26 LTS is recommended). Responses containing Assinafy's `{ status, message, data }` envelope resolve to `data`; operations with empty result data resolve to `IEmptyResult` (`unknown[]`). Responses without `data` remain unchanged, including direct `IStatusResponse` (`{ status, message }`) bodies. `sendToken` resolves to `{ document, channel, recipient }`.
4
4
 
5
5
  The [API request/response reference](./api-reference.md) is the canonical source for every published HTTP payload and example. Complete TypeScript declarations are exported and packaged with `@assinafy/cli/api`.
6
6
 
@@ -121,7 +121,7 @@ try {
121
121
  | `download(documentId, artifactName?)` | [`GET /documents/{documentId}/download/{artifact}`](./api-reference.md#download-document-artifact) | `Buffer` |
122
122
  | `thumbnail(documentId)` | [`GET /documents/{documentId}/thumbnail`](./api-reference.md#download-document-thumbnail) | JPEG `Buffer` |
123
123
  | `downloadPage(documentId, pageId)` | [`GET /documents/{documentId}/pages/{pageId}/download`](./api-reference.md#download-document-page) | JPEG `Buffer` |
124
- | `activities(documentId)` | [`GET /documents/{documentId}/activities`](./api-reference.md#list-document-activities) | `IDocumentActivity[]` |
124
+ | `activities(documentId, params?)` | [`GET /documents/{documentId}/activities`](./api-reference.md#list-document-activities) | `IDocumentActivity[]` |
125
125
  | `delete(documentId)` | [`DELETE /documents/{documentId}`](./api-reference.md#delete-document) | `IEmptyResult` (`unknown[]`) |
126
126
  | `listTags(documentId, accountId?)` | [`GET /accounts/{accountId}/documents/{documentId}/tags`](./api-reference.md#list-document-tags) | `ITag[]` |
127
127
  | `replaceTags(documentId, tags, accountId?)` | [`PUT /accounts/{accountId}/documents/{documentId}/tags`](./api-reference.md#replace-document-tags) | `ITag[]` |
@@ -152,14 +152,151 @@ interface IDocumentUploadOptions {
152
152
 
153
153
  Uploads must be non-empty PDFs up to 25 MiB. `DocumentArtifactName` is `original | certificated | certificate-page | pades | bundle`; `bundle` is ZIP and the other document artifacts are PDF. `sendToken(documentId, 'signer@example.com')` emails a one-time access token to a signer who has not signed a pending document yet and sends `{ "channel": "email", "recipient": "signer@example.com" }`. Only the `email` channel is accepted; any other channel is rejected locally. The `{ email }` overload sends the same body.
154
154
 
155
- Template document creation sends `{ signers, name?, message?, expires_at?, editor_fields?, tags? }`. Each signer is `{ role_id, id, verification_method?, notification_methods?, step? }`; each editor field is `{ field_id, value: string }`. Template cost estimation publishes `{ signers: Array<{ role_id, verification_method?, notification_methods? }> }`. The optional cost-signer `id` and `step` properties remain compatibility extensions for existing integrations. A template with placed signer fields creates a `collect` assignment, so it cannot use a `DigitalCertificate` signer. For certificate-bearing template create and estimate calls, the SDK reads the template details first and rejects placed fields with `ValidationError.errors.code` set to `digital_certificate_requires_virtual`.
155
+ Template document creation sends `{ signers, name?, message?, expires_at?, editor_fields?, tags? }`. Each signer is `{ role_id, id?, email?, name?, whatsapp_phone_number?, verification_method?, notification_methods?, step? }`; supply an existing ID or an email for creation/reuse (an ID takes precedence); each editor field is `{ field_id, value: string }`. Template cost estimation publishes `{ signers: Array<{ role_id, verification_method?, notification_methods? }> }`. The optional cost-signer `id` and `step` properties remain compatibility extensions for existing integrations. A template with placed signer fields creates a `collect` assignment, so it cannot use a `DigitalCertificate` signer. For certificate-bearing template create and estimate calls, the SDK reads the template details first and rejects placed Signer-role fields with `ValidationError.errors.code` set to `digital_certificate_requires_virtual`.
156
156
 
157
157
  Document list params are `{ page?, per_page?, status?, method?, tags?, search?, sort? }`; search params omit `method`/`tags`. Supported sort values are `name`, `-name`, `updated_at`, and `-updated_at`.
158
158
 
159
159
  In production, `replaceTags` and `addTags` accept tag names, reuse matching tags, and create missing names. Use `replaceTags(documentId, ['Contracts'])` or `addTags(documentId, ['Contracts'])`; an empty replacement removes all associations. Values are sent unchanged. Pass the tag ID from `listTags` to `detachTag`. Document-list tag filters also use IDs.
160
160
 
161
+ Activity queries use `IDocumentActivityListParams`: `{ page?, per_page?, 'per-page'?, sort?: 'id' | '-id' }`; the default is 20 records per page, newest first. Page until an empty array to read the complete history. Expirations accept `YYYY-MM-DD` (23:59 UTC), an offsetless datetime (UTC), or an RFC 3339 timestamp; values are forwarded unchanged. Template signing steps apply to Signer roles; CopyReceiver steps are ignored. Editor fields do not force a certificate template into collect signing. Template creation/estimation forwards role-specific verification, notification and step settings to the API, which ignores them for CopyReceiver roles. The SDK validates descriptor identity locally without fetching roles solely for validation.
162
+
161
163
  Document responses expose typed `IDocumentArtifacts`, `IDocumentPage`, inline tags, assignment/signing state, decline state, and creation/update timestamps. `IPublicDocumentInfo` models the complete published public-document payload while retaining the older optional `page_count` and `created_by` fields.
162
164
 
165
+ ## Contracts (`client.contracts`)
166
+
167
+ Contract tracking (CLM / Gestão de Contratos) records terms on an existing document. It does not upload a document or request signatures. Writes require a plan with contract tracking; reads remain available when the plan lapses. OAuth uses `documents:read` for reads and `documents:write` for writes.
168
+
169
+ | SDK method | HTTP operation | Resolves to |
170
+ | --- | --- | --- |
171
+ | `list(params?, accountId?)` | [`GET /accounts/{accountId}/contracts`](./api-reference.md#list-contracts) | `PaginatedResult<IContract>` |
172
+ | `get(documentId, accountId?)` | [`GET /accounts/{accountId}/documents/{documentId}/contract`](./api-reference.md#get-a-documents-contract-terms) | `IContract \| IContractAmendment` |
173
+ | `set(documentId, payload, accountId?)` | [`PUT /accounts/{accountId}/documents/{documentId}/contract`](./api-reference.md#set-a-documents-contract-terms) | `IContract \| IContractAmendment` |
174
+ | `related(documentId, accountId?)` | [`GET …/contract/related`](./api-reference.md#list-the-contracts-related-to-a-document) | `IContract`, including `amendments` |
175
+ | `renew(documentId, payload, accountId?)` | [`POST …/contract/renew`](./api-reference.md#renew-a-contract) | `IContract` |
176
+ | `terminate(documentId, payload?, accountId?)` | [`POST …/contract/terminate`](./api-reference.md#terminate-a-contract) | `IContract` |
177
+
178
+ `IContractListParams` accepts `{ page?, per_page?, 'per-page'?, status?, counterparty?, search?, end_date_from?, end_date_to?, ending_within_days?, external_system?, external_id?, sort?, expand? }`. Status is `draft`, `active`, `expired` or `terminated`, supplied singly, as a comma-separated string, or an array. `sort` is `end_date`, `-end_date`, `updated_at` or `-updated_at` (the default). `expand: 'document'` embeds the document. Date filters use `YYYY-MM-DD`; `ending_within_days` is an integer from 0 to 3650 and includes today in Brasília when zero. External reference IDs are forwarded unchanged. Results use the shared `{ data, meta? }` pagination contract.
179
+
180
+ The complete `ISetContractPayload` is:
181
+
182
+ ```ts
183
+ {
184
+ status?: 'draft' | 'active' | 'expired' | 'terminated';
185
+ counterparty_name?: string | null;
186
+ counterparty_taxpayer_id?: string | null;
187
+ value?: number | null;
188
+ currency?: string | null;
189
+ start_date?: string | null;
190
+ end_date?: string | null;
191
+ auto_renew?: boolean | null;
192
+ renewal_term_months?: number | null;
193
+ notice_period_days?: number | null;
194
+ owner_id?: string | null;
195
+ metadata?: Record<string, string> | null;
196
+ external_references?: Array<{ system: string; id: string }> | null;
197
+ parent_document_id?: string | null;
198
+ relation_type?: 'amendment' | 'renewal' | 'termination';
199
+ updated_at?: string | null;
200
+ }
201
+ ```
202
+
203
+ Send at least one attribute. Omitted fields stay unchanged. `null` clears a root term, except `auto_renew` resets to false and `currency` returns to BRL while a value exists; status cannot be null. Sending `external_references` replaces the entire list; `[]` or `null` clears it. An amount is from 0 to 9999999999999.99 with at most two decimal places; currency is three letters. Stored dates start at year 1000 and the end cannot precede the start. Renewal terms are 1–600 months (12 when unset), notice periods 0–3650 days. Metadata accepts up to 50 keys of 1–40 letters, digits, `_`, `-` or `.`, each with plain text up to 500 characters. External references allow up to 20 `{ system, id }` entries, with a 1–64-character system using those same characters and a nonempty ID up to 255 characters without four-byte characters. CPF/CNPJ and workspace membership are validated by the API; the SDK forwards their values unchanged.
204
+
205
+ Create a draft, then activate it when its terms should enter the hourly lifecycle:
206
+
207
+ ```ts
208
+ const uploaded = await client.documents.upload({ filePath: './contract.pdf' });
209
+ // Persist uploaded.id before setting terms; it remains valid if the next call fails.
210
+ const terms = await client.contracts.set(uploaded.id, {
211
+ status: 'draft',
212
+ counterparty_name: 'Example Company',
213
+ value: 1200.50,
214
+ currency: 'BRL',
215
+ start_date: '2027-01-01',
216
+ end_date: '2027-12-31',
217
+ auto_renew: false,
218
+ renewal_term_months: 12,
219
+ notice_period_days: 30,
220
+ metadata: { crm_stage: 'won' },
221
+ external_references: [{ system: 'erp', id: 'example-contract' }],
222
+ });
223
+ await client.contracts.set(uploaded.id, { status: 'active', updated_at: terms.updated_at });
224
+ ```
225
+
226
+ The unwrapped root response (`IContract`) is:
227
+
228
+ ```json
229
+ {
230
+ "resource": "document_contract",
231
+ "document_id": "example-document",
232
+ "status": "active",
233
+ "counterparty_name": "Example Company",
234
+ "counterparty_taxpayer_id": null,
235
+ "value": 1200.5,
236
+ "currency": "BRL",
237
+ "start_date": "2027-01-01",
238
+ "end_date": "2027-12-31",
239
+ "auto_renew": false,
240
+ "renewal_term_months": 12,
241
+ "notice_period_days": 30,
242
+ "term": 1,
243
+ "owner_id": null,
244
+ "metadata": { "crm_stage": "won" },
245
+ "external_references": [{ "system": "erp", "id": "example-contract" }],
246
+ "amendments": [],
247
+ "created_at": "2026-10-23T12:00:00Z",
248
+ "updated_at": "2026-10-23T12:00:00Z"
249
+ }
250
+ ```
251
+
252
+ `document` is optional and uses `IDocumentListItem`; `amendments` is returned on root/family reads. `resource` may be omitted in lists or embedded objects. Owner document details expose `has_contract?: boolean`; absence means unknown, not false. Missing terms produce `ApiError` 404; `responseData.code: 'NoContractTerms'` distinguishes them from a missing document.
253
+
254
+ For a signed instrument, upload a separate document and set its link:
255
+
256
+ ```ts
257
+ await client.contracts.set('example-amendment', {
258
+ parent_document_id: 'example-document',
259
+ relation_type: 'amendment',
260
+ value: 1500,
261
+ end_date: '2028-12-31',
262
+ });
263
+ const family = await client.contracts.related('example-amendment');
264
+ ```
265
+
266
+ `get` and `set` on an instrument return `IContractAmendment`:
267
+
268
+ ```json
269
+ {
270
+ "resource": "document_contract_amendment",
271
+ "document_id": "example-amendment",
272
+ "document_name": "Example amendment.pdf",
273
+ "parent_document_id": "example-document",
274
+ "relation_type": "amendment",
275
+ "number": null,
276
+ "status": "pending",
277
+ "document_status": "metadata_ready",
278
+ "apply_error": null,
279
+ "currency": "BRL",
280
+ "terms": { "value": 1500, "end_date": "2028-12-31" },
281
+ "changes": {
282
+ "value": { "from": 1200.5, "to": 1500 },
283
+ "end_date": { "from": "2027-12-31", "to": "2028-12-31" },
284
+ "term": { "from": 1, "to": 2 }
285
+ },
286
+ "applied_at": null,
287
+ "created_at": "2026-10-23T12:00:00Z",
288
+ "updated_at": "2026-10-23T12:00:00Z"
289
+ }
290
+ ```
291
+
292
+ Use `'parent_document_id' in result` to distinguish an instrument from root terms. A link may target any document in the family; the API resolves the root. `amendment` changes value, currency, start/end dates, renewal settings, counterparty and metadata; `renewal` changes only end date/value, and `termination` only end date. Pending updates merge into `terms`, where null removes a proposed change. `parent_document_id: null` unlinks a pending instrument. Once certificated, instruments apply in signing order; `status` becomes `applied`, `number` is assigned, `applied_at` is set, and the recorded changes become read-only. Inspect `apply_error` when an instrument remains pending. `terms` and `changes` can be null.
293
+
294
+ Renewal input (`IRenewContractPayload`) is `{ term?: number; end_date?: string | null; value?: number | null; updated_at?: string | null }`. Supply the current `term` or an explicit later end date. An omitted/empty/null end date uses the configured renewal period and requires `term`. A null value clears the amount. Renewal advances `term`, can reopen expired terms, and rejects terminated contracts. A repeat cannot silently renew twice: a stale term/date yields 400, or a stale timestamp yields 409. The SDK never retries writes automatically.
295
+
296
+ Termination input (`ITerminateContractPayload`) is `{ reason?: string | null; updated_at?: string | null }`; the default is `{}`. The reason allows up to 500 Unicode characters and is stored in the event. The response is the complete root contract with status `terminated`. For either write, send the `updated_at` from the latest read; on `409 ContractChanged`, re-read and decide whether the change still applies. On an ambiguous network error, inspect current terms before repeating anything.
297
+
298
+ The hourly lifecycle uses Brasília calendar days: notice-period alerts, warnings 45/30 days before expiry, then renewal or expiry the day after the end date. Owner notification preferences include `ContractRenewalNotice`, `ContractExpiring`, `ContractExpired` and `ContractRenewed`. Contract activities include `document_contract_updated`, `document_contract_amendment_updated`, `document_contract_amended`, `document_contract_renewal_notice`, `document_contract_expiring`, `document_contract_expired`, `document_contract_renewed` and `document_contract_terminated`. Subscribe explicitly to the event types needed; webhook defaults do not add these events. Reconcile missed events by paging `list({ sort: '-updated_at' })` until older than the last sync, and page `documents.activities(documentId, { page, sort: 'id' })` for history. A lapsed plan pauses lifecycle changes and pending amendments; restoration catches up without sending alerts whose windows have passed.
299
+
163
300
  ## Assignments (`client.assignments`)
164
301
 
165
302
  | SDK method | HTTP operation | Resolves to |
@@ -167,7 +304,7 @@ Document responses expose typed `IDocumentArtifacts`, `IDocumentPage`, inline ta
167
304
  | `list(params?, accountId?)` | [`GET /assignments?accountId=…`](./api-reference.md#list-assignments) | `PaginatedResult<IAssignment>` |
168
305
  | `create(documentId, payload)` | [`POST /documents/{documentId}/assignments`](./api-reference.md#create-assignment-request-signatures) | `IAssignment` |
169
306
  | `estimateCost(documentId, payload)` | [`POST /documents/{documentId}/assignments/estimate-cost`](./api-reference.md#estimate-assignment-cost) | `IEstimateCostResponse` |
170
- | `resetExpiration(documentId, assignmentId, expiresAt)` | [`PUT …/reset-expiration`](./api-reference.md#reset-assignment-expiration) | `IAssignment`; the published API accepts an ISO 8601 timestamp, and deployments that support clearing also accept `null` |
307
+ | `resetExpiration(documentId, assignmentId, expiresAt)` | [`PUT …/reset-expiration`](./api-reference.md#reset-assignment-expiration) | `IAssignment`; accepts a date, datetime or `null` to clear the deadline |
171
308
  | `resendNotification(documentId, assignmentId, signerId)` | [`PUT …/signers/{signerId}/resend`](./api-reference.md#resend-signature-request) | `IResendEmailResponse` |
172
309
  | `estimateResendCost(documentId, assignmentId, signerId)` | [`POST …/estimate-resend-cost`](./api-reference.md#estimate-resend-cost) | `IResendCostEstimate` |
173
310
  | `listWhatsAppNotifications(documentId, assignmentId)` | [`GET …/whatsapp-notifications`](./api-reference.md#list-whatsapp-notifications) | `IWhatsAppNotification[]` |
@@ -211,7 +348,7 @@ Production defaults `notification_methods: []` to `['Email']` and sends an invit
211
348
  }
212
349
  ```
213
350
 
214
- `IResendCostEstimate` also accepts the published `IEstimateCostResponse` shape. Check `'total' in estimate` to select the production shape; use its `has_sufficient_credits` before resending. The published shape uses `total_credits` and `has_sufficient_resources`.
351
+ `credit_balance` can be null for unlimited plans. `IResendCostEstimate` also accepts the published `IEstimateCostResponse` shape. Check `'total' in estimate` to select the production shape; use its `has_sufficient_credits` before resending. The published shape uses `total_credits` and `has_sufficient_resources`.
215
352
 
216
353
  ## Signers (`client.signers`)
217
354
 
@@ -436,6 +573,8 @@ assinafy documents download example_document --artifact pades -o signed-pades.pd
436
573
 
437
574
  Create/update payloads use `name` and `notification_sender_type?: 'User' | 'Account'`; legacy color fields remain accepted for compatibility. List/detail responses include `resource`, `id`, `name`, nullable colors, `notification_sender_type`, roles, delete permission, and `created_at`. `IAccountTheme` is `{ account_name; primary_color; secondary_color: string | null; logo: string | null }`. Logo options are `{ fileName?, contentType? }`. Statistics params are `{ granularity?: 'monthly' | 'daily'; month?: 'YYYY-MM' }`; `month` is required for daily data.
438
575
 
576
+ OAuth `account:read` permits workspace statistics; user statistics still require an endpoint-supported owner or first-party credential.
577
+
439
578
  Both account and user statistics resolve to the complete published row:
440
579
 
441
580
  ```ts
@@ -474,7 +613,7 @@ Notification counters can overlap when a request uses multiple delivery channels
474
613
 
475
614
  | SDK method | HTTP operation | Request / result |
476
615
  | --- | --- | --- |
477
- | `login(email, password)` | [`POST /login`](./api-reference.md#login) | `{ email, password }` → `ILoginResponse` |
616
+ | `login(email, password)` | [`POST /login`](./api-reference.md#login) | `{ email, password }` → `ILoginResponse \| IMfaChallengeResponse` |
478
617
  | `socialLogin({ provider, token, has_accepted_terms })` | [`POST /authentication/social-login`](./api-reference.md#social-login) | Google token → `ILoginResponse` |
479
618
  | `linkSocialLogin({ provider, token })` | [`POST /auth/link-social-login`](./api-reference.md#link-social-login) | Google token → `IStatusResponse` |
480
619
  | `changePassword({ email, password, new_password })` | [`PUT /authentication/change-password`](./api-reference.md#change-password) | `{ email }` |
@@ -492,7 +631,7 @@ Notification counters can overlap when a request uses multiple delivery channels
492
631
 
493
632
  ### Two-factor authentication
494
633
 
495
- When the user has a confirmed authenticator, `login` returns an `mfa_token` challenge instead of a session. Exchange it within 5 minutes, once, with a 6-digit authenticator code or a recovery code:
634
+ When the user has a confirmed authenticator, `login` returns `IMfaChallengeResponse` (`{ mfa_token: string }`) instead of `ILoginResponse` (`{ access_token, user, accounts }`). The challenge has no session fields; narrow the result before reading them. Exchange it within 5 minutes, once, with a 6-digit authenticator code or a recovery code:
496
635
 
497
636
  ```ts
498
637
  let session = await client.auth.login('user@example.com', password);
@@ -601,7 +740,7 @@ An account can register 1 webhook endpoint, or up to 3 on paid plans. Each endpo
601
740
  | `listEndpoints(accountId?, params?)` | [`GET /accounts/{accountId}/webhooks/endpoints`](./api-reference.md#list-webhook-endpoints), with optional `{ url: string }` exact-match filter | `IWebhookEndpoint[]`, oldest first |
602
741
  | `createEndpoint(payload, accountId?)` | [`POST /accounts/{accountId}/webhooks/endpoints`](./api-reference.md#create-webhook-endpoint) | `IWebhookEndpointCreatePayload` → `IWebhookEndpointCreateResponse` (endpoint plus optional `secret`) |
603
742
  | `getEndpoint(endpointId, accountId?)` | [`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}`](./api-reference.md#get-webhook-endpoint) | `IWebhookEndpoint` |
604
- | `updateEndpoint(endpointId, payload, accountId?)` | [`PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}`](./api-reference.md#update-webhook-endpoint) | `IWebhookEndpointUpdatePayload` → `IWebhookEndpoint` |
743
+ | `updateEndpoint(endpointId, payload, accountId?)` | [`PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}`](./api-reference.md#update-webhook-endpoint) | `IWebhookEndpointUpdatePayload` → `IWebhookEndpointUpdateResponse` |
605
744
  | `deleteEndpoint(endpointId, accountId?)` | [`DELETE /accounts/{accountId}/webhooks/endpoints/{endpointId}`](./api-reference.md#delete-webhook-endpoint) | `IEmptyResult` (`[]`) |
606
745
  | `deleteEndpointByUrl(url, accountId?)` | [`DELETE /accounts/{accountId}/webhooks/endpoints?url=…`](./api-reference.md#delete-webhook-endpoint-by-url) | `IEmptyResult` (`[]`); exact registered URL required |
607
746
  | `getEndpointSecret(endpointId, accountId?)` | [`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret`](./api-reference.md#get-webhook-endpoint-signing-secret) | `IWebhookEndpointSecret` (`{ secret }`) |
@@ -613,7 +752,7 @@ An account can register 1 webhook endpoint, or up to 3 on paid plans. Each endpo
613
752
  | `listDispatches(params?, accountId?)` | [`GET /accounts/{accountId}/webhooks`](./api-reference.md#list-webhook-deliveries) | `PaginatedResult<IWebhookDispatch>` |
614
753
  | `retryDispatch(dispatchId, accountId?)` | [`POST /accounts/{accountId}/webhooks/{dispatchId}/retry`](./api-reference.md#retry-webhook-delivery) | `IWebhookDispatch` |
615
754
 
616
- Endpoint payload: `{ url: string; email: string; events?: string[]; name?: string; is_active?: boolean; signing_enabled?: boolean }`. Update sends only the given fields and requires at least one. URLs must be HTTP(S) and unique within the workspace (`400`); creating past the plan limit returns `403`. Enabling signing creates a `whsec_` secret if none exists; disabling it discards the secret. Secret read and rotation return `400` when signing is disabled and are not available to OAuth applications; rotation invalidates the previous secret immediately.
755
+ Endpoint payload: `{ url: string; email: string; events?: string[]; name?: string; is_active?: boolean; signing_enabled?: boolean }`. Update sends only the given fields and requires at least one. New or changed URLs must be HTTPS and unique within the workspace (`400`); legacy HTTP URLs remain usable for exact lookup/deletion; creating past the plan limit returns `403`. Enabling signing creates a `whsec_` secret if none exists; disabling it discards the secret. Secret read and rotation return `400` when signing is disabled. OAuth applications cannot read an existing secret, but `webhooks:write` permits rotation; rotation invalidates the previous secret immediately.
617
756
 
618
757
  ```ts
619
758
  const endpoint = await client.webhooks.createEndpoint({
@@ -627,12 +766,14 @@ const { secret } = endpoint;
627
766
  // Store `secret` in your receiver's secret manager.
628
767
  ```
629
768
 
630
- When signing is enabled, endpoint creation returns `secret` once, including to OAuth applications. List/get responses omit it. OAuth applications cannot read or rotate it later: if lost, delete and recreate the endpoint. The CLI prints the creation secret in human and JSON output; store that output securely. `webhooks endpoints list --url <url>` and `delete-by-url --url <url> [--yes]` match the exact registered URL, including its query string. Deletion returns 404 if no endpoint matches. Existing endpoint-ID and subscription methods remain supported.
769
+ When signing is enabled, endpoint creation returns `secret` once, including to OAuth applications. Enabling signing on an existing endpoint also returns its new secret once (`IWebhookEndpointUpdateResponse`); list/get responses omit it. OAuth applications can rotate a lost secret with `webhooks:write`. The CLI prints returned secrets in human and JSON output; store that output securely. `webhooks endpoints list --url <url>` and `delete-by-url --url <url> [--yes]` match the exact registered URL, including its query string. Deletion returns 404 if no endpoint matches. Existing endpoint-ID and subscription methods remain supported.
631
770
 
632
771
  Registration payload: `{ url: string; email: string; events?: string[]; is_active?: boolean }`. When `events` is omitted on `register` or `createEndpoint`, the SDK uses `document_ready`, `document_prepared`, `signer_signed_document`, `signer_rejected_document`, and `document_processing_failed`; pass `[]` deliberately for none. Dispatch filters extend pagination with `{ endpoint_id?, event?, delivered?, from?, to?, sort?: 'created_at' | '-created_at' }`; sort is a compatibility extension. Dispatch records include `endpoint_id`. Dispatch `search` is unsupported and rejected locally. Retrying re-sends only to that entry's endpoint and requires the endpoint to be active. There is no delete-subscription operation; delete a specific endpoint with `deleteEndpoint` or deactivate the oldest with `inactivate`.
633
772
 
634
773
  Decline operations require a non-empty reason of at most 2,000 Unicode characters. `signers.findByEmail` follows pagination metadata until an exact case-insensitive email match is found or the search is exhausted; when a response carries no pagination metadata a partial page ends the search, and the scan is bounded at 100 pages.
635
774
 
775
+ Biometric identity status can be read with OAuth `documents:read`. Evidence downloads and review decisions are unavailable to OAuth applications; use the supported owner credential for those operations. CLI downloads create and replace files with owner-only POSIX permissions (`0600`).
776
+
636
777
  ## Responses, pagination, errors, and binary data
637
778
 
638
779
  - JSON responses with `data` are unwrapped from the API envelope; direct status bodies remain `IStatusResponse`. Paginated calls resolve to `{ data: T[]; meta?: { current_page?, last_page?, per_page?, total? } }`; metadata comes from `X-Pagination-*` headers.
@@ -654,7 +795,7 @@ try {
654
795
 
655
796
  ## Webhook verification
656
797
 
657
- Deliveries are `POST` requests with `Content-Type: application/json`, a `webhook-id` (stable across retries of the same event to the same endpoint; use it to deduplicate), a `webhook-timestamp` (Unix seconds), and, when the endpoint has `signing_enabled`, a `webhook-signature` following [Standard Webhooks](https://www.standardwebhooks.com). Any `2xx` is success; a failed delivery is retried once after 3 seconds. After 10 consecutive failed events the endpoint's delivery is paused and probed until one succeeds; use `retryDispatch` to force redelivery.
798
+ Deliveries are `POST` requests with `Content-Type: application/json`, a `webhook-id` (stable across retries of the same event to the same endpoint; use it to deduplicate), a `webhook-timestamp` (Unix seconds), and, when the endpoint has `signing_enabled`, a `webhook-signature` following [Standard Webhooks](https://www.standardwebhooks.com). Any `2xx` is success. Connection failures, timeouts, `408`, `429` and `5xx` are retried up to six total attempts, about ten minutes apart; other statuses are final. Ten consecutive failed deliveries pause the endpoint. Probes run after 3, 15 and 60 minutes, then every six hours; a successful probe resumes missed events oldest first. Editing the URL or setting `is_active: true` also clears the pause. `retryDispatch` sends a manual attempt even while paused. `IWebhookEndpoint` and `IWebhookSubscription` expose `is_held`/`held_since`; dispatches include `webhook_id`, `attempt`, `kind` and `will_retry`. Delivery history is kept for seven days.
658
799
 
659
800
  | API | Result |
660
801
  | --- | --- |
@@ -686,7 +827,7 @@ Verify the raw bytes before parsing; re-serialized JSON does not match. The enve
686
827
 
687
828
  ## Contract boundaries
688
829
 
689
- - Production OpenAPI currently publishes 112 operations. Some sandbox deployments lag it; account/user statistics and user notification-preference routes may return route-level 404s even though production documentation includes them.
690
- - Certificate start/complete are deployed production extensions, exposed by `startCertificate` and `completeCertificate` with the signing application's payloads. They supplement the 112 OpenAPI operations; the API manifest contains only published paths.
830
+ - Production OpenAPI currently publishes 118 operations. Some sandbox deployments lag it; account/user statistics and user notification-preference routes may return route-level 404s even though production documentation includes them.
831
+ - Certificate start/complete are deployed production extensions, exposed by `startCertificate` and `completeCertificate` with the signing application's payloads. They supplement the 118 OpenAPI operations; the API manifest contains only published paths.
691
832
  - The SDK retains the two template compatibility routes above. Both `sendToken` call forms send the email-only production body.
692
833
  - Signer artifact downloads are public in the published contract. Supplying a signer access code opts into an SDK identity preflight; it does not change the server route into a private endpoint.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assinafy/cli",
3
- "version": "2.6.1",
3
+ "version": "2.7.0",
4
4
  "description": "The official command-line interface for the Assinafy digital-signature API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -86,7 +86,7 @@
86
86
  "tsup": "^8.3.5",
87
87
  "tsx": "^4.23.12",
88
88
  "typescript": "^7.0.2",
89
- "vitest": "^4.1.11"
89
+ "vitest": "^4.1.12"
90
90
  },
91
91
  "overrides": {
92
92
  "esbuild": "^0.28.2"