@assinafy/sdk 1.4.0 → 2.0.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.
- package/README.md +105 -19
- package/dist/index.d.mts +572 -74
- package/dist/index.d.ts +572 -74
- package/dist/index.js +564 -115
- package/dist/index.mjs +562 -115
- package/package.json +24 -12
package/dist/index.d.ts
CHANGED
|
@@ -4,12 +4,26 @@ import { AxiosInstance, AxiosResponse } from 'axios';
|
|
|
4
4
|
type DocumentStatus = 'uploading' | 'uploaded' | 'metadata_processing' | 'metadata_ready' | 'pending_signature' | 'expired' | 'certificating' | 'certificated' | 'rejected_by_signer' | 'rejected_by_user' | 'failed';
|
|
5
5
|
/** Artifact names available for document download. */
|
|
6
6
|
type DocumentArtifactName = 'original' | 'certificated' | 'certificate-page' | 'bundle';
|
|
7
|
+
/**
|
|
8
|
+
* Any string, while keeping editor autocomplete for the literals it is unioned
|
|
9
|
+
* with.
|
|
10
|
+
*
|
|
11
|
+
* `'Email' | 'Whatsapp' | string` collapses to plain `string`, so the literals
|
|
12
|
+
* vanish from autocomplete. `'Email' | 'Whatsapp' | AnyString` keeps them
|
|
13
|
+
* suggested while staying assignable from any string, so a value the API adds
|
|
14
|
+
* later still type-checks.
|
|
15
|
+
*
|
|
16
|
+
* This deliberately does **not** reject unknown strings — these fields mirror
|
|
17
|
+
* server-controlled vocabularies, so forward-compatibility is worth more than
|
|
18
|
+
* rejecting a typo at compile time.
|
|
19
|
+
*/
|
|
20
|
+
type AnyString = string & {};
|
|
7
21
|
/** Assignment methods supported by the API. */
|
|
8
22
|
type AssignmentMethod = 'virtual' | 'collect';
|
|
9
23
|
/** Verification methods accepted by assignment signer entries. */
|
|
10
|
-
type AssignmentVerificationMethod = 'Email' | 'Whatsapp' |
|
|
24
|
+
type AssignmentVerificationMethod = 'Email' | 'Whatsapp' | AnyString;
|
|
11
25
|
/** Notification methods accepted by assignment signer entries. */
|
|
12
|
-
type AssignmentNotificationMethod = 'Email' | 'Whatsapp' |
|
|
26
|
+
type AssignmentNotificationMethod = 'Email' | 'Whatsapp' | AnyString;
|
|
13
27
|
/** Minimal logger contract (compatible with console, pino, winston, etc.). */
|
|
14
28
|
interface Logger {
|
|
15
29
|
debug: (message: string, context?: Record<string, unknown>) => void;
|
|
@@ -34,6 +48,11 @@ interface AssinafyClientOptions {
|
|
|
34
48
|
webhookSecret?: string;
|
|
35
49
|
/** Request timeout in milliseconds. Defaults to 30_000. */
|
|
36
50
|
timeout?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Max automatic retries on HTTP 429 (rate limit), honoring `Retry-After`.
|
|
53
|
+
* Defaults to `2`. Set to `0` to disable retrying.
|
|
54
|
+
*/
|
|
55
|
+
maxRetries?: number;
|
|
37
56
|
/** Optional logger. Defaults to a no-op logger. */
|
|
38
57
|
logger?: Logger;
|
|
39
58
|
}
|
|
@@ -70,6 +89,10 @@ interface ISigner {
|
|
|
70
89
|
full_name: string;
|
|
71
90
|
email: string | null;
|
|
72
91
|
whatsapp_phone_number?: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* Accepted on create/update payloads but **never echoed back** on any signer
|
|
94
|
+
* response — present here only so response objects stay assignable from inputs.
|
|
95
|
+
*/
|
|
73
96
|
cpf?: string | null;
|
|
74
97
|
has_accepted_terms?: boolean;
|
|
75
98
|
/** Only returned by `GET /signers/self`. */
|
|
@@ -127,27 +150,74 @@ interface ICreateAssignmentPayload {
|
|
|
127
150
|
signerIds?: string[];
|
|
128
151
|
message?: string;
|
|
129
152
|
expires_at?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Recipients CC'd on the signature request.
|
|
155
|
+
*
|
|
156
|
+
* ⚠️ Observed to be **silently dropped** on the sandbox plan: values sent
|
|
157
|
+
* here came back as `[]` from `assignments.create`, `assignments.list` and
|
|
158
|
+
* `documents.details().assignment` alike, for both email addresses and
|
|
159
|
+
* signer IDs. The field is accepted (no error) but nothing is persisted.
|
|
160
|
+
*
|
|
161
|
+
* It is retained because this was verified on a single sandbox account and
|
|
162
|
+
* may be plan-gated — the WhatsApp channel on the same account is rejected
|
|
163
|
+
* with an explicit plan error, so silent no-ops for un-provisioned features
|
|
164
|
+
* are plausible. **Do not rely on it without verifying against your own
|
|
165
|
+
* account**, and do not treat a CC as delivered.
|
|
166
|
+
*/
|
|
130
167
|
copy_receivers?: string[];
|
|
131
168
|
/** Field placement entries used when `method` is `collect`. */
|
|
132
169
|
entries?: unknown[];
|
|
133
170
|
}
|
|
171
|
+
/** A signer as embedded inside an assignment (richer than the bare {@link ISigner}). */
|
|
172
|
+
interface IAssignmentSigner extends ISigner {
|
|
173
|
+
completed: boolean;
|
|
174
|
+
notification_history: unknown[];
|
|
175
|
+
verification_method: AssignmentVerificationMethod;
|
|
176
|
+
notification_methods: AssignmentNotificationMethod[];
|
|
177
|
+
/** 1-based signing order. See {@link SignerReference.step}. */
|
|
178
|
+
step: number;
|
|
179
|
+
notified: boolean;
|
|
180
|
+
}
|
|
181
|
+
/** A placed field/item within an assignment (one row per signer × field). */
|
|
182
|
+
interface IAssignmentItem {
|
|
183
|
+
id: string;
|
|
184
|
+
page: {
|
|
185
|
+
id: string;
|
|
186
|
+
number: number;
|
|
187
|
+
height: number;
|
|
188
|
+
width: number;
|
|
189
|
+
download_url: string;
|
|
190
|
+
} | null;
|
|
191
|
+
signer: ISigner;
|
|
192
|
+
field: IFieldDefinition;
|
|
193
|
+
value: string | null;
|
|
194
|
+
completed?: boolean;
|
|
195
|
+
[key: string]: unknown;
|
|
196
|
+
}
|
|
134
197
|
/** Assignment object as returned by the API. */
|
|
135
198
|
interface IAssignment {
|
|
199
|
+
resource?: string;
|
|
136
200
|
id: string;
|
|
137
201
|
sender_email?: string;
|
|
138
202
|
method: AssignmentMethod;
|
|
139
|
-
expires_at?: string;
|
|
203
|
+
expires_at?: string | null;
|
|
140
204
|
expiration?: string;
|
|
141
205
|
message?: string;
|
|
142
|
-
signers:
|
|
206
|
+
signers: IAssignmentSigner[];
|
|
143
207
|
copy_receivers?: string[];
|
|
144
|
-
items?:
|
|
208
|
+
items?: IAssignmentItem[];
|
|
145
209
|
summary?: {
|
|
146
210
|
signer_count: number;
|
|
147
211
|
completed_count: number;
|
|
148
|
-
signers:
|
|
212
|
+
signers: Array<ISigner & {
|
|
213
|
+
completed?: boolean;
|
|
214
|
+
}>;
|
|
149
215
|
};
|
|
150
|
-
|
|
216
|
+
/** Per-signer signing URLs. Array of `{ signer_id, url }` (not a map). */
|
|
217
|
+
signing_urls?: Array<{
|
|
218
|
+
signer_id: string;
|
|
219
|
+
url: string;
|
|
220
|
+
}>;
|
|
151
221
|
}
|
|
152
222
|
type ICreateAssignmentResponse = IAssignment;
|
|
153
223
|
interface IResendEmailResponse {
|
|
@@ -155,6 +225,41 @@ interface IResendEmailResponse {
|
|
|
155
225
|
document_id?: string;
|
|
156
226
|
signer_id?: string;
|
|
157
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Credit/document cost estimate returned by `assignments.estimateCost` and
|
|
230
|
+
* `documents.estimateCostFromTemplate`.
|
|
231
|
+
*/
|
|
232
|
+
interface ICostEstimate {
|
|
233
|
+
documents: number;
|
|
234
|
+
credits: number;
|
|
235
|
+
needs_extra_document: boolean;
|
|
236
|
+
extra_document_cost: number;
|
|
237
|
+
total_credits: number;
|
|
238
|
+
breakdown: Array<{
|
|
239
|
+
code: string;
|
|
240
|
+
name: string;
|
|
241
|
+
cost: number;
|
|
242
|
+
quantity?: number;
|
|
243
|
+
unit_cost?: number;
|
|
244
|
+
}>;
|
|
245
|
+
document_balance: number;
|
|
246
|
+
credit_balance: number;
|
|
247
|
+
has_sufficient_resources: boolean;
|
|
248
|
+
/** `null` when the operation can proceed; otherwise a reason code. */
|
|
249
|
+
blocking_reason: string | null;
|
|
250
|
+
message: string | null;
|
|
251
|
+
}
|
|
252
|
+
/** Cost estimate returned by `assignments.estimateResendCost`. */
|
|
253
|
+
interface IResendCostEstimate {
|
|
254
|
+
total: number;
|
|
255
|
+
breakdown: Array<{
|
|
256
|
+
code: string;
|
|
257
|
+
name: string;
|
|
258
|
+
cost: number;
|
|
259
|
+
}>;
|
|
260
|
+
credit_balance: number;
|
|
261
|
+
has_sufficient_credits: boolean;
|
|
262
|
+
}
|
|
158
263
|
/** Webhook payload envelope. */
|
|
159
264
|
interface IWebhookPayload {
|
|
160
265
|
id?: number;
|
|
@@ -182,6 +287,14 @@ interface IDocumentListItem {
|
|
|
182
287
|
status: DocumentStatus;
|
|
183
288
|
account_id?: string;
|
|
184
289
|
template_id?: string | null;
|
|
290
|
+
/** Artifact download URLs keyed by name (`original`, `thumbnail`, …). */
|
|
291
|
+
artifacts?: IDocumentUploadResponse['artifacts'];
|
|
292
|
+
/** Public signing-portal URL for the document. */
|
|
293
|
+
signing_url?: string;
|
|
294
|
+
pages?: IDocumentUploadResponse['pages'];
|
|
295
|
+
assignment?: IAssignment | null;
|
|
296
|
+
decline_reason?: string | null;
|
|
297
|
+
declined_by?: ISigner | null;
|
|
185
298
|
/** Tags attached to the document (inline `{ id, name, color }` shape). */
|
|
186
299
|
tags?: IInlineTag[];
|
|
187
300
|
created_at: string;
|
|
@@ -192,12 +305,44 @@ type IDocumentListResponse = PaginatedResult<IDocumentListItem>;
|
|
|
192
305
|
/** Query parameters accepted by `documents.list`. */
|
|
193
306
|
interface IDocumentListParams extends IListParams {
|
|
194
307
|
/** Filter by document status, e.g. `pending_signature`. */
|
|
195
|
-
status?: DocumentStatus |
|
|
308
|
+
status?: DocumentStatus | AnyString;
|
|
196
309
|
/** Filter by signature method (`virtual` or `collect`). */
|
|
197
310
|
method?: AssignmentMethod;
|
|
198
311
|
/** Comma-separated list of tag IDs (AND semantics). */
|
|
199
312
|
tags?: string;
|
|
200
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* Response of `documents.rename` (`PATCH /documents/{documentId}`).
|
|
316
|
+
*
|
|
317
|
+
* The rename endpoint returns the document **without** `pages` or
|
|
318
|
+
* `assignment` — verified against the live API, which echoes only
|
|
319
|
+
* `resource`, `id`, `account_id`, `template_id`, `name`, `status`,
|
|
320
|
+
* `artifacts`, `signing_url`, `is_closed`, `decline_reason`, `declined_by`,
|
|
321
|
+
* `tags`, `created_at` and `updated_at`. Typing it as a full
|
|
322
|
+
* {@link IDocumentDetailsResponse} would promise a required `pages` array that
|
|
323
|
+
* is absent at runtime, so `result.pages.length` would throw.
|
|
324
|
+
*/
|
|
325
|
+
type IRenameDocumentResponse = Omit<IDocumentDetailsResponse, 'pages' | 'assignment'>;
|
|
326
|
+
/** Query parameters accepted by `documents.search`. */
|
|
327
|
+
interface IDocumentSearchParams extends IListParams {
|
|
328
|
+
/** Free-text term matched against the document name. */
|
|
329
|
+
search?: string;
|
|
330
|
+
/** Filter by document status, e.g. `pending_signature`. */
|
|
331
|
+
status?: DocumentStatus | AnyString;
|
|
332
|
+
/** Page number (1-based). */
|
|
333
|
+
page?: number;
|
|
334
|
+
/** Results per page. */
|
|
335
|
+
'per-page'?: number;
|
|
336
|
+
}
|
|
337
|
+
/** Query parameters accepted by `assignments.list`. */
|
|
338
|
+
interface IAssignmentListParams extends IListParams {
|
|
339
|
+
/** Page number (1-based). */
|
|
340
|
+
page?: number;
|
|
341
|
+
/** Results per page. */
|
|
342
|
+
'per-page'?: number;
|
|
343
|
+
}
|
|
344
|
+
/** Paginated result of `assignments.list`. */
|
|
345
|
+
type IAssignmentListResponse = PaginatedResult<IAssignment>;
|
|
201
346
|
/** Document upload response. */
|
|
202
347
|
interface IDocumentUploadResponse {
|
|
203
348
|
resource?: string;
|
|
@@ -206,7 +351,8 @@ interface IDocumentUploadResponse {
|
|
|
206
351
|
template_id: string | null;
|
|
207
352
|
name: string;
|
|
208
353
|
status: DocumentStatus;
|
|
209
|
-
|
|
354
|
+
/** Absent on a fresh upload; an {@link IAssignment} (or `null`) once one exists. */
|
|
355
|
+
assignment?: IAssignment | null;
|
|
210
356
|
artifacts: {
|
|
211
357
|
original: string;
|
|
212
358
|
certificated?: string;
|
|
@@ -214,6 +360,7 @@ interface IDocumentUploadResponse {
|
|
|
214
360
|
bundle?: string;
|
|
215
361
|
thumbnail?: string;
|
|
216
362
|
};
|
|
363
|
+
/** Empty (`[]`) on fresh upload (status `uploaded`); populated once `metadata_ready`. */
|
|
217
364
|
pages: Array<{
|
|
218
365
|
id: string;
|
|
219
366
|
number: number;
|
|
@@ -234,6 +381,7 @@ interface IDocumentDetailsResponse {
|
|
|
234
381
|
resource?: string;
|
|
235
382
|
id: string;
|
|
236
383
|
account_id: string;
|
|
384
|
+
template_id?: string | null;
|
|
237
385
|
name: string;
|
|
238
386
|
status: DocumentStatus;
|
|
239
387
|
assignment: IAssignment | null;
|
|
@@ -247,13 +395,14 @@ interface IDocumentDetailsResponse {
|
|
|
247
395
|
bundle?: string;
|
|
248
396
|
thumbnail?: string;
|
|
249
397
|
};
|
|
250
|
-
pages
|
|
398
|
+
/** Rendered pages. Empty until the document reaches `metadata_ready`. */
|
|
399
|
+
pages: IPage[];
|
|
251
400
|
/** Tags attached to the document (inline `{ id, name, color }` shape). */
|
|
252
401
|
tags?: IInlineTag[];
|
|
253
402
|
created_at: string;
|
|
254
403
|
updated_at: string;
|
|
255
404
|
is_closed: boolean;
|
|
256
|
-
decline_reason?: string;
|
|
405
|
+
decline_reason?: string | null;
|
|
257
406
|
declined_by?: ISigner | null;
|
|
258
407
|
activities?: Array<IDocumentActivity>;
|
|
259
408
|
}
|
|
@@ -300,8 +449,8 @@ interface IUpdateWorkspacePayload {
|
|
|
300
449
|
interface IWorkspaceResponse {
|
|
301
450
|
id: string;
|
|
302
451
|
name: string;
|
|
303
|
-
primary_color?: string;
|
|
304
|
-
secondary_color?: string;
|
|
452
|
+
primary_color?: string | null;
|
|
453
|
+
secondary_color?: string | null;
|
|
305
454
|
created_at: string;
|
|
306
455
|
}
|
|
307
456
|
interface IWorkspaceListItem {
|
|
@@ -319,22 +468,25 @@ interface IWebhookRegisterPayload {
|
|
|
319
468
|
events?: WebhookEventType[] | string[];
|
|
320
469
|
is_active?: boolean;
|
|
321
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Webhook subscription as returned by the API. There is exactly one
|
|
473
|
+
* subscription per workspace, keyed by URL — the API returns
|
|
474
|
+
* `{ events, is_active, url, email, updated_at }` (no `id` / `created_at`).
|
|
475
|
+
*/
|
|
322
476
|
interface IWebhookSubscription {
|
|
323
|
-
id?: string;
|
|
324
477
|
url: string;
|
|
325
478
|
email: string;
|
|
326
479
|
events: string[];
|
|
327
480
|
is_active: boolean;
|
|
328
|
-
created_at?: string;
|
|
329
481
|
updated_at?: string;
|
|
330
482
|
}
|
|
331
483
|
interface IWebhookEventTypeInfo {
|
|
332
|
-
id: WebhookEventType |
|
|
484
|
+
id: WebhookEventType | AnyString;
|
|
333
485
|
description: string;
|
|
334
486
|
}
|
|
335
487
|
interface IWebhookDispatch {
|
|
336
488
|
id: string;
|
|
337
|
-
event: WebhookEventType |
|
|
489
|
+
event: WebhookEventType | AnyString;
|
|
338
490
|
activity_id: number;
|
|
339
491
|
endpoint: string | null;
|
|
340
492
|
payload: IWebhookPayload | Record<string, unknown> | null;
|
|
@@ -342,11 +494,13 @@ interface IWebhookDispatch {
|
|
|
342
494
|
http_status: number | null;
|
|
343
495
|
response_body: string | null;
|
|
344
496
|
error: string | null;
|
|
345
|
-
|
|
346
|
-
|
|
497
|
+
/** ISO-8601 UTC timestamp, e.g. `'2026-07-15T20:04:36Z'`. */
|
|
498
|
+
created_at: string;
|
|
499
|
+
/** ISO-8601 UTC timestamp, e.g. `'2026-07-15T20:04:36Z'`. */
|
|
500
|
+
updated_at?: string;
|
|
347
501
|
}
|
|
348
502
|
interface IWebhookDispatchListParams extends IListParams {
|
|
349
|
-
event?: WebhookEventType |
|
|
503
|
+
event?: WebhookEventType | AnyString;
|
|
350
504
|
delivered?: boolean | 'true' | 'false';
|
|
351
505
|
from?: number;
|
|
352
506
|
to?: number;
|
|
@@ -372,17 +526,33 @@ interface IUploadAndRequestSignaturesSigner {
|
|
|
372
526
|
interface ITemplateRole {
|
|
373
527
|
id: string;
|
|
374
528
|
name: string;
|
|
529
|
+
/** Role kind, e.g. `Editor` or `Signer`. */
|
|
530
|
+
assignment_type?: string;
|
|
531
|
+
created_at?: string;
|
|
532
|
+
updated_at?: string;
|
|
375
533
|
[key: string]: unknown;
|
|
376
534
|
}
|
|
535
|
+
/** Payload for `PUT /accounts/{id}/templates/{template_id}`. Omit a field to leave it unchanged. */
|
|
536
|
+
interface IUpdateTemplatePayload {
|
|
537
|
+
name?: string;
|
|
538
|
+
/** Default invitation message applied to documents created from the template. */
|
|
539
|
+
message?: string;
|
|
540
|
+
}
|
|
377
541
|
/** Template list item (paginated). */
|
|
378
542
|
interface ITemplateListItem {
|
|
379
|
-
resource?: string;
|
|
380
543
|
id: string;
|
|
381
544
|
name: string;
|
|
382
545
|
document_name?: string | null;
|
|
383
546
|
message?: string | null;
|
|
384
547
|
status: string;
|
|
385
|
-
|
|
548
|
+
/**
|
|
549
|
+
* Rendered pages, each with a `download_url`. Empty until the template
|
|
550
|
+
* finishes processing (`status: 'Ready'`).
|
|
551
|
+
*
|
|
552
|
+
* The list endpoint does return `pages` — contrary to what
|
|
553
|
+
* `templates.get`'s documentation implies.
|
|
554
|
+
*/
|
|
555
|
+
pages?: IPage[];
|
|
386
556
|
roles?: ITemplateRole[];
|
|
387
557
|
/** Tags attached to the template itself (inline `{ id, name }` shape). */
|
|
388
558
|
tags?: IInlineTag[];
|
|
@@ -391,6 +561,38 @@ interface ITemplateListItem {
|
|
|
391
561
|
}
|
|
392
562
|
type ITemplateListResponse = PaginatedResult<ITemplateListItem>;
|
|
393
563
|
/** Full template details. */
|
|
564
|
+
/**
|
|
565
|
+
* A rendered page of a document or template.
|
|
566
|
+
*
|
|
567
|
+
* `download_url` is an absolute, API-key-authenticated URL for the page's JPEG
|
|
568
|
+
* rendering — the same bytes returned by `templates.downloadPage()` /
|
|
569
|
+
* `documents.downloadPage()`.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```jsonc
|
|
573
|
+
* {
|
|
574
|
+
* "id": "e5f6a7b8c9d0e1f2a3b4c5d6e7f8",
|
|
575
|
+
* "number": 1,
|
|
576
|
+
* "height": 1651,
|
|
577
|
+
* "width": 1275,
|
|
578
|
+
* "download_url": "https://api.assinafy.com.br/v1/accounts/…/pages/…/download",
|
|
579
|
+
* "fields": []
|
|
580
|
+
* }
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
583
|
+
interface IPage {
|
|
584
|
+
id: string;
|
|
585
|
+
/** 1-based page number. */
|
|
586
|
+
number: number;
|
|
587
|
+
/** Rendered height in pixels (150 DPI). */
|
|
588
|
+
height: number;
|
|
589
|
+
/** Rendered width in pixels (150 DPI). */
|
|
590
|
+
width: number;
|
|
591
|
+
/** Absolute URL of the page's JPEG rendering. */
|
|
592
|
+
download_url?: string;
|
|
593
|
+
/** Fields positioned on this page. Present on templates; absent on documents. */
|
|
594
|
+
fields?: unknown[];
|
|
595
|
+
}
|
|
394
596
|
interface ITemplateDetailsResponse {
|
|
395
597
|
resource?: string;
|
|
396
598
|
id: string;
|
|
@@ -398,8 +600,8 @@ interface ITemplateDetailsResponse {
|
|
|
398
600
|
document_name?: string | null;
|
|
399
601
|
message?: string | null;
|
|
400
602
|
status: string;
|
|
401
|
-
|
|
402
|
-
pages?:
|
|
603
|
+
/** Empty until the template finishes processing (`status: 'Ready'`). */
|
|
604
|
+
pages?: IPage[];
|
|
403
605
|
roles?: ITemplateRole[];
|
|
404
606
|
/** Tags attached to the template itself. */
|
|
405
607
|
tags?: IInlineTag[];
|
|
@@ -437,7 +639,7 @@ interface ICreateDocumentFromTemplateOptions {
|
|
|
437
639
|
* is documented in the table but is not currently present in the JSON payload.
|
|
438
640
|
*/
|
|
439
641
|
interface IDocumentStatusInfo {
|
|
440
|
-
code: DocumentStatus |
|
|
642
|
+
code: DocumentStatus | AnyString;
|
|
441
643
|
deletable: boolean;
|
|
442
644
|
description?: string;
|
|
443
645
|
}
|
|
@@ -451,7 +653,7 @@ interface IPublicDocumentInfo {
|
|
|
451
653
|
[key: string]: unknown;
|
|
452
654
|
}
|
|
453
655
|
/** Channel accepted by the `send-token` endpoint. */
|
|
454
|
-
type SendTokenChannel = 'email' | 'whatsapp' |
|
|
656
|
+
type SendTokenChannel = 'email' | 'whatsapp' | AnyString;
|
|
455
657
|
/** Authentication: login response (also returned by social login). */
|
|
456
658
|
interface ILoginResponse {
|
|
457
659
|
access_token: string;
|
|
@@ -579,6 +781,17 @@ interface IUpdateTagPayload {
|
|
|
579
781
|
color?: string | null;
|
|
580
782
|
}
|
|
581
783
|
|
|
784
|
+
/** Maximum upload size accepted by the API (hard limit, 25 MB). */
|
|
785
|
+
declare const MAX_UPLOAD_BYTES: number;
|
|
786
|
+
/** Input for an upload: either an on-disk file or an in-memory buffer. */
|
|
787
|
+
type DocumentUploadSource = {
|
|
788
|
+
filePath: string;
|
|
789
|
+
fileName?: string;
|
|
790
|
+
} | {
|
|
791
|
+
buffer: Buffer;
|
|
792
|
+
fileName: string;
|
|
793
|
+
};
|
|
794
|
+
|
|
582
795
|
/**
|
|
583
796
|
* Shared plumbing for every Assinafy resource:
|
|
584
797
|
*
|
|
@@ -608,20 +821,43 @@ declare abstract class BaseResource {
|
|
|
608
821
|
protected callVoid(label: string, request: RequestFn): Promise<void>;
|
|
609
822
|
/** Execute an HTTP call that returns binary data (artifact downloads). */
|
|
610
823
|
protected callBinary(label: string, request: () => Promise<AxiosResponse<ArrayBuffer>>): Promise<Buffer>;
|
|
824
|
+
/**
|
|
825
|
+
* Upload a PDF as `multipart/form-data` and assert the API echoed an id.
|
|
826
|
+
*
|
|
827
|
+
* Shared by `documents.upload` and `templates.create`, which are the same
|
|
828
|
+
* sequence over different paths: load → validate → build form → POST →
|
|
829
|
+
* assert an id came back. Callers keep their own success logging.
|
|
830
|
+
*
|
|
831
|
+
* @param path - Account-scoped endpoint to POST to.
|
|
832
|
+
* @param source - The PDF, as a file path or in-memory buffer.
|
|
833
|
+
* @param formOptions - `name` (display name) and optional `metadata`.
|
|
834
|
+
* @param labels - `errorLabel` for the request failure, `missingId` for a
|
|
835
|
+
* `2xx` that returned no id.
|
|
836
|
+
*/
|
|
837
|
+
protected uploadPdf<T extends {
|
|
838
|
+
id?: string;
|
|
839
|
+
}>(path: string, source: DocumentUploadSource, formOptions: {
|
|
840
|
+
name?: string;
|
|
841
|
+
metadata?: Record<string, unknown>;
|
|
842
|
+
}, labels: {
|
|
843
|
+
errorLabel: string;
|
|
844
|
+
missingId: string;
|
|
845
|
+
}): Promise<T>;
|
|
611
846
|
/** Execute a paginated list call and attach meta from `X-Pagination-*` headers. */
|
|
612
847
|
protected callList<T>(label: string, request: RequestFn): Promise<PaginatedResult<T>>;
|
|
613
848
|
}
|
|
614
849
|
type RequestFn = () => Promise<AxiosResponse>;
|
|
615
850
|
|
|
616
|
-
/**
|
|
617
|
-
type DocumentUploadSource = {
|
|
618
|
-
filePath: string;
|
|
619
|
-
fileName?: string;
|
|
620
|
-
} | {
|
|
621
|
-
buffer: Buffer;
|
|
622
|
-
fileName: string;
|
|
623
|
-
};
|
|
851
|
+
/** Options accepted by {@link DocumentResource.upload}. */
|
|
624
852
|
interface IDocumentUploadOptions {
|
|
853
|
+
/**
|
|
854
|
+
* Display name for the document. Defaults to the uploaded file's own name.
|
|
855
|
+
*
|
|
856
|
+
* `.pdf` is appended when absent, so `'Service agreement'` is stored as
|
|
857
|
+
* `'Service agreement.pdf'`. Accents are transliterated by the API
|
|
858
|
+
* (`'Contrato de Serviço'` → `'Contrato de Servico.pdf'`).
|
|
859
|
+
*/
|
|
860
|
+
name?: string;
|
|
625
861
|
/** Optional metadata sent alongside the file (JSON-encoded). */
|
|
626
862
|
metadata?: Record<string, unknown>;
|
|
627
863
|
/** Override the default account ID configured on the client. */
|
|
@@ -629,20 +865,119 @@ interface IDocumentUploadOptions {
|
|
|
629
865
|
}
|
|
630
866
|
declare class DocumentResource extends BaseResource {
|
|
631
867
|
/**
|
|
632
|
-
* Upload a PDF to the workspace.
|
|
868
|
+
* Upload a PDF to the workspace (`POST /accounts/{accountId}/documents`).
|
|
869
|
+
*
|
|
870
|
+
* The document is created in `metadata_processing` status and becomes
|
|
871
|
+
* usable once it reaches `metadata_ready`; use
|
|
872
|
+
* {@link DocumentResource.waitUntilReady} to await that transition. Note
|
|
873
|
+
* that {@link DocumentResource.rename} and {@link DocumentResource.delete}
|
|
874
|
+
* return `400` while the document is still processing.
|
|
875
|
+
*
|
|
876
|
+
* @param source - The PDF to upload, as a file path or an in-memory buffer.
|
|
877
|
+
* @param options - Display name, metadata, and account override.
|
|
878
|
+
* @returns The created document. Response shape:
|
|
879
|
+
* ```jsonc
|
|
880
|
+
* {
|
|
881
|
+
* "resource": "document",
|
|
882
|
+
* "id": "c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
|
|
883
|
+
* "name": "Service agreement.pdf",
|
|
884
|
+
* "status": "metadata_processing",
|
|
885
|
+
* "created_at": "2026-07-15T16:15:33Z",
|
|
886
|
+
* "updated_at": "2026-07-15T16:15:33Z"
|
|
887
|
+
* }
|
|
888
|
+
* ```
|
|
889
|
+
* @throws {ValidationError} If the file is empty, not a `.pdf`, exceeds
|
|
890
|
+
* 25 MB, or the API returns no document ID.
|
|
891
|
+
* @throws {ApiError} If the API rejects the upload.
|
|
633
892
|
*
|
|
634
893
|
* @example
|
|
635
894
|
* ```ts
|
|
636
895
|
* await client.documents.upload({ filePath: './contract.pdf' });
|
|
637
|
-
* await client.documents.upload(
|
|
896
|
+
* await client.documents.upload(
|
|
897
|
+
* { buffer, fileName: 'contract.pdf' },
|
|
898
|
+
* { name: 'Service agreement', metadata: { orderId: 'A-1' } },
|
|
899
|
+
* );
|
|
900
|
+
* // → name is stored as 'Service agreement.pdf'
|
|
638
901
|
* ```
|
|
639
902
|
*/
|
|
640
903
|
upload(source: DocumentUploadSource, options?: IDocumentUploadOptions): Promise<IDocumentUploadResponse>;
|
|
641
904
|
/**
|
|
642
905
|
* List workspace documents. Pagination info (if any) is attached in `meta`.
|
|
643
|
-
* Supports `status`, `method`, `tags`, `search`, `sort`, `page`, `
|
|
906
|
+
* Supports `status`, `method`, `tags`, `search`, `sort`, `page`, `per-page`.
|
|
644
907
|
*/
|
|
645
908
|
list(params?: IDocumentListParams, accountId?: string): Promise<IDocumentListResponse>;
|
|
909
|
+
/**
|
|
910
|
+
* Search workspace documents
|
|
911
|
+
* (`GET /accounts/{accountId}/documents/search`).
|
|
912
|
+
*
|
|
913
|
+
* A lighter-weight alternative to {@link DocumentResource.list}: it returns
|
|
914
|
+
* a compact representation with no expanded `assignment` or `pages`, so
|
|
915
|
+
* prefer it for name lookups and pickers.
|
|
916
|
+
*
|
|
917
|
+
* @param params - `search`, `status`, `page`, `per-page`.
|
|
918
|
+
* @param accountId - Override the client's default account ID.
|
|
919
|
+
* @returns Matching documents, with pagination in `meta`. Each item:
|
|
920
|
+
* ```jsonc
|
|
921
|
+
* {
|
|
922
|
+
* "id": "c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
|
|
923
|
+
* "account_id": "d4e5f6a7b8c9d0e1f2a3b4c5d6e7",
|
|
924
|
+
* "template_id": null,
|
|
925
|
+
* "name": "Service agreement.pdf",
|
|
926
|
+
* "status": "pending_signature",
|
|
927
|
+
* "artifacts": { "original": "https://…" },
|
|
928
|
+
* "is_closed": false,
|
|
929
|
+
* "signing_url": "https://…",
|
|
930
|
+
* "decline_reason": null,
|
|
931
|
+
* "declined_by": null,
|
|
932
|
+
* "tags": [],
|
|
933
|
+
* "created_at": "2026-07-15T16:15:33Z",
|
|
934
|
+
* "updated_at": "2026-07-15T16:15:40Z"
|
|
935
|
+
* }
|
|
936
|
+
* ```
|
|
937
|
+
* @throws {ValidationError} If no account ID is available.
|
|
938
|
+
* @throws {ApiError} If the API rejects the request.
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* ```ts
|
|
942
|
+
* const { data, meta } = await client.documents.search({
|
|
943
|
+
* search: 'agreement',
|
|
944
|
+
* status: 'pending_signature',
|
|
945
|
+
* 'per-page': 20,
|
|
946
|
+
* });
|
|
947
|
+
* ```
|
|
948
|
+
*/
|
|
949
|
+
search(params?: IDocumentSearchParams, accountId?: string): Promise<IDocumentListResponse>;
|
|
950
|
+
/**
|
|
951
|
+
* Rename a document (`PATCH /documents/{documentId}`).
|
|
952
|
+
*
|
|
953
|
+
* Only valid while the document is still renameable: the API returns `400`
|
|
954
|
+
* ("Document cannot be renamed after the signature process has started")
|
|
955
|
+
* both once signing has begun **and** while the document is still in
|
|
956
|
+
* `metadata_processing` immediately after upload. Await
|
|
957
|
+
* {@link DocumentResource.waitUntilReady} before renaming a fresh upload.
|
|
958
|
+
*
|
|
959
|
+
* To set a name at upload time instead, pass `name` to
|
|
960
|
+
* {@link DocumentResource.upload} — that avoids the extra round-trip and
|
|
961
|
+
* the processing race entirely.
|
|
962
|
+
*
|
|
963
|
+
* @param documentId - The document to rename.
|
|
964
|
+
* @param name - The new display name (max 255 chars), e.g.
|
|
965
|
+
* `'Service agreement.pdf'`.
|
|
966
|
+
* @returns The updated document — **without** `pages` or `assignment`,
|
|
967
|
+
* which this endpoint does not return (unlike
|
|
968
|
+
* {@link DocumentResource.details}). Call `details()` if you need them.
|
|
969
|
+
* @throws {ValidationError} If `documentId` or `name` is missing.
|
|
970
|
+
* @throws {ApiError} `400` if the document is processing or already in
|
|
971
|
+
* signing; `404` if it does not exist.
|
|
972
|
+
*
|
|
973
|
+
* @example
|
|
974
|
+
* ```ts
|
|
975
|
+
* const doc = await client.documents.upload({ filePath: './c.pdf' });
|
|
976
|
+
* await client.documents.waitUntilReady(doc.id); // else 400
|
|
977
|
+
* await client.documents.rename(doc.id, 'Service agreement.pdf');
|
|
978
|
+
* ```
|
|
979
|
+
*/
|
|
980
|
+
rename(documentId: string, name: string): Promise<IRenameDocumentResponse>;
|
|
646
981
|
/** Get document details. */
|
|
647
982
|
details(documentId: string): Promise<IDocumentDetailsResponse>;
|
|
648
983
|
/** Alias for {@link details}. */
|
|
@@ -684,8 +1019,13 @@ declare class DocumentResource extends BaseResource {
|
|
|
684
1019
|
* ```
|
|
685
1020
|
*/
|
|
686
1021
|
createFromTemplate(templateId: string, signers: ITemplateSigner[], options?: ICreateDocumentFromTemplateOptions, accountId?: string): Promise<IDocumentDetailsResponse>;
|
|
687
|
-
/**
|
|
688
|
-
|
|
1022
|
+
/**
|
|
1023
|
+
* Estimate the credit cost of creating a document from a template.
|
|
1024
|
+
*
|
|
1025
|
+
* @returns an {@link ICostEstimate}: `total_credits`, balances, and a
|
|
1026
|
+
* per-line `breakdown` of what the operation would consume.
|
|
1027
|
+
*/
|
|
1028
|
+
estimateCostFromTemplate(templateId: string, signers: ITemplateSigner[], accountId?: string): Promise<ICostEstimate>;
|
|
689
1029
|
/** Verify a document by its signature hash. */
|
|
690
1030
|
verify(hash: string): Promise<Record<string, unknown>>;
|
|
691
1031
|
/**
|
|
@@ -722,13 +1062,30 @@ declare class SignerResource extends BaseResource {
|
|
|
722
1062
|
create(payload: ICreateSignerPayload, accountId?: string): Promise<ICreateSignerResponse>;
|
|
723
1063
|
/** Get a signer by ID. */
|
|
724
1064
|
get(signerId: string, accountId?: string): Promise<ISigner>;
|
|
725
|
-
/** List signers for the workspace (supports `page`, `
|
|
1065
|
+
/** List signers for the workspace (supports `page`, `per-page`, `search`, `sort`). */
|
|
726
1066
|
list(params?: IListParams, accountId?: string): Promise<ISignerListResponse>;
|
|
727
1067
|
/** Update a signer. Fails if the signer has active assignments. */
|
|
728
1068
|
update(signerId: string, payload: IUpdateSignerPayload, accountId?: string): Promise<ICreateSignerResponse>;
|
|
729
1069
|
/** Delete a signer. */
|
|
730
1070
|
delete(signerId: string, accountId?: string): Promise<void>;
|
|
731
|
-
/**
|
|
1071
|
+
/**
|
|
1072
|
+
* Find a signer by exact email, using the API's `search` filter to narrow
|
|
1073
|
+
* the page first. Returns `null` if none match.
|
|
1074
|
+
*
|
|
1075
|
+
* `search` is a substring match across signer fields, so the result is
|
|
1076
|
+
* re-filtered here for an exact, case-insensitive email match.
|
|
1077
|
+
*
|
|
1078
|
+
* Page size is pinned to the API's maximum of 50: larger values are
|
|
1079
|
+
* silently clamped to 50 by the server, so asking for more is misleading.
|
|
1080
|
+
* An exact address realistically matches one signer, but a search term that
|
|
1081
|
+
* matched more than 50 could in principle miss one — the API exposes no
|
|
1082
|
+
* exact-email filter to rule that out.
|
|
1083
|
+
*
|
|
1084
|
+
* @param email - Exact email address to look for.
|
|
1085
|
+
* @param accountId - Override the client's default account ID.
|
|
1086
|
+
* @returns The matching {@link ISigner}, or `null`.
|
|
1087
|
+
* @throws {ValidationError} If `email` is not a valid address.
|
|
1088
|
+
*/
|
|
732
1089
|
findByEmail(email: string, accountId?: string): Promise<ISigner | null>;
|
|
733
1090
|
private assertEmail;
|
|
734
1091
|
}
|
|
@@ -754,10 +1111,62 @@ declare function buildAssignmentPayload(payload: ICreateAssignmentPayload, optio
|
|
|
754
1111
|
allowSignersWithoutId?: boolean;
|
|
755
1112
|
}): Record<string, unknown>;
|
|
756
1113
|
declare class AssignmentResource extends BaseResource {
|
|
1114
|
+
/**
|
|
1115
|
+
* List assignments across the workspace (`GET /assignments`).
|
|
1116
|
+
*
|
|
1117
|
+
* The account is passed as an `accountId` **query parameter** — the API
|
|
1118
|
+
* responds `400` ("Um contexto de conta é necessário e não foi fornecido")
|
|
1119
|
+
* without it. Note the camelCase spelling: `account_id` and an
|
|
1120
|
+
* `X-Account-Id` header are both rejected.
|
|
1121
|
+
*
|
|
1122
|
+
* @param params - `page`, `per-page`.
|
|
1123
|
+
* @param accountId - Override the client's default account ID.
|
|
1124
|
+
* @returns Assignments, with pagination in `meta`. Each item:
|
|
1125
|
+
* ```jsonc
|
|
1126
|
+
* {
|
|
1127
|
+
* "id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4",
|
|
1128
|
+
* "sender_email": "sender@example.com",
|
|
1129
|
+
* "method": "virtual",
|
|
1130
|
+
* "expires_at": null,
|
|
1131
|
+
* "message": "Please sign this contract",
|
|
1132
|
+
* "signers": [
|
|
1133
|
+
* {
|
|
1134
|
+
* "id": "b2c3d4e5f6a7b8c9d0e1f2a3b4c5",
|
|
1135
|
+
* "full_name": "Ana Souza",
|
|
1136
|
+
* "email": "signer@example.com",
|
|
1137
|
+
* "whatsapp_phone_number": null,
|
|
1138
|
+
* "has_accepted_terms": false,
|
|
1139
|
+
* "completed": false,
|
|
1140
|
+
* "notification_history": [],
|
|
1141
|
+
* "verification_method": "Email",
|
|
1142
|
+
* "notification_methods": ["Email"],
|
|
1143
|
+
* "step": 1,
|
|
1144
|
+
* "notified": true
|
|
1145
|
+
* }
|
|
1146
|
+
* ]
|
|
1147
|
+
* }
|
|
1148
|
+
* ```
|
|
1149
|
+
* @throws {ValidationError} If no account ID is available.
|
|
1150
|
+
* @throws {ApiError} If the API rejects the request.
|
|
1151
|
+
*
|
|
1152
|
+
* @example
|
|
1153
|
+
* ```ts
|
|
1154
|
+
* const { data, meta } = await client.assignments.list({ 'per-page': 20 });
|
|
1155
|
+
* ```
|
|
1156
|
+
*/
|
|
1157
|
+
list(params?: IAssignmentListParams, accountId?: string): Promise<IAssignmentListResponse>;
|
|
757
1158
|
/** Create a signing assignment for a document. */
|
|
758
1159
|
create(documentId: string, payload: ICreateAssignmentPayload): Promise<ICreateAssignmentResponse>;
|
|
759
|
-
/**
|
|
760
|
-
|
|
1160
|
+
/**
|
|
1161
|
+
* Estimate the cost (in credits/documents) of creating the assignment.
|
|
1162
|
+
*
|
|
1163
|
+
* Signer entries may omit `id` and supply only `verification_method` /
|
|
1164
|
+
* `notification_methods` when only the channel mix matters for the estimate.
|
|
1165
|
+
*
|
|
1166
|
+
* @returns an {@link ICostEstimate} with `total_credits`, balances, and a
|
|
1167
|
+
* line-item `breakdown`.
|
|
1168
|
+
*/
|
|
1169
|
+
estimateCost(documentId: string, payload: ICreateAssignmentPayload): Promise<ICostEstimate>;
|
|
761
1170
|
/**
|
|
762
1171
|
* Update the expiration date of an existing assignment.
|
|
763
1172
|
* Pass `null` to remove the expiration entirely.
|
|
@@ -765,28 +1174,51 @@ declare class AssignmentResource extends BaseResource {
|
|
|
765
1174
|
resetExpiration(documentId: string, assignmentId: string, expiresAt: string | null): Promise<IAssignment>;
|
|
766
1175
|
/** Resend the signing notification to a single signer. */
|
|
767
1176
|
resendNotification(documentId: string, assignmentId: string, signerId: string): Promise<IResendEmailResponse>;
|
|
768
|
-
/**
|
|
769
|
-
|
|
1177
|
+
/**
|
|
1178
|
+
* Estimate the cost of resending a signer notification.
|
|
1179
|
+
*
|
|
1180
|
+
* @returns an {@link IResendCostEstimate} (`total`, `breakdown`, balances).
|
|
1181
|
+
*/
|
|
1182
|
+
estimateResendCost(documentId: string, assignmentId: string, signerId: string): Promise<IResendCostEstimate>;
|
|
770
1183
|
/**
|
|
771
1184
|
* `GET /documents/{documentId}/assignments/{assignmentId}/whatsapp-notifications`
|
|
772
1185
|
* — list every WhatsApp notification rendered + sent for an assignment.
|
|
773
1186
|
*/
|
|
774
1187
|
listWhatsAppNotifications(documentId: string, assignmentId: string): Promise<IWhatsAppNotification[]>;
|
|
775
|
-
/**
|
|
776
|
-
* Cancel a signature request. This endpoint is not listed in the public
|
|
777
|
-
* Swagger but is exposed by the platform.
|
|
778
|
-
*/
|
|
779
|
-
cancel(documentId: string, reason: string, accountId?: string): Promise<unknown>;
|
|
780
1188
|
}
|
|
781
1189
|
|
|
1190
|
+
/**
|
|
1191
|
+
* Default webhook events applied by {@link WebhookResource.register} when the
|
|
1192
|
+
* caller omits `events` (or passes an empty array).
|
|
1193
|
+
*/
|
|
1194
|
+
declare const DEFAULT_WEBHOOK_EVENTS: WebhookEventType[];
|
|
782
1195
|
declare class WebhookResource extends BaseResource {
|
|
783
|
-
/**
|
|
1196
|
+
/**
|
|
1197
|
+
* Register (or replace) the workspace's single webhook subscription
|
|
1198
|
+
* (`PUT /accounts/{id}/webhooks/subscriptions`). There is exactly one
|
|
1199
|
+
* subscription per workspace, keyed by URL.
|
|
1200
|
+
*
|
|
1201
|
+
* When `events` is omitted or empty, {@link DEFAULT_WEBHOOK_EVENTS} is used
|
|
1202
|
+
* (`document_ready`, `document_prepared`, `signer_signed_document`,
|
|
1203
|
+
* `signer_rejected_document`, `document_processing_failed`).
|
|
1204
|
+
*
|
|
1205
|
+
* @example
|
|
1206
|
+
* ```ts
|
|
1207
|
+
* await client.webhooks.register({ url: 'https://example.com/hook', email: 'ops@example.com' });
|
|
1208
|
+
* // → { url, email, events: [...], is_active: true, updated_at: '2026-…' }
|
|
1209
|
+
* ```
|
|
1210
|
+
*/
|
|
784
1211
|
register(payload: IWebhookRegisterPayload, accountId?: string): Promise<IWebhookSubscription>;
|
|
785
1212
|
/** Fetch the current webhook subscription. Returns `null` if none exists. */
|
|
786
1213
|
get(accountId?: string): Promise<IWebhookSubscription | null>;
|
|
787
|
-
/**
|
|
788
|
-
|
|
789
|
-
|
|
1214
|
+
/**
|
|
1215
|
+
* Inactivate the current webhook subscription.
|
|
1216
|
+
*
|
|
1217
|
+
* This is the only supported way to stop deliveries — the API has no
|
|
1218
|
+
* subscription-delete route. The subscription is retained (with its `url`
|
|
1219
|
+
* and `events`) and simply stops firing; re-enable it by calling
|
|
1220
|
+
* {@link WebhookResource.register} again with `is_active: true`.
|
|
1221
|
+
*/
|
|
790
1222
|
inactivate(accountId?: string): Promise<IWebhookSubscription>;
|
|
791
1223
|
/** List currently supported webhook event types. */
|
|
792
1224
|
listEventTypes(): Promise<IWebhookEventTypeInfo[]>;
|
|
@@ -797,20 +1229,58 @@ declare class WebhookResource extends BaseResource {
|
|
|
797
1229
|
}
|
|
798
1230
|
|
|
799
1231
|
declare class TemplateResource extends BaseResource {
|
|
1232
|
+
/**
|
|
1233
|
+
* Create a template by uploading a PDF (`POST /accounts/{id}/templates`).
|
|
1234
|
+
*
|
|
1235
|
+
* The template is created in `Uploaded` status and transitions to `Ready`
|
|
1236
|
+
* once the platform finishes processing its pages. Configure roles/fields
|
|
1237
|
+
* afterwards in the Assinafy editor.
|
|
1238
|
+
*
|
|
1239
|
+
* @example
|
|
1240
|
+
* ```ts
|
|
1241
|
+
* const tmpl = await client.templates.create(
|
|
1242
|
+
* { filePath: './nda.pdf' },
|
|
1243
|
+
* { name: 'NDA template' },
|
|
1244
|
+
* );
|
|
1245
|
+
* // → { resource: 'template', id, name, status: 'Uploaded',
|
|
1246
|
+
* // roles: [{ id, name: 'TemplateEditor', assignment_type: 'Editor' }],
|
|
1247
|
+
* // pages: [], tags: [], created_at, updated_at }
|
|
1248
|
+
* ```
|
|
1249
|
+
*/
|
|
1250
|
+
create(source: DocumentUploadSource, options?: {
|
|
1251
|
+
name?: string;
|
|
1252
|
+
accountId?: string;
|
|
1253
|
+
}): Promise<ITemplateDetailsResponse>;
|
|
800
1254
|
/** List templates for the workspace. */
|
|
801
1255
|
list(params?: IListParams, accountId?: string): Promise<ITemplateListResponse>;
|
|
802
1256
|
/**
|
|
803
|
-
* Get a template by ID.
|
|
1257
|
+
* Get a template by ID (`GET /accounts/{id}/templates/{template_id}`).
|
|
804
1258
|
*
|
|
805
|
-
*
|
|
806
|
-
* `
|
|
807
|
-
*
|
|
1259
|
+
* Returns the same shape as {@link TemplateResource.list} plus
|
|
1260
|
+
* `default_document_tags` (the tags auto-applied to every document created
|
|
1261
|
+
* from this template) and `resource`. Both endpoints return `pages` with
|
|
1262
|
+
* per-page `download_url`, so fetching a template again purely to read its
|
|
1263
|
+
* pages is unnecessary.
|
|
808
1264
|
*/
|
|
809
1265
|
get(templateId: string, accountId?: string): Promise<ITemplateDetailsResponse>;
|
|
810
1266
|
/**
|
|
811
|
-
* `
|
|
812
|
-
*
|
|
813
|
-
*
|
|
1267
|
+
* Update a template's `name` and/or default `message`
|
|
1268
|
+
* (`PUT /accounts/{id}/templates/{template_id}`). Returns the updated template.
|
|
1269
|
+
*
|
|
1270
|
+
* @example
|
|
1271
|
+
* ```ts
|
|
1272
|
+
* await client.templates.update(templateId, { name: 'NDA v2', message: 'Please sign' });
|
|
1273
|
+
* ```
|
|
1274
|
+
*/
|
|
1275
|
+
update(templateId: string, payload: IUpdateTemplatePayload, accountId?: string): Promise<ITemplateDetailsResponse>;
|
|
1276
|
+
/** Delete a template (`DELETE /accounts/{id}/templates/{template_id}`). */
|
|
1277
|
+
delete(templateId: string, accountId?: string): Promise<void>;
|
|
1278
|
+
/**
|
|
1279
|
+
* Download a template page as a JPEG
|
|
1280
|
+
* (`GET /accounts/{id}/templates/{template_id}/pages/{page_id}/download`).
|
|
1281
|
+
*
|
|
1282
|
+
* Used by template editors to render page thumbnails on the client. The
|
|
1283
|
+
* matching `download_url` is also returned on each `template.pages[]` entry.
|
|
814
1284
|
*/
|
|
815
1285
|
downloadPage(templateId: string, pageId: string, accountId?: string): Promise<Buffer>;
|
|
816
1286
|
}
|
|
@@ -959,6 +1429,34 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
959
1429
|
getCurrent(signerId: string, signerAccessCode: string): Promise<IDocumentDetailsResponse>;
|
|
960
1430
|
/** `GET /signers/{signer_id}/documents?signer-access-code=…` */
|
|
961
1431
|
list(signerId: string, signerAccessCode: string, params?: IListParams): Promise<IDocumentListResponse>;
|
|
1432
|
+
/**
|
|
1433
|
+
* Search the documents awaiting a given signer
|
|
1434
|
+
* (`GET /signers/{signer_id}/documents/search?signer-access-code=…`).
|
|
1435
|
+
*
|
|
1436
|
+
* The signer-side counterpart of {@link DocumentResource.search}, scoped to
|
|
1437
|
+
* one signer and authorised by their access code rather than the API key.
|
|
1438
|
+
* Like {@link SignerDocumentsResource.list}, it requires
|
|
1439
|
+
* `signer-access-code`; the published spec omits that parameter, but the
|
|
1440
|
+
* endpoint is not usable without it.
|
|
1441
|
+
*
|
|
1442
|
+
* @param signerId - The signer whose documents are searched.
|
|
1443
|
+
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
1444
|
+
* @param search - Free-text term matched against the document name.
|
|
1445
|
+
* @returns Matching documents for that signer, in the compact
|
|
1446
|
+
* {@link IDocumentListItem} shape, with pagination in `meta`.
|
|
1447
|
+
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing.
|
|
1448
|
+
* @throws {ApiError} If the access code is invalid or expired.
|
|
1449
|
+
*
|
|
1450
|
+
* @example
|
|
1451
|
+
* ```ts
|
|
1452
|
+
* const { data } = await client.signerDocuments.search(
|
|
1453
|
+
* signerId,
|
|
1454
|
+
* accessCode,
|
|
1455
|
+
* 'agreement',
|
|
1456
|
+
* );
|
|
1457
|
+
* ```
|
|
1458
|
+
*/
|
|
1459
|
+
search(signerId: string, signerAccessCode: string, search?: string): Promise<IDocumentListResponse>;
|
|
962
1460
|
/** `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}?signer-access-code=…` */
|
|
963
1461
|
download(signerId: string, documentId: string, artifactName: DocumentArtifactName, signerAccessCode: string): Promise<Buffer>;
|
|
964
1462
|
/** `PUT /signers/documents/sign-multiple?signer-access-code=…` */
|
|
@@ -990,14 +1488,19 @@ declare class SignerDocumentsResource extends BaseResource {
|
|
|
990
1488
|
}): Promise<unknown>;
|
|
991
1489
|
/** `GET /signature/{type}?signer-access-code=…` — download the signer's signature/initial. */
|
|
992
1490
|
downloadSignature(signerAccessCode: string, imageType?: 'signature' | 'initial'): Promise<Buffer>;
|
|
993
|
-
/**
|
|
1491
|
+
/**
|
|
1492
|
+
* `GET /sign?signer-access-code=…` — fetch the assignment as the signer sees it.
|
|
1493
|
+
*
|
|
1494
|
+
* @param hasAcceptedTerms maps to the `has_accepted_terms` query param
|
|
1495
|
+
* (server default `false`); pass `true` once the signer has accepted terms.
|
|
1496
|
+
*/
|
|
994
1497
|
getAssignment(signerAccessCode: string, hasAcceptedTerms?: boolean): Promise<unknown>;
|
|
995
1498
|
/** `POST /documents/{documentId}/assignments/{assignmentId}?signer-access-code=…` — sign. */
|
|
996
1499
|
sign(documentId: string, assignmentId: string, signerAccessCode: string, entries: ISignFieldEntry[]): Promise<unknown>;
|
|
997
1500
|
/**
|
|
998
1501
|
* `PUT /documents/{documentId}/assignments/{assignmentId}/reject?signer-access-code=…`
|
|
999
|
-
* — signer-side decline. (
|
|
1000
|
-
* workspace
|
|
1502
|
+
* — signer-side decline. (The workspace-side equivalent is to delete the
|
|
1503
|
+
* document via `documents.delete`; there is no workspace "cancel" endpoint.)
|
|
1001
1504
|
*/
|
|
1002
1505
|
decline(documentId: string, assignmentId: string, signerAccessCode: string, declineReason: string): Promise<unknown>;
|
|
1003
1506
|
}
|
|
@@ -1037,6 +1540,7 @@ interface ClientConfigInput {
|
|
|
1037
1540
|
webhook_secret?: string;
|
|
1038
1541
|
webhookSecret?: string;
|
|
1039
1542
|
timeout?: number;
|
|
1543
|
+
maxRetries?: number;
|
|
1040
1544
|
logger?: Logger;
|
|
1041
1545
|
}
|
|
1042
1546
|
/**
|
|
@@ -1095,17 +1599,13 @@ declare class AssinafyClient {
|
|
|
1095
1599
|
/** Base class for all Assinafy SDK errors. */
|
|
1096
1600
|
declare class AssinafyError extends Error {
|
|
1097
1601
|
readonly context: Record<string, unknown>;
|
|
1098
|
-
constructor(message: string, context?: Record<string, unknown>, options?:
|
|
1099
|
-
cause?: unknown;
|
|
1100
|
-
});
|
|
1602
|
+
constructor(message: string, context?: Record<string, unknown>, options?: ErrorOptions);
|
|
1101
1603
|
}
|
|
1102
1604
|
/** Thrown when the API returns a non-success HTTP status. */
|
|
1103
1605
|
declare class ApiError extends AssinafyError {
|
|
1104
1606
|
readonly statusCode: number;
|
|
1105
1607
|
readonly responseData: unknown;
|
|
1106
|
-
constructor(message: string, statusCode: number, responseData?: unknown, options?:
|
|
1107
|
-
cause?: unknown;
|
|
1108
|
-
});
|
|
1608
|
+
constructor(message: string, statusCode: number, responseData?: unknown, options?: ErrorOptions);
|
|
1109
1609
|
static fromResponse(statusCode: number, responseData: unknown): ApiError;
|
|
1110
1610
|
}
|
|
1111
1611
|
/** Thrown when client-side validation fails before the request is sent. */
|
|
@@ -1115,9 +1615,7 @@ declare class ValidationError extends AssinafyError {
|
|
|
1115
1615
|
}
|
|
1116
1616
|
/** Thrown when the HTTP transport itself fails (DNS, timeout, etc.). */
|
|
1117
1617
|
declare class NetworkError extends AssinafyError {
|
|
1118
|
-
constructor(message: string, options?:
|
|
1119
|
-
cause?: unknown;
|
|
1120
|
-
});
|
|
1618
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1121
1619
|
}
|
|
1122
1620
|
|
|
1123
|
-
export { ApiError, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, type DocumentArtifactName, DocumentResource, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IApiKeyResponse, type IAssignment, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDocumentActivity, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationResult, type IInlineTag, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type IPaginatedResponse, type IPublicDocumentInfo, type IResendEmailResponse, type ISignFieldEntry, type ISigner, type ISignerListResponse, type ISigningProgress, type ITag, type ITemplateDetailsResponse, type ITemplateListItem, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type IUpdateFieldPayload, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type Logger, NetworkError, type PaginatedResult, type PaginationMeta, type SendTokenChannel, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, ValidationError, type WebhookEventType, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload };
|
|
1621
|
+
export { type AnyString, ApiError, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, DEFAULT_WEBHOOK_EVENTS, type DocumentArtifactName, DocumentResource, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IApiKeyResponse, type IAssignment, type IAssignmentItem, type IAssignmentListParams, type IAssignmentListResponse, type IAssignmentSigner, type ICostEstimate, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDocumentActivity, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentSearchParams, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationResult, type IInlineTag, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type IPage, type IPaginatedResponse, type IPublicDocumentInfo, type IRenameDocumentResponse, type IResendCostEstimate, type IResendEmailResponse, type ISignFieldEntry, type ISigner, type ISignerListResponse, type ISigningProgress, type ITag, type ITemplateDetailsResponse, type ITemplateListItem, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type IUpdateFieldPayload, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateTemplatePayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type Logger, MAX_UPLOAD_BYTES, NetworkError, type PaginatedResult, type PaginationMeta, type SendTokenChannel, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, ValidationError, type WebhookEventType, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload };
|