@assinafy/cli 2.7.1 → 2.8.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/.env.example +2 -0
- package/README.en.md +14 -8
- package/README.md +11 -3
- package/dist/api.cjs +517 -61
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +514 -61
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +1009 -169
- package/dist/types/api/client.d.ts +5 -0
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/api/envelope-types.d.ts +73 -0
- package/dist/types/api/envelope-types.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +3 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/resources/assignments.d.ts.map +1 -1
- package/dist/types/api/resources/contracts.d.ts +3 -1
- package/dist/types/api/resources/contracts.d.ts.map +1 -1
- package/dist/types/api/resources/documents.d.ts +21 -6
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/resources/embed.d.ts +14 -0
- package/dist/types/api/resources/embed.d.ts.map +1 -0
- package/dist/types/api/resources/envelopes.d.ts +31 -0
- package/dist/types/api/resources/envelopes.d.ts.map +1 -0
- package/dist/types/api/resources/signer-documents.d.ts +23 -11
- package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
- package/dist/types/api/resources/signers.d.ts +1 -1
- package/dist/types/api/resources/signers.d.ts.map +1 -1
- package/dist/types/api/resources/users.d.ts +3 -1
- package/dist/types/api/resources/users.d.ts.map +1 -1
- package/dist/types/api/resources/webhooks.d.ts +6 -2
- package/dist/types/api/resources/webhooks.d.ts.map +1 -1
- package/dist/types/api/resources/workspaces.d.ts +9 -2
- package/dist/types/api/resources/workspaces.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +103 -7
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/api/utils.d.ts +6 -0
- package/dist/types/api/utils.d.ts.map +1 -1
- package/docs/README.md +3 -1
- package/docs/api-operations.json +234 -2
- package/docs/api-reference.md +11533 -3716
- package/docs/assignments.md +16 -14
- package/docs/contracts.md +4 -3
- package/docs/documents.md +44 -27
- package/docs/embed.md +119 -0
- package/docs/envelopes.md +210 -0
- package/docs/sdk-reference.md +215 -29
- package/docs/send.md +15 -11
- package/docs/signer.md +84 -3
- package/docs/users.md +41 -0
- package/docs/webhooks.md +22 -6
- package/docs/workspaces.md +66 -3
- package/package.json +1 -1
package/docs/sdk-reference.md
CHANGED
|
@@ -56,7 +56,7 @@ const publicClient = new AssinafyClient({ allowUnauthenticated: true });
|
|
|
56
56
|
|
|
57
57
|
| API | Result |
|
|
58
58
|
| --- | --- |
|
|
59
|
-
| `new AssinafyClient(options: AssinafyClientOptions)` | Client with `documents`, `signers`, `workspaces`, `assignments`, `webhooks`, `templates`, `tags`, `auth`, `oauth`, `fields`, `users`, `signerDocuments`, and `webhookVerifier`. |
|
|
59
|
+
| `new AssinafyClient(options: AssinafyClientOptions)` | Client with `documents`, `signers`, `workspaces`, `assignments`, `webhooks`, `templates`, `tags`, `auth`, `oauth`, `fields`, `users`, `signerDocuments`, `contracts`, `envelopes`, `embed`, and `webhookVerifier`. |
|
|
60
60
|
| `AssinafyClient.create(apiKey, accountId, options?)` | Convenience constructor. |
|
|
61
61
|
| `AssinafyClient.fromConfig(config: ClientConfigInput)` | Accepts snake-case or camel-case configuration keys. |
|
|
62
62
|
| `client.uploadAndRequestSignatures(options)` | Uploads a PDF, optionally waits for processing, creates/reuses signers, and creates a virtual assignment; returns `IUploadAndRequestSignaturesResult`. |
|
|
@@ -78,12 +78,14 @@ const publicClient = new AssinafyClient({ allowUnauthenticated: true });
|
|
|
78
78
|
verification_method?: 'Email' | 'Whatsapp' | 'DigitalCertificate' | 'IdDocumentFaceMatchBasic';
|
|
79
79
|
notification_methods?: Array<'Email' | 'Whatsapp'>;
|
|
80
80
|
step?: number;
|
|
81
|
+
embedded?: boolean;
|
|
81
82
|
}>;
|
|
82
83
|
message?: string;
|
|
83
84
|
metadata?: Record<string, unknown>;
|
|
84
85
|
waitForReady?: boolean;
|
|
85
86
|
expiresAt?: string;
|
|
86
87
|
copyReceivers?: string[];
|
|
88
|
+
maxTotalCredits?: number;
|
|
87
89
|
accountId?: string;
|
|
88
90
|
}
|
|
89
91
|
```
|
|
@@ -114,13 +116,14 @@ try {
|
|
|
114
116
|
| `upload(source, options?)` | [`POST /accounts/{accountId}/documents`](./api-reference.md#upload-and-create-document) | `IDocumentUploadResponse` |
|
|
115
117
|
| `list(params?, accountId?)` | [`GET /accounts/{accountId}/documents`](./api-reference.md#list-documents) | `IDocumentListResponse` |
|
|
116
118
|
| `search(params?, accountId?)` | [`GET /accounts/{accountId}/documents/search`](./api-reference.md#search-documents-lightweight) | `IDocumentListResponse` |
|
|
117
|
-
| `details(documentId)` | [`GET /documents/{documentId}`](./api-reference.md#get-document) | `IDocumentDetailsResponse` |
|
|
118
|
-
| `get(documentId)` | Same as `details` | `IDocumentDetailsResponse` |
|
|
119
|
+
| `details(documentId, params?)` | [`GET /documents/{documentId}`](./api-reference.md#get-document) | `IDocumentDetailsResponse` |
|
|
120
|
+
| `get(documentId, params?)` | Same as `details` | `IDocumentDetailsResponse` |
|
|
121
|
+
| `getAsSigner(documentId, accessCode)` | `GET /documents/{documentId}`, stripped owner headers | `ISignerDocumentDetailsResponse` |
|
|
119
122
|
| `rename(documentId, name)` | [`PATCH /documents/{documentId}`](./api-reference.md#rename-document) | `IDocumentDetailsResponse` |
|
|
120
123
|
| `waitUntilReady(documentId, { maxWaitMs?, pollIntervalMs? }?)` | Polls [Get document](./api-reference.md#get-document) | `IDocumentDetailsResponse`; rejects on terminal failure, permanent 4xx, or timeout |
|
|
121
|
-
| `download(documentId, artifactName?)` | [`GET /documents/{documentId}/download/{artifact}`](./api-reference.md#download-document-artifact) | `Buffer` |
|
|
122
|
-
| `thumbnail(documentId)` | [`GET /documents/{documentId}/thumbnail`](./api-reference.md#download-document-thumbnail) | JPEG `Buffer` |
|
|
123
|
-
| `downloadPage(documentId, pageId)` | [`GET /documents/{documentId}/pages/{pageId}/download`](./api-reference.md#download-document-page) | JPEG `Buffer` |
|
|
124
|
+
| `download(documentId, artifactName?, options?)` | [`GET /documents/{documentId}/download/{artifact}`](./api-reference.md#download-document-artifact) | `Buffer` |
|
|
125
|
+
| `thumbnail(documentId, options?)` | [`GET /documents/{documentId}/thumbnail`](./api-reference.md#download-document-thumbnail) | JPEG `Buffer` |
|
|
126
|
+
| `downloadPage(documentId, pageId, options?)` | [`GET /documents/{documentId}/pages/{pageId}/download`](./api-reference.md#download-document-page) | JPEG `Buffer` |
|
|
124
127
|
| `activities(documentId, params?)` | [`GET /documents/{documentId}/activities`](./api-reference.md#list-document-activities) | `IDocumentActivity[]` |
|
|
125
128
|
| `delete(documentId)` | [`DELETE /documents/{documentId}`](./api-reference.md#delete-document) | `IEmptyResult` (`unknown[]`) |
|
|
126
129
|
| `listTags(documentId, accountId?)` | [`GET /accounts/{accountId}/documents/{documentId}/tags`](./api-reference.md#list-document-tags) | `ITag[]` |
|
|
@@ -152,26 +155,177 @@ interface IDocumentUploadOptions {
|
|
|
152
155
|
|
|
153
156
|
Uploads must be non-empty PDFs up to 25 MiB. `DocumentArtifactName` is `original | certificated | certificate-page | pades | bundle`; `bundle` is ZIP and the other document artifacts are PDF. `sendToken(documentId, 'signer@example.com')` emails a one-time access token to a signer who has not signed a pending document yet and sends `{ "channel": "email", "recipient": "signer@example.com" }`. Only the `email` channel is accepted; any other channel is rejected locally. The `{ email }` overload sends the same body.
|
|
154
157
|
|
|
155
|
-
Template document creation sends `{ signers, name?, message?, expires_at?, editor_fields?, tags? }`. Each signer is `{ role_id, id?, email?, name?, whatsapp_phone_number?, verification_method?, notification_methods?, step? }`; supply an existing ID or an email for creation/reuse (an ID takes precedence); each editor field is `{ field_id, value: string }`. Template cost estimation publishes `{ signers: Array<{ role_id, verification_method?, notification_methods? }> }`. The optional cost-signer `id` and `step` properties remain compatibility extensions for existing integrations. A template with placed signer fields creates a `collect` assignment, so it cannot use a `DigitalCertificate` signer. For certificate-bearing template create and estimate calls, the SDK reads the template details first and rejects placed Signer-role fields with `ValidationError.errors.code` set to `digital_certificate_requires_virtual`.
|
|
158
|
+
Template document creation sends `{ signers, name?, message?, expires_at?, editor_fields?, tags?, max_total_credits? }`. Options also accept `idempotencyKey`, sent only in the `Idempotency-Key` header. Each signer is `{ role_id, id?, email?, name?, whatsapp_phone_number?, verification_method?, notification_methods?, step?, embedded? }`; supply an existing ID or an email for creation/reuse (an ID takes precedence); each editor field is `{ field_id, value: string }`. Template cost estimation publishes `{ signers: Array<{ role_id, verification_method?, notification_methods? }> }`. The optional cost-signer `id` and `step` properties remain compatibility extensions for existing integrations. A template with placed signer fields creates a `collect` assignment, so it cannot use a `DigitalCertificate` signer. For certificate-bearing template create and estimate calls, the SDK reads the template details first and rejects placed Signer-role fields with `ValidationError.errors.code` set to `digital_certificate_requires_virtual`.
|
|
156
159
|
|
|
157
|
-
Document list params are `{ page?, per_page?, status?, method?, tags?, search?, sort? }`; search params omit `method`/`tags`. Supported sort values are `name`, `-name`, `updated_at`, and `-updated_at`.
|
|
160
|
+
Document list params are `{ page?, per_page?, status?, method?, tags?, search?, sort?, envelope_id? }`; search params omit `method`/`tags`. Supported sort values are `name`, `-name`, `updated_at`, and `-updated_at`.
|
|
158
161
|
|
|
159
162
|
In production, `replaceTags` and `addTags` accept tag names, reuse matching tags, and create missing names. Use `replaceTags(documentId, ['Contracts'])` or `addTags(documentId, ['Contracts'])`; an empty replacement removes all associations. Values are sent unchanged. Pass the tag ID from `listTags` to `detachTag`. Document-list tag filters also use IDs.
|
|
160
163
|
|
|
161
164
|
Activity queries use `IDocumentActivityListParams`: `{ page?, per_page?, 'per-page'?, sort?: 'id' | '-id' }`; the default is 20 records per page, newest first. Page until an empty array to read the complete history. Expirations accept `YYYY-MM-DD` (23:59 UTC), an offsetless datetime (UTC), or an RFC 3339 timestamp; values are forwarded unchanged. Template signing steps apply to Signer roles; CopyReceiver steps are ignored. Editor fields do not force a certificate template into collect signing. Template creation/estimation forwards role-specific verification, notification and step settings to the API, which ignores them for CopyReceiver roles. The SDK validates descriptor identity locally without fetching roles solely for validation.
|
|
162
165
|
|
|
166
|
+
Owner `get`/`details` params accept `{ expand: "envelope" | "envelope_id" | "envelope,envelope_id" }`; the expanded relation is null for a standalone document. `getAsSigner` returns only the signer-visible assignment fields. Download options accept `{ signerAccessCode? }`; thumbnail/page options also accept `{ artifact: "certificated" }` to render the signed PDF. Omit the code to use owner authentication; a supplied code strips owner credentials, and a blank code is rejected. CLI `documents get|download|thumbnail|download-page --access-code` selects the same behavior.
|
|
167
|
+
|
|
163
168
|
Document responses expose typed `IDocumentArtifacts`, `IDocumentPage`, inline tags, assignment/signing state, decline state, and creation/update timestamps. `IPublicDocumentInfo` models the complete published public-document payload while retaining the older optional `page_count` and `created_by` fields.
|
|
164
169
|
|
|
170
|
+
## Envelopes (`client.envelopes`)
|
|
171
|
+
|
|
172
|
+
An envelope groups up to 20 processed documents and 20 existing workspace signers. Each document keeps its own assignment, status, certificate, artifacts and webhooks. Creation consumes one document allowance; notifications and biometric verification are charged once per signer for the envelope, while certificate signatures are charged per document. The Envelopes feature is required for creation, adding documents and estimates. OAuth uses `documents:read`/`documents:write`.
|
|
173
|
+
|
|
174
|
+
| SDK method | HTTP operation | SDK result |
|
|
175
|
+
| --- | --- | --- |
|
|
176
|
+
| `list(params?, accountId?)` | `GET /accounts/{accountId}/envelopes`; `{ page?, per_page?, search?, status?: "open" | "closed" }` | `PaginatedResult<IDocumentEnvelope>` |
|
|
177
|
+
| `create(payload, options?)` | `POST /accounts/{accountId}/envelopes`; `ICreateEnvelopePayload` | `IDocumentEnvelope` |
|
|
178
|
+
| `estimateCost(payload, accountId?)` | `POST /accounts/{accountId}/envelopes/estimate-cost`; same creation body, no changes or charges | `IEstimateCostResponse` |
|
|
179
|
+
| `get(envelopeId, accountId?)` | `GET /accounts/{accountId}/envelopes/{envelopeId}` | `IDocumentEnvelope` |
|
|
180
|
+
| `update(envelopeId, payload, accountId?)` | `PATCH /accounts/{accountId}/envelopes/{envelopeId}`; `{ name?, message?: string | null, document_ids?: string[] }` | `IDocumentEnvelope` |
|
|
181
|
+
| `delete(envelopeId, accountId?)` | `DELETE /accounts/{accountId}/envelopes/{envelopeId}`; no body, requires all documents closed | `[]`; documents remain |
|
|
182
|
+
| `activities(envelopeId, params?, accountId?)` | `GET …/{envelopeId}/activities`; pagination and `sort: "id" | "-id"` | `PaginatedResult<IEnvelopeActivity>` |
|
|
183
|
+
| `download(envelopeId, artifactName?, accountId?)` | `GET …/{envelopeId}/download/{artifactName}`; defaults to certificated | ZIP `Buffer` |
|
|
184
|
+
| `cancel(envelopeId, accountId?)` | `PUT …/{envelopeId}/cancel`, no body | `Array<{ id, status, cancelled: boolean }>` |
|
|
185
|
+
| `resendNotification(envelopeId, signerId, accountId?)` | `PUT …/{envelopeId}/signers/{signerId}/resend`, no body | `{ is_sent: boolean, envelope_id: string, signer_id: string }` |
|
|
186
|
+
| `addDocument(envelopeId, payload, accountId?)` | `POST …/{envelopeId}/documents`; `IEnvelopeDocumentPayload & { max_total_credits?: number }` | `IDocumentEnvelope` |
|
|
187
|
+
| `removeDocument(envelopeId, documentId, accountId?)` | `DELETE …/{envelopeId}/documents/{documentId}`, no body | `IDocumentEnvelope` |
|
|
188
|
+
|
|
189
|
+
Complete creation body (optional controls shown):
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
interface ICreateEnvelopePayload {
|
|
193
|
+
name: string; // 1–255 characters, no <
|
|
194
|
+
message?: string | null;
|
|
195
|
+
max_total_credits?: number;
|
|
196
|
+
signers: Array<{
|
|
197
|
+
id: string;
|
|
198
|
+
verification_method?: 'Email' | 'Whatsapp' | 'DigitalCertificate' | 'IdDocumentFaceMatchBasic';
|
|
199
|
+
notification_methods?: Array<'Email' | 'Whatsapp'>;
|
|
200
|
+
embedded?: boolean;
|
|
201
|
+
}>;
|
|
202
|
+
documents: Array<{
|
|
203
|
+
id: string;
|
|
204
|
+
signer_ids: string[];
|
|
205
|
+
method?: 'virtual' | 'collect';
|
|
206
|
+
entries?: ICollectAssignmentEntry[];
|
|
207
|
+
expires_at?: string | number | null;
|
|
208
|
+
copy_receiver_ids?: string[];
|
|
209
|
+
}>;
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Signers act in parallel; `step` is not accepted. Every signer must appear on at least one document, and every document signer must be in the envelope's signer list. A certificate signer must be alone on each virtual document they sign. Collect entries use the assignment field format and exactly that document's signers. The server enforces workspace ownership, document readiness, at most 2,000 fields and 100 copy receivers across the envelope. Expiration accepts ISO dates/timestamps or Unix seconds; null, zero or empty text means no expiration. Reorder updates must name every current document exactly once; null clears only the message.
|
|
214
|
+
|
|
215
|
+
A complete SDK flow:
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
import { randomUUID } from 'node:crypto';
|
|
219
|
+
import { AssinafyClient } from '@assinafy/cli/api';
|
|
220
|
+
|
|
221
|
+
const client = new AssinafyClient({
|
|
222
|
+
apiKey: process.env.ASSINAFY_API_KEY!,
|
|
223
|
+
accountId: process.env.ASSINAFY_ACCOUNT_ID!,
|
|
224
|
+
});
|
|
225
|
+
const signer = await client.signers.create({ full_name: 'Example Signer', email: 'signer@example.com' });
|
|
226
|
+
const documents = [];
|
|
227
|
+
for (const filePath of ['./contract.pdf', './annex.pdf']) {
|
|
228
|
+
const uploaded = await client.documents.upload({ filePath });
|
|
229
|
+
// Persist uploaded.id before waiting so a failure can be resumed.
|
|
230
|
+
await client.documents.waitUntilReady(uploaded.id);
|
|
231
|
+
documents.push({ id: uploaded.id, signer_ids: [signer.id] });
|
|
232
|
+
}
|
|
233
|
+
const payload = {
|
|
234
|
+
name: 'Service agreement',
|
|
235
|
+
message: 'Please review both documents.',
|
|
236
|
+
signers: [{ id: signer.id }],
|
|
237
|
+
documents,
|
|
238
|
+
max_total_credits: 0,
|
|
239
|
+
};
|
|
240
|
+
const estimate = await client.envelopes.estimateCost(payload);
|
|
241
|
+
if (!estimate.has_sufficient_resources) throw new Error('Insufficient resources');
|
|
242
|
+
const idempotencyKey = randomUUID(); // Persist with this business operation before sending.
|
|
243
|
+
const envelope = await client.envelopes.create(payload, { idempotencyKey });
|
|
244
|
+
// Persist envelope.id, then inspect document status and notification history.
|
|
245
|
+
const current = await client.envelopes.get(envelope.id);
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
The SDK result has this complete shape (the wire body wraps it in `{ status, message, data }`):
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
interface IDocumentEnvelope {
|
|
252
|
+
resource?: string;
|
|
253
|
+
id: string;
|
|
254
|
+
name: string;
|
|
255
|
+
message: string | null;
|
|
256
|
+
documents: Array<{
|
|
257
|
+
id: string;
|
|
258
|
+
position: number;
|
|
259
|
+
name: string;
|
|
260
|
+
status: string;
|
|
261
|
+
artifacts: Record<string, string>;
|
|
262
|
+
signers: Array<{
|
|
263
|
+
id: string;
|
|
264
|
+
full_name: string;
|
|
265
|
+
email: string | null;
|
|
266
|
+
whatsapp_phone_number: string | null;
|
|
267
|
+
completed: boolean;
|
|
268
|
+
signed_at: string | null;
|
|
269
|
+
}>;
|
|
270
|
+
}>;
|
|
271
|
+
counts: Record<string, number> | null;
|
|
272
|
+
signing_urls: Array<{ signer_id: string; url: string | null; embedded?: boolean }>;
|
|
273
|
+
created_at: string;
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
A successful creation means the envelope exists, not that every invitation arrived. Inspect assignment `notification_history` and WhatsApp delivery history. One invitation covers a signer's documents; the email/WhatsApp code carries across the envelope. `getAssignment(code, undefined, { document_id })` selects a document, and `sign`/`decline` perform that selection automatically. Biometric verification and review are shared across the signer's envelope documents; certificate signing remains one operation per document. Pass `documentId` to `startCertificate(code, documentId)` and `completeCertificate(code, token, documentId)` to select each one.
|
|
278
|
+
|
|
279
|
+
Creation options are `{ accountId?, idempotencyKey? }`. The case-sensitive key belongs to the workspace and does not expire; reusing it returns the original envelope regardless of the replacement body. Persist and deliberately reuse it after an ambiguous failure; never generate a new key for the same intended operation. `IdempotencyKeyInUse` is 409 while the first request runs. A credit ceiling refusal creates and charges nothing. There are no SDK write retries. Deleting an envelope also removes its idempotency replay result.
|
|
280
|
+
|
|
281
|
+
Adding a document uses existing envelope signers, sends updated invitations, and can charge certificate credits. Removing an open document cancels it and notifies recipients; links from it continue to open the rest. Cancel affects only cancellable documents; completed certificates stay valid. Deleting requires every document closed and leaves the documents intact. Document deletion is refused while its envelope remains open, including documents removed from it. CLI cancel/delete/remove-document confirm unless `--yes`.
|
|
282
|
+
|
|
283
|
+
## Embedded signing (`client.embed`)
|
|
284
|
+
|
|
285
|
+
The Embed feature and an owner API key or first-party user token are required to mint sessions; OAuth application tokens cannot mint them. Keep that credential on your backend. The Node SDK is not shipped in the browser or a native mobile app; the frontend displays the hosted iframe. See the [official Embedded Signing Guide](https://api.assinafy.com.br/v1/docs) for the frontend message protocol and event payloads.
|
|
286
|
+
|
|
287
|
+
| SDK method | HTTP operation and request | SDK result |
|
|
288
|
+
| --- | --- | --- |
|
|
289
|
+
| `listOrigins(accountId?)` | `GET /accounts/{accountId}/embed-origins`, no body | `IEmbedOrigin[]` |
|
|
290
|
+
| `createOrigin(origin, accountId?)` | `POST /accounts/{accountId}/embed-origins`; `{ origin }` | `IEmbedOrigin` |
|
|
291
|
+
| `updateOrigin(originId, origin, accountId?)` | `PUT …/embed-origins/{originId}`; `{ origin }` | `IEmbedOrigin` |
|
|
292
|
+
| `deleteOrigin(originId, accountId?)` | `DELETE …/embed-origins/{originId}`, no body | `[]` |
|
|
293
|
+
| `createSession(documentId, assignmentId, signerId)` | `POST /documents/{documentId}/assignments/{assignmentId}/signers/{signerId}/embed-sessions`, no body | `IEmbedSession` |
|
|
294
|
+
| `exchangeSession(token, parentOrigin?)` | `POST /embed/sessions/{token}/exchange`; no body or `{ parent_origin }`, no owner headers | `IEmbedSessionExchange` |
|
|
295
|
+
|
|
296
|
+
Complete SDK response types:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
interface IEmbedOrigin { id: string; origin: string; created_at: string }
|
|
300
|
+
interface IEmbedSession { url: string; expires_at: string }
|
|
301
|
+
interface IEmbedSessionExchange {
|
|
302
|
+
signer_access_code: string;
|
|
303
|
+
signer_id: string;
|
|
304
|
+
document_id: string;
|
|
305
|
+
verification_method: string;
|
|
306
|
+
embed_origins: string[];
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
1. Register an exact HTTPS origin with `createOrigin('https://app.example.com')`. HTTP is allowed only on localhost or 127.0.0.1. Paths, credentials, wildcards, query strings and fragments are rejected; at most 10 origins are allowed. No origins means embedding is disabled.
|
|
311
|
+
2. Create the assignment/template/envelope signer with `embedded: true`, Email or Whatsapp verification, and the matching notification method. Invitations still deliver the OTP; `signing_urls` contains `{ signer_id, url: null, embedded: true }`.
|
|
312
|
+
3. Your authenticated backend verifies that the logged-in application user may act for that signer, then calls `createSession(documentId, assignmentId, signerId)`. Pass only its URL to that user's frontend. Sessions expire after five minutes and are single-use; mint a new one each time the frame is opened. Limit: 30 per signer per hour.
|
|
313
|
+
4. Load the URL in the iframe. On load, send `{ v: 1, type: 'assinafy:hello' }` every 500 ms for at most 10 seconds, targeting the exact Assinafy origin, until `ready` or `error`. Repeat the handshake on frame reload. Accept messages only when both `event.origin` and `event.source === iframe.contentWindow` match. Production iframe origin: `https://app.assinafy.com.br`; sandbox: `https://app-sandbox.assinafy.com.br`.
|
|
314
|
+
5. The hosted page exchanges the token and handles verification, terms and signing. Integrations must not call `exchangeSession` before loading the frame: it consumes the token, including on a 409. That method/CLI operation is exposed for implementing the hosted-page protocol. Unknown, expired or consumed tokens return 410/`embed_session_invalid`.
|
|
315
|
+
6. Treat frame events as UI hints. Confirm completion using verified webhooks or document reads before releasing goods or changing permissions. An external invitation can also complete signing; the frame reports that with `via: 'external'`.
|
|
316
|
+
|
|
317
|
+
A 409/`document_not_ready` from session creation permits a later deliberate mint after processing. Other refusal codes distinguish `already_signed`, `document_unavailable`, and `embed_origins_missing`; inspect `ApiError.responseData`. Editing the signer's contact before verification rotates the access code and expires open frames. Re-send an invitation only as an intentional notification operation. Never store/log embed URLs or exchange results in browser storage.
|
|
318
|
+
|
|
165
319
|
## Contracts (`client.contracts`)
|
|
166
320
|
|
|
167
|
-
Contract tracking (CLM / Gestão de Contratos) records terms on an existing document. It does not upload a document or request signatures.
|
|
321
|
+
Contract tracking (CLM / Gestão de Contratos) records terms on an existing document. It does not upload a document or request signatures. Contract tracking is included in all standard plans, including Free; writes require the feature to be active; reads remain available when the plan lapses. OAuth uses `documents:read` for reads and `documents:write` for writes.
|
|
168
322
|
|
|
169
323
|
| SDK method | HTTP operation | Resolves to |
|
|
170
324
|
| --- | --- | --- |
|
|
171
325
|
| `list(params?, accountId?)` | [`GET /accounts/{accountId}/contracts`](./api-reference.md#list-contracts) | `PaginatedResult<IContract>` |
|
|
172
326
|
| `get(documentId, accountId?)` | [`GET /accounts/{accountId}/documents/{documentId}/contract`](./api-reference.md#get-a-documents-contract-terms) | `IContract \| IContractAmendment` |
|
|
173
327
|
| `set(documentId, payload, accountId?)` | [`PUT /accounts/{accountId}/documents/{documentId}/contract`](./api-reference.md#set-a-documents-contract-terms) | `IContract \| IContractAmendment` |
|
|
174
|
-
| `related(documentId, accountId?)` | [`GET …/contract/related`](./api-reference.md#list-the-contracts-related-to-a-document) | `IContract`, including `amendments` |
|
|
328
|
+
| `related(documentId, accountId?, params?)` | [`GET …/contract/related`](./api-reference.md#list-the-contracts-related-to-a-document) | `IContract`, including `amendments` |
|
|
175
329
|
| `renew(documentId, payload, accountId?)` | [`POST …/contract/renew`](./api-reference.md#renew-a-contract) | `IContract` |
|
|
176
330
|
| `terminate(documentId, payload?, accountId?)` | [`POST …/contract/terminate`](./api-reference.md#terminate-a-contract) | `IContract` |
|
|
177
331
|
|
|
@@ -297,6 +451,8 @@ Termination input (`ITerminateContractPayload`) is `{ reason?: string | null; up
|
|
|
297
451
|
|
|
298
452
|
The hourly lifecycle uses Brasília calendar days: notice-period alerts, warnings 45/30 days before expiry, then renewal or expiry the day after the end date. Owner notification preferences include `ContractRenewalNotice`, `ContractExpiring`, `ContractExpired` and `ContractRenewed`. Contract activities include `document_contract_updated`, `document_contract_amendment_updated`, `document_contract_amended`, `document_contract_renewal_notice`, `document_contract_expiring`, `document_contract_expired`, `document_contract_renewed` and `document_contract_terminated`. Subscribe explicitly to the event types needed; webhook defaults do not add these events. Reconcile missed events by paging `list({ sort: '-updated_at' })` until older than the last sync, and page `documents.activities(documentId, { page, sort: 'id' })` for history. A lapsed plan pauses lifecycle changes and pending amendments; restoration catches up without sending alerts whose windows have passed.
|
|
299
453
|
|
|
454
|
+
`related` accepts `{ expand: "document" }` to include document details, also available as `contracts related --expand document`.
|
|
455
|
+
|
|
300
456
|
## Assignments (`client.assignments`)
|
|
301
457
|
|
|
302
458
|
| SDK method | HTTP operation | Resolves to |
|
|
@@ -323,16 +479,20 @@ Assignment payload:
|
|
|
323
479
|
verification_method?: 'Email' | 'Whatsapp' | 'DigitalCertificate' | 'IdDocumentFaceMatchBasic';
|
|
324
480
|
notification_methods?: Array<'Email' | 'Whatsapp'>;
|
|
325
481
|
step?: number;
|
|
482
|
+
embedded?: boolean;
|
|
326
483
|
}>;
|
|
327
484
|
signer_ids?: string[]; // compatibility alias
|
|
328
485
|
signerIds?: string[]; // compatibility alias
|
|
329
486
|
message?: string;
|
|
330
487
|
expires_at?: string;
|
|
331
488
|
copy_receivers?: string[];
|
|
489
|
+
max_total_credits?: number;
|
|
332
490
|
entries?: ICollectAssignmentEntry[];
|
|
333
491
|
}
|
|
334
492
|
```
|
|
335
493
|
|
|
494
|
+
`max_total_credits` is a finite non-negative ceiling; `0` allows only a free request. A higher live price returns `409`/`CreditCeilingExceeded` before creation or charging. The high-level helper calls this option `maxTotalCredits`; CLI `send`, `assignments create`, and `documents create-from-template` expose `--max-total-credits`. A null balance means unlimited, not zero. `embedded: true` requires Email or Whatsapp verification and the workspace Embed feature; signing links return `url: null`.
|
|
495
|
+
|
|
336
496
|
Production defaults `notification_methods: []` to `['Email']` and sends an invitation. An empty array is not a way to disable delivery. Choose the intended supported channel explicitly before creating an assignment.
|
|
337
497
|
|
|
338
498
|
`buildAssignmentPayload(payload, options?)` is exported for callers that need the same normalization. It resolves synchronously to the JSON assignment body above; no HTTP call occurs. Options are `{ allowSignersWithoutId?: boolean; skipDigitalCertificateStepValidation?: boolean }`, both false by default. Both support cost estimation: the first accepts signer descriptors without an `id`, and the second bypasses signing-order and certificate-step checks for estimates. An empty signer list always throws `ValidationError('At least one signer is required')`, in `virtual` and `collect` modes and in cost estimates alike. `DigitalCertificate` signers require `method: 'virtual'`: `create` and `estimateCost` reject `collect` before sending a request with `ValidationError.errors.code` set to `digital_certificate_requires_virtual`. `create` also enforces complete contiguous signing steps from 1 when supplied and requires each digital-certificate signer to be alone in its step. The estimate schema has no `step`, so `estimateCost` passes `skipDigitalCertificateStepValidation` to skip that create-only rule. Assignment list params are pagination plus the compatible `sort?: 'created_at' | '-created_at'`; the runtime endpoint requires the SDK's `accountId` query even though the published parameter table omits it. Assignment `search` is unsupported and rejected locally.
|
|
@@ -361,20 +521,20 @@ Production defaults `notification_methods: []` to `['Email']` and sends an invit
|
|
|
361
521
|
| `delete(signerId, accountId?)` | [`DELETE /accounts/{accountId}/signers/{signerId}`](./api-reference.md#delete-signer) | `IEmptyResult` (`unknown[]`) |
|
|
362
522
|
| `findByEmail(email, accountId?)` | SDK helper over `list({ search: email })` | `ISigner | null` |
|
|
363
523
|
|
|
364
|
-
Create payload: `{ full_name: string; email?; whatsapp_phone_number?; government_id?; phone?; cpf?; metadata? }`. Update payload: `{ full_name?; email?; whatsapp_phone_number?; phone?; government_id?; cpf? }`. `government_id` accepts CPF or numeric/alphanumeric CNPJ and is forwarded unchanged for server normalization. `phone`, create-time `cpf`/`metadata`, and update-time `cpf` are compatibility extensions; the `cpf` alias retains its digit-only normalization. New integrations should use the published fields. Creation is idempotent by exact case-insensitive email when email is supplied; full-name-only signers are valid. Existing email matches are reused without updating their government ID; call `update` explicitly when needed. List params support published `search` and compatible `sort?: 'full_name' | '-full_name'`; ignored sort fields are rejected locally.
|
|
524
|
+
Create payload: `{ full_name: string; email?; whatsapp_phone_number?; government_id?; phone?; cpf?; metadata? }`. Update payload: `{ full_name?; email?; whatsapp_phone_number?; phone?; government_id?; cpf? }`. `government_id` accepts CPF or numeric/alphanumeric CNPJ and is forwarded unchanged for server normalization. `phone`, create-time `cpf`/`metadata`, and update-time `cpf` are compatibility extensions; the `cpf` alias retains its digit-only normalization. New integrations should use the published fields. Creation is idempotent by exact case-insensitive email when email is supplied; full-name-only signers are valid. Existing email matches are reused without updating their government ID; call `update` explicitly when needed. Update `email`, `whatsapp_phone_number` and `government_id` with `null` or `""` to clear them; omitted values stay unchanged. `findByEmail` requests the server maximum of 50 records per page so a capped page cannot end its search early. List params support published `search` and compatible `sort?: 'full_name' | '-full_name'`; ignored sort fields are rejected locally.
|
|
365
525
|
|
|
366
526
|
## Signer-side flows (`client.signerDocuments`)
|
|
367
527
|
|
|
368
|
-
These methods use the private `signer-access-code
|
|
528
|
+
These methods use the private `signer-access-code` and strip the workspace API key or bearer header. Token-based certified-copy downloads use the private download token instead. `listAsOwner` and `searchAsOwner` call the same routes with the client's API key or bearer token instead; the signer must belong to that workspace. For email or WhatsApp verification, obtain the access code from the verification link and the OTP from the same message. An invitation containing only a document ID and recipient is not an access code. Call `self` and `getAssignment` to confirm the signer and document before submitting a decision; keep each document's verification credentials together.
|
|
369
529
|
|
|
370
530
|
| SDK method | HTTP operation | Resolves to |
|
|
371
531
|
| --- | --- | --- |
|
|
372
|
-
| `getCurrent(signerId, accessCode)` | [`GET /signers/{signerId}/document`](./api-reference.md#get-signers-document) | `
|
|
532
|
+
| `getCurrent(signerId, accessCode, params?)` | [`GET /signers/{signerId}/document`](./api-reference.md#get-signers-document) | `ISigningDocument` |
|
|
373
533
|
| `list(signerId, accessCode, params?)` | [`GET /signers/{signerId}/documents`](./api-reference.md#list-signers-documents) | `IDocumentListResponse` |
|
|
374
534
|
| `listAsOwner(signerId, params?)` | [`GET /signers/{signerId}/documents`](./api-reference.md#list-signers-documents) with owner credentials | `IDocumentListResponse` |
|
|
375
|
-
| `search(signerId, search, accessCode)` | [`GET /signers/{signerId}/documents/search`](./api-reference.md#search-signers-documents) | `IDocumentListResponse` |
|
|
376
|
-
| `searchAsOwner(signerId, search)` | [`GET /signers/{signerId}/documents/search`](./api-reference.md#search-signers-documents) with owner credentials | `IDocumentListResponse` |
|
|
377
|
-
| `download(signerId, documentId, artifact, accessCode?)` | [`GET /signers/{signerId}/documents/{documentId}/download/{artifact}`](./api-reference.md#download-
|
|
535
|
+
| `search(signerId, search, accessCode, params?)` | [`GET /signers/{signerId}/documents/search`](./api-reference.md#search-signers-documents) | `IDocumentListResponse` |
|
|
536
|
+
| `searchAsOwner(signerId, search, params?)` | [`GET /signers/{signerId}/documents/search`](./api-reference.md#search-signers-documents) with owner credentials | `IDocumentListResponse` |
|
|
537
|
+
| `download(signerId, documentId, artifact, accessCode?)` | [`GET /signers/{signerId}/documents/{documentId}/download/{artifact}`](./api-reference.md#download-the-document-to-sign) | `Buffer` |
|
|
378
538
|
| `signMultiple(documentIds, accessCode)` | [`PUT /signers/documents/sign-multiple`](./api-reference.md#sign-multiple-documents) | `unknown[]` |
|
|
379
539
|
| `declineMultiple(documentIds, reason, accessCode)` | [`PUT /signers/documents/decline-multiple`](./api-reference.md#decline-multiple-documents) | `unknown[]` |
|
|
380
540
|
| `self(accessCode)` | [`GET /signers/self`](./api-reference.md#get-current-signer) | `ISignerSelf` |
|
|
@@ -383,18 +543,18 @@ These methods use the private `signer-access-code`, not the workspace API key, e
|
|
|
383
543
|
| `verifyEmail(payload: IVerifySignerCodePayload)` | Compatibility alias for `verifyCode` | `IEmptyResult \| IStatusResponse` |
|
|
384
544
|
| `getIdentityVerification(accessCode)` | [`GET /signers/identity-verification`](./api-reference.md#identity-document-verification-status) | `IIdentityVerificationState` |
|
|
385
545
|
| `startIdentityVerification(accessCode, payload)` | [`POST /signers/identity-verification`](./api-reference.md#start-identity-document-verification) | `IIdentityVerificationSession`; payload is `{ consent: true }` |
|
|
386
|
-
| `startCertificate(accessCode)` | [`POST /signers/certificate/start`](#icp-brasil-a1a3-certificates) | `ICertificateStartResponse` (`{ token: string }`) |
|
|
387
|
-
| `completeCertificate(accessCode, token)` | [`POST /signers/certificate/complete`](#icp-brasil-a1a3-certificates) | `ICertificateCompleteResponse` (`{ signerName: string }`) |
|
|
546
|
+
| `startCertificate(accessCode, documentId?)` | [`POST /signers/certificate/start`](#icp-brasil-a1a3-certificates) | `ICertificateStartResponse` (`{ token: string }`) |
|
|
547
|
+
| `completeCertificate(accessCode, token, documentId?)` | [`POST /signers/certificate/complete`](#icp-brasil-a1a3-certificates) | `ICertificateCompleteResponse` (`{ signerName: string }`) |
|
|
388
548
|
| `confirmData(documentId, accessCode, payload)` | [`PUT /documents/{documentId}/signers/confirm-data`](./api-reference.md#confirm-signer-data) | `ISigner \| IEmptyResult` |
|
|
389
549
|
| `uploadSignature(accessCode, image, options?)` | [`POST /signature`](./api-reference.md#upload-signature-image) | `IEmptyResult \| IStatusResponse` |
|
|
390
550
|
| `downloadSignature(accessCode, imageType?)` | [`GET /signature/{type}`](./api-reference.md#download-signature-image) | `Buffer` |
|
|
391
|
-
| `getAssignment(accessCode, hasAcceptedTerms?)` | [`GET /sign`](./api-reference.md#view-document-to-sign) | `
|
|
551
|
+
| `getAssignment(accessCode, hasAcceptedTerms?, params?)` | [`GET /sign`](./api-reference.md#view-document-to-sign) | `ISigningDocument` |
|
|
392
552
|
| `sign(documentId, assignmentId, accessCode, entries)` | [`POST /documents/{documentId}/assignments/{assignmentId}`](./api-reference.md#sign-assignment-items) | `Record<string, unknown>` |
|
|
393
553
|
| `decline(documentId, assignmentId, accessCode, reason)` | [`PUT …/reject`](./api-reference.md#reject-decline-assignment) | `unknown[]` |
|
|
394
554
|
|
|
395
555
|
`confirmData` accepts `{ full_name?, email?, government_id?, whatsapp_phone_number?, has_accepted_terms? }`. `uploadSignature` accepts a non-empty image `Buffer` plus `{ imageType?: 'signature' | 'initial'; contentType?: string; reuse?: boolean }`. Each signing entry is `{ itemId, fieldId, pageId, value }`.
|
|
396
556
|
|
|
397
|
-
`confirmData
|
|
557
|
+
`confirmData` preflights `GET /documents/{documentId}` with the signer code: `/sign` is blocked until certificate data and terms are confirmed. `sign` and `decline` preflight `getAssignment(accessCode, undefined, { document_id: documentId })`, enabling selection of another document of the same envelope and checking the returned document/assignment IDs before writing. These methods make one additional GET request. For virtual assignments, confirm the signer's data and then call `sign(documentId, assignmentId, accessCode, [])`. Collect assignments require a non-empty array with the actual assignment item, field, and page IDs. Signing resolves to the server's assignment result; poll document details until `certificated` before downloading final artifacts.
|
|
398
558
|
|
|
399
559
|
Each request below includes `?signer-access-code=<private-access-code>`. These are complete example bodies and SDK results for production:
|
|
400
560
|
|
|
@@ -407,7 +567,19 @@ Each request below includes `?signer-access-code=<private-access-code>`. These a
|
|
|
407
567
|
|
|
408
568
|
An empty result is successful acknowledgement, not a signer profile. Use `self(accessCode)` afterward when you need the updated profile, terms acceptance, or signature flags. The response types retain the published status/profile alternatives without converting or fabricating response fields.
|
|
409
569
|
|
|
410
|
-
|
|
570
|
+
`getCurrent` accepts `{ expand: "envelope" }`; `getAssignment` additionally accepts `document_id` for another document of the same envelope. List/search params accept `envelope_id` and pagination. The API carries email/WhatsApp verification across documents of that envelope. `ISigningDocument` exposes `current_signer`, `is_signer_access_closed`, and `certified_copy`; closed links return only identity and copy state, and other signer operations return 410. Code closure occurs 30 minutes after this signer's work is done across the envelope. Assignment details contain only this signer's items, without other signers or their private links.
|
|
571
|
+
|
|
572
|
+
The legacy `download` signature is retained, but the current API permits only `original` with an access code; without one it redirects to an expired-link page, which the SDK rejects rather than following. Supplied codes get a `/signers/self` identity preflight. Use `downloadCertifiedCopy` for completed PDFs.
|
|
573
|
+
|
|
574
|
+
| SDK method | HTTP operation and request | SDK response |
|
|
575
|
+
| --- | --- | --- |
|
|
576
|
+
| `getTheme(accessCode)` | `GET /sign/theme`, no body | `IAccountTheme` |
|
|
577
|
+
| `downloadLogo(accessCode)` | `GET /sign/logo`, no body | Image `Buffer`; 404 if absent |
|
|
578
|
+
| `resendCertifiedCopy(accessCode, documentId?)` | `POST /sign/certified-copy`; no body or `{ document_id }` for an envelope document | `ICertifiedCopyResponse` |
|
|
579
|
+
| `downloadCertifiedCopy(token, artifact?)` | `GET /signers/downloads/{token}`; `artifact: "pades"` selects `/pades`; default `"certificated"` | PDF `Buffer` |
|
|
580
|
+
| `resendDownloadLink(token)` | `POST /signers/downloads/{token}/resend`, no body | `ICertifiedCopyResponse` |
|
|
581
|
+
|
|
582
|
+
Certified-copy requests deliver to the original signing contact, never an arbitrary recipient. The result is `{ available: boolean, notification_method: "Email" | "Whatsapp", sent_to: string, resends_left: number | null }`. Links last 30 minutes. Email allows one resend every two minutes and ten per 24 hours; WhatsApp allows one resend per signature request. `sent_to` is masked. See the [HTTP reference](./api-reference.md) for refusal payloads. Expired download URLs return 302, surfaced as `ApiError`; the SDK never follows the redirect. CLI `signer certified-copy`, `download-copy`, and `resend-download-link` use `ASSINAFY_SIGNER_ACCESS_CODE` or `ASSINAFY_DOWNLOAD_TOKEN`. Theme and logo need no owner credential. Protect download URLs and the resulting files as private documents.
|
|
411
583
|
|
|
412
584
|
### Email and WhatsApp verification
|
|
413
585
|
|
|
@@ -506,9 +678,9 @@ Both A1 and A3 use `verification_method: "DigitalCertificate"`; they are not sep
|
|
|
506
678
|
|
|
507
679
|
1. Create or select the signer and set their CPF/CNPJ with `signers.update(signerId, { government_id })`. An existing signer returned by `create` is reused without updating their data. Configure an eligible workspace, estimate cost, then create a `virtual` assignment with `DigitalCertificate` and one delivery channel. Use contiguous steps beginning at `1`, with each certificate signer alone in their step. The same descriptor works for template roles only when the template has no placed signer fields.
|
|
508
680
|
2. Obtain the private signer access code through the delivered link. Load `self` and `getAssignment` to confirm the identity and document. Present the document and terms; call `acceptTerms` only after the signer agrees.
|
|
509
|
-
3. Call `startCertificate(accessCode)` and retain its operation token with that signer session.
|
|
681
|
+
3. Call `startCertificate(accessCode, documentId?)` and retain its operation token with that signer session.
|
|
510
682
|
4. On the signer's device, use an initialized Web PKI browser client to select their A1 certificate or A3 device and execute `pki.signWithRestPki({ thumbprint, token })`. Wait for its success callback. The private key, PFX password, and device PIN stay with the local certificate provider.
|
|
511
|
-
5. Call `completeCertificate(accessCode, token)` with the **same operation token**, only after Web PKI succeeds. This returns the certificate signer's name. The API validates the certificate against the required CPF/CNPJ; normal `sign` and `signMultiple` do not perform certificate signing.
|
|
683
|
+
5. Call `completeCertificate(accessCode, token, documentId?)` with the **same operation token**, only after Web PKI succeeds. This returns the certificate signer's name. The API validates the certificate against the required CPF/CNPJ; normal `sign` and `signMultiple` do not perform certificate signing.
|
|
512
684
|
6. Track document status until `certificated`, then download `pades` or `bundle`. The PAdES artifact exists only for documents with certificate signatures.
|
|
513
685
|
|
|
514
686
|
The SDK exposes the server handshake. Browser certificate selection, the Web PKI extension/native component, and signer approval belong to the signing application. For the hosted experience, use the Assinafy signing page reached through the invitation; no separate CLI certificate driver is required.
|
|
@@ -562,7 +734,10 @@ assinafy documents download example_document --artifact pades -o signed-pades.pd
|
|
|
562
734
|
| --- | --- | --- |
|
|
563
735
|
| `create(payload)` | [`POST /accounts`](./api-reference.md#create-account) | `IWorkspaceResponse` |
|
|
564
736
|
| `list()` | [`GET /accounts`](./api-reference.md#list-my-accounts) | `IWorkspaceListResponse` |
|
|
565
|
-
| `get(accountId)` | [`GET /accounts/{accountId}`](./api-reference.md#get-account) | `IWorkspaceResponse` |
|
|
737
|
+
| `get(accountId, params?)` | [`GET /accounts/{accountId}`](./api-reference.md#get-account) | `IWorkspaceResponse` |
|
|
738
|
+
| `usage(accountId)` | `GET /accounts/{accountId}/usage`, no body | `IAccountUsage` |
|
|
739
|
+
| `getNotificationPolicy(accountId)` | `GET /accounts/{accountId}/notification-policy`, no body | `INotificationPolicy` |
|
|
740
|
+
| `updateNotificationPolicy(accountId, payload)` | `PUT /accounts/{accountId}/notification-policy` | `INotificationPolicy` |
|
|
566
741
|
| `getTheme(accountId)` | [`GET /accounts/{accountId}/theme`](./api-reference.md#get-account-theme) | `IAccountTheme` |
|
|
567
742
|
| `downloadLogo(accountId)` | [`GET /accounts/{accountId}/logo`](./api-reference.md#download-account-logo) | image `Buffer` |
|
|
568
743
|
| `uploadLogo(accountId, logo, options?)` | [`POST /accounts/{accountId}/logo`](./api-reference.md#upload-account-logo) | `IStatusResponse` |
|
|
@@ -573,6 +748,10 @@ assinafy documents download example_document --artifact pades -o signed-pades.pd
|
|
|
573
748
|
|
|
574
749
|
Create/update payloads use `name` and `notification_sender_type?: 'User' | 'Account'`; legacy color fields remain accepted for compatibility. List/detail responses include `resource`, `id`, `name`, nullable colors, `notification_sender_type`, roles, delete permission, and `created_at`. `IAccountTheme` is `{ account_name; primary_color; secondary_color: string | null; logo: string | null }`. Logo options are `{ fileName?, contentType? }`. Statistics params are `{ granularity?: 'monthly' | 'daily'; month?: 'YYYY-MM' }`; `month` is required for daily data.
|
|
575
750
|
|
|
751
|
+
`get(accountId, { expand: "signing_features" })` adds the available verification, notification and Embed features. `usage` returns `{ plan: string | null, documents_renewal_date: string | null, balances: { documents: { balance: number | null, limit: number | null, spent: number }, credits: { balance: number | null, limit: number | null, spent: number } } }`. Treat null balances as unlimited. These reads are also CLI `workspaces get <id> --expand signing_features` and `workspaces usage <id>`. Usage is unavailable to third-party OAuth application tokens.
|
|
752
|
+
|
|
753
|
+
Notification policy GET returns `{ editable: boolean, owners_receive_all: boolean, events: INotificationPolicyEvents }`. PUT accepts a non-empty partial `{ owners_receive_all?: boolean, events?: Partial<INotificationPolicyEvents> }`; omitted settings stay unchanged and explicit false disables that setting. The 16 event keys are the union of the email and push preference keys below. Only owners may edit. Workspace false overrides a user's preference, while `owners_receive_all` still respects each owner's preferences. Identity review email is always sent; the corresponding policy key affects only push. CLI `workspaces notification-policy update example_account --data '{"owners_receive_all":false,"events":{"SignerViewed":false}}'` sends that exact body.
|
|
754
|
+
|
|
576
755
|
OAuth `account:read` permits workspace statistics; user statistics still require an endpoint-supported owner or first-party credential.
|
|
577
756
|
|
|
578
757
|
Both account and user statistics resolve to the complete published row:
|
|
@@ -604,11 +783,17 @@ Notification counters can overlap when a request uses multiple delivery channels
|
|
|
604
783
|
| --- | --- | --- |
|
|
605
784
|
| `self()` | [`GET /users/self`](./api-reference.md#get-the-authenticated-user) | `IUserSelfResponse` |
|
|
606
785
|
| `stats(params?)` | [`GET /users/self/stats`](./api-reference.md#my-cross-account-document-kpis) | `IDocumentStatsRow[]` |
|
|
786
|
+
| `getPushPreferences()` | `GET /users/self/push-preferences`, no body | `IPushPreferences` |
|
|
787
|
+
| `updatePushPreferences(payload)` | `PUT /users/self/push-preferences` | `IPushPreferences` |
|
|
607
788
|
| `getNotificationPreferences()` | [`GET /users/self/notification-preferences`](./api-reference.md#get-my-notification-preferences) | `INotificationPreferences` |
|
|
608
789
|
| `updateNotificationPreferences(payload)` | [`PUT /users/self/notification-preferences`](./api-reference.md#update-my-notification-preferences) | `INotificationPreferences` |
|
|
609
790
|
|
|
610
791
|
`IUserSelfResponse` accepts the published user object and the compatible `{ user, accounts }` envelope. Preference payloads are a non-empty partial mapping of the exported `NOTIFICATION_PREFERENCE_CODES` to booleans. The production OpenAPI publishes these routes; a lagging sandbox deployment may return route-level 404s for statistics/preferences.
|
|
611
792
|
|
|
793
|
+
Email keys: `DocumentCompleted`, `SignerDeclined`, `DocumentCancelled`, `DocumentAboutToExpire`, `DocumentExpired`, `DocumentExpirationReset`, `DocumentProcessingFailed`, `TemplateProcessingFailed`, `SignerWhatsappFailed`, `ContractRenewalNotice`, `ContractExpiring`, `ContractExpired`, `ContractRenewed`. Push keys (`PUSH_PREFERENCE_CODES`): `SignerViewed`, `SignerSigned`, `DocumentCompleted`, `SignerDeclined`, `DocumentAboutToExpire`, `DocumentExpired`, `SignerIdentityReviewRequired`, `SignerWhatsappFailed`.
|
|
794
|
+
|
|
795
|
+
Push reads/writes return all eight booleans. Update accepts a non-empty partial map, for example `{ "SignerViewed": false }`; CLI `users push-preferences update --set '{"SignerViewed":false}'` sends that body. These are user phone preferences, separate from email. Delivery also requires the mobile app's device registration; this Node SDK does not manage devices or implement a mobile client. OAuth application tokens cannot access user preferences; use endpoint-supported owner/first-party authentication.
|
|
796
|
+
|
|
612
797
|
## Authentication (`client.auth`)
|
|
613
798
|
|
|
614
799
|
| SDK method | HTTP operation | Request / result |
|
|
@@ -744,15 +929,16 @@ An account can register 1 webhook endpoint, or up to 3 on paid plans. Each endpo
|
|
|
744
929
|
| `deleteEndpoint(endpointId, accountId?)` | [`DELETE /accounts/{accountId}/webhooks/endpoints/{endpointId}`](./api-reference.md#delete-webhook-endpoint) | `IEmptyResult` (`[]`) |
|
|
745
930
|
| `deleteEndpointByUrl(url, accountId?)` | [`DELETE /accounts/{accountId}/webhooks/endpoints?url=…`](./api-reference.md#delete-webhook-endpoint-by-url) | `IEmptyResult` (`[]`); exact registered URL required |
|
|
746
931
|
| `getEndpointSecret(endpointId, accountId?)` | [`GET /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret`](./api-reference.md#get-webhook-endpoint-signing-secret) | `IWebhookEndpointSecret` (`{ secret }`) |
|
|
747
|
-
| `rotateEndpointSecret(endpointId, accountId?)` | [`POST /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret/rotate`](./api-reference.md#rotate-webhook-endpoint-signing-secret) | `IWebhookEndpointSecret` |
|
|
932
|
+
| `rotateEndpointSecret(endpointId, accountId?, options?)` | [`POST /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret/rotate`](./api-reference.md#rotate-webhook-endpoint-signing-secret) | `IWebhookEndpointSecret` |
|
|
748
933
|
| `register(payload, accountId?)` | [`PUT /accounts/{accountId}/webhooks/subscriptions`](./api-reference.md#update-webhook-subscription) | `IWebhookSubscription` (oldest endpoint) |
|
|
749
934
|
| `get(accountId?)` | [`GET /accounts/{accountId}/webhooks/subscriptions`](./api-reference.md#get-webhook-subscription) | `IWebhookSubscription | null` |
|
|
750
935
|
| `inactivate(accountId?)` | [`PUT /accounts/{accountId}/webhooks/inactivate`](./api-reference.md#inactivate-webhook-subscription) | `IWebhookSubscription` |
|
|
751
936
|
| `listEventTypes()` | [`GET /webhooks/event-types`](./api-reference.md#list-webhook-event-types) | `IWebhookEventTypeInfo[]` |
|
|
752
937
|
| `listDispatches(params?, accountId?)` | [`GET /accounts/{accountId}/webhooks`](./api-reference.md#list-webhook-deliveries) | `PaginatedResult<IWebhookDispatch>` |
|
|
938
|
+
| `testEndpoint(endpointId, accountId?)` | `POST /accounts/{accountId}/webhooks/endpoints/{endpointId}/test`, no body | `IWebhookDispatch` |
|
|
753
939
|
| `retryDispatch(dispatchId, accountId?)` | [`POST /accounts/{accountId}/webhooks/{dispatchId}/retry`](./api-reference.md#retry-webhook-delivery) | `IWebhookDispatch` |
|
|
754
940
|
|
|
755
|
-
Endpoint payload: `{ url: string; email: string; events?: string[]; name?: string; is_active?: boolean; signing_enabled?: boolean }`. Update sends only the given fields and requires at least one. New or changed URLs must be HTTPS and unique within the workspace (`400`); legacy HTTP URLs remain usable for exact lookup/deletion; creating past the plan limit returns `403`. Enabling signing creates a `whsec_` secret if none exists; disabling it discards the secret. Secret read and rotation return `400` when signing is disabled. OAuth applications cannot read an existing secret, but `webhooks:write` permits rotation; rotation invalidates the previous secret immediately.
|
|
941
|
+
Endpoint payload: `{ url: string; email: string; events?: string[]; name?: string; is_active?: boolean; signing_enabled?: boolean }`. Update sends only the given fields and requires at least one. New or changed URLs must be HTTPS and unique within the workspace (`400`); legacy HTTP URLs remain usable for exact lookup/deletion; creating past the plan limit returns `403`. Enabling signing creates a `whsec_` secret if none exists; disabling it discards the secret. Secret read and rotation return `400` when signing is disabled. OAuth applications cannot read an existing secret, but `webhooks:write` permits rotation; rotation invalidates the previous secret immediately unless `{ keep_previous: true }` is passed. That option signs deliveries with both secrets for 24 hours and returns `previous_secret_expires_at`; another rotation replaces the one retained secret. CLI `rotate-secret --keep-previous` exposes the overlap. `testEndpoint` sends a synthetic event to the registered receiver and records its delivery; it is a write, not a connectivity read. CLI: `webhooks endpoints test <endpointId>`. Dispatches include `duration_ms` when measured.
|
|
756
942
|
|
|
757
943
|
```ts
|
|
758
944
|
const endpoint = await client.webhooks.createEndpoint({
|
|
@@ -827,7 +1013,7 @@ Verify the raw bytes before parsing; re-serialized JSON does not match. The enve
|
|
|
827
1013
|
|
|
828
1014
|
## Contract boundaries
|
|
829
1015
|
|
|
830
|
-
- Production OpenAPI currently publishes
|
|
831
|
-
- Certificate start/complete are deployed production extensions, exposed by `startCertificate` and `completeCertificate` with the signing application's payloads. They supplement the
|
|
1016
|
+
- Production OpenAPI currently publishes 147 operations. Some sandbox deployments lag it; account/user statistics and user notification-preference routes may return route-level 404s even though production documentation includes them.
|
|
1017
|
+
- Certificate start/complete are deployed production extensions, exposed by `startCertificate` and `completeCertificate` with the signing application's payloads. They supplement the 147 OpenAPI operations; the API manifest contains only published paths.
|
|
832
1018
|
- The SDK retains the two template compatibility routes above. Both `sendToken` call forms send the email-only production body.
|
|
833
|
-
-
|
|
1019
|
+
- Original signer artifacts require a signer code. Completed copies use private expiring download tokens. Older download call forms remain callable for compatibility; server authorization and lifecycle rules apply.
|
package/docs/send.md
CHANGED
|
@@ -8,17 +8,21 @@ Usage: assinafy send [options] <file>
|
|
|
8
8
|
Upload a PDF, create signers, and request signatures in one step
|
|
9
9
|
|
|
10
10
|
Arguments:
|
|
11
|
-
file
|
|
11
|
+
file Path to the PDF file
|
|
12
12
|
|
|
13
13
|
Options:
|
|
14
|
-
--signer <spec>
|
|
15
|
-
|
|
16
|
-
--signers <json>
|
|
17
|
-
--
|
|
18
|
-
|
|
19
|
-
--
|
|
20
|
-
|
|
21
|
-
--
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
--signer <spec> Signer as "Name <email-or-phone>" (repeatable)
|
|
15
|
+
(default: [])
|
|
16
|
+
--signers <json> JSON array of signer objects
|
|
17
|
+
--max-total-credits <amount> Reject the assignment if its credit cost exceeds
|
|
18
|
+
this amount
|
|
19
|
+
--message <message> Message shown to signers
|
|
20
|
+
--expires-at <iso8601> Expiration timestamp
|
|
21
|
+
--copy-receivers <csv> Comma-separated signer IDs to receive a copy of
|
|
22
|
+
the document
|
|
23
|
+
--metadata <json> JSON object of metadata to attach to the
|
|
24
|
+
document
|
|
25
|
+
--no-wait Do not wait for the document to finish
|
|
26
|
+
processing
|
|
27
|
+
-h, --help display help for command
|
|
24
28
|
```
|