@assinafy/sdk 1.5.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/dist/index.d.mts 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' | string;
24
+ type AssignmentVerificationMethod = 'Email' | 'Whatsapp' | AnyString;
11
25
  /** Notification methods accepted by assignment signer entries. */
12
- type AssignmentNotificationMethod = 'Email' | 'Whatsapp' | string;
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;
@@ -136,6 +150,20 @@ interface ICreateAssignmentPayload {
136
150
  signerIds?: string[];
137
151
  message?: string;
138
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
+ */
139
167
  copy_receivers?: string[];
140
168
  /** Field placement entries used when `method` is `collect`. */
141
169
  entries?: unknown[];
@@ -277,12 +305,44 @@ type IDocumentListResponse = PaginatedResult<IDocumentListItem>;
277
305
  /** Query parameters accepted by `documents.list`. */
278
306
  interface IDocumentListParams extends IListParams {
279
307
  /** Filter by document status, e.g. `pending_signature`. */
280
- status?: DocumentStatus | string;
308
+ status?: DocumentStatus | AnyString;
281
309
  /** Filter by signature method (`virtual` or `collect`). */
282
310
  method?: AssignmentMethod;
283
311
  /** Comma-separated list of tag IDs (AND semantics). */
284
312
  tags?: string;
285
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>;
286
346
  /** Document upload response. */
287
347
  interface IDocumentUploadResponse {
288
348
  resource?: string;
@@ -335,7 +395,8 @@ interface IDocumentDetailsResponse {
335
395
  bundle?: string;
336
396
  thumbnail?: string;
337
397
  };
338
- pages: unknown[];
398
+ /** Rendered pages. Empty until the document reaches `metadata_ready`. */
399
+ pages: IPage[];
339
400
  /** Tags attached to the document (inline `{ id, name, color }` shape). */
340
401
  tags?: IInlineTag[];
341
402
  created_at: string;
@@ -420,12 +481,12 @@ interface IWebhookSubscription {
420
481
  updated_at?: string;
421
482
  }
422
483
  interface IWebhookEventTypeInfo {
423
- id: WebhookEventType | string;
484
+ id: WebhookEventType | AnyString;
424
485
  description: string;
425
486
  }
426
487
  interface IWebhookDispatch {
427
488
  id: string;
428
- event: WebhookEventType | string;
489
+ event: WebhookEventType | AnyString;
429
490
  activity_id: number;
430
491
  endpoint: string | null;
431
492
  payload: IWebhookPayload | Record<string, unknown> | null;
@@ -433,11 +494,13 @@ interface IWebhookDispatch {
433
494
  http_status: number | null;
434
495
  response_body: string | null;
435
496
  error: string | null;
436
- created_at: number;
437
- updated_at?: number;
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;
438
501
  }
439
502
  interface IWebhookDispatchListParams extends IListParams {
440
- event?: WebhookEventType | string;
503
+ event?: WebhookEventType | AnyString;
441
504
  delivered?: boolean | 'true' | 'false';
442
505
  from?: number;
443
506
  to?: number;
@@ -477,13 +540,19 @@ interface IUpdateTemplatePayload {
477
540
  }
478
541
  /** Template list item (paginated). */
479
542
  interface ITemplateListItem {
480
- resource?: string;
481
543
  id: string;
482
544
  name: string;
483
545
  document_name?: string | null;
484
546
  message?: string | null;
485
547
  status: string;
486
- account_id?: string;
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[];
487
556
  roles?: ITemplateRole[];
488
557
  /** Tags attached to the template itself (inline `{ id, name }` shape). */
489
558
  tags?: IInlineTag[];
@@ -492,6 +561,38 @@ interface ITemplateListItem {
492
561
  }
493
562
  type ITemplateListResponse = PaginatedResult<ITemplateListItem>;
494
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
+ }
495
596
  interface ITemplateDetailsResponse {
496
597
  resource?: string;
497
598
  id: string;
@@ -499,8 +600,8 @@ interface ITemplateDetailsResponse {
499
600
  document_name?: string | null;
500
601
  message?: string | null;
501
602
  status: string;
502
- account_id?: string;
503
- pages?: unknown[];
603
+ /** Empty until the template finishes processing (`status: 'Ready'`). */
604
+ pages?: IPage[];
504
605
  roles?: ITemplateRole[];
505
606
  /** Tags attached to the template itself. */
506
607
  tags?: IInlineTag[];
@@ -538,7 +639,7 @@ interface ICreateDocumentFromTemplateOptions {
538
639
  * is documented in the table but is not currently present in the JSON payload.
539
640
  */
540
641
  interface IDocumentStatusInfo {
541
- code: DocumentStatus | string;
642
+ code: DocumentStatus | AnyString;
542
643
  deletable: boolean;
543
644
  description?: string;
544
645
  }
@@ -552,7 +653,7 @@ interface IPublicDocumentInfo {
552
653
  [key: string]: unknown;
553
654
  }
554
655
  /** Channel accepted by the `send-token` endpoint. */
555
- type SendTokenChannel = 'email' | 'whatsapp' | string;
656
+ type SendTokenChannel = 'email' | 'whatsapp' | AnyString;
556
657
  /** Authentication: login response (also returned by social login). */
557
658
  interface ILoginResponse {
558
659
  access_token: string;
@@ -680,6 +781,17 @@ interface IUpdateTagPayload {
680
781
  color?: string | null;
681
782
  }
682
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
+
683
795
  /**
684
796
  * Shared plumbing for every Assinafy resource:
685
797
  *
@@ -709,21 +821,43 @@ declare abstract class BaseResource {
709
821
  protected callVoid(label: string, request: RequestFn): Promise<void>;
710
822
  /** Execute an HTTP call that returns binary data (artifact downloads). */
711
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>;
712
846
  /** Execute a paginated list call and attach meta from `X-Pagination-*` headers. */
713
847
  protected callList<T>(label: string, request: RequestFn): Promise<PaginatedResult<T>>;
714
848
  }
715
849
  type RequestFn = () => Promise<AxiosResponse>;
716
850
 
717
- /** Input for an upload: either an on-disk file or an in-memory buffer. */
718
- type DocumentUploadSource = {
719
- filePath: string;
720
- fileName?: string;
721
- } | {
722
- buffer: Buffer;
723
- fileName: string;
724
- };
725
-
851
+ /** Options accepted by {@link DocumentResource.upload}. */
726
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;
727
861
  /** Optional metadata sent alongside the file (JSON-encoded). */
728
862
  metadata?: Record<string, unknown>;
729
863
  /** Override the default account ID configured on the client. */
@@ -731,20 +865,119 @@ interface IDocumentUploadOptions {
731
865
  }
732
866
  declare class DocumentResource extends BaseResource {
733
867
  /**
734
- * 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.
735
892
  *
736
893
  * @example
737
894
  * ```ts
738
895
  * await client.documents.upload({ filePath: './contract.pdf' });
739
- * await client.documents.upload({ buffer, fileName: 'contract.pdf' }, { metadata });
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'
740
901
  * ```
741
902
  */
742
903
  upload(source: DocumentUploadSource, options?: IDocumentUploadOptions): Promise<IDocumentUploadResponse>;
743
904
  /**
744
905
  * List workspace documents. Pagination info (if any) is attached in `meta`.
745
- * Supports `status`, `method`, `tags`, `search`, `sort`, `page`, `per_page`.
906
+ * Supports `status`, `method`, `tags`, `search`, `sort`, `page`, `per-page`.
746
907
  */
747
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>;
748
981
  /** Get document details. */
749
982
  details(documentId: string): Promise<IDocumentDetailsResponse>;
750
983
  /** Alias for {@link details}. */
@@ -829,13 +1062,30 @@ declare class SignerResource extends BaseResource {
829
1062
  create(payload: ICreateSignerPayload, accountId?: string): Promise<ICreateSignerResponse>;
830
1063
  /** Get a signer by ID. */
831
1064
  get(signerId: string, accountId?: string): Promise<ISigner>;
832
- /** List signers for the workspace (supports `page`, `per_page`, `search`, `sort`). */
1065
+ /** List signers for the workspace (supports `page`, `per-page`, `search`, `sort`). */
833
1066
  list(params?: IListParams, accountId?: string): Promise<ISignerListResponse>;
834
1067
  /** Update a signer. Fails if the signer has active assignments. */
835
1068
  update(signerId: string, payload: IUpdateSignerPayload, accountId?: string): Promise<ICreateSignerResponse>;
836
1069
  /** Delete a signer. */
837
1070
  delete(signerId: string, accountId?: string): Promise<void>;
838
- /** Find a signer by email via the API's `search` parameter. Returns `null` if none match. */
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
+ */
839
1089
  findByEmail(email: string, accountId?: string): Promise<ISigner | null>;
840
1090
  private assertEmail;
841
1091
  }
@@ -861,6 +1111,50 @@ declare function buildAssignmentPayload(payload: ICreateAssignmentPayload, optio
861
1111
  allowSignersWithoutId?: boolean;
862
1112
  }): Record<string, unknown>;
863
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>;
864
1158
  /** Create a signing assignment for a document. */
865
1159
  create(documentId: string, payload: ICreateAssignmentPayload): Promise<ICreateAssignmentResponse>;
866
1160
  /**
@@ -917,9 +1211,14 @@ declare class WebhookResource extends BaseResource {
917
1211
  register(payload: IWebhookRegisterPayload, accountId?: string): Promise<IWebhookSubscription>;
918
1212
  /** Fetch the current webhook subscription. Returns `null` if none exists. */
919
1213
  get(accountId?: string): Promise<IWebhookSubscription | null>;
920
- /** Delete the current webhook subscription. */
921
- delete(accountId?: string): Promise<void>;
922
- /** Inactivate the current webhook subscription without deleting it. */
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
+ */
923
1222
  inactivate(accountId?: string): Promise<IWebhookSubscription>;
924
1223
  /** List currently supported webhook event types. */
925
1224
  listEventTypes(): Promise<IWebhookEventTypeInfo[]>;
@@ -957,8 +1256,11 @@ declare class TemplateResource extends BaseResource {
957
1256
  /**
958
1257
  * Get a template by ID (`GET /accounts/{id}/templates/{template_id}`).
959
1258
  *
960
- * Unlike the list endpoint, the single-template response includes `pages`
961
- * (with per-page `download_url`) and `default_document_tags`.
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.
962
1264
  */
963
1265
  get(templateId: string, accountId?: string): Promise<ITemplateDetailsResponse>;
964
1266
  /**
@@ -1127,6 +1429,34 @@ declare class SignerDocumentsResource extends BaseResource {
1127
1429
  getCurrent(signerId: string, signerAccessCode: string): Promise<IDocumentDetailsResponse>;
1128
1430
  /** `GET /signers/{signer_id}/documents?signer-access-code=…` */
1129
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>;
1130
1460
  /** `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}?signer-access-code=…` */
1131
1461
  download(signerId: string, documentId: string, artifactName: DocumentArtifactName, signerAccessCode: string): Promise<Buffer>;
1132
1462
  /** `PUT /signers/documents/sign-multiple?signer-access-code=…` */
@@ -1269,17 +1599,13 @@ declare class AssinafyClient {
1269
1599
  /** Base class for all Assinafy SDK errors. */
1270
1600
  declare class AssinafyError extends Error {
1271
1601
  readonly context: Record<string, unknown>;
1272
- constructor(message: string, context?: Record<string, unknown>, options?: {
1273
- cause?: unknown;
1274
- });
1602
+ constructor(message: string, context?: Record<string, unknown>, options?: ErrorOptions);
1275
1603
  }
1276
1604
  /** Thrown when the API returns a non-success HTTP status. */
1277
1605
  declare class ApiError extends AssinafyError {
1278
1606
  readonly statusCode: number;
1279
1607
  readonly responseData: unknown;
1280
- constructor(message: string, statusCode: number, responseData?: unknown, options?: {
1281
- cause?: unknown;
1282
- });
1608
+ constructor(message: string, statusCode: number, responseData?: unknown, options?: ErrorOptions);
1283
1609
  static fromResponse(statusCode: number, responseData: unknown): ApiError;
1284
1610
  }
1285
1611
  /** Thrown when client-side validation fails before the request is sent. */
@@ -1289,9 +1615,7 @@ declare class ValidationError extends AssinafyError {
1289
1615
  }
1290
1616
  /** Thrown when the HTTP transport itself fails (DNS, timeout, etc.). */
1291
1617
  declare class NetworkError extends AssinafyError {
1292
- constructor(message: string, options?: {
1293
- cause?: unknown;
1294
- });
1618
+ constructor(message: string, options?: ErrorOptions);
1295
1619
  }
1296
1620
 
1297
- export { 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 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 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 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, 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 };