@assinafy/sdk 2.8.1 → 2.9.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.ts CHANGED
@@ -446,10 +446,18 @@ interface IAssignmentItem {
446
446
  completed?: boolean;
447
447
  [key: string]: unknown;
448
448
  }
449
+ /** Per-signer browser URL returned with a created assignment. */
450
+ interface ISigningUrl {
451
+ signer_id: string;
452
+ url: string;
453
+ }
449
454
  /** Assignment object as returned by the API. */
450
455
  interface IAssignment {
451
456
  resource?: string;
452
457
  id: string;
458
+ /** The document this assignment belongs to; null only after document deletion. */
459
+ document_id?: string | null;
460
+ created_at?: string;
453
461
  sender_email?: string;
454
462
  method: AssignmentMethod;
455
463
  expires_at?: string | null;
@@ -468,10 +476,7 @@ interface IAssignment {
468
476
  }>;
469
477
  };
470
478
  /** Per-signer signing URLs. Array of `{ signer_id, url }` (not a map). */
471
- signing_urls?: Array<{
472
- signer_id: string;
473
- url: string;
474
- }>;
479
+ signing_urls?: ISigningUrl[];
475
480
  }
476
481
  /** Assignment returned after requesting signatures. */
477
482
  type ICreateAssignmentResponse = IAssignment;
@@ -546,7 +551,7 @@ interface IWebhookPayload {
546
551
  [key: string]: unknown;
547
552
  }
548
553
  /** Known webhook event names. */
549
- 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_identity_verified' | 'signer_identity_verification_failed' | 'signer_identity_review_required' | 'signer_identity_review_approved' | 'signer_identity_review_rejected' | 'signer_signed_document' | 'signer_rejected_document' | 'user_rejected_document' | 'document_processing_failed' | 'template_created' | 'template_processed' | 'template_processing_failed';
554
+ 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_identity_verified' | 'signer_identity_verification_failed' | 'signer_identity_review_required' | 'signer_identity_review_approved' | 'signer_identity_review_rejected' | 'signer_signed_document' | 'signer_rejected_document' | 'user_rejected_document' | 'document_processing_failed' | 'template_created' | 'template_processed' | 'template_processing_failed' | 'document_contract_updated' | 'document_contract_renewal_notice' | 'document_contract_expiring' | 'document_contract_expired' | 'document_contract_renewed' | 'document_contract_terminated' | 'document_contract_amended' | 'document_contract_amendment_updated';
550
555
  /** Document listing item (paginated). */
