@assinafy/sdk 1.4.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.
@@ -0,0 +1,1123 @@
1
+ import { AxiosInstance, AxiosResponse } from 'axios';
2
+
3
+ /** Document lifecycle states emitted by the API. */
4
+ type DocumentStatus = 'uploading' | 'uploaded' | 'metadata_processing' | 'metadata_ready' | 'pending_signature' | 'expired' | 'certificating' | 'certificated' | 'rejected_by_signer' | 'rejected_by_user' | 'failed';
5
+ /** Artifact names available for document download. */
6
+ type DocumentArtifactName = 'original' | 'certificated' | 'certificate-page' | 'bundle';
7
+ /** Assignment methods supported by the API. */
8
+ type AssignmentMethod = 'virtual' | 'collect';
9
+ /** Verification methods accepted by assignment signer entries. */
10
+ type AssignmentVerificationMethod = 'Email' | 'Whatsapp' | string;
11
+ /** Notification methods accepted by assignment signer entries. */
12
+ type AssignmentNotificationMethod = 'Email' | 'Whatsapp' | string;
13
+ /** Minimal logger contract (compatible with console, pino, winston, etc.). */
14
+ interface Logger {
15
+ debug: (message: string, context?: Record<string, unknown>) => void;
16
+ info: (message: string, context?: Record<string, unknown>) => void;
17
+ warn: (message: string, context?: Record<string, unknown>) => void;
18
+ error: (message: string, context?: Record<string, unknown>) => void;
19
+ }
20
+ /** Client configuration options. */
21
+ interface AssinafyClientOptions {
22
+ /** Assinafy API key. Preferred authentication method (sends `X-Api-Key` header). */
23
+ apiKey?: string;
24
+ /**
25
+ * Legacy access token. If provided (and `apiKey` is not), the client will send
26
+ * `Authorization: Bearer <token>` instead. Kept for backwards compatibility.
27
+ */
28
+ token?: string;
29
+ /** Default account (workspace) ID applied to account-scoped endpoints. */
30
+ accountId?: string;
31
+ /** Override the API base URL. Defaults to https://api.assinafy.com.br/v1. */
32
+ baseUrl?: string;
33
+ /** Secret used to verify webhook payload signatures (HMAC-SHA256). */
34
+ webhookSecret?: string;
35
+ /** Request timeout in milliseconds. Defaults to 30_000. */
36
+ timeout?: number;
37
+ /** Optional logger. Defaults to a no-op logger. */
38
+ logger?: Logger;
39
+ }
40
+ /**
41
+ * Payload for creating a signer.
42
+ *
43
+ * `email` is optional: the API accepts a signer with only a
44
+ * `whatsapp_phone_number`. At least one of the two must be supplied.
45
+ */
46
+ interface ICreateSignerPayload {
47
+ full_name: string;
48
+ email?: string;
49
+ whatsapp_phone_number?: string;
50
+ /** PHP SDK compatibility alias for `whatsapp_phone_number`. */
51
+ phone?: string;
52
+ /** Brazilian tax ID (CPF). Non-digits are stripped before sending. */
53
+ cpf?: string;
54
+ metadata?: Record<string, unknown>;
55
+ }
56
+ /** Payload for updating a signer. */
57
+ interface IUpdateSignerPayload {
58
+ full_name?: string;
59
+ email?: string;
60
+ whatsapp_phone_number?: string;
61
+ /** PHP SDK compatibility alias for `whatsapp_phone_number`. */
62
+ phone?: string;
63
+ /** Brazilian tax ID (CPF). Non-digits are stripped before sending. */
64
+ cpf?: string;
65
+ }
66
+ /** Signer object as returned by the API. */
67
+ interface ISigner {
68
+ resource?: string;
69
+ id: string;
70
+ full_name: string;
71
+ email: string | null;
72
+ whatsapp_phone_number?: string | null;
73
+ cpf?: string | null;
74
+ has_accepted_terms?: boolean;
75
+ /** Only returned by `GET /signers/self`. */
76
+ has_signature?: boolean;
77
+ /** Only returned by `GET /signers/self`. */
78
+ has_initial?: boolean;
79
+ metadata?: Record<string, unknown>;
80
+ }
81
+ type ICreateSignerResponse = ISigner;
82
+ /** Pagination metadata extracted from `X-Pagination-*` response headers. */
83
+ interface PaginationMeta {
84
+ current_page?: number;
85
+ last_page?: number;
86
+ per_page?: number;
87
+ total?: number;
88
+ }
89
+ /** Shape returned by every paginated list call in the SDK. */
90
+ interface PaginatedResult<T> {
91
+ data: T[];
92
+ meta?: PaginationMeta;
93
+ }
94
+ /** @deprecated use {@link PaginatedResult} — retained for existing type imports. */
95
+ type IPaginatedResponse<T> = PaginatedResult<T>;
96
+ type ISignerListResponse = PaginatedResult<ISigner>;
97
+ /** Signer reference accepted by the assignment endpoints. */
98
+ type SignerReference = string | {
99
+ id?: string;
100
+ signer_id?: string;
101
+ verification_method?: AssignmentVerificationMethod;
102
+ notification_methods?: AssignmentNotificationMethod[];
103
+ /**
104
+ * Positive integer controlling signing order. Signers sharing a step
105
+ * sign in parallel; a step is activated (and its signers notified)
106
+ * only after every signer in the previous step has signed. If supplied
107
+ * for one signer it must be supplied for all, forming a contiguous
108
+ * sequence starting at 1.
109
+ */
110
+ step?: number;
111
+ };
112
+ /** Payload for creating an assignment. */
113
+ interface ICreateAssignmentPayload {
114
+ method?: AssignmentMethod;
115
+ /**
116
+ * List of signers. Each entry may be a signer id string, or an object with
117
+ * `id` / `signer_id`. For cost estimation, entries may omit the ID and
118
+ * specify only `verification_method` / `notification_methods`.
119
+ *
120
+ * The SDK normalises them to the docs-sanctioned `signers: [{ ... }]`
121
+ * shape before sending.
122
+ */
123
+ signers?: SignerReference[];
124
+ /** Legacy field still accepted by the API docs and used by the PHP SDK. */
125
+ signer_ids?: string[];
126
+ /** Camel-case legacy alias used by the quick-start docs. */
127
+ signerIds?: string[];
128
+ message?: string;
129
+ expires_at?: string;
130
+ copy_receivers?: string[];
131
+ /** Field placement entries used when `method` is `collect`. */
132
+ entries?: unknown[];
133
+ }
134
+ /** Assignment object as returned by the API. */
135
+ interface IAssignment {
136
+ id: string;
137
+ sender_email?: string;
138
+ method: AssignmentMethod;
139
+ expires_at?: string;
140
+ expiration?: string;
141
+ message?: string;
142
+ signers: ISigner[];
143
+ copy_receivers?: string[];
144
+ items?: unknown[];
145
+ summary?: {
146
+ signer_count: number;
147
+ completed_count: number;
148
+ signers: unknown[];
149
+ };
150
+ signing_urls?: Record<string, string>;
151
+ }
152
+ type ICreateAssignmentResponse = IAssignment;
153
+ interface IResendEmailResponse {
154
+ is_sent?: boolean;
155
+ document_id?: string;
156
+ signer_id?: string;
157
+ }
158
+ /** Webhook payload envelope. */
159
+ interface IWebhookPayload {
160
+ id?: number;
161
+ event?: string;
162
+ type?: string;
163
+ message?: string | null;
164
+ payload?: Record<string, unknown> | null;
165
+ origin?: Record<string, unknown> | null;
166
+ subject?: Record<string, unknown>;
167
+ object?: Record<string, unknown>;
168
+ account_id?: string;
169
+ data?: {
170
+ document_uuid?: string;
171
+ document_id?: string;
172
+ [key: string]: unknown;
173
+ };
174
+ [key: string]: unknown;
175
+ }
176
+ /** Known webhook event names. */
177
+ type WebhookEventType = 'document_uploaded' | 'document_metadata_ready' | 'document_prepared' | 'assignment_created' | 'document_ready' | 'signature_requested' | 'signer_created' | 'signer_email_verified' | 'signer_whatsapp_verified' | 'signer_data_confirmed' | 'signer_viewed_document' | 'signer_signed_document' | 'signer_rejected_document' | 'user_rejected_document' | 'document_processing_failed' | 'template_created' | 'template_processed' | 'template_processing_failed';
178
+ /** Document listing item (paginated). */
179
+ interface IDocumentListItem {
180
+ id: string;
181
+ name: string;
182
+ status: DocumentStatus;
183
+ account_id?: string;
184
+ template_id?: string | null;
185
+ /** Tags attached to the document (inline `{ id, name, color }` shape). */
186
+ tags?: IInlineTag[];
187
+ created_at: string;
188
+ updated_at?: string;
189
+ is_closed?: boolean;
190
+ }
191
+ type IDocumentListResponse = PaginatedResult<IDocumentListItem>;
192
+ /** Query parameters accepted by `documents.list`. */
193
+ interface IDocumentListParams extends IListParams {
194
+ /** Filter by document status, e.g. `pending_signature`. */
195
+ status?: DocumentStatus | string;
196
+ /** Filter by signature method (`virtual` or `collect`). */
197
+ method?: AssignmentMethod;
198
+ /** Comma-separated list of tag IDs (AND semantics). */
199
+ tags?: string;
200
+ }
201
+ /** Document upload response. */
202
+ interface IDocumentUploadResponse {
203
+ resource?: string;
204
+ id: string;
205
+ account_id: string;
206
+ template_id: string | null;
207
+ name: string;
208
+ status: DocumentStatus;
209
+ assignment: unknown;
210
+ artifacts: {
211
+ original: string;
212
+ certificated?: string;
213
+ 'certificate-page'?: string;
214
+ bundle?: string;
215
+ thumbnail?: string;
216
+ };
217
+ pages: Array<{
218
+ id: string;
219
+ number: number;
220
+ height: number;
221
+ width: number;
222
+ download_url: string;
223
+ }>;
224
+ /** Tags attached to the document (inline `{ id, name, color }` shape). */
225
+ tags?: IInlineTag[];
226
+ created_at: string;
227
+ updated_at: string;
228
+ is_closed: boolean;
229
+ decline_reason: string | null;
230
+ declined_by: string | null;
231
+ }
232
+ /** Detailed document response. */
233
+ interface IDocumentDetailsResponse {
234
+ resource?: string;
235
+ id: string;
236
+ account_id: string;
237
+ name: string;
238
+ status: DocumentStatus;
239
+ assignment: IAssignment | null;
240
+ download_url?: string;
241
+ download_final_url?: string;
242
+ signing_url?: string;
243
+ artifacts?: {
244
+ original: string;
245
+ certificated?: string;
246
+ 'certificate-page'?: string;
247
+ bundle?: string;
248
+ thumbnail?: string;
249
+ };
250
+ pages: unknown[];
251
+ /** Tags attached to the document (inline `{ id, name, color }` shape). */
252
+ tags?: IInlineTag[];
253
+ created_at: string;
254
+ updated_at: string;
255
+ is_closed: boolean;
256
+ decline_reason?: string;
257
+ declined_by?: ISigner | null;
258
+ activities?: Array<IDocumentActivity>;
259
+ }
260
+ interface IDocumentActivity {
261
+ id: number;
262
+ event: string;
263
+ message: string;
264
+ /** Event-specific payload snapshot. Object for most events, occasionally `[]`. */
265
+ payload?: Record<string, unknown> | unknown[];
266
+ /** Request origin (`ip` / `user-agent`) when available; `null` for system events. */
267
+ origin: {
268
+ ip?: string;
269
+ 'user-agent'?: string;
270
+ } | string | null;
271
+ created_at: string;
272
+ }
273
+ /** Progress summary returned by `documents.getSigningProgress`. */
274
+ interface ISigningProgress {
275
+ signed: number;
276
+ total: number;
277
+ percentage: number;
278
+ pending: number;
279
+ }
280
+ /** Query parameters accepted by paginated list endpoints. */
281
+ interface IListParams {
282
+ page?: number;
283
+ per_page?: number;
284
+ 'per-page'?: number;
285
+ search?: string;
286
+ sort?: string;
287
+ [key: string]: string | number | boolean | undefined;
288
+ }
289
+ /** Workspace creation payload. */
290
+ interface ICreateWorkspacePayload {
291
+ name: string;
292
+ primary_color?: string;
293
+ secondary_color?: string;
294
+ }
295
+ interface IUpdateWorkspacePayload {
296
+ name?: string;
297
+ primary_color?: string | null;
298
+ secondary_color?: string | null;
299
+ }
300
+ interface IWorkspaceResponse {
301
+ id: string;
302
+ name: string;
303
+ primary_color?: string;
304
+ secondary_color?: string;
305
+ created_at: string;
306
+ }
307
+ interface IWorkspaceListItem {
308
+ id: string;
309
+ name: string;
310
+ is_delete_allowed: boolean;
311
+ roles: string[];
312
+ created_at: string;
313
+ }
314
+ type IWorkspaceListResponse = PaginatedResult<IWorkspaceListItem>;
315
+ /** Webhook subscription payload. */
316
+ interface IWebhookRegisterPayload {
317
+ url: string;
318
+ email: string;
319
+ events?: WebhookEventType[] | string[];
320
+ is_active?: boolean;
321
+ }
322
+ interface IWebhookSubscription {
323
+ id?: string;
324
+ url: string;
325
+ email: string;
326
+ events: string[];
327
+ is_active: boolean;
328
+ created_at?: string;
329
+ updated_at?: string;
330
+ }
331
+ interface IWebhookEventTypeInfo {
332
+ id: WebhookEventType | string;
333
+ description: string;
334
+ }
335
+ interface IWebhookDispatch {
336
+ id: string;
337
+ event: WebhookEventType | string;
338
+ activity_id: number;
339
+ endpoint: string | null;
340
+ payload: IWebhookPayload | Record<string, unknown> | null;
341
+ delivered: boolean;
342
+ http_status: number | null;
343
+ response_body: string | null;
344
+ error: string | null;
345
+ created_at: number;
346
+ updated_at?: number;
347
+ }
348
+ interface IWebhookDispatchListParams extends IListParams {
349
+ event?: WebhookEventType | string;
350
+ delivered?: boolean | 'true' | 'false';
351
+ from?: number;
352
+ to?: number;
353
+ }
354
+ /** Shape of the high-level `uploadAndRequestSignatures` helper result. */
355
+ interface IUploadAndRequestSignaturesResult {
356
+ document: IDocumentUploadResponse;
357
+ assignment: IAssignment;
358
+ signer_ids: string[];
359
+ }
360
+ /** Input for a signer in `uploadAndRequestSignatures`. */
361
+ interface IUploadAndRequestSignaturesSigner {
362
+ name: string;
363
+ email?: string;
364
+ whatsapp_phone_number?: string;
365
+ /** PHP SDK compatibility alias for `whatsapp_phone_number`. */
366
+ phone?: string;
367
+ /** Brazilian tax ID (CPF). Non-digits are stripped before sending. */
368
+ cpf?: string;
369
+ metadata?: Record<string, unknown>;
370
+ }
371
+ /** Template role definition. */
372
+ interface ITemplateRole {
373
+ id: string;
374
+ name: string;
375
+ [key: string]: unknown;
376
+ }
377
+ /** Template list item (paginated). */
378
+ interface ITemplateListItem {
379
+ resource?: string;
380
+ id: string;
381
+ name: string;
382
+ document_name?: string | null;
383
+ message?: string | null;
384
+ status: string;
385
+ account_id?: string;
386
+ roles?: ITemplateRole[];
387
+ /** Tags attached to the template itself (inline `{ id, name }` shape). */
388
+ tags?: IInlineTag[];
389
+ created_at: string;
390
+ updated_at?: string;
391
+ }
392
+ type ITemplateListResponse = PaginatedResult<ITemplateListItem>;
393
+ /** Full template details. */
394
+ interface ITemplateDetailsResponse {
395
+ resource?: string;
396
+ id: string;
397
+ name: string;
398
+ document_name?: string | null;
399
+ message?: string | null;
400
+ status: string;
401
+ account_id?: string;
402
+ pages?: unknown[];
403
+ roles?: ITemplateRole[];
404
+ /** Tags attached to the template itself. */
405
+ tags?: IInlineTag[];
406
+ /** Tags auto-applied to every document created from this template. */
407
+ default_document_tags?: IInlineTag[];
408
+ created_at: string;
409
+ updated_at?: string;
410
+ [key: string]: unknown;
411
+ }
412
+ /** Signer assignment for creating a document from a template. */
413
+ interface ITemplateSigner {
414
+ role_id: string;
415
+ id: string;
416
+ verification_method?: string;
417
+ notification_methods?: string[];
418
+ /** Positive integer controlling signing order (see {@link SignerReference}). */
419
+ step?: number;
420
+ }
421
+ /** Options for creating a document from a template. */
422
+ interface ICreateDocumentFromTemplateOptions {
423
+ name?: string;
424
+ message?: string;
425
+ expires_at?: string;
426
+ editor_fields?: unknown[];
427
+ /**
428
+ * Tag names to attach to the new document. Names that don't exist yet are
429
+ * auto-created; the template's default-document-tags are always merged in.
430
+ */
431
+ tags?: string[];
432
+ }
433
+ /**
434
+ * Item returned by `GET /documents/statuses`.
435
+ *
436
+ * The API uses `code` (the status name); we mirror that field. `description`
437
+ * is documented in the table but is not currently present in the JSON payload.
438
+ */
439
+ interface IDocumentStatusInfo {
440
+ code: DocumentStatus | string;
441
+ deletable: boolean;
442
+ description?: string;
443
+ }
444
+ /** Item returned by `GET /public/documents/{id}`. */
445
+ interface IPublicDocumentInfo {
446
+ resource?: string;
447
+ id: string;
448
+ name: string;
449
+ page_count?: string | number;
450
+ created_by?: string;
451
+ [key: string]: unknown;
452
+ }
453
+ /** Channel accepted by the `send-token` endpoint. */
454
+ type SendTokenChannel = 'email' | 'whatsapp' | string;
455
+ /** Authentication: login response (also returned by social login). */
456
+ interface ILoginResponse {
457
+ access_token: string;
458
+ user: {
459
+ id: string;
460
+ name: string;
461
+ email: string;
462
+ telephone?: string;
463
+ government_id?: string;
464
+ is_email_verified?: boolean;
465
+ has_accepted_terms?: boolean;
466
+ created_at?: string;
467
+ to_be_deleted_at?: string | null;
468
+ };
469
+ accounts: Array<{
470
+ id: string;
471
+ name: string;
472
+ roles: string[];
473
+ is_delete_allowed: boolean;
474
+ created_at: string;
475
+ }>;
476
+ }
477
+ /** Authentication: API key payload returned by `POST /users/api-keys`. */
478
+ interface IApiKeyResponse {
479
+ api_key: string;
480
+ }
481
+ /** Authentication: masked API key returned by `GET /users/api-keys` (or null when never generated). */
482
+ type IMaskedApiKeyResponse = {
483
+ api_key: string;
484
+ } | null;
485
+ /** Field definition object. */
486
+ interface IFieldDefinition {
487
+ resource?: string;
488
+ id: string;
489
+ name: string;
490
+ type: string;
491
+ regex?: string | null;
492
+ is_pre_defined?: boolean;
493
+ is_active: boolean;
494
+ is_required?: boolean;
495
+ is_standard?: boolean;
496
+ is_read_only?: boolean;
497
+ is_visible?: boolean;
498
+ }
499
+ /** Payload for creating a field definition. */
500
+ interface ICreateFieldPayload {
501
+ type: string;
502
+ name: string;
503
+ regex?: string;
504
+ is_required?: boolean;
505
+ is_active?: boolean;
506
+ }
507
+ /** Payload for updating a field definition. */
508
+ interface IUpdateFieldPayload {
509
+ type?: string;
510
+ name?: string;
511
+ regex?: string | null;
512
+ is_required?: boolean;
513
+ is_active?: boolean;
514
+ }
515
+ /** Field type description returned by `GET /field-types`. */
516
+ interface IFieldType {
517
+ type: string;
518
+ name: string;
519
+ }
520
+ /** Single result returned by `POST /accounts/{id}/fields/{id}/validate`. */
521
+ interface IFieldValidationResult {
522
+ type?: string;
523
+ field_id?: string;
524
+ success: boolean;
525
+ error_message: string;
526
+ }
527
+ /** Payload entry for `POST /accounts/{id}/fields/validate-multiple`. */
528
+ interface IFieldValidateMultipleEntry {
529
+ field_id: string;
530
+ value: unknown;
531
+ }
532
+ /** Item returned by `GET /documents/{id}/assignments/{id}/whatsapp-notifications`. */
533
+ interface IWhatsAppNotification {
534
+ sent_at: number;
535
+ header: string;
536
+ body: string;
537
+ buttons: Array<{
538
+ text: string;
539
+ url?: string;
540
+ }>;
541
+ phone_number: string;
542
+ signer_id: string;
543
+ }
544
+ /** Body entry for the signer-side `POST /documents/{id}/assignments/{id}` sign endpoint. */
545
+ interface ISignFieldEntry {
546
+ itemId: string;
547
+ fieldId: string;
548
+ pageId: string;
549
+ value: string;
550
+ }
551
+ /**
552
+ * Workspace tag object. Tag names are unique per workspace (case-insensitive)
553
+ * and `color` is an optional 6-char hex string (without the leading `#`).
554
+ */
555
+ interface ITag {
556
+ resource?: string;
557
+ id: string;
558
+ name: string;
559
+ color: string | null;
560
+ created_at: string;
561
+ updated_at: string;
562
+ }
563
+ /** Inline tag shape embedded inside documents/templates (`{ id, name, color? }`). */
564
+ interface IInlineTag {
565
+ id: string;
566
+ name: string;
567
+ color?: string | null;
568
+ }
569
+ /** Payload for `POST /accounts/{id}/tags`. */
570
+ interface ICreateTagPayload {
571
+ name: string;
572
+ /** 6-char hex color, with or without a leading `#`. Omit/`null` for none. */
573
+ color?: string | null;
574
+ }
575
+ /** Payload for `PUT /accounts/{id}/tags/{id}`. Omit a field to leave it unchanged. */
576
+ interface IUpdateTagPayload {
577
+ name?: string;
578
+ /** Pass `null` to clear the color; omit to leave unchanged. */
579
+ color?: string | null;
580
+ }
581
+
582
+ /**
583
+ * Shared plumbing for every Assinafy resource:
584
+ *
585
+ * - holds the axios instance, default account ID, and logger
586
+ * - provides `accountId()` / `requireId()` argument guards
587
+ * - wraps HTTP calls in a single `try/catch` → typed-error pipeline
588
+ * - unwraps the Assinafy response envelope
589
+ * - parses `X-Pagination-*` headers into a typed meta object
590
+ *
591
+ * Resources should never `try/catch` or touch the envelope directly — they call
592
+ * one of `call` / `callVoid` / `callBinary` / `callList` instead.
593
+ */
594
+ declare abstract class BaseResource {
595
+ protected readonly http: AxiosInstance;
596
+ protected readonly defaultAccountId?: string | undefined;
597
+ protected readonly logger: Logger;
598
+ constructor(http: AxiosInstance, defaultAccountId?: string | undefined, logger?: Logger);
599
+ /** Resolve the effective account id, throwing if none is available. */
600
+ protected accountId(explicit?: string): string;
601
+ /** Guard required path arguments (documentId, signerId, …). */
602
+ protected requireId<T extends string>(value: T | undefined | null, name: string): T;
603
+ /** Execute an HTTP call and return the unwrapped envelope body. */
604
+ protected call<T>(label: string, request: RequestFn): Promise<T>;
605
+ /** Like {@link call} but returns `null` when the API responds with 404. */
606
+ protected callOptional<T>(label: string, request: RequestFn): Promise<T | null>;
607
+ /** Execute an HTTP call that returns no body (DELETE / 204). */
608
+ protected callVoid(label: string, request: RequestFn): Promise<void>;
609
+ /** Execute an HTTP call that returns binary data (artifact downloads). */
610
+ protected callBinary(label: string, request: () => Promise<AxiosResponse<ArrayBuffer>>): Promise<Buffer>;
611
+ /** Execute a paginated list call and attach meta from `X-Pagination-*` headers. */
612
+ protected callList<T>(label: string, request: RequestFn): Promise<PaginatedResult<T>>;
613
+ }
614
+ type RequestFn = () => Promise<AxiosResponse>;
615
+
616
+ /** Input for uploading a document: either an on-disk file or an in-memory buffer. */
617
+ type DocumentUploadSource = {
618
+ filePath: string;
619
+ fileName?: string;
620
+ } | {
621
+ buffer: Buffer;
622
+ fileName: string;
623
+ };
624
+ interface IDocumentUploadOptions {
625
+ /** Optional metadata sent alongside the file (JSON-encoded). */
626
+ metadata?: Record<string, unknown>;
627
+ /** Override the default account ID configured on the client. */
628
+ accountId?: string;
629
+ }
630
+ declare class DocumentResource extends BaseResource {
631
+ /**
632
+ * Upload a PDF to the workspace.
633
+ *
634
+ * @example
635
+ * ```ts
636
+ * await client.documents.upload({ filePath: './contract.pdf' });
637
+ * await client.documents.upload({ buffer, fileName: 'contract.pdf' }, { metadata });
638
+ * ```
639
+ */
640
+ upload(source: DocumentUploadSource, options?: IDocumentUploadOptions): Promise<IDocumentUploadResponse>;
641
+ /**
642
+ * List workspace documents. Pagination info (if any) is attached in `meta`.
643
+ * Supports `status`, `method`, `tags`, `search`, `sort`, `page`, `per_page`.
644
+ */
645
+ list(params?: IDocumentListParams, accountId?: string): Promise<IDocumentListResponse>;
646
+ /** Get document details. */
647
+ details(documentId: string): Promise<IDocumentDetailsResponse>;
648
+ /** Alias for {@link details}. */
649
+ get(documentId: string): Promise<IDocumentDetailsResponse>;
650
+ /** Poll document status until ready (or a terminal status / timeout). */
651
+ waitUntilReady(documentId: string, options?: {
652
+ maxWaitMs?: number;
653
+ pollIntervalMs?: number;
654
+ }): Promise<IDocumentDetailsResponse>;
655
+ /** Download a document artifact. Defaults to the certificated (signed) PDF. */
656
+ download(documentId: string, artifactName?: DocumentArtifactName): Promise<Buffer>;
657
+ /** Download the document thumbnail. */
658
+ thumbnail(documentId: string): Promise<Buffer>;
659
+ /** Download a single page as a JPEG. */
660
+ downloadPage(documentId: string, pageId: string): Promise<Buffer>;
661
+ /** Fetch the document activity log. */
662
+ activities(documentId: string): Promise<IDocumentActivity[]>;
663
+ /** Delete a document. */
664
+ delete(documentId: string): Promise<void>;
665
+ /** List the tags attached to a document. */
666
+ listTags(documentId: string, accountId?: string): Promise<ITag[]>;
667
+ /**
668
+ * Replace the document's tag set with `tags` (an array of tag names).
669
+ * Unknown names are auto-created; an empty array detaches all tags.
670
+ */
671
+ replaceTags(documentId: string, tags: string[], accountId?: string): Promise<ITag[]>;
672
+ /** Attach additional tags (by name) without removing existing ones. Idempotent. */
673
+ addTags(documentId: string, tags: string[], accountId?: string): Promise<ITag[]>;
674
+ /** Detach a single tag from a document (the tag itself is not deleted). */
675
+ detachTag(documentId: string, tagId: string, accountId?: string): Promise<void>;
676
+ /**
677
+ * Create a document from a template.
678
+ *
679
+ * @example
680
+ * ```ts
681
+ * await client.documents.createFromTemplate('tmpl_id', [
682
+ * { role_id: 'role_id', id: 'signer_id', verification_method: 'Email', notification_methods: ['Email'] },
683
+ * ], { name: 'My Contract' });
684
+ * ```
685
+ */
686
+ createFromTemplate(templateId: string, signers: ITemplateSigner[], options?: ICreateDocumentFromTemplateOptions, accountId?: string): Promise<IDocumentDetailsResponse>;
687
+ /** Estimate the credit cost of creating a document from a template. */
688
+ estimateCostFromTemplate(templateId: string, signers: ITemplateSigner[], accountId?: string): Promise<Record<string, unknown>>;
689
+ /** Verify a document by its signature hash. */
690
+ verify(hash: string): Promise<Record<string, unknown>>;
691
+ /**
692
+ * `GET /documents/statuses` — list every possible document status with
693
+ * its description and whether documents in that status can be deleted.
694
+ */
695
+ statuses(): Promise<IDocumentStatusInfo[]>;
696
+ /**
697
+ * `GET /public/documents/{document_id}` — public, unauthenticated lookup of
698
+ * basic document info (used by the signing portal before the signer
699
+ * authenticates via the access code).
700
+ */
701
+ getPublic(documentId: string): Promise<IPublicDocumentInfo>;
702
+ /**
703
+ * `PUT /public/documents/{document_id}/send-token` — send the 6-digit
704
+ * verification token to the signer's email / WhatsApp.
705
+ */
706
+ sendToken(documentId: string, recipient: string, channel?: SendTokenChannel): Promise<unknown>;
707
+ /** Quick check: has every signer completed their assignment? */
708
+ isFullySigned(documentId: string): Promise<boolean>;
709
+ /** Summarise signing progress for UI display. */
710
+ getSigningProgress(documentId: string): Promise<ISigningProgress>;
711
+ }
712
+
713
+ declare class SignerResource extends BaseResource {
714
+ /**
715
+ * Create a signer in the workspace.
716
+ *
717
+ * `email` is optional — the API also accepts whatsapp-only signers — but at
718
+ * least one of `email` / `whatsapp_phone_number` (or the `phone` alias) is
719
+ * required. When an `email` is supplied the call is idempotent by email:
720
+ * an existing signer with that address is reused instead of duplicated.
721
+ */
722
+ create(payload: ICreateSignerPayload, accountId?: string): Promise<ICreateSignerResponse>;
723
+ /** Get a signer by ID. */
724
+ get(signerId: string, accountId?: string): Promise<ISigner>;
725
+ /** List signers for the workspace (supports `page`, `per_page`, `search`, `sort`). */
726
+ list(params?: IListParams, accountId?: string): Promise<ISignerListResponse>;
727
+ /** Update a signer. Fails if the signer has active assignments. */
728
+ update(signerId: string, payload: IUpdateSignerPayload, accountId?: string): Promise<ICreateSignerResponse>;
729
+ /** Delete a signer. */
730
+ delete(signerId: string, accountId?: string): Promise<void>;
731
+ /** Find a signer by email via the API's `search` parameter. Returns `null` if none match. */
732
+ findByEmail(email: string, accountId?: string): Promise<ISigner | null>;
733
+ private assertEmail;
734
+ }
735
+
736
+ declare class WorkspaceResource extends BaseResource {
737
+ /** Create a new workspace. */
738
+ create(payload: ICreateWorkspacePayload): Promise<IWorkspaceResponse>;
739
+ /** List workspaces the authenticated user can access. */
740
+ list(): Promise<IWorkspaceListResponse>;
741
+ /** Fetch a single workspace. */
742
+ get(accountId: string): Promise<IWorkspaceResponse>;
743
+ /** Update a workspace. */
744
+ update(accountId: string, payload: IUpdateWorkspacePayload): Promise<IWorkspaceResponse>;
745
+ /** Delete a workspace. */
746
+ delete(accountId: string): Promise<void>;
747
+ }
748
+
749
+ /**
750
+ * Normalise an assignment payload into the shape the API expects:
751
+ * `signers: [{ id }]` plus optional docs-level fields.
752
+ */
753
+ declare function buildAssignmentPayload(payload: ICreateAssignmentPayload, options?: {
754
+ allowSignersWithoutId?: boolean;
755
+ }): Record<string, unknown>;
756
+ declare class AssignmentResource extends BaseResource {
757
+ /** Create a signing assignment for a document. */
758
+ create(documentId: string, payload: ICreateAssignmentPayload): Promise<ICreateAssignmentResponse>;
759
+ /** Estimate the cost (in credits) of creating the assignment. */
760
+ estimateCost(documentId: string, payload: ICreateAssignmentPayload): Promise<Record<string, unknown>>;
761
+ /**
762
+ * Update the expiration date of an existing assignment.
763
+ * Pass `null` to remove the expiration entirely.
764
+ */
765
+ resetExpiration(documentId: string, assignmentId: string, expiresAt: string | null): Promise<IAssignment>;
766
+ /** Resend the signing notification to a single signer. */
767
+ resendNotification(documentId: string, assignmentId: string, signerId: string): Promise<IResendEmailResponse>;
768
+ /** Estimate the cost of resending a signer notification. */
769
+ estimateResendCost(documentId: string, assignmentId: string, signerId: string): Promise<Record<string, unknown>>;
770
+ /**
771
+ * `GET /documents/{documentId}/assignments/{assignmentId}/whatsapp-notifications`
772
+ * — list every WhatsApp notification rendered + sent for an assignment.
773
+ */
774
+ 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
+ }
781
+
782
+ declare class WebhookResource extends BaseResource {
783
+ /** Register (or replace) the webhook subscription for the workspace. */
784
+ register(payload: IWebhookRegisterPayload, accountId?: string): Promise<IWebhookSubscription>;
785
+ /** Fetch the current webhook subscription. Returns `null` if none exists. */
786
+ get(accountId?: string): Promise<IWebhookSubscription | null>;
787
+ /** Delete the current webhook subscription. */
788
+ delete(accountId?: string): Promise<void>;
789
+ /** Inactivate the current webhook subscription without deleting it. */
790
+ inactivate(accountId?: string): Promise<IWebhookSubscription>;
791
+ /** List currently supported webhook event types. */
792
+ listEventTypes(): Promise<IWebhookEventTypeInfo[]>;
793
+ /** List webhook delivery history for the workspace. */
794
+ listDispatches(params?: IWebhookDispatchListParams, accountId?: string): Promise<PaginatedResult<IWebhookDispatch>>;
795
+ /** Retry delivery of a specific webhook dispatch. */
796
+ retryDispatch(dispatchId: string, accountId?: string): Promise<IWebhookDispatch>;
797
+ }
798
+
799
+ declare class TemplateResource extends BaseResource {
800
+ /** List templates for the workspace. */
801
+ list(params?: IListParams, accountId?: string): Promise<ITemplateListResponse>;
802
+ /**
803
+ * Get a template by ID.
804
+ *
805
+ * Note: the swagger only documents the list endpoint; this single-resource
806
+ * `GET /accounts/{id}/templates/{id}` is exposed by the platform and used
807
+ * by the official PHP SDK.
808
+ */
809
+ get(templateId: string, accountId?: string): Promise<ITemplateDetailsResponse>;
810
+ /**
811
+ * `GET /accounts/{id}/templates/{template_id}/pages/{page_id}/download` —
812
+ * download a template page as a JPEG (used by template editors to render
813
+ * thumbnails on the client).
814
+ */
815
+ downloadPage(templateId: string, pageId: string, accountId?: string): Promise<Buffer>;
816
+ }
817
+
818
+ /**
819
+ * Workspace-scoped tags used to label documents and templates.
820
+ *
821
+ * Covers the full Tag section of the API docs:
822
+ * - `GET /accounts/{id}/tags` → {@link list}
823
+ * - `POST /accounts/{id}/tags` → {@link create}
824
+ * - `PUT /accounts/{id}/tags/{tag_id}` → {@link update}
825
+ * - `DELETE /accounts/{id}/tags/{tag_id}` → {@link delete}
826
+ *
827
+ * Document-level attach/detach lives on {@link DocumentResource} (`listTags`,
828
+ * `replaceTags`, `addTags`, `detachTag`).
829
+ */
830
+ declare class TagResource extends BaseResource {
831
+ /** List the workspace's tags, ordered alphabetically. Optional case-insensitive `search`. */
832
+ list(params?: {
833
+ search?: string;
834
+ }, accountId?: string): Promise<ITag[]>;
835
+ /** Create a tag. Throws `ApiError` (409) if the name already exists (case-insensitive). */
836
+ create(payload: ICreateTagPayload, accountId?: string): Promise<ITag>;
837
+ /**
838
+ * Update a tag's name and/or color. Omit a field to leave it unchanged;
839
+ * pass `color: null` to clear the color. Throws `ApiError` (409) if another
840
+ * tag already uses the new name.
841
+ */
842
+ update(tagId: string, payload: IUpdateTagPayload, accountId?: string): Promise<ITag>;
843
+ /**
844
+ * Delete a tag. By default fails with `ApiError` (409) if the tag is still
845
+ * attached to anything; pass `{ force: true }` to detach everywhere first.
846
+ */
847
+ delete(tagId: string, options?: {
848
+ force?: boolean;
849
+ accountId?: string;
850
+ }): Promise<void>;
851
+ }
852
+
853
+ /**
854
+ * Authentication endpoints (login, social login, password management) and
855
+ * personal API key management (`/users/api-keys`).
856
+ *
857
+ * Most of these endpoints are intended to bootstrap an authenticated session
858
+ * for a human user. Production server-to-server integrations should use
859
+ * `X-Api-Key` and skip this resource entirely.
860
+ */
861
+ declare class AuthenticationResource extends BaseResource {
862
+ /** `POST /login` — exchange email + password for a JWT access token. */
863
+ login(email: string, password: string): Promise<ILoginResponse>;
864
+ /** `POST /authentication/social-login` — exchange a provider token for an Assinafy JWT. */
865
+ socialLogin(payload: {
866
+ provider: string;
867
+ token: string;
868
+ has_accepted_terms: boolean;
869
+ }): Promise<ILoginResponse>;
870
+ /** `POST /users/api-keys` — generate (and rotate) the current user's API key. */
871
+ createApiKey(password: string): Promise<IApiKeyResponse>;
872
+ /**
873
+ * `GET /users/api-keys` — fetch a masked version of the current API key, or
874
+ * `null` if no key has been generated yet.
875
+ */
876
+ getApiKey(): Promise<IMaskedApiKeyResponse>;
877
+ /** `DELETE /users/api-keys` — revoke the current API key. */
878
+ deleteApiKey(): Promise<void>;
879
+ /** `PUT /authentication/change-password` — change the authenticated user's password. */
880
+ changePassword(payload: {
881
+ email: string;
882
+ password: string;
883
+ new_password: string;
884
+ }): Promise<{
885
+ email: string;
886
+ }>;
887
+ /** `PUT /authentication/request-password-reset` — email a reset link to the user. */
888
+ requestPasswordReset(email: string): Promise<{
889
+ email: string;
890
+ }>;
891
+ /** `PUT /authentication/reset-password` — complete a password reset using the emailed token. */
892
+ resetPassword(payload: {
893
+ email: string;
894
+ token?: string;
895
+ new_password: string;
896
+ }): Promise<{
897
+ email: string;
898
+ }>;
899
+ }
900
+
901
+ /**
902
+ * Custom field definitions used by `collect` assignments.
903
+ *
904
+ * Covers the full Field Definition section of the API docs:
905
+ * - `POST /accounts/{id}/fields`
906
+ * - `GET /accounts/{id}/fields`
907
+ * - `GET /accounts/{id}/fields/{id}`
908
+ * - `PUT /accounts/{id}/fields/{id}`
909
+ * - `DELETE /accounts/{id}/fields/{id}`
910
+ * - `POST /accounts/{id}/fields/{id}/validate?signer-access-code=…`
911
+ * - `POST /accounts/{id}/fields/validate-multiple?signer-access-code=…`
912
+ * - `GET /field-types`
913
+ */
914
+ declare class FieldsResource extends BaseResource {
915
+ /** Create a field definition. */
916
+ create(payload: ICreateFieldPayload, accountId?: string): Promise<IFieldDefinition>;
917
+ /**
918
+ * List field definitions for the workspace.
919
+ *
920
+ * @param params.include_inactive return inactive fields too
921
+ * @param params.include_standard also return `signature`, `initial`, `signatureDate`
922
+ */
923
+ list(params?: {
924
+ include_inactive?: boolean;
925
+ include_standard?: boolean;
926
+ }, accountId?: string): Promise<IFieldDefinition[]>;
927
+ /** Get a single field definition by ID. */
928
+ get(fieldId: string, accountId?: string): Promise<IFieldDefinition>;
929
+ /** Update a field definition. */
930
+ update(fieldId: string, payload: IUpdateFieldPayload, accountId?: string): Promise<IFieldDefinition>;
931
+ /** Delete a field definition. Fails if the field has been used. */
932
+ delete(fieldId: string, accountId?: string): Promise<void>;
933
+ /**
934
+ * Validate a single value against a field definition.
935
+ *
936
+ * Pass `signerAccessCode` for signer-side validation (the typical use case);
937
+ * omit it when the caller is authenticated via API key.
938
+ */
939
+ validate(fieldId: string, value: unknown, options?: {
940
+ signerAccessCode?: string;
941
+ accountId?: string;
942
+ }): Promise<IFieldValidationResult>;
943
+ /** Validate multiple values at once. */
944
+ validateMultiple(entries: IFieldValidateMultipleEntry[], options?: {
945
+ signerAccessCode?: string;
946
+ accountId?: string;
947
+ }): Promise<IFieldValidationResult[]>;
948
+ /** List the platform's supported field types. */
949
+ listTypes(): Promise<IFieldType[]>;
950
+ }
951
+
952
+ /**
953
+ * Signer-side endpoints. Every call here is authenticated by `signer-access-code`
954
+ * (the one-time link emailed/whatsapped to the signer), not by the workspace
955
+ * API key. Use this resource when building a custom signer UI.
956
+ */
957
+ declare class SignerDocumentsResource extends BaseResource {
958
+ /** `GET /signers/{signer_id}/document?signer-access-code=…` */
959
+ getCurrent(signerId: string, signerAccessCode: string): Promise<IDocumentDetailsResponse>;
960
+ /** `GET /signers/{signer_id}/documents?signer-access-code=…` */
961
+ list(signerId: string, signerAccessCode: string, params?: IListParams): Promise<IDocumentListResponse>;
962
+ /** `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}?signer-access-code=…` */
963
+ download(signerId: string, documentId: string, artifactName: DocumentArtifactName, signerAccessCode: string): Promise<Buffer>;
964
+ /** `PUT /signers/documents/sign-multiple?signer-access-code=…` */
965
+ signMultiple(documentIds: string[], signerAccessCode: string): Promise<unknown>;
966
+ /** `PUT /signers/documents/decline-multiple?signer-access-code=…` */
967
+ declineMultiple(documentIds: string[], declineReason: string, signerAccessCode: string): Promise<unknown>;
968
+ /** `GET /signers/self?signer-access-code=…` — fetch the signer's own profile. */
969
+ self(signerAccessCode: string): Promise<unknown>;
970
+ /** `PUT /signers/accept-terms` — accept the platform terms as the signer. */
971
+ acceptTerms(signerAccessCode: string): Promise<unknown>;
972
+ /** `POST /verify` — verify the email OTP for a signer. */
973
+ verifyEmail(payload: {
974
+ signerAccessCode: string;
975
+ verificationCode: string;
976
+ }): Promise<unknown>;
977
+ /** `PUT /documents/{documentId}/signers/confirm-data?signer-access-code=…` */
978
+ confirmData(documentId: string, signerAccessCode: string, payload: {
979
+ email?: string;
980
+ whatsapp_phone_number?: string;
981
+ has_accepted_terms?: boolean;
982
+ }): Promise<unknown>;
983
+ /**
984
+ * `POST /signature?signer-access-code=…&type=…` — upload the signer's
985
+ * signature or initial image. `imageType` defaults to `signature`.
986
+ */
987
+ uploadSignature(signerAccessCode: string, image: Buffer, options?: {
988
+ imageType?: 'signature' | 'initial';
989
+ contentType?: string;
990
+ }): Promise<unknown>;
991
+ /** `GET /signature/{type}?signer-access-code=…` — download the signer's signature/initial. */
992
+ downloadSignature(signerAccessCode: string, imageType?: 'signature' | 'initial'): Promise<Buffer>;
993
+ /** `GET /sign?signer-access-code=…` — fetch the assignment as the signer sees it. */
994
+ getAssignment(signerAccessCode: string, hasAcceptedTerms?: boolean): Promise<unknown>;
995
+ /** `POST /documents/{documentId}/assignments/{assignmentId}?signer-access-code=…` — sign. */
996
+ sign(documentId: string, assignmentId: string, signerAccessCode: string, entries: ISignFieldEntry[]): Promise<unknown>;
997
+ /**
998
+ * `PUT /documents/{documentId}/assignments/{assignmentId}/reject?signer-access-code=…`
999
+ * — signer-side decline. (Distinct from `assignments.cancel`, which is the
1000
+ * workspace-side cancellation flow.)
1001
+ */
1002
+ decline(documentId: string, assignmentId: string, signerAccessCode: string, declineReason: string): Promise<unknown>;
1003
+ }
1004
+
1005
+ /**
1006
+ * Verifier for Assinafy webhook payloads.
1007
+ *
1008
+ * The Assinafy platform signs webhook bodies with HMAC-SHA256 using the
1009
+ * workspace webhook secret and sends the hex digest in an `X-Assinafy-Signature`
1010
+ * header. Use {@link WebhookVerifier.verify} to confirm the signature before
1011
+ * trusting the payload.
1012
+ */
1013
+ declare class WebhookVerifier {
1014
+ private readonly webhookSecret?;
1015
+ constructor(webhookSecret?: string | undefined);
1016
+ /** Returns `true` if `signature` is a valid HMAC-SHA256 of `payload`. */
1017
+ verify(payload: string | Buffer, signature: string): boolean;
1018
+ /** Parse the raw webhook body into a JSON event envelope. */
1019
+ extractEvent(payload: string | Buffer): IWebhookPayload | null;
1020
+ /** Extract the event name (`event` or `type`) from an event envelope. */
1021
+ getEventType(event: IWebhookPayload | null | undefined): string | null;
1022
+ /** Extract the event data (`data` or `object`) from an event envelope. */
1023
+ getEventData(event: IWebhookPayload | null | undefined): Record<string, unknown>;
1024
+ }
1025
+
1026
+ /** Flexible input accepted by {@link AssinafyClient.fromConfig} (snake_case or camelCase). */
1027
+ interface ClientConfigInput {
1028
+ api_key?: string;
1029
+ apiKey?: string;
1030
+ token?: string;
1031
+ access_token?: string;
1032
+ accessToken?: string;
1033
+ account_id?: string;
1034
+ accountId?: string;
1035
+ base_url?: string;
1036
+ baseUrl?: string;
1037
+ webhook_secret?: string;
1038
+ webhookSecret?: string;
1039
+ timeout?: number;
1040
+ logger?: Logger;
1041
+ }
1042
+ /**
1043
+ * Primary entry point for the Assinafy API.
1044
+ *
1045
+ * @example
1046
+ * ```ts
1047
+ * const client = new AssinafyClient({
1048
+ * apiKey: process.env.ASSINAFY_API_KEY!,
1049
+ * accountId: process.env.ASSINAFY_ACCOUNT_ID!,
1050
+ * webhookSecret: process.env.ASSINAFY_WEBHOOK_SECRET,
1051
+ * });
1052
+ *
1053
+ * const document = await client.documents.upload({ filePath: './contract.pdf' });
1054
+ * ```
1055
+ */
1056
+ declare class AssinafyClient {
1057
+ private readonly axiosInstance;
1058
+ private readonly defaultAccountId;
1059
+ private readonly logger;
1060
+ private readonly webhookSecret;
1061
+ readonly documents: DocumentResource;
1062
+ readonly signers: SignerResource;
1063
+ readonly workspaces: WorkspaceResource;
1064
+ readonly assignments: AssignmentResource;
1065
+ readonly webhooks: WebhookResource;
1066
+ readonly templates: TemplateResource;
1067
+ readonly tags: TagResource;
1068
+ readonly auth: AuthenticationResource;
1069
+ readonly fields: FieldsResource;
1070
+ readonly signerDocuments: SignerDocumentsResource;
1071
+ readonly webhookVerifier: WebhookVerifier;
1072
+ constructor(options: AssinafyClientOptions);
1073
+ /** Convenience factory for the common apiKey + accountId setup. */
1074
+ static create(apiKey: string, accountId: string, options?: Omit<AssinafyClientOptions, 'apiKey' | 'accountId'>): AssinafyClient;
1075
+ /** Build a client from a plain object (supports snake_case and camelCase keys). */
1076
+ static fromConfig(config: ClientConfigInput): AssinafyClient;
1077
+ /**
1078
+ * High-level helper that uploads a PDF, ensures it's processed, creates any
1079
+ * missing signers, and kicks off a virtual signature assignment.
1080
+ */
1081
+ uploadAndRequestSignatures(options: {
1082
+ source: DocumentUploadSource;
1083
+ signers: IUploadAndRequestSignaturesSigner[];
1084
+ message?: string;
1085
+ metadata?: Record<string, unknown>;
1086
+ waitForReady?: boolean;
1087
+ expiresAt?: string;
1088
+ copyReceivers?: string[];
1089
+ accountId?: string;
1090
+ }): Promise<IUploadAndRequestSignaturesResult>;
1091
+ /** Expose the underlying axios instance for advanced use cases (interceptors, custom endpoints). */
1092
+ getAxiosInstance(): AxiosInstance;
1093
+ }
1094
+
1095
+ /** Base class for all Assinafy SDK errors. */
1096
+ declare class AssinafyError extends Error {
1097
+ readonly context: Record<string, unknown>;
1098
+ constructor(message: string, context?: Record<string, unknown>, options?: {
1099
+ cause?: unknown;
1100
+ });
1101
+ }
1102
+ /** Thrown when the API returns a non-success HTTP status. */
1103
+ declare class ApiError extends AssinafyError {
1104
+ readonly statusCode: number;
1105
+ readonly responseData: unknown;
1106
+ constructor(message: string, statusCode: number, responseData?: unknown, options?: {
1107
+ cause?: unknown;
1108
+ });
1109
+ static fromResponse(statusCode: number, responseData: unknown): ApiError;
1110
+ }
1111
+ /** Thrown when client-side validation fails before the request is sent. */
1112
+ declare class ValidationError extends AssinafyError {
1113
+ readonly errors: Record<string, unknown>;
1114
+ constructor(message?: string, errors?: Record<string, unknown>);
1115
+ }
1116
+ /** Thrown when the HTTP transport itself fails (DNS, timeout, etc.). */
1117
+ declare class NetworkError extends AssinafyError {
1118
+ constructor(message: string, options?: {
1119
+ cause?: unknown;
1120
+ });
1121
+ }
1122
+
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 };