@assinafy/sdk 3.0.1 → 3.1.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.mjs CHANGED
@@ -699,7 +699,7 @@ import axios2 from "axios";
699
699
  // package.json
700
700
  var package_default = {
701
701
  name: "@assinafy/sdk",
702
- version: "3.0.1",
702
+ version: "3.1.0",
703
703
  packageManager: "bun@1.4.4",
704
704
  description: "TypeScript SDK for Assinafy API - Digital signature platform",
705
705
  type: "commonjs",
@@ -722,16 +722,16 @@ var package_default = {
722
722
  sideEffects: false,
723
723
  scripts: {
724
724
  build: "tsup src/index.ts --format cjs,esm --dts --clean",
725
- test: "bun test",
726
- "test:coverage": "bun test --coverage",
727
- lint: "eslint src scripts --max-warnings=0",
728
- "lint:fix": "eslint src scripts --fix",
725
+ test: "bun test src tests/api-contract.test.ts",
726
+ "test:coverage": "bun test src tests/api-contract.test.ts --coverage",
727
+ lint: "eslint src tests/api-contract.test.ts --max-warnings=0",
728
+ "lint:fix": "eslint src tests/api-contract.test.ts --fix",
729
729
  "lint:pkg": "publint --strict && attw --pack .",
730
730
  audit: "bun audit",
731
- "audit:api": "bun scripts/api-contract-audit.ts",
731
+ "audit:api": "ASSINAFY_CONTRACT_CHECK=1 bun test tests/api-contract.test.ts",
732
732
  prepack: "bun run build",
733
733
  prepublishOnly: "bun run verify && bun run audit",
734
- typecheck: "bun ./node_modules/@typescript/native/bin/tsc --noEmit && bun ./node_modules/@typescript/native/bin/tsc --noEmit -p tsconfig.scripts.json && bun ./node_modules/@typescript/native/bin/tsc --noEmit -p tsconfig.tests.json",
734
+ typecheck: "bun ./node_modules/@typescript/native/bin/tsc --noEmit && bun ./node_modules/@typescript/native/bin/tsc --noEmit -p tsconfig.tests.json",
735
735
  verify: "bun run typecheck && bun run lint && bun run test:coverage && bun run build && bun run lint:pkg"
736
736
  },
737
737
  keywords: [
@@ -771,20 +771,20 @@ var package_default = {
771
771
  "@types/bun": "^1.4.4",
772
772
  "@types/node": "^22.20.5",
773
773
  "@typescript/native": "npm:typescript@^7.0.2",
774
- eslint: "^10.13.0",
774
+ eslint: "^10.15.0",
775
775
  publint: "^0.3.25",
776
- tsup: "^8.5.1",
776
+ tsup: "^9.0.0",
777
777
  typescript: "^6.0.3",
778
- "typescript-eslint": "^8.72.1"
778
+ "typescript-eslint": "^8.72.2"
779
779
  },
780
780
  dependencies: {
781
- axios: "^1.21.0"
781
+ axios: "^1.21.1"
782
782
  },
783
783
  overrides: {
784
784
  esbuild: "0.28.2",
785
785
  "follow-redirects": "1.16.2",
786
786
  "brace-expansion": "5.0.12",
787
- minimatch: "11.0.3"
787
+ minimatch: "11.0.9"
788
788
  },
789
789
  files: [
790
790
  "dist",
@@ -1059,6 +1059,31 @@ var VERIFICATION_METHODS = /* @__PURE__ */ new Set([
1059
1059
  "Bypass"
1060
1060
  ]);
1061
1061
  var NOTIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp", "Bypass"]);
1062
+ var SIGNER_CAPACITIES = /* @__PURE__ */ new Set([
1063
+ "Sign",
1064
+ "Approve",
1065
+ "Acknowledge",
1066
+ "Party",
1067
+ "Witness",
1068
+ "Intervening",
1069
+ "Receipt",
1070
+ "IssuerEndorserGuarantor",
1071
+ "IssuerEndorserGuarantorSurety",
1072
+ "Surety",
1073
+ "PartySurety",
1074
+ "JointDebtor",
1075
+ "PartyJointDebtor",
1076
+ "ContractingParty",
1077
+ "ContractedParty",
1078
+ "Landlord",
1079
+ "Tenant",
1080
+ "Buyer",
1081
+ "Seller",
1082
+ "AttorneyInFact",
1083
+ "LegalRepresentative",
1084
+ "Employer",
1085
+ "Employee"
1086
+ ]);
1062
1087
  var EMBEDDED_VERIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp", "Bypass"]);
1063
1088
  var DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD = "digital_certificate_requires_virtual_method";
1064
1089
  var ALLOWED_NOTIFICATION_METHODS = {
@@ -1190,6 +1215,7 @@ function buildAssignmentEstimatePayload(payload) {
1190
1215
  }
1191
1216
  const normalisedSigners = signers.map((signer) => normaliseEstimateSigner(signer));
1192
1217
  validateDigitalCertificateMethod(method, normalisedSigners);
1218
+ validateSigningOrder(normalisedSigners, "assignment cost signers");
1193
1219
  return cleanParams({
1194
1220
  method,
1195
1221
  signers: normalisedSigners,
@@ -1211,6 +1237,7 @@ function normaliseSignerRef(ref) {
1211
1237
  if (ref && typeof ref === "object") {
1212
1238
  const input = ref;
1213
1239
  validateAssignmentSignerOptions(input);
1240
+ validateSignerCapacity(input.sign_as);
1214
1241
  const id = input.id ?? input.signer_id;
1215
1242
  const normalised = cleanParams({
1216
1243
  id,
@@ -1219,6 +1246,7 @@ function normaliseSignerRef(ref) {
1219
1246
  embedded: input.embedded,
1220
1247
  step: input.step
1221
1248
  });
1249
+ if (input.sign_as !== void 0) normalised["sign_as"] = input.sign_as;
1222
1250
  if (typeof id === "string" && id.trim().length > 0) {
1223
1251
  return normalised;
1224
1252
  }
@@ -1232,10 +1260,19 @@ function normaliseEstimateSigner(signer) {
1232
1260
  }
1233
1261
  const descriptor = signer;
1234
1262
  validateAssignmentSignerOptions(descriptor);
1235
- return cleanParams({
1263
+ validateSignerCapacity(descriptor.sign_as);
1264
+ const normalised = cleanParams({
1236
1265
  verification_method: descriptor.verification_method,
1237
- notification_methods: descriptor.notification_methods
1266
+ notification_methods: descriptor.notification_methods,
1267
+ step: descriptor.step
1238
1268
  });
1269
+ if (descriptor.sign_as !== void 0) normalised["sign_as"] = descriptor.sign_as;
1270
+ return normalised;
1271
+ }
1272
+ function validateSignerCapacity(value) {
1273
+ if (value !== void 0 && value !== null && !SIGNER_CAPACITIES.has(value)) {
1274
+ throw new ValidationError("sign_as must be a supported signer capacity or null");
1275
+ }
1239
1276
  }
1240
1277
  function normaliseAssignmentEntries(entries) {
1241
1278
  if (!Array.isArray(entries)) {
@@ -1473,6 +1510,7 @@ var AssignmentResource = class extends BaseResource {
1473
1510
  * This route takes no `Idempotency-Key`: a document takes one assignment,
1474
1511
  * so a retry after a lost response answers `400` and charges nothing —
1475
1512
  * read the document to see whether the first request went through.
1513
+ * @param payload.signers[].sign_as - Staging capacity printed on the certificate; omitted/null means `Sign`.
1476
1514
  * @returns The created {@link IAssignment}: `signers` (rich, with `step` /
1477
1515
  * `notified` / `verification_method`), `items` (one row per signer × field),
1478
1516
  * a `summary` count block, and per-signer `signing_urls`. Response shape:
@@ -1611,9 +1649,11 @@ var AssignmentResource = class extends BaseResource {
1611
1649
  * ```
1612
1650
  *
1613
1651
  * @param documentId - The document the assignment would be created on.
1614
- * @param payload - `method` plus channel-only signer descriptors and/or
1615
- * `collect`-mode `entries`. Create-only fields and signer IDs are not part
1616
- * of this request schema.
1652
+ * @param payload - `method` plus signer channel descriptors and/or
1653
+ * `collect`-mode `entries`. Signer IDs are not part of this request. Send
1654
+ * each signer's creation `step` too: the API keeps every
1655
+ * `DigitalCertificate` signer alone in its step when it estimates.
1656
+ * @param payload.signers[].sign_as - Optional staging capacity, validated as on creation; it does not change the cost.
1617
1657
  * @returns an {@link ICostEstimate} with `total_credits`, balances, a
1618
1658
  * line-item `breakdown`, and a `has_sufficient_resources` gate.
1619
1659
  * `blocking_reason` may be `PendingPayment`, `InsufficientDocuments`, or
@@ -1635,7 +1675,8 @@ var AssignmentResource = class extends BaseResource {
1635
1675
  * ```
1636
1676
  * @throws {ValidationError} If `documentId` is missing, a `virtual` request
1637
1677
  * has no signer entry, or a `collect` request has no signer entry or no
1638
- * field-placement entry, or combines `DigitalCertificate` with `collect`.
1678
+ * field-placement entry, the signing order is invalid, or the request
1679
+ * combines `DigitalCertificate` with `collect`.
1639
1680
  * The last case has `errors.code ===
1640
1681
  * 'digital_certificate_requires_virtual_method'`.
1641
1682
  * @throws {ApiError} If the API rejects the request.
@@ -2002,6 +2043,57 @@ var AssignmentResource = class extends BaseResource {
2002
2043
  () => this.http.post(`${path2}/review`, body)
2003
2044
  );
2004
2045
  }
2046
+ /**
2047
+ * Read the capacity each signer signs in (`GET /documents/{documentId}/signer-capacities`).
2048
+ *
2049
+ * Staging extension. Order matches the assignment's signers; an unsent
2050
+ * document returns an empty list. OAuth applications need `documents:read`.
2051
+ * @param documentId - Workspace document ID.
2052
+ * @returns Sender-stated capacities, defaulting to `Sign`:
2053
+ * ```jsonc
2054
+ * [{ "signer_id": "signer-1", "sign_as": "Witness" }]
2055
+ * ```
2056
+ * @throws {ValidationError} If the document ID is invalid.
2057
+ * @throws {ApiError} `401`, `403`, or `404` for an unknown document or an older deployment.
2058
+ * @example
2059
+ * ```ts
2060
+ * const capacities = await client.assignments.getSignerCapacities(document.id);
2061
+ * ```
2062
+ */
2063
+ async getSignerCapacities(documentId) {
2064
+ return this.call(
2065
+ "Failed to fetch signer capacities",
2066
+ () => this.http.get(`/documents/${this.pathSegment(documentId, "Document ID")}/signer-capacities`)
2067
+ );
2068
+ }
2069
+ /**
2070
+ * Read delivery and open times (`GET /documents/{documentId}/notification-history`).
2071
+ *
2072
+ * Staging extension. An open can come from a mail scanner; it is not proof
2073
+ * of human reading. An unsent document returns `[]`. Needs `documents:read`.
2074
+ * @param documentId - Workspace document ID.
2075
+ * @returns History in assignment-signer order:
2076
+ * ```jsonc
2077
+ * [{ "signer_id": "signer-1", "notification_history": [{
2078
+ * "event": "signature_request", "status": "delivered",
2079
+ * "error_code": null, "error_message": null,
2080
+ * "sent_at": "2026-11-24T12:00:00Z", "failed_at": null,
2081
+ * "delivered_at": "2026-11-24T12:00:05Z", "opened_at": null
2082
+ * }] }]
2083
+ * ```
2084
+ * @throws {ValidationError} If the document ID is invalid.
2085
+ * @throws {ApiError} `401`, `403`, or `404` for an unknown document or an older deployment.
2086
+ * @example
2087
+ * ```ts
2088
+ * const history = await client.assignments.getNotificationHistory(document.id);
2089
+ * ```
2090
+ */
2091
+ async getNotificationHistory(documentId) {
2092
+ return this.call(
2093
+ "Failed to fetch notification history",
2094
+ () => this.http.get(`/documents/${this.pathSegment(documentId, "Document ID")}/notification-history`)
2095
+ );
2096
+ }
2005
2097
  identityVerificationPath(documentId, assignmentId, signerId) {
2006
2098
  const docId = this.pathSegment(documentId, "Document ID");
2007
2099
  const asgId = this.pathSegment(assignmentId, "Assignment ID");
@@ -3023,9 +3115,10 @@ var DocumentResource = class extends BaseResource {
3023
3115
  *
3024
3116
  * @param templateId - The template that would be instantiated.
3025
3117
  * @param signers - One channel descriptor per template role. Cost requests
3026
- * use only `role_id`, `verification_method`, and `notification_methods`;
3027
- * they do not send a signer ID or signing-order step, and editor roles are
3028
- * ignored by the cost calculation.
3118
+ * use `role_id`, `verification_method`, `notification_methods`, and the
3119
+ * role's creation `step`, which the API reads to keep each
3120
+ * `DigitalCertificate` signer alone in its step; they send no signer ID,
3121
+ * and editor roles are ignored by the cost calculation.
3029
3122
  * @param accountId - Override the client's default account ID.
3030
3123
  * @returns An {@link ICostEstimate}: `total_credits`, balances, and a
3031
3124
  * per-line `breakdown` of what the operation would consume:
@@ -3318,6 +3411,66 @@ var DocumentResource = class extends BaseResource {
3318
3411
  const percentage = total > 0 ? Math.round(signed / total * 1e4) / 100 : 0;
3319
3412
  return { signed, total, pending, percentage };
3320
3413
  }
3414
+ /**
3415
+ * List contacts watching a document (`GET /documents/{documentId}/watchers`).
3416
+ *
3417
+ * Staging extension. Returns contacts in the order set, omitting deleted
3418
+ * contacts. API key or user token only; OAuth application tokens are refused.
3419
+ * @param documentId - Workspace document ID.
3420
+ * @returns Watcher contacts:
3421
+ * ```jsonc
3422
+ * [{ "resource": "signer", "id": "signer-1", "full_name": "Example Watcher",
3423
+ * "email": "watcher@example.com", "whatsapp_phone_number": null,
3424
+ * "government_id": null, "has_accepted_terms": false }]
3425
+ * ```
3426
+ * @throws {ValidationError} If the document ID is invalid.
3427
+ * @throws {ApiError} `401`, `403`, or `404` for an unknown document or older deployment.
3428
+ * @example
3429
+ * ```ts
3430
+ * const watchers = await client.documents.listWatchers(document.id);
3431
+ * ```
3432
+ */
3433
+ async listWatchers(documentId) {
3434
+ return this.call(
3435
+ "Failed to list document watchers",
3436
+ () => this.http.get(`/documents/${this.pathSegment(documentId, "Document ID")}/watchers`)
3437
+ );
3438
+ }
3439
+ /**
3440
+ * Replace a document's watchers (`PUT /documents/{documentId}/watchers`).
3441
+ *
3442
+ * Staging extension. Each contact must belong to the workspace and have an
3443
+ * email. Watchers get one queued email when the document ends, without a
3444
+ * document link or file. Workspace notification preferences do not suppress
3445
+ * it. Set before sending or while open; `[]` removes every watcher.
3446
+ * API key or user token only; OAuth application tokens are refused.
3447
+ * @param documentId - Workspace document ID.
3448
+ * @param watcherIds - Up to ten contact IDs; duplicate IDs count once.
3449
+ * @returns The stored contacts:
3450
+ * ```jsonc
3451
+ * [{ "resource": "signer", "id": "signer-1", "full_name": "Example Watcher",
3452
+ * "email": "watcher@example.com", "whatsapp_phone_number": null,
3453
+ * "government_id": null, "has_accepted_terms": false }]
3454
+ * ```
3455
+ * @throws {ValidationError} If an ID is invalid or more than ten distinct watchers are supplied.
3456
+ * @throws {ApiError} `400` for a closed document or invalid contact; `401`, `403`, `404`.
3457
+ * @example
3458
+ * ```ts
3459
+ * await client.documents.setWatchers(document.id, [contact.id]);
3460
+ * // body: { watcher_ids: [contact.id] }
3461
+ * ```
3462
+ */
3463
+ async setWatchers(documentId, watcherIds) {
3464
+ if (!Array.isArray(watcherIds) || watcherIds.some((id) => typeof id !== "string" || !id.trim()) || new Set(watcherIds).size > 10) {
3465
+ throw new ValidationError("watcherIds must contain at most ten distinct non-empty contact IDs");
3466
+ }
3467
+ return this.call(
3468
+ "Failed to set document watchers",
3469
+ () => this.http.put(`/documents/${this.pathSegment(documentId, "Document ID")}/watchers`, {
3470
+ watcher_ids: watcherIds
3471
+ })
3472
+ );
3473
+ }
3321
3474
  };
3322
3475
  function normaliseTemplateSigners(signers) {
3323
3476
  if (!Array.isArray(signers) || signers.length === 0) {
@@ -3414,6 +3567,7 @@ function normaliseTemplateCostSigners(signers) {
3414
3567
  if (signer.notification_methods !== void 0) {
3415
3568
  descriptor.notification_methods = signer.notification_methods;
3416
3569
  }
3570
+ if (signer.step !== void 0) descriptor.step = signer.step;
3417
3571
  return descriptor;
3418
3572
  });
3419
3573
  return normalised;
@@ -9249,7 +9403,8 @@ var ContractResource = class extends BaseResource {
9249
9403
  * @param payload.currency - Three-letter currency; null resets as documented.
9250
9404
  * @param payload.start_date - Start date (`YYYY-MM-DD`), or null.
9251
9405
  * @param payload.end_date - End date (`YYYY-MM-DD`), or null.
9252
- * @param payload.auto_renew - Whether the hourly lifecycle starts a new term.
9406
+ * @param payload.auto_renew - Whether the hourly lifecycle starts a new term;
9407
+ * null resets it to false, or drops it from a pending amendment's terms.
9253
9408
  * @param payload.renewal_term_months - 1–600 months, or null for the default.
9254
9409
  * @param payload.notice_period_days - 0–3650 days, or null to disable notice.
9255
9410
  * @param payload.owner_id - Active workspace member ID, or null.
@@ -9554,8 +9709,8 @@ function buildContractInput(payload) {
9554
9709
  if (typeof payload.start_date === "string" && typeof payload.end_date === "string" && payload.end_date < payload.start_date) {
9555
9710
  throw new ValidationError("end_date must be on or after start_date");
9556
9711
  }
9557
- if (payload.auto_renew !== void 0 && typeof payload.auto_renew !== "boolean") {
9558
- throw new ValidationError("auto_renew must be a boolean");
9712
+ if (payload.auto_renew !== void 0 && payload.auto_renew !== null && typeof payload.auto_renew !== "boolean") {
9713
+ throw new ValidationError("auto_renew must be a boolean or null");
9559
9714
  }
9560
9715
  validateNullableInteger(payload.renewal_term_months, "renewal_term_months", 1, 600);
9561
9716
  validateNullableInteger(payload.notice_period_days, "notice_period_days", 0, 3650);
@@ -9914,6 +10069,7 @@ var EnvelopeResource = class extends BaseResource {
9914
10069
  *
9915
10070
  * @param envelopeId - Envelope ID.
9916
10071
  * @param accountId - Override the client's default account ID.
10072
+ * @returns Nothing; the acknowledgement body is discarded.
9917
10073
  * @throws {ValidationError} If an ID is missing or invalid.
9918
10074
  * @throws {ApiError} `403` for a token without `documents:write`, `404` for an
9919
10075
  * unknown envelope, `409` (`EnvelopeOpen`) while a document is still open.
@@ -10131,6 +10287,35 @@ var EnvelopeResource = class extends BaseResource {
10131
10287
  )
10132
10288
  );
10133
10289
  }
10290
+ /**
10291
+ * Price a whole-envelope reminder
10292
+ * (`POST /accounts/{accountId}/envelopes/{envelopeId}/signers/{signerId}/estimate-resend-cost`).
10293
+ *
10294
+ * Staging extension. Sends and charges nothing. Prices one reminder per
10295
+ * channel regardless of document count, without checking reminder cooldown
10296
+ * or whether the envelope is closed. OAuth requires `documents:write`.
10297
+ * @param envelopeId - Envelope ID.
10298
+ * @param signerId - Signer of the envelope.
10299
+ * @param accountId - Override the client's default workspace.
10300
+ * @returns The current reminder price:
10301
+ * ```jsonc
10302
+ * { "total": 0, "breakdown": [], "credit_balance": null, "has_sufficient_credits": true }
10303
+ * ```
10304
+ * @throws {ValidationError} If an ID is missing or invalid.
10305
+ * @throws {ApiError} `401`, `403`, or `404` for an unknown envelope/signer or older deployment.
10306
+ * @example
10307
+ * ```ts
10308
+ * const estimate = await client.envelopes.estimateResendCost(envelope.id, signer.id);
10309
+ * ```
10310
+ */
10311
+ async estimateResendCost(envelopeId, signerId, accountId) {
10312
+ return this.call(
10313
+ "Failed to estimate envelope reminder cost",
10314
+ () => this.http.post(
10315
+ `${this.envelopePath(envelopeId, accountId)}/signers/${this.pathSegment(signerId, "Signer ID")}/estimate-resend-cost`
10316
+ )
10317
+ );
10318
+ }
10134
10319
  envelopesPath(accountId) {
10135
10320
  return `/accounts/${this.pathSegment(this.accountId(accountId), "Account ID")}/envelopes`;
10136
10321
  }
@@ -10304,6 +10489,7 @@ var EmbedResource = class extends BaseResource {
10304
10489
  *
10305
10490
  * @param originId - Embed origin ID.
10306
10491
  * @param accountId - Override the client's default account ID.
10492
+ * @returns Nothing; the acknowledgement body is discarded.
10307
10493
  * @throws {ValidationError} If an ID is missing or invalid.
10308
10494
  * @throws {ApiError} `403`, or `404` for an unknown origin ID.
10309
10495
  *
@@ -10368,6 +10554,202 @@ var EmbedResource = class extends BaseResource {
10368
10554
  }
10369
10555
  };
10370
10556
 
10557
+ // src/resources/scheduled-sends.ts
10558
+ var ScheduledSendResource = class extends BaseResource {
10559
+ /**
10560
+ * Schedule an assignment (`POST /documents/{documentId}/scheduled-sends`).
10561
+ *
10562
+ * Sends and charges nothing now. Each document takes one pending or
10563
+ * processing scheduled send. A failed due send records its reason and
10564
+ * emails the scheduling member (active owners if that member has left).
10565
+ * @param documentId - Unassigned document in the workspace.
10566
+ * @param payload - The same signing request as `assignments.create()` plus its send time.
10567
+ * @param payload.send_at - ISO date-time (no offset means UTC) or Unix seconds, one hour to 90 days ahead.
10568
+ * @param payload.method - `virtual` (default) or `collect`.
10569
+ * @param payload.signers - Contacts and their verification, notification, capacity and ordering options.
10570
+ * @param payload.signer_ids - Compatibility alias for signer IDs.
10571
+ * @param payload.signerIds - Compatibility alias for signer IDs.
10572
+ * @param payload.entries - Required field placements for `collect`.
10573
+ * @param payload.message - Invitation text.
10574
+ * @param payload.copy_receivers - Contacts receiving copies.
10575
+ * @param payload.expires_at - Absolute deadline at least two hours after send_at, or null for none.
10576
+ * @param payload.max_total_credits - Credit ceiling enforced when sending.
10577
+ * @returns The saved request's state:
10578
+ * ```jsonc
10579
+ * { "resource": "scheduled_send", "id": "send-1", "type": "assignment",
10580
+ * "document_ids": ["doc-1"], "status": "pending", "send_at": "2026-12-01T12:00:00Z",
10581
+ * "assignment_id": null, "envelope_id": null, "failure_reason": null,
10582
+ * "created_at": "2026-11-24T12:00:00Z", "processed_at": null }
10583
+ * ```
10584
+ * @throws {ValidationError} If the ID, time or signing request is malformed.
10585
+ * @throws {ApiError} `400` for timing, assignment or pending-send conflicts;
10586
+ * `401`, `403` for plan/scope restrictions, `404` for document/contact/deployment availability.
10587
+ * @example
10588
+ * ```ts
10589
+ * const scheduled = await client.scheduledSends.createAssignment(document.id, {
10590
+ * signers: [{ id: signer.id, verification_method: 'Email', notification_methods: ['Email'] }],
10591
+ * send_at: new Date(Date.now() + 86_400_000).toISOString(),
10592
+ * max_total_credits: 0,
10593
+ * });
10594
+ * ```
10595
+ */
10596
+ async createAssignment(documentId, payload) {
10597
+ assertRecord(payload, "scheduled assignment");
10598
+ validateTimestamp(payload.send_at, "send_at");
10599
+ const { expires_at, ...assignment } = payload;
10600
+ const body = buildAssignmentPayload(assignment);
10601
+ body["send_at"] = payload.send_at;
10602
+ if (expires_at !== void 0) {
10603
+ if (expires_at !== null) validateTimestamp(expires_at, "expires_at");
10604
+ body["expires_at"] = expires_at;
10605
+ }
10606
+ return this.call(
10607
+ "Failed to schedule assignment",
10608
+ () => this.http.post(`/documents/${this.pathSegment(documentId, "Document ID")}/scheduled-sends`, body)
10609
+ );
10610
+ }
10611
+ /**
10612
+ * Schedule an envelope (`POST /accounts/{accountId}/scheduled-sends`).
10613
+ *
10614
+ * Creates no envelope and charges nothing now. Uses the same plan and
10615
+ * signing rules as envelope estimation; checks balances when sending.
10616
+ * @param payload - Envelope request and send time.
10617
+ * @param payload.send_at - ISO date-time or Unix seconds, one hour to 90 days ahead.
10618
+ * @param payload.name - Envelope name, 1–255 characters without `<`.
10619
+ * @param payload.message - Invitation text or null.
10620
+ * @param payload.signers - 1–20 contacts with shared channel options; no signing steps.
10621
+ * @param payload.documents - 1–20 unassigned documents, signer IDs and optional placements/copy receivers.
10622
+ * Each document's expires_at must be at least two hours after send_at.
10623
+ * @param payload.max_total_credits - Credit ceiling enforced when sending.
10624
+ * @param accountId - Override the client's default workspace.
10625
+ * @returns The saved request's state:
10626
+ * ```jsonc
10627
+ * { "resource": "scheduled_send", "id": "send-2", "type": "envelope",
10628
+ * "document_ids": ["doc-1", "doc-2"], "status": "pending", "send_at": "2026-12-01T12:00:00Z",
10629
+ * "assignment_id": null, "envelope_id": null, "failure_reason": null,
10630
+ * "created_at": "2026-11-24T12:00:00Z", "processed_at": null }
10631
+ * ```
10632
+ * @throws {ValidationError} If the time or envelope request is malformed.
10633
+ * @throws {ApiError} `400` for timing or envelope/pending-send conflicts;
10634
+ * `401`, `403` (`PlanRestricted`, `InsufficientScope`), `404`.
10635
+ * @example
10636
+ * ```ts
10637
+ * const scheduled = await client.scheduledSends.createEnvelope({
10638
+ * name: 'Agreement', signers: [{ id: signer.id }],
10639
+ * documents: [{ id: document.id, signer_ids: [signer.id] }],
10640
+ * send_at: new Date(Date.now() + 86_400_000).toISOString(),
10641
+ * });
10642
+ * ```
10643
+ */
10644
+ async createEnvelope(payload, accountId) {
10645
+ assertRecord(payload, "scheduled envelope");
10646
+ validateTimestamp(payload.send_at, "send_at");
10647
+ const body = buildEnvelopePayload(payload);
10648
+ body["send_at"] = payload.send_at;
10649
+ return this.call("Failed to schedule envelope", () => this.http.post(this.path(accountId), body));
10650
+ }
10651
+ /**
10652
+ * List scheduled sends (`GET /accounts/{accountId}/scheduled-sends`).
10653
+ *
10654
+ * Newest first, in every state. Requires `documents:write`, because failure
10655
+ * reasons can expose balance and workspace membership information.
10656
+ * @param params - Optional document filter and pagination.
10657
+ * @param params.document_id - Return only sends containing this document.
10658
+ * @param params.page - One-based page number.
10659
+ * @param params.per-page - Page size, default 20 and maximum 50.
10660
+ * @param params.per_page - Compatibility alias for per-page.
10661
+ * @param accountId - Override the client's default workspace.
10662
+ * @returns Requests and header-derived pagination:
10663
+ * ```jsonc
10664
+ * { "data": [{ "id": "send-1", "type": "assignment", "document_ids": ["doc-1"],
10665
+ * "status": "sent", "send_at": "2026-12-01T12:00:00Z", "assignment_id": "assignment-1",
10666
+ * "envelope_id": null, "failure_reason": null, "created_at": "2026-11-24T12:00:00Z",
10667
+ * "processed_at": "2026-12-01T12:00:03Z" }],
10668
+ * "meta": { "current_page": 1, "per_page": 20, "total": 1, "last_page": 1 } }
10669
+ * ```
10670
+ * @throws {ValidationError} If the workspace/filter is invalid.
10671
+ * @throws {ApiError} `400` for an invalid filter, `401`, `403`, `404`.
10672
+ * @example
10673
+ * ```ts
10674
+ * const sends = await client.scheduledSends.list({ document_id: document.id });
10675
+ * ```
10676
+ */
10677
+ async list(params = {}, accountId) {
10678
+ assertRecord(params, "scheduled send list parameters");
10679
+ if (params.document_id !== void 0) assertNonEmptyString(params.document_id, "document_id");
10680
+ return this.callList(
10681
+ "Failed to list scheduled sends",
10682
+ () => this.http.get(this.path(accountId), { params: cleanListParams({ ...params }) })
10683
+ );
10684
+ }
10685
+ /**
10686
+ * Cancel a pending send (`PUT /accounts/{accountId}/scheduled-sends/{scheduledSendId}/cancel`).
10687
+ *
10688
+ * Sends and charges nothing. A second cancellation is a conflict.
10689
+ * @param scheduledSendId - Pending scheduled send ID.
10690
+ * @param accountId - Override the client's default workspace.
10691
+ * @returns The cancelled state:
10692
+ * ```jsonc
10693
+ * { "id": "send-1", "type": "assignment", "document_ids": ["doc-1"],
10694
+ * "status": "cancelled", "send_at": "2026-12-01T12:00:00Z", "assignment_id": null,
10695
+ * "envelope_id": null, "failure_reason": null, "created_at": "2026-11-24T12:00:00Z",
10696
+ * "processed_at": "2026-11-24T12:05:00Z" }
10697
+ * ```
10698
+ * @throws {ValidationError} If an ID is invalid.
10699
+ * @throws {ApiError} `401`, `403`, `404`, `409` if no longer pending.
10700
+ * @example
10701
+ * ```ts
10702
+ * await client.scheduledSends.cancel(scheduled.id);
10703
+ * ```
10704
+ */
10705
+ async cancel(scheduledSendId, accountId) {
10706
+ return this.call(
10707
+ "Failed to cancel scheduled send",
10708
+ () => this.http.put(`${this.path(accountId)}/${this.pathSegment(scheduledSendId, "Scheduled send ID")}/cancel`)
10709
+ );
10710
+ }
10711
+ /**
10712
+ * Send a pending request now (`PUT /accounts/{accountId}/scheduled-sends/{scheduledSendId}/send`).
10713
+ *
10714
+ * Checks and charges as the scheduling member. A refusal leaves it pending
10715
+ * for its original time; cancel it explicitly to stop that future attempt.
10716
+ * @param scheduledSendId - Pending scheduled send ID.
10717
+ * @param accountId - Override the client's default workspace.
10718
+ * @returns The sent state and created assignment or envelope ID:
10719
+ * ```jsonc
10720
+ * { "id": "send-1", "type": "assignment", "document_ids": ["doc-1"],
10721
+ * "status": "sent", "send_at": "2026-12-01T12:00:00Z", "assignment_id": "assignment-1",
10722
+ * "envelope_id": null, "failure_reason": null, "created_at": "2026-11-24T12:00:00Z",
10723
+ * "processed_at": "2026-11-24T13:00:00Z" }
10724
+ * ```
10725
+ * @throws {ValidationError} If an ID is invalid.
10726
+ * @throws {ApiError} `400` for invalid requests/balances or departed members;
10727
+ * `401`, `403`, `404`, `409` if no longer pending or `CreditCeilingExceeded`.
10728
+ * @example
10729
+ * ```ts
10730
+ * const sent = await client.scheduledSends.sendNow(scheduled.id);
10731
+ * ```
10732
+ */
10733
+ async sendNow(scheduledSendId, accountId) {
10734
+ return this.call(
10735
+ "Failed to send scheduled request",
10736
+ () => this.http.put(`${this.path(accountId)}/${this.pathSegment(scheduledSendId, "Scheduled send ID")}/send`)
10737
+ );
10738
+ }
10739
+ path(accountId) {
10740
+ return `/accounts/${this.pathSegment(this.accountId(accountId), "Account ID")}/scheduled-sends`;
10741
+ }
10742
+ };
10743
+ function validateTimestamp(value, label) {
10744
+ if (typeof value === "number") {
10745
+ if (!Number.isSafeInteger(value) || value < 0) {
10746
+ throw new ValidationError(`${label} must be a non-negative Unix time in seconds`);
10747
+ }
10748
+ } else {
10749
+ assertExpirationDate(value, label);
10750
+ }
10751
+ }
10752
+
10371
10753
  // src/support/webhook-verifier.ts
10372
10754
  import { createHmac, timingSafeEqual as timingSafeEqual2 } from "crypto";
10373
10755
  var DEFAULT_TOLERANCE_SECONDS = 300;
@@ -10427,8 +10809,8 @@ var WebhookVerifier = class {
10427
10809
  if (Math.abs(Date.now() / 1e3 - Number(timestamp)) > toleranceSeconds) return false;
10428
10810
  const expected = createHmac("sha256", key).update(`${id}.${timestamp}.`).update(payload).digest();
10429
10811
  return signatures.split(" ").some((entry) => {
10430
- const [version, signature] = entry.split(",", 2);
10431
- if (version !== "v1" || !signature) return false;
10812
+ const [version, signature, extra] = entry.split(",");
10813
+ if (version !== "v1" || !signature || extra !== void 0) return false;
10432
10814
  const actual = Buffer.from(signature, "base64");
10433
10815
  if (actual.toString("base64") !== signature) return false;
10434
10816
  return actual.length === expected.length && timingSafeEqual2(actual, expected);
@@ -10560,6 +10942,7 @@ var AssinafyClient = class _AssinafyClient {
10560
10942
  contracts;
10561
10943
  envelopes;
10562
10944
  embed;
10945
+ scheduledSends;
10563
10946
  webhookVerifier;
10564
10947
  /**
10565
10948
  * Create a client. Supply `apiKey` (preferred, sent as `X-Api-Key`) or a
@@ -10689,6 +11072,7 @@ var AssinafyClient = class _AssinafyClient {
10689
11072
  );
10690
11073
  this.envelopes = new EnvelopeResource(this.axiosInstance, this.defaultAccountId, this.logger);
10691
11074
  this.embed = new EmbedResource(this.axiosInstance, this.defaultAccountId, this.logger);
11075
+ this.scheduledSends = new ScheduledSendResource(this.axiosInstance, this.defaultAccountId, this.logger);
10692
11076
  this.webhookVerifier = new WebhookVerifier(this.webhookSecret);
10693
11077
  }
10694
11078
  /**
@@ -11128,6 +11512,7 @@ export {
11128
11512
  OAuthError,
11129
11513
  OAuthResource,
11130
11514
  SDK_USER_AGENT,
11515
+ ScheduledSendResource,
11131
11516
  SignerDocumentsResource,
11132
11517
  SignerResource,
11133
11518
  TagResource,
@@ -3,7 +3,8 @@
3
3
  This ledger maps the official
4
4
  [`GET /v1/docs/openapi.json`](https://api.assinafy.com.br/v1/docs/openapi.json)
5
5
  contract to the public SDK API: 112 paths, 147 HTTP operations, and 62 component
6
- schemas.
6
+ schemas. Staging additionally publishes 10 operations (120 paths, 157 operations,
7
+ 63 schemas); those methods require a deployment that serves them.
7
8
 
8
9
  All paths below include the `/v1` prefix shown by the OpenAPI document, except
9
10
  the RFC 8615 `.well-known` document, which is served at the host root. The
@@ -13,6 +14,7 @@ the corresponding relative path without repeating that prefix.
13
14
  Status meanings:
14
15
 
15
16
  - **Covered** — a public, typed SDK method sends the operation.
17
+ - **Covered (staging)** — typed method for an operation currently published on staging.
16
18
  - **Not exposed** — official route the API reserves for Assinafy's own pages;
17
19
  integrations must not call it.
18
20
  - **Compatibility extension** — route retained for existing integrations but
@@ -321,3 +323,18 @@ interfaces and each method's JSDoc examples together with the
321
323
  [official API reference](https://api.assinafy.com.br/v1/docs). Deployment
322
324
  variants that require compatibility handling are recorded in
323
325
  [COMPATIBILITY.md](COMPATIBILITY.md).
326
+
327
+ ## Additional staging operations — 10/10
328
+
329
+ | Method | Path | SDK method | Status |
330
+ | --- | --- | --- | --- |
331
+ | `GET` | `/v1/documents/{documentId}/signer-capacities` | `client.assignments.getSignerCapacities(documentId)` | Covered (staging) |
332
+ | `GET` | `/v1/documents/{documentId}/notification-history` | `client.assignments.getNotificationHistory(documentId)` | Covered (staging) |
333
+ | `GET` | `/v1/documents/{documentId}/watchers` | `client.documents.listWatchers(documentId)` | Covered (staging) |
334
+ | `PUT` | `/v1/documents/{documentId}/watchers` | `client.documents.setWatchers(documentId, watcherIds)` | Covered (staging) |
335
+ | `POST` | `/v1/accounts/{accountId}/envelopes/{envelopeId}/signers/{signerId}/estimate-resend-cost` | `client.envelopes.estimateResendCost(envelopeId, signerId, accountId?)` | Covered (staging) |
336
+ | `POST` | `/v1/documents/{documentId}/scheduled-sends` | `client.scheduledSends.createAssignment(documentId, payload)` | Covered (staging) |
337
+ | `POST` | `/v1/accounts/{accountId}/scheduled-sends` | `client.scheduledSends.createEnvelope(payload, accountId?)` | Covered (staging) |
338
+ | `GET` | `/v1/accounts/{accountId}/scheduled-sends` | `client.scheduledSends.list(params?, accountId?)` | Covered (staging) |
339
+ | `PUT` | `/v1/accounts/{accountId}/scheduled-sends/{scheduledSendId}/cancel` | `client.scheduledSends.cancel(scheduledSendId, accountId?)` | Covered (staging) |
340
+ | `PUT` | `/v1/accounts/{accountId}/scheduled-sends/{scheduledSendId}/send` | `client.scheduledSends.sendNow(scheduledSendId, accountId?)` | Covered (staging) |