551
556
  interface IDocumentListItem {
552
557
  id: string;
@@ -570,6 +575,123 @@ interface IDocumentListItem {
570
575
  }
571
576
  /** Paginated document-list/search response. */
572
577
  type IDocumentListResponse = PaginatedResult<IDocumentListItem>;
578
+ /** Lifecycle state of contract terms tracked on a document. */
579
+ type DocumentContractStatus = 'draft' | 'active' | 'expired' | 'terminated';
580
+ /** How a signed instrument changes its parent contract. */
581
+ type DocumentContractRelationType = 'amendment' | 'renewal' | 'termination';
582
+ /** External-system identifier attached to contract terms. */
583
+ interface IDocumentContractExternalReference {
584
+ system: string;
585
+ id: string;
586
+ }
587
+ /** Contract terms tracked on one workspace document. */
588
+ interface IDocumentContract {
589
+ resource?: 'document_contract' | AnyString;
590
+ document_id: string;
591
+ status: DocumentContractStatus;
592
+ counterparty_name: string | null;
593
+ /** Normalized CPF or CNPJ. */
594
+ counterparty_taxpayer_id: string | null;
595
+ value: number | null;
596
+ /** ISO 4217 currency code, or null when the contract has no value. */
597
+ currency: string | null;
598
+ /** Calendar dates use `YYYY-MM-DD`. */
599
+ start_date: string | null;
600
+ end_date: string | null;
601
+ auto_renew: boolean;
602
+ renewal_term_months: number | null;
603
+ notice_period_days: number | null;
604
+ /** Starts at 1 and increments on every renewal. */
605
+ term: number;
606
+ owner_id: string | null;
607
+ metadata: Record<string, string> | null;
608
+ external_references: IDocumentContractExternalReference[];
609
+ /** Present only when `contracts.list({ expand: 'document' })` is used. */
610
+ document?: IDocumentDetailsResponse;
611
+ /** Present on single-contract and related-family reads. */
612
+ amendments?: IDocumentContractAmendment[];
613
+ created_at: string;
614
+ updated_at: string;
615
+ }
616
+ /** A document linked to amend, renew, or terminate a parent contract. */
617
+ interface IDocumentContractAmendment {
618
+ resource?: 'document_contract_amendment' | AnyString;
619
+ document_id: string;
620
+ document_name: string;
621
+ parent_document_id: string;
622
+ relation_type: DocumentContractRelationType;
623
+ /** Position among applied amendments; null while the instrument is pending. */
624
+ number: number | null;
625
+ status: 'pending' | 'applied';
626
+ document_status: DocumentStatus | AnyString;
627
+ apply_error: string | null;
628
+ currency: string | null;
629
+ /** Only the parent terms this instrument changes. */
630
+ terms: Record<string, unknown> | null;
631
+ /** Parent fields moved by the instrument, as `{ from, to }`. */
632
+ changes: Record<string, {
633
+ from: unknown;
634
+ to: unknown;
635
+ }> | null;
636
+ applied_at: string | null;
637
+ created_at: string;
638
+ updated_at: string;
639
+ }
640
+ /** Partial terms accepted by `contracts.set()`. Null clears the field where documented. */
641
+ interface IDocumentContractInput {
642
+ status?: DocumentContractStatus;
643
+ counterparty_name?: string | null;
644
+ counterparty_taxpayer_id?: string | null;
645
+ value?: number | null;
646
+ currency?: string | null;
647
+ start_date?: string | null;
648
+ end_date?: string | null;
649
+ auto_renew?: boolean;
650
+ renewal_term_months?: number | null;
651
+ notice_period_days?: number | null;
652
+ owner_id?: string | null;
653
+ metadata?: Record<string, string> | null;
654
+ /** Replaces the complete list; an empty array or null clears it. */
655
+ external_references?: IDocumentContractExternalReference[] | null;
656
+ /** Link this document as an instrument, or null to unlink a pending one. */
657
+ parent_document_id?: string | null;
658
+ relation_type?: DocumentContractRelationType;
659
+ /** Optimistic-concurrency value read from the contract or pending amendment. */
660
+ updated_at?: string | null;
661
+ }
662
+ /** Filters accepted by `contracts.list()`. */
663
+ interface IDocumentContractListParams {
664
+ status?: DocumentContractStatus[];
665
+ counterparty?: string;
666
+ search?: string;
667
+ end_date_from?: string;
668
+ end_date_to?: string;
669
+ ending_within_days?: number;
670
+ external_system?: string;
671
+ external_id?: string;
672
+ sort?: 'end_date' | '-end_date' | 'updated_at' | '-updated_at';
673
+ expand?: 'document';
674
+ page?: number;
675
+ per_page?: number;
676
+ 'per-page'?: number;
677
+ }
678
+ /** Body accepted by `contracts.renew()`. */
679
+ interface IRenewDocumentContractPayload {
680
+ end_date?: string | null;
681
+ value?: number | null;
682
+ /** Current contract term; makes a renewal safe to repeat. */
683
+ term?: number;
684
+ /** Optional optimistic-concurrency value read from the contract. */
685
+ updated_at?: string;
686
+ }
687
+ /** Body accepted by `contracts.terminate()`. */
688
+ interface ITerminateDocumentContractPayload {
689
+ reason?: string | null;
690
+ /** Optional optimistic-concurrency value read from the contract. */
691
+ updated_at?: string;
692
+ }
693
+ /** Paginated workspace contract list. */
694
+ type IDocumentContractListResponse = PaginatedResult<IDocumentContract>;
573
695
  /** Query parameters accepted by `documents.list`. */
574
696
  interface IDocumentListParams extends IListParams {
575
697
  /** Free-text term matched against document fields. */
@@ -663,6 +785,10 @@ interface IDocumentDetailsResponse {
663
785
  download_url?: string;
664
786
  download_final_url?: string;
665
787
  signing_url?: string;
788
+ verification_code?: string | null;
789
+ verification_url?: string | null;
790
+ /** Present only on workspace detail reads when contract tracking is available. */
791
+ has_contract?: boolean;
666
792
  artifacts?: {
667
793
  original: string;
668
794
  certificated?: string;
@@ -1164,7 +1290,7 @@ interface IAuthenticatedUser {
1164
1290
  }
1165
1291
  /**
1166
1292
  * Owner-facing document e-mail preferences returned by
1167
- * `GET /users/self/notification-preferences`. The API always returns all nine
1293
+ * `GET /users/self/notification-preferences`. The API always returns all thirteen
1168
1294
  * keys; `true` means that notification is enabled.
1169
1295
  */
1170
1296
  interface INotificationPreferences {
@@ -1177,6 +1303,10 @@ interface INotificationPreferences {
1177
1303
  DocumentProcessingFailed: boolean;
1178
1304
  TemplateProcessingFailed: boolean;
1179
1305
  SignerWhatsappFailed: boolean;
1306
+ ContractRenewalNotice: boolean;
1307
+ ContractExpiring: boolean;
1308
+ ContractExpired: boolean;
1309
+ ContractRenewed: boolean;
1180
1310
  }
1181
1311
  /** Partial preference map accepted by `PUT /users/self/notification-preferences`. */
1182
1312
  type IUpdateNotificationPreferences = Partial<INotificationPreferences>;
@@ -6854,7 +6984,7 @@ declare class UserResource extends BaseResource {
6854
6984
  *
6855
6985
  * Request body: none. Authentication: `X-Api-Key` or Bearer token.
6856
6986
  *
6857
- * @returns The complete nine-key preference map:
6987
+ * @returns The complete thirteen-key preference map:
6858
6988
  * ```json
6859
6989
  * {
6860
6990
  * "DocumentCompleted": true,
@@ -6865,7 +6995,11 @@ declare class UserResource extends BaseResource {
6865
6995
  * "DocumentExpirationReset": true,
6866
6996
  * "DocumentProcessingFailed": true,
6867
6997
  * "TemplateProcessingFailed": true,
6868
- * "SignerWhatsappFailed": true
6998
+ * "SignerWhatsappFailed": true,
6999
+ * "ContractRenewalNotice": true,
7000
+ * "ContractExpiring": true,
7001
+ * "ContractExpired": true,
7002
+ * "ContractRenewed": true
6869
7003
  * }
6870
7004
  * ```
6871
7005
  * @throws {ApiError} `401` when credentials are missing/invalid, or `500`
@@ -6893,16 +7027,33 @@ declare class UserResource extends BaseResource {
6893
7027
  * "DocumentExpirationReset": true,
6894
7028
  * "DocumentProcessingFailed": true,
6895
7029
  * "TemplateProcessingFailed": true,
6896
- * "SignerWhatsappFailed": true
7030
+ * "SignerWhatsappFailed": true,
7031
+ * "ContractRenewalNotice": true,
7032
+ * "ContractExpiring": true,
7033
+ * "ContractExpired": true,
7034
+ * "ContractRenewed": true
6897
7035
  * }
6898
7036
  * ```
6899
7037
  *
6900
- * @param preferences - One or more of the nine documented keys, each with
7038
+ * @param preferences - One or more of the thirteen documented keys, each with
6901
7039
  * a boolean value. Request example:
6902
7040
  * ```json
6903
7041
  * { "DocumentCompleted": true, "SignerDeclined": false }
6904
7042
  * ```
6905
- * @returns The complete updated nine-key preference map:
7043
+ * @param preferences.DocumentCompleted - Notify when a document completes.
7044
+ * @param preferences.SignerDeclined - Notify when a signer declines.
7045
+ * @param preferences.DocumentCancelled - Notify when a document is cancelled.
7046
+ * @param preferences.DocumentAboutToExpire - Notify before signature expiry.
7047
+ * @param preferences.DocumentExpired - Notify after signature expiry.
7048
+ * @param preferences.DocumentExpirationReset - Notify after resetting expiry.
7049
+ * @param preferences.DocumentProcessingFailed - Notify after document processing fails.
7050
+ * @param preferences.TemplateProcessingFailed - Notify after template processing fails.
7051
+ * @param preferences.SignerWhatsappFailed - Notify after WhatsApp delivery fails.
7052
+ * @param preferences.ContractRenewalNotice - Notify when the contract notice period starts.
7053
+ * @param preferences.ContractExpiring - Notify before a tracked contract ends.
7054
+ * @param preferences.ContractExpired - Notify when a tracked contract expires.
7055
+ * @param preferences.ContractRenewed - Notify when a tracked contract renews.
7056
+ * @returns The complete updated thirteen-key preference map:
6906
7057
  * ```json
6907
7058
  * {
6908
7059
  * "DocumentCompleted": true,
@@ -6913,7 +7064,11 @@ declare class UserResource extends BaseResource {
6913
7064
  * "DocumentExpirationReset": true,
6914
7065
  * "DocumentProcessingFailed": true,
6915
7066
  * "TemplateProcessingFailed": true,
6916
- * "SignerWhatsappFailed": true
7067
+ * "SignerWhatsappFailed": true,
7068
+ * "ContractRenewalNotice": true,
7069
+ * "ContractExpiring": true,
7070
+ * "ContractExpired": true,
7071
+ * "ContractRenewed": true
6917
7072
  * }
6918
7073
  * ```
6919
7074
  * @throws {ValidationError} Before requesting when the map is empty, has an
@@ -7073,6 +7228,348 @@ declare class UserResource extends BaseResource {
7073
7228
  }>;
7074
7229
  }
7075
7230
 
7231
+ /** Operations for contract terms tracked on workspace documents. */
7232
+ declare class ContractResource extends BaseResource {
7233
+ /**
7234
+ * List the workspace's tracked contracts (`GET /accounts/{accountId}/contracts`).
7235
+ *
7236
+ * Results are ordered by `-updated_at` unless `sort` is supplied. Use
7237
+ * `updated_at` to catch up after a missed webhook; `ending_within_days` is
7238
+ * evaluated by the API in the Brasília calendar day. OAuth tokens need
7239
+ * `documents:read`.
7240
+ *
7241
+ * @param params - Optional filters, expansion, sorting, and pagination.
7242
+ * @param params.status - Contract states to match; sent comma-separated.
7243
+ * @param params.counterparty - Part of the name, or an exact CPF/CNPJ.
7244
+ * @param params.search - Part of the document name.
7245
+ * @param params.end_date_from - Earliest end date (`YYYY-MM-DD`).
7246
+ * @param params.end_date_to - Latest end date (`YYYY-MM-DD`).
7247
+ * @param params.ending_within_days - Inclusive 0–3650 day window from today.
7248
+ * @param params.external_system - External-reference system.
7249
+ * @param params.external_id - External-reference ID.
7250
+ * @param params.sort - `end_date` / `updated_at`, optionally prefixed by `-`.
7251
+ * @param params.expand - Pass `document` to embed each document.
7252
+ * @param params.page - One-based page number.
7253
+ * @param params.per_page - Alias normalized to the API's `per-page` spelling.
7254
+ * @param params.per-page - Page size; the deployed API returns at most 50.
7255
+ * @param accountId - Override the client's default account ID.
7256
+ * @returns Contract rows and pagination metadata:
7257
+ * ```jsonc
7258
+ * {
7259
+ * "data": [{
7260
+ * "document_id": "66b2f0e1c3a4d5e6f7a8b9c0",
7261
+ * "status": "active",
7262
+ * "counterparty_name": "Example Ltda",
7263
+ * "counterparty_taxpayer_id": "11222333000181",
7264
+ * "value": 120000.5,
7265
+ * "currency": "BRL",
7266
+ * "start_date": "2026-11-01",
7267
+ * "end_date": "2027-10-31",
7268
+ * "auto_renew": true,
7269
+ * "renewal_term_months": 12,
7270
+ * "notice_period_days": 30,
7271
+ * "term": 1,
7272
+ * "owner_id": "d6zqpbyog2v3xvxerwn8la94",
7273
+ * "metadata": { "crm_stage": "won" },
7274
+ * "external_references": [{ "system": "crm", "id": "98765" }],
7275
+ * "created_at": "2026-10-23T12:00:00Z",
7276
+ * "updated_at": "2026-10-23T12:00:00Z"
7277
+ * }],
7278
+ * "meta": { "current_page": 1, "per_page": 20, "total": 1, "last_page": 1 }
7279
+ * }
7280
+ * ```
7281
+ * @throws {ValidationError} If a filter is malformed or no account ID is available.
7282
+ * @throws {ApiError} `400` for invalid filters, `401` for invalid credentials,
7283
+ * or `500` when the API cannot list contracts.
7284
+ *
7285
+ * @example
7286
+ * ```ts
7287
+ * const contracts = await client.contracts.list({
7288
+ * status: ['active'],
7289
+ * ending_within_days: 30,
7290
+ * expand: 'document',
7291
+ * });
7292
+ * ```
7293
+ */
7294
+ list(params?: IDocumentContractListParams, accountId?: string): Promise<IDocumentContractListResponse>;
7295
+ /**
7296
+ * Read a document's contract terms or amendment link
7297
+ * (`GET /accounts/{accountId}/documents/{documentId}/contract`).
7298
+ *
7299
+ * A root contract includes its `amendments`; a document that is itself an
7300
+ * instrument returns the `document_contract_amendment` shape. Reads remain
7301
+ * available if the workspace's plan no longer includes contract tracking.
7302
+ *
7303
+ * @param documentId - Contract or amendment document ID.
7304
+ * @param accountId - Override the client's default account ID.
7305
+ * @returns The root contract or amendment. Root-contract response:
7306
+ * ```jsonc
7307
+ * {
7308
+ * "resource": "document_contract",
7309
+ * "document_id": "66b2f0e1c3a4d5e6f7a8b9c0",
7310
+ * "status": "active",
7311
+ * "counterparty_name": "Example Ltda",
7312
+ * "counterparty_taxpayer_id": "11222333000181",
7313
+ * "value": 130000,
7314
+ * "currency": "BRL",
7315
+ * "start_date": "2026-11-01",
7316
+ * "end_date": "2028-06-30",
7317
+ * "auto_renew": true,
7318
+ * "renewal_term_months": 12,
7319
+ * "notice_period_days": 30,
7320
+ * "term": 2,
7321
+ * "owner_id": null,
7322
+ * "metadata": null,
7323
+ * "external_references": [],
7324
+ * "amendments": [],
7325
+ * "created_at": "2026-10-23T12:00:00Z",
7326
+ * "updated_at": "2027-05-12T18:20:00Z"
7327
+ * }
7328
+ * ```
7329
+ * @throws {ValidationError} If an ID is missing or invalid.
7330
+ * @throws {ApiError} `401` for invalid credentials, `404` when the document
7331
+ * has no tracked terms, or `500` on a server error.
7332
+ *
7333
+ * @example
7334
+ * ```ts
7335
+ * const contract = await client.contracts.get(document.id);
7336
+ * if (contract.resource === 'document_contract_amendment') {
7337
+ * console.log(contract.parent_document_id);
7338
+ * }
7339
+ * ```
7340
+ */
7341
+ get(documentId: string, accountId?: string): Promise<IDocumentContract | IDocumentContractAmendment>;
7342
+ /**
7343
+ * Create or partially update contract terms
7344
+ * (`PUT /accounts/{accountId}/documents/{documentId}/contract`).
7345
+ *
7346
+ * Only supplied fields are sent. `external_references` replaces the list;
7347
+ * `parent_document_id` links this document as an instrument. Pass the
7348
+ * `updated_at` previously read to reject concurrent changes with `409`.
7349
+ * OAuth tokens need `documents:write`; writes require a contract-tracking plan.
7350
+ *
7351
+ * @param documentId - Document whose terms or amendment link will change.
7352
+ * @param payload - At least one contract attribute.
7353
+ * @param payload.status - `draft`, `active`, `expired`, or `terminated`.
7354
+ * @param payload.counterparty_name - Counterparty name; null clears it.
7355
+ * @param payload.counterparty_taxpayer_id - CPF/CNPJ; null clears it.
7356
+ * @param payload.value - Non-negative contract value; null clears it.
7357
+ * @param payload.currency - Three-letter currency; null resets as documented.
7358
+ * @param payload.start_date - Start date (`YYYY-MM-DD`), or null.
7359
+ * @param payload.end_date - End date (`YYYY-MM-DD`), or null.
7360
+ * @param payload.auto_renew - Whether the hourly lifecycle starts a new term.
7361
+ * @param payload.renewal_term_months - 1–600 months, or null for the default.
7362
+ * @param payload.notice_period_days - 0–3650 days, or null to disable notice.
7363
+ * @param payload.owner_id - Active workspace member ID, or null.
7364
+ * @param payload.metadata - Up to 50 string fields, or null.
7365
+ * @param payload.external_references - Up to 20 `{ system, id }` entries; null/[] clears.
7366
+ * @param payload.parent_document_id - Parent contract document, or null to unlink pending.
7367
+ * @param payload.relation_type - `amendment`, `renewal`, or `termination`.
7368
+ * @param payload.updated_at - Optimistic-concurrency timestamp, or null for last-write-wins.
7369
+ * @param accountId - Override the client's default account ID.
7370
+ * @returns The saved contract or amendment link. Amendment response:
7371
+ * ```jsonc
7372
+ * {
7373
+ * "resource": "document_contract_amendment",
7374
+ * "document_id": "7c3d1e2f4a5b6c7d8e9f0a1b",
7375
+ * "document_name": "Amendment 1.pdf",
7376
+ * "parent_document_id": "66b2f0e1c3a4d5e6f7a8b9c0",
7377
+ * "relation_type": "amendment",
7378
+ * "number": null,
7379
+ * "status": "pending",
7380
+ * "document_status": "pending_signature",
7381
+ * "apply_error": null,
7382
+ * "currency": "BRL",
7383
+ * "terms": { "value": 130000, "end_date": "2028-06-30" },
7384
+ * "changes": { "value": { "from": 120000.5, "to": 130000 } },
7385
+ * "applied_at": null,
7386
+ * "created_at": "2027-05-10T15:00:00Z",
7387
+ * "updated_at": "2027-05-10T15:00:00Z"
7388
+ * }
7389
+ * ```
7390
+ * @throws {ValidationError} If the payload or an ID is malformed.
7391
+ * @throws {ApiError} `400` for invalid terms, `403` when the plan does not
7392
+ * include tracking, `404` for an unknown document, `409` after a concurrent
7393
+ * change, or `500` on a server error.
7394
+ *
7395
+ * @example
7396
+ * ```ts
7397
+ * const contract = await client.contracts.set(document.id, {
7398
+ * status: 'active',
7399
+ * counterparty_name: 'Example Ltda',
7400
+ * value: 120000.50,
7401
+ * currency: 'BRL',
7402
+ * start_date: '2026-11-01',
7403
+ * end_date: '2027-10-31',
7404
+ * });
7405
+ * ```
7406
+ */
7407
+ set(documentId: string, payload: IDocumentContractInput, accountId?: string): Promise<IDocumentContract | IDocumentContractAmendment>;
7408
+ /**
7409
+ * Read a document's complete contract family
7410
+ * (`GET /accounts/{accountId}/documents/{documentId}/contract/related`).
7411
+ *
7412
+ * The document may be the root or any linked instrument; the response is
7413
+ * always the root contract with every amendment, renewal, and termination.
7414
+ *
7415
+ * @param documentId - Any document in the contract family.
7416
+ * @param accountId - Override the client's default account ID.
7417
+ * @returns The root contract and ordered instruments:
7418
+ * ```jsonc
7419
+ * {
7420
+ * "resource": "document_contract",
7421
+ * "document_id": "66b2f0e1c3a4d5e6f7a8b9c0",
7422
+ * "status": "active",
7423
+ * "counterparty_name": "Example Ltda",
7424
+ * "counterparty_taxpayer_id": "11222333000181",
7425
+ * "value": 130000,
7426
+ * "currency": "BRL",
7427
+ * "start_date": "2026-11-01",
7428
+ * "end_date": "2028-06-30",
7429
+ * "auto_renew": true,
7430
+ * "renewal_term_months": 12,
7431
+ * "notice_period_days": 30,
7432
+ * "term": 2,
7433
+ * "owner_id": null,
7434
+ * "metadata": null,
7435
+ * "external_references": [],
7436
+ * "amendments": [{
7437
+ * "document_id": "7c3d1e2f4a5b6c7d8e9f0a1b",
7438
+ * "document_name": "Amendment 1.pdf",
7439
+ * "parent_document_id": "66b2f0e1c3a4d5e6f7a8b9c0",
7440
+ * "relation_type": "amendment",
7441
+ * "status": "applied",
7442
+ * "number": 1,
7443
+ * "document_status": "certificated",
7444
+ * "apply_error": null,
7445
+ * "currency": "BRL",
7446
+ * "terms": { "value": 130000, "end_date": "2028-06-30" },
7447
+ * "changes": {
7448
+ * "value": { "from": 120000.5, "to": 130000 },
7449
+ * "end_date": { "from": "2027-10-31", "to": "2028-06-30" }
7450
+ * },
7451
+ * "applied_at": "2027-05-12T18:20:00Z",
7452
+ * "created_at": "2027-05-10T15:00:00Z",
7453
+ * "updated_at": "2027-05-12T18:20:00Z"
7454
+ * }],
7455
+ * "created_at": "2026-10-23T12:00:00Z",
7456
+ * "updated_at": "2027-05-12T18:20:00Z"
7457
+ * }
7458
+ * ```
7459
+ * @throws {ValidationError} If an ID is missing or invalid.
7460
+ * @throws {ApiError} `401` for invalid credentials, `404` when no contract
7461
+ * family exists, or `500` on a server error.
7462
+ *
7463
+ * @example
7464
+ * ```ts
7465
+ * const family = await client.contracts.listRelated(amendmentDocument.id);
7466
+ * ```
7467
+ */
7468
+ listRelated(documentId: string, accountId?: string): Promise<IDocumentContract>;
7469
+ /**
7470
+ * Start a contract's next term
7471
+ * (`POST /accounts/{accountId}/documents/{documentId}/contract/renew`).
7472
+ *
7473
+ * Supply the current `term` to make a by-term renewal safe to repeat, or an
7474
+ * explicit later `end_date`. `updated_at` rejects concurrent changes. A
7475
+ * renewal reopens an expired contract but cannot reopen a terminated one.
7476
+ *
7477
+ * @param documentId - Root contract document ID.
7478
+ * @param payload - Renewal precondition and optional new date/value.
7479
+ * @param payload.end_date - Explicit new end date, or null to renew by term.
7480
+ * @param payload.value - New value; omitted keeps it and null clears it.
7481
+ * @param payload.term - Current term, required by the API when no date is sent.
7482
+ * @param payload.updated_at - Optional optimistic-concurrency timestamp.
7483
+ * @param accountId - Override the client's default account ID.
7484
+ * @returns The renewed contract:
7485
+ * ```jsonc
7486
+ * {
7487
+ * "resource": "document_contract",
7488
+ * "document_id": "66b2f0e1c3a4d5e6f7a8b9c0",
7489
+ * "status": "active",
7490
+ * "counterparty_name": "Example Ltda",
7491
+ * "counterparty_taxpayer_id": "11222333000181",
7492
+ * "value": 130000,
7493
+ * "currency": "BRL",
7494
+ * "start_date": "2026-11-01",
7495
+ * "end_date": "2029-06-30",
7496
+ * "auto_renew": true,
7497
+ * "renewal_term_months": 12,
7498
+ * "notice_period_days": 30,
7499
+ * "term": 2,
7500
+ * "owner_id": null,
7501
+ * "metadata": null,
7502
+ * "external_references": [],
7503
+ * "created_at": "2026-10-23T12:00:00Z",
7504
+ * "updated_at": "2027-10-15T09:30:00Z"
7505
+ * }
7506
+ * ```
7507
+ * @throws {ValidationError} If the payload or an ID is malformed.
7508
+ * @throws {ApiError} `400` for an invalid renewal, `403` when tracking is
7509
+ * unavailable, `404` when terms do not exist, `409` after a concurrent
7510
+ * change, or `500` on a server error.
7511
+ *
7512
+ * @example
7513
+ * ```ts
7514
+ * const renewed = await client.contracts.renew(document.id, {
7515
+ * term: contract.term,
7516
+ * value: 130000,
7517
+ * updated_at: contract.updated_at,
7518
+ * });
7519
+ * ```
7520
+ */
7521
+ renew(documentId: string, payload: IRenewDocumentContractPayload, accountId?: string): Promise<IDocumentContract>;
7522
+ /**
7523
+ * Close a contract (`POST /accounts/{accountId}/documents/{documentId}/contract/terminate`).
7524
+ *
7525
+ * Termination stops lifecycle alerts and records the optional reason in the
7526
+ * document activity. Pass `updated_at` to reject concurrent changes.
7527
+ *
7528
+ * @param documentId - Root contract document ID.
7529
+ * @param payload - Optional reason and concurrency precondition.
7530
+ * @param payload.reason - Activity reason (up to 500 characters), or null.
7531
+ * @param payload.updated_at - Optional optimistic-concurrency timestamp.
7532
+ * @param accountId - Override the client's default account ID.
7533
+ * @returns The terminated contract:
7534
+ * ```jsonc
7535
+ * {
7536
+ * "resource": "document_contract",
7537
+ * "document_id": "66b2f0e1c3a4d5e6f7a8b9c0",
7538
+ * "status": "terminated",
7539
+ * "counterparty_name": "Example Ltda",
7540
+ * "counterparty_taxpayer_id": "11222333000181",
7541
+ * "value": 120000.5,
7542
+ * "currency": "BRL",
7543
+ * "start_date": "2026-11-01",
7544
+ * "end_date": "2027-10-31",
7545
+ * "auto_renew": false,
7546
+ * "renewal_term_months": 12,
7547
+ * "notice_period_days": 30,
7548
+ * "term": 1,
7549
+ * "owner_id": null,
7550
+ * "metadata": null,
7551
+ * "external_references": [],
7552
+ * "created_at": "2026-10-23T12:00:00Z",
7553
+ * "updated_at": "2027-03-02T14:00:00Z"
7554
+ * }
7555
+ * ```
7556
+ * @throws {ValidationError} If the payload or an ID is malformed.
7557
+ * @throws {ApiError} `400` for invalid state/input, `403` when tracking is
7558
+ * unavailable, `404` when terms do not exist, `409` after a concurrent
7559
+ * change, or `500` on a server error.
7560
+ *
7561
+ * @example
7562
+ * ```ts
7563
+ * await client.contracts.terminate(document.id, {
7564
+ * reason: 'Replaced by a new agreement',
7565
+ * updated_at: contract.updated_at,
7566
+ * });
7567
+ * ```
7568
+ */
7569
+ terminate(documentId: string, payload?: ITerminateDocumentContractPayload, accountId?: string): Promise<IDocumentContract>;
7570
+ private contractPath;
7571
+ }
7572
+
7076
7573
  /** Headers read by {@link WebhookVerifier.verifySignature}. */
7077
7574
  type WebhookHeaders = {
7078
7575
  get(name: string): string | null;
@@ -7242,6 +7739,7 @@ declare class AssinafyClient {
7242
7739
  readonly fields: FieldsResource;
7243
7740
  readonly signerDocuments: SignerDocumentsResource;
7244
7741
  readonly users: UserResource;
7742
+ readonly contracts: ContractResource;
7245
7743
  readonly webhookVerifier: WebhookVerifier;
7246
7744
  /**
7247
7745
  * Create a client. Supply `apiKey` (preferred, sent as `X-Api-Key`) or a
@@ -7720,4 +8218,4 @@ declare const MAX_LIST_PAGE_SIZE = 50;
7720
8218
 
7721
8219
  declare const SDK_USER_AGENT: string;
7722
8220
 
7723
- export { type AccountLogoUploadSource, type AnyString, ApiError, type AssignmentDisplaySettings, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, DEFAULT_WEBHOOK_EVENTS, DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD, type DocumentArtifactName, DocumentResource, type DocumentStatsGranularity, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IAccountTheme, type IApiKeyResponse, type IAssignment, type IAssignmentCostSigner, type IAssignmentEntry, type IAssignmentItem, type IAssignmentListParams, type IAssignmentListResponse, type IAssignmentSigner, type IAuthenticateChallenge, type IAuthenticatedUser, type IConfirmSignerDataPayload, type IConfirmTotpPayload, type ICostEstimate, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDeleteTagResponse, type IDetachDocumentTagResponse, type IDisplaySettings, type IDocumentActivity, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentSearchParams, type IDocumentStatsParams, type IDocumentStatsRow, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IDocumentVerification, type IEstimateAssignmentCostPayload, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationMultipleResult, type IFieldValidationResponse, type IFieldValidationResult, type IInlineTag, type ILegacyConfirmSignerDataPayload, type ILegacyResendCostEstimate, type ILegacyUploadSignatureOptions, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type IMfaMethod, type IMfaReauth, type IMfaRecoveryCodes, type IMfaStatus, type INotificationHistoryEntry, type INotificationPreferences, type IOAuthAuthorizationCallback, type IOAuthAuthorizationRequest, type IOAuthAuthorizationServerMetadata, type IOAuthProtectedResourceMetadata, type IOAuthTokenResponse, type IOAuthUserInfo, type IPage, type IPaginatedResponse, type IPublicDocumentInfo, type IRateLimitInfo, type IRenameDocumentResponse, type IResendCostEstimate, type IResendEmailResponse, type IReviewIdentityVerificationPayload, type ISendTokenResult, type ISignFieldEntry, type ISigner, type ISignerIdentityReview, type ISignerIdentityVerification, type ISignerIdentityVerificationSession, type ISignerListParams, type ISignerListResponse, type ISignerSelf, type ISigningProgress, type IStartIdentityVerificationPayload, type ITag, type ITemplateCostSigner, type ITemplateDetailsResponse, type ITemplateFieldPlacement, type ITemplateListItem, type ITemplateListParams, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type ITotpEnrollment, type IUpdateFieldPayload, type IUpdateNotificationPreferences, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateTemplatePayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IUploadSignatureOptions, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEndpoint, type IWebhookEndpointCreatePayload, type IWebhookEndpointCreateResponse, type IWebhookEndpointSecret, type IWebhookEndpointUpdatePayload, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type IdentityVerificationImageName, type IdentityVerificationStatus, type Logger, MAX_LIST_PAGE_SIZE, MAX_UPLOAD_BYTES, NetworkError, type NotificationSenderType, OAuthError, OAuthResource, type OAuthScope, type PaginatedResult, type PaginationMeta, SDK_USER_AGENT, type SendTokenChannel, type SignatureImageType, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, UserResource, ValidationError, type WebhookEventType, type WebhookHeaders, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload, parseWwwAuthenticate };
8221
+ export { type AccountLogoUploadSource, type AnyString, ApiError, type AssignmentDisplaySettings, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, ContractResource, DEFAULT_WEBHOOK_EVENTS, DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD, type DocumentArtifactName, type DocumentContractRelationType, type DocumentContractStatus, DocumentResource, type DocumentStatsGranularity, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IAccountTheme, type IApiKeyResponse, type IAssignment, type IAssignmentCostSigner, type IAssignmentEntry, type IAssignmentItem, type IAssignmentListParams, type IAssignmentListResponse, type IAssignmentSigner, type IAuthenticateChallenge, type IAuthenticatedUser, type IConfirmSignerDataPayload, type IConfirmTotpPayload, type ICostEstimate, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDeleteTagResponse, type IDetachDocumentTagResponse, type IDisplaySettings, type IDocumentActivity, type IDocumentContract, type IDocumentContractAmendment, type IDocumentContractExternalReference, type IDocumentContractInput, type IDocumentContractListParams, type IDocumentContractListResponse, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentSearchParams, type IDocumentStatsParams, type IDocumentStatsRow, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IDocumentVerification, type IEstimateAssignmentCostPayload, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationMultipleResult, type IFieldValidationResponse, type IFieldValidationResult, type IInlineTag, type ILegacyConfirmSignerDataPayload, type ILegacyResendCostEstimate, type ILegacyUploadSignatureOptions, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type IMfaMethod, type IMfaReauth, type IMfaRecoveryCodes, type IMfaStatus, type INotificationHistoryEntry, type INotificationPreferences, type IOAuthAuthorizationCallback, type IOAuthAuthorizationRequest, type IOAuthAuthorizationServerMetadata, type IOAuthProtectedResourceMetadata, type IOAuthTokenResponse, type IOAuthUserInfo, type IPage, type IPaginatedResponse, type IPublicDocumentInfo, type IRateLimitInfo, type IRenameDocumentResponse, type IRenewDocumentContractPayload, type IResendCostEstimate, type IResendEmailResponse, type IReviewIdentityVerificationPayload, type ISendTokenResult, type ISignFieldEntry, type ISigner, type ISignerIdentityReview, type ISignerIdentityVerification, type ISignerIdentityVerificationSession, type ISignerListParams, type ISignerListResponse, type ISignerSelf, type ISigningProgress, type ISigningUrl, type IStartIdentityVerificationPayload, type ITag, type ITemplateCostSigner, type ITemplateDetailsResponse, type ITemplateFieldPlacement, type ITemplateListItem, type ITemplateListParams, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type ITerminateDocumentContractPayload, type ITotpEnrollment, type IUpdateFieldPayload, type IUpdateNotificationPreferences, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateTemplatePayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IUploadSignatureOptions, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEndpoint, type IWebhookEndpointCreatePayload, type IWebhookEndpointCreateResponse, type IWebhookEndpointSecret, type IWebhookEndpointUpdatePayload, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type IdentityVerificationImageName, type IdentityVerificationStatus, type Logger, MAX_LIST_PAGE_SIZE, MAX_UPLOAD_BYTES, NetworkError, type NotificationSenderType, OAuthError, OAuthResource, type OAuthScope, type PaginatedResult, type PaginationMeta, SDK_USER_AGENT, type SendTokenChannel, type SignatureImageType, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, UserResource, ValidationError, type WebhookEventType, type WebhookHeaders, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload, parseWwwAuthenticate };