assinafy 2.1.1 → 2.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/README.en.md +243 -32
- data/README.md +26 -9
- data/docs/API_REFERENCE.md +1085 -663
- data/lib/assinafy/client.rb +6 -0
- data/lib/assinafy/configuration.rb +3 -3
- data/lib/assinafy/errors.rb +3 -2
- data/lib/assinafy/resources/account_resource.rb +190 -2
- data/lib/assinafy/resources/assignment_resource.rb +206 -31
- data/lib/assinafy/resources/base_resource.rb +32 -1
- data/lib/assinafy/resources/contract_resource.rb +14 -5
- data/lib/assinafy/resources/document_resource.rb +170 -31
- data/lib/assinafy/resources/envelope_resource.rb +362 -0
- data/lib/assinafy/resources/field_resource.rb +7 -9
- data/lib/assinafy/resources/oauth_resource.rb +6 -0
- data/lib/assinafy/resources/scheduled_send_resource.rb +122 -0
- data/lib/assinafy/resources/signer_document_resource.rb +93 -26
- data/lib/assinafy/resources/signer_resource.rb +79 -37
- data/lib/assinafy/resources/user_resource.rb +46 -12
- data/lib/assinafy/resources/webhook_resource.rb +38 -6
- data/lib/assinafy/utils.rb +17 -0
- data/lib/assinafy/version.rb +1 -1
- data/lib/assinafy.rb +2 -0
- data/sig/assinafy.rbs +72 -14
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f488fc7c84952ceacc1c347c568fa80236a16da81b3d0c52ce8c65059488316
|
|
4
|
+
data.tar.gz: 407ed8967da231155348739babf34033185c7eae926dccccbb18f8c1669cfc25
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4bc9ae570a8e0807194a76d70064b90f775988c16298dfe910370e991ee07fc61f108feae018fee2c37b5f677bd8146287d3eddbb0f1f144b059db10a5e3f31
|
|
7
|
+
data.tar.gz: 355bc37d3b84d6c5104e6b5f6563dc29f4ebea978709b027c6729f4cc17624d1435a7027f03c25ebabe7bcedf228d45b99f706df481e21689820822b5a0f452b
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the `assinafy` Ruby gem are documented here.
|
|
4
4
|
|
|
5
|
+
## [2.3.0] - 2026-11-24
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Scheduled assignment and envelope creation, listing, cancellation and immediate delivery for environments that publish scheduled sends.
|
|
10
|
+
- Document watchers, signer capacities (`sign_as`), notification delivery/open history, and envelope reminder cost estimates on staging.
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Virtual assignments can be signed with an empty item array; collect items can carry empty String values.
|
|
15
|
+
- Signer updates preserve explicit null or empty contact and government-ID fields so they can be cleared.
|
|
16
|
+
- Single and batch field validation preserve explicit null values for optional fields.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Development uses Ruby 4.0.10, including the latest Ruby security fixes.
|
|
21
|
+
|
|
22
|
+
## [2.2.0] - 2026-11-11
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Envelope creation, estimates, document management, reminders, activities and ZIP downloads through `client.envelopes`.
|
|
27
|
+
- Embedded signing origins and sessions, signer branding, and token-based certified-copy delivery and downloads.
|
|
28
|
+
- Account usage and notification policies, user push preferences, and webhook test deliveries.
|
|
29
|
+
- Credit ceilings for assignments, templates and envelopes; idempotency keys for template and envelope creation.
|
|
30
|
+
- Document and contract expansions, signed page renders, and `documents.activities_page` pagination metadata.
|
|
31
|
+
- Webhook secret rotation with a 24-hour overlap through `keep_previous: true`.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Signer downloads require the signer access code and default to the original artifact.
|
|
36
|
+
- Template creation supports email-based signer references and returns its asynchronous processing state.
|
|
37
|
+
- Template copy receivers no longer interfere with signing-step validation.
|
|
38
|
+
- Collect fields, credit ceilings, OAuth revocation secrets and contract inputs reject invalid values locally.
|
|
39
|
+
- OAuth assignment listing can use the token's workspace without a separate account ID.
|
|
40
|
+
- Signer confirmation and verification return the documented response shapes.
|
|
41
|
+
|
|
5
42
|
## [2.1.1] - 2026-11-02
|
|
6
43
|
|
|
7
44
|
### Fixed
|
data/README.en.md
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
Ruby SDK for the [Assinafy API v1](https://api.assinafy.com.br/v1/docs).
|
|
9
9
|
|
|
10
|
+
Run this SDK on your server. Mobile and browser clients call your backend; keep API keys, OAuth client secrets,
|
|
11
|
+
refresh tokens and signer access codes out of application bundles, logs and browser storage.
|
|
12
|
+
|
|
10
13
|
The SDK exposes every Assinafy API v1 operation — including OAuth 2.1, two-factor authentication, webhook
|
|
11
|
-
endpoints with native signatures, and the complete supported template lifecycle. The checked-in
|
|
14
|
+
endpoints with native signatures, envelopes, contracts, embedded signing, and the complete supported template lifecycle. The checked-in
|
|
12
15
|
[`spec/api_coverage_spec.rb`](spec/api_coverage_spec.rb) validates that each route maps uniquely to a public SDK
|
|
13
16
|
method.
|
|
14
17
|
|
|
@@ -24,7 +27,7 @@ This guide follows an integration end to end — [install and configure](#instal
|
|
|
24
27
|
|
|
25
28
|
## Installation and configuration
|
|
26
29
|
|
|
27
|
-
Requirements: Ruby 3.2+ (
|
|
30
|
+
Requirements: Ruby 3.2+ (use patched Ruby 4.0.10, 3.4.13 or 3.3.14; 3.2 is legacy/EOL compatibility), Bundler, and TLS 1.2 or
|
|
28
31
|
newer (the SDK refuses TLS 1.0 and 1.1).
|
|
29
32
|
|
|
30
33
|
```ruby
|
|
@@ -157,8 +160,9 @@ client.auth.reset_password(email: 'user@example.com', new_password: 'new', token
|
|
|
157
160
|
## OAuth 2.1
|
|
158
161
|
|
|
159
162
|
Use OAuth when an application acts **on behalf of a user**, with that user's permission. Unlike an API key, the
|
|
160
|
-
token is scoped to one workspace and carries only the scopes the user approved.
|
|
161
|
-
lifecycle, credential management, webhook
|
|
163
|
+
token is scoped to one workspace and carries only the scopes the user approved. Third-party OAuth tokens cannot
|
|
164
|
+
reach billing, account lifecycle, credential management, webhook-secret reads, embed-session creation,
|
|
165
|
+
biometric review images/decisions, or admin surfaces, whatever scopes they hold.
|
|
162
166
|
|
|
163
167
|
The flow is authorization-code with **mandatory PKCE**; the authorization server accepts `S256` only.
|
|
164
168
|
|
|
@@ -191,7 +195,7 @@ redirect_to Assinafy::OAuth.authorization_url(
|
|
|
191
195
|
redirect_uri: 'https://app.example.com/oauth/callback',
|
|
192
196
|
code_verifier: verifier,
|
|
193
197
|
state: state,
|
|
194
|
-
scope: %w[documents:read documents:write offline_access]
|
|
198
|
+
scope: %w[documents:read documents:write openid profile email offline_access]
|
|
195
199
|
)
|
|
196
200
|
```
|
|
197
201
|
|
|
@@ -206,8 +210,11 @@ that are not yours. The code is single-use and expires 60 seconds after approval
|
|
|
206
210
|
same `redirect_uri`, and never retry.
|
|
207
211
|
|
|
208
212
|
```ruby
|
|
209
|
-
|
|
210
|
-
|
|
213
|
+
expected_state = session.delete(:assinafy_state)
|
|
214
|
+
expected_issuer = session.delete(:assinafy_issuer)
|
|
215
|
+
unless expected_state.is_a?(String) && !expected_state.empty? &&
|
|
216
|
+
expected_issuer.is_a?(String) && !expected_issuer.empty? &&
|
|
217
|
+
params[:state] == expected_state && params[:iss] == expected_issuer
|
|
211
218
|
raise 'authorization response is not ours'
|
|
212
219
|
end
|
|
213
220
|
raise "authorization not granted: #{params[:error]}" if params[:error] # access_denied, invalid_scope, ...
|
|
@@ -219,7 +226,7 @@ tokens = Assinafy::Client.new.oauth.exchange_code(
|
|
|
219
226
|
redirect_uri: 'https://app.example.com/oauth/callback'
|
|
220
227
|
)
|
|
221
228
|
# => { 'access_token' => ..., 'token_type' => 'Bearer', 'expires_in' => 3600,
|
|
222
|
-
# 'refresh_token' => ..., 'scope' => 'documents:read documents:write' }
|
|
229
|
+
# 'refresh_token' => ..., 'scope' => 'documents:read documents:write openid profile email' }
|
|
223
230
|
```
|
|
224
231
|
|
|
225
232
|
The SDK checks the `code_verifier` grammar locally, because the server reports a malformed verifier as
|
|
@@ -353,6 +360,9 @@ The document is named after the uploaded file; rename it with `client.documents.
|
|
|
353
360
|
in-memory data, pass `{ buffer: pdf_bytes, file_name: 'contract.pdf' }`. PDF only, at most 25 MB: the SDK checks
|
|
354
361
|
the extension, size, and `%PDF-` header before sending. `wait_until_ready` raises `Assinafy::ValidationError` for
|
|
355
362
|
invalid interval values and `Assinafy::Error` for a failed terminal status or a timeout.
|
|
363
|
+
The high-level `upload_and_request_signatures` helper waits up to 30 seconds by default. For asynchronous
|
|
364
|
+
processing, pass `wait_for_ready: false` and poll separately with the required timeout. Its errors retain
|
|
365
|
+
the uploaded document and any created signer IDs in `error.context` for recovery without uploading again.
|
|
356
366
|
|
|
357
367
|
**Or select a template.** A template upload initially contains an `Editor` role. Configure at least one `Signer`
|
|
358
368
|
role and its fields in the Assinafy application before generating a document. Template uploads have the same
|
|
@@ -441,7 +451,7 @@ all-or-none, positive, and contiguous from 1; equal steps sign in parallel, and
|
|
|
441
451
|
previous one finishes. A certificate signer is alone in its step. Deadlines are zoned ISO 8601 and at least one
|
|
442
452
|
hour ahead.
|
|
443
453
|
|
|
444
|
-
For a template, bind one distinct
|
|
454
|
+
For a template, bind one distinct signer to each role; processing creates the document's assignment:
|
|
445
455
|
|
|
446
456
|
```ruby
|
|
447
457
|
role_signer = {
|
|
@@ -454,10 +464,19 @@ role_signer = {
|
|
|
454
464
|
client.documents.estimate_cost_from_template(template.fetch('id'), [role_signer])
|
|
455
465
|
template_document = client.documents.create_from_template(
|
|
456
466
|
template.fetch('id'), [role_signer],
|
|
457
|
-
name: 'customer-agreement.pdf', message: 'Please review and sign.'
|
|
467
|
+
name: 'customer-agreement.pdf', message: 'Please review and sign.',
|
|
468
|
+
idempotency_key: 'template-request-id'
|
|
458
469
|
)
|
|
470
|
+
# Initial response: status "uploaded", assignment nil; processing creates the assignment afterward.
|
|
471
|
+
# Follow document status/webhooks until pending_signature or failed.
|
|
472
|
+
# wait_until_ready waits for metadata and can return before the template assignment exists.
|
|
459
473
|
```
|
|
460
474
|
|
|
475
|
+
Template creation also accepts `email` and `name` for a role instead of an existing signer `id`; the server reuses
|
|
476
|
+
or creates the signer. Keep the same `idempotency_key` after a lost response to avoid duplicate documents and
|
|
477
|
+
charges. `max_total_credits` can cap creation costs; a higher actual price returns `409` with
|
|
478
|
+
`error_code == 'CreditCeilingExceeded'`, creating and charging nothing.
|
|
479
|
+
|
|
461
480
|
**Shortcut.** `Client#upload_and_request_signatures` bundles upload, waiting, signer creation (including
|
|
462
481
|
`government_id`), and a virtual assignment, validating the whole payload before anything is uploaded:
|
|
463
482
|
|
|
@@ -477,8 +496,11 @@ created so you can clean up.
|
|
|
477
496
|
|
|
478
497
|
### 6. The signer experience
|
|
479
498
|
|
|
480
|
-
The signer receives an access link through the notification channel. Signer-facing calls use
|
|
481
|
-
`signer-access-code`
|
|
499
|
+
The signer receives an access link through the notification channel. Signer-facing calls use
|
|
500
|
+
`signer-access-code` as a query parameter, with workspace credentials removed. The code remains usable during
|
|
501
|
+
signing and closes 30 minutes after that signer is done; an envelope code closes after all their documents are
|
|
502
|
+
done. After closure, document reads return only signer status, theme/logo and certified-copy delivery remain
|
|
503
|
+
available, and other signer calls return `410`.
|
|
482
504
|
|
|
483
505
|
```ruby
|
|
484
506
|
signing = Assinafy::Client.new(base_url: ENV.fetch('ASSINAFY_BASE_URL'))
|
|
@@ -489,7 +511,7 @@ signing.signers.accept_terms(signer_access_code: access_code) unless signer_data
|
|
|
489
511
|
|
|
490
512
|
signing_document = signing.assignments.signer_document(signer_access_code: access_code, has_accepted_terms: true)
|
|
491
513
|
signing.signers.confirm_data(
|
|
492
|
-
signing_document.fetch('id'), {
|
|
514
|
+
signing_document.fetch('id'), { email: 'signer@example.com', has_accepted_terms: true },
|
|
493
515
|
signer_access_code: access_code
|
|
494
516
|
)
|
|
495
517
|
signing.signers.verify_email( # the OTP from email or WhatsApp
|
|
@@ -498,14 +520,20 @@ signing.signers.verify_email( # the OTP from email or Whats
|
|
|
498
520
|
)
|
|
499
521
|
signing.signers.upload_signature(File.binread('signature.png'), signer_access_code: access_code, type: 'signature')
|
|
500
522
|
|
|
501
|
-
signing.
|
|
523
|
+
signing.assignments.sign(
|
|
524
|
+
signing_document.fetch('id'), signing_document.dig('assignment', 'id'), [], signer_access_code: access_code
|
|
525
|
+
)
|
|
526
|
+
# sign_multiple is also available for batches of virtual documents.
|
|
502
527
|
```
|
|
503
528
|
|
|
504
|
-
That signs a virtual assignment. For a collect assignment,
|
|
505
|
-
|
|
529
|
+
That signs a virtual assignment. For a collect assignment, upload both the signature and initial images, then
|
|
530
|
+
submit required item values through `assignments.sign`. This example places only signature fields; add values
|
|
531
|
+
matching each field's type for other editable fields. Omit read-only dates, which the server fills:
|
|
506
532
|
|
|
507
533
|
```ruby
|
|
508
|
-
|
|
534
|
+
signing.signers.upload_signature(File.binread('initial.png'), signer_access_code: access_code, type: 'initial')
|
|
535
|
+
items = signing_document.fetch('assignment').fetch('items')
|
|
536
|
+
collect_items = items.select { |item| item.dig('field', 'type') == 'signature' }.map do |item|
|
|
509
537
|
{ item_id: item.fetch('id'), field_id: item.dig('field', 'id'), page_id: item.dig('page', 'id'), value: 'Accepted' }
|
|
510
538
|
end
|
|
511
539
|
|
|
@@ -543,7 +571,7 @@ before any session or after Expired; restarting an Expired session costs nothing
|
|
|
543
571
|
requires a new document and assignment.
|
|
544
572
|
|
|
545
573
|
InReview lets the signer view, confirm data and sign while account review holds certification. After all signers
|
|
546
|
-
sign, the document can be `pending_identity_review`. The account reviewer uses
|
|
574
|
+
sign, the document can be `pending_identity_review`. The account reviewer uses an API key or user session:
|
|
547
575
|
|
|
548
576
|
```ruby
|
|
549
577
|
review = client.assignments.identity_review(document.fetch('id'), assignment.fetch('id'), signer.fetch('id'))
|
|
@@ -562,6 +590,9 @@ client.assignments.decide_identity_review(
|
|
|
562
590
|
most 2000 characters, goes to activities and the provider, and is never shown to the signer. Images exist only
|
|
563
591
|
during InReview. Observe signer_identity_review_required, signer_identity_review_approved,
|
|
564
592
|
signer_identity_review_rejected, signer_identity_verified and signer_identity_verification_failed events.
|
|
593
|
+
Third-party OAuth apps can read the review summary with `documents:read`; they cannot fetch evidence images or
|
|
594
|
+
submit the human review decision. For envelopes, one biometric check covers the signer's documents; rejection
|
|
595
|
+
cancels the whole envelope and notifies each recipient once.
|
|
565
596
|
|
|
566
597
|
**A1/A3 certificate signers** complete their signature in Assinafy's hosted signing flow, opened from
|
|
567
598
|
`assignment['signing_urls']`: they accept the terms, confirm their data, and sign with their A1 or A3 certificate
|
|
@@ -592,17 +623,22 @@ secret = endpoint.fetch('secret') # returned once on creation; store it immediat
|
|
|
592
623
|
- Creating one past the plan limit answers `403`; a URL another endpoint already uses answers `400`.
|
|
593
624
|
- `update_endpoint(id, payload)` changes only the fields sent. `signing_enabled: true` creates a secret when the
|
|
594
625
|
endpoint has none and keeps the current one otherwise; `false` discards it.
|
|
595
|
-
- `rotate_endpoint_secret(id)` returns a new secret; the old one stops working immediately.
|
|
596
|
-
|
|
597
|
-
|
|
626
|
+
- `rotate_endpoint_secret(id)` returns a new secret; the old one stops working immediately. Pass
|
|
627
|
+
`keep_previous: true` for 24 hours of signatures from both secrets while receivers switch.
|
|
628
|
+
- Reading a secret requires an API key or user session. Rotation is available to OAuth apps with
|
|
629
|
+
`webhooks:write`, including recovery of a lost secret. Both methods answer `400` when signing is disabled.
|
|
630
|
+
- Enabling signing with `update_endpoint` returns the new secret once. Store it before using the endpoint.
|
|
598
631
|
- `list_endpoints(url: registered_url)` filters by exact URL; `delete_endpoint_by_url(registered_url)` removes
|
|
599
632
|
that endpoint and returns `nil` (`404` when no endpoint matches).
|
|
600
633
|
|
|
601
634
|
**Delivery contract.** Each delivery is a `POST` with an `application/json` body and the headers `webhook-id`
|
|
602
635
|
(identical on every attempt of the same event to the same endpoint — deduplicate on it), `webhook-timestamp`
|
|
603
|
-
(Unix seconds), and, when signing is enabled, `webhook-signature`. Any `2xx` is success.
|
|
604
|
-
|
|
605
|
-
|
|
636
|
+
(Unix seconds), and, when signing is enabled, `webhook-signature`. Any `2xx` is success. Network failures,
|
|
637
|
+
timeouts, `408`, `429` and `5xx` get up to six attempts about ten minutes apart; other statuses are final.
|
|
638
|
+
After ten failed deliveries in a row the endpoint pauses. Probes follow after 3, 15 and 60 minutes, then every
|
|
639
|
+
six hours; success releases queued events oldest first. Updating its URL or setting `is_active: true` also lifts
|
|
640
|
+
the pause. `retry_dispatch` sends now; `test_endpoint` sends a separate `webhook_test` without changing the pause.
|
|
641
|
+
Delivery history is retained for seven days and captures the first 2000 response-body characters.
|
|
606
642
|
|
|
607
643
|
**Verifying signatures.** Signatures follow [Standard Webhooks](https://www.standardwebhooks.com): space-separated
|
|
608
644
|
`v1,<base64 HMAC-SHA256>` entries over `"{webhook-id}.{webhook-timestamp}.{raw body}"`, keyed with the
|
|
@@ -641,6 +677,9 @@ subject, object, account_id }`. `subject` and `object` carry a `type` (`User`, `
|
|
|
641
677
|
`verify(raw_body, hex_signature)` remains only for receivers whose own gateway signs bodies with a hex
|
|
642
678
|
HMAC-SHA256 shared secret.
|
|
643
679
|
|
|
680
|
+
Give the webhook event table a unique index on `webhook_id`, process events idempotently, and arrange durable
|
|
681
|
+
job delivery before acknowledging the request so concurrent retries or a failed enqueue cannot lose an event.
|
|
682
|
+
|
|
644
683
|
### 8. Track progress, download, and verify
|
|
645
684
|
|
|
646
685
|
```ruby
|
|
@@ -648,7 +687,8 @@ document_id = document.fetch('id')
|
|
|
648
687
|
|
|
649
688
|
client.documents.signing_progress(document_id) # => { signed: 1, total: 2, pending: 1, percentage: 50.0 }
|
|
650
689
|
client.documents.fully_signed?(document_id)
|
|
651
|
-
client.documents.activities(document_id) # => Array<DocumentActivity>
|
|
690
|
+
client.documents.activities(document_id) # => one page of Array<DocumentActivity>
|
|
691
|
+
client.documents.activities_page(document_id, page: 1, per_page: 20) # => { data:, meta: }
|
|
652
692
|
|
|
653
693
|
signed_pdf = client.documents.download(document_id, 'certificated')
|
|
654
694
|
# also 'original', 'certificate-page', 'bundle' (zip), and 'pades' for certificate-signed documents
|
|
@@ -691,7 +731,7 @@ See [Errors](#errors) for the full hierarchy.
|
|
|
691
731
|
|
|
692
732
|
## Resource reference
|
|
693
733
|
|
|
694
|
-
`Assinafy::Client` exposes
|
|
734
|
+
`Assinafy::Client` exposes the API resources below plus the local `webhook_verifier` helper:
|
|
695
735
|
|
|
696
736
|
| Accessor | What it covers |
|
|
697
737
|
| --------------------------- | ------------------------------------------------------------------ |
|
|
@@ -700,6 +740,7 @@ See [Errors](#errors) for the full hierarchy.
|
|
|
700
740
|
| `client.accounts` | Account CRUD, theme, KPI stats, brand logo |
|
|
701
741
|
| `client.users` | User profile, notification preferences, cross-account KPIs |
|
|
702
742
|
| `client.documents` | Upload, list, search, rename, download, delete, verify, tags |
|
|
743
|
+
| `client.envelopes` | Send several documents together, estimate, reorder, cancel and download |
|
|
703
744
|
| `client.contracts` | Contract terms, amendments, renewals, terminations |
|
|
704
745
|
| `client.signers` | Workspace signer CRUD + signer self-service endpoints |
|
|
705
746
|
| `client.signer_documents` | Signer-authenticated multi-document operations + search |
|
|
@@ -715,6 +756,7 @@ See [Errors](#errors) for the full hierarchy.
|
|
|
715
756
|
```ruby
|
|
716
757
|
client.accounts.list # { data: [...] } — no pagination meta
|
|
717
758
|
client.accounts.get # the current account (or pass an id)
|
|
759
|
+
client.accounts.get(expand: 'signing_features') # includes available signing features
|
|
718
760
|
client.accounts.create(name: 'Acme Inc.')
|
|
719
761
|
client.accounts.update({ name: 'Acme Renamed' })
|
|
720
762
|
client.accounts.delete(force: true, account_id_override: 'account-id')
|
|
@@ -723,8 +765,15 @@ client.accounts.stats(granularity: 'monthly', month: '2026-06') # account KPI r
|
|
|
723
765
|
client.accounts.upload_logo({ file_path: './logo.png' })
|
|
724
766
|
client.accounts.download_logo # raw bytes; raises ApiError on HTTP 404 when unset
|
|
725
767
|
client.accounts.delete_logo
|
|
768
|
+
client.accounts.usage # { 'plan' => ..., 'documents_renewal_date' => ..., 'balances' => { ... } }
|
|
769
|
+
client.accounts.notification_policy # { 'editable' => true, 'owners_receive_all' => false, 'events' => { ... } }
|
|
770
|
+
client.accounts.update_notification_policy(events: { SignerViewed: false }, owners_receive_all: true)
|
|
726
771
|
```
|
|
727
772
|
|
|
773
|
+
Usage and notification policy are unavailable to third-party OAuth applications. Policy writes require an owner;
|
|
774
|
+
they merge only supplied event flags. A disabled workspace event suppresses it across channels even when a
|
|
775
|
+
member enables it. `SignerIdentityReviewRequired: false` disables only push; its email is always sent.
|
|
776
|
+
|
|
728
777
|
### Users
|
|
729
778
|
|
|
730
779
|
```ruby
|
|
@@ -732,8 +781,13 @@ client.users.me
|
|
|
732
781
|
client.users.stats(granularity: 'daily', month: '2026-06') # cross-account KPI rows
|
|
733
782
|
client.users.notification_preferences # returns all thirteen owner-email preferences
|
|
734
783
|
client.users.update_notification_preferences(SignerDeclined: false) # partial request; returns all thirteen
|
|
784
|
+
client.users.push_preferences # eight phone-push preferences; separate from email
|
|
785
|
+
client.users.update_push_preferences(SignerViewed: false) # partial request; returns the full push map
|
|
735
786
|
```
|
|
736
787
|
|
|
788
|
+
Email and push preferences apply to the user across workspaces. They accept boolean values and reject unknown
|
|
789
|
+
keys or an empty update. These personal settings are unavailable to third-party OAuth applications.
|
|
790
|
+
|
|
737
791
|
Both stats methods validate `granularity` (`monthly` or `daily`) and `month` (`YYYY-MM`) locally; daily statistics
|
|
738
792
|
require `month`. They return rows
|
|
739
793
|
with `period`, `documents_uploaded`, `documents_sent`, `signature_requests`,
|
|
@@ -749,17 +803,22 @@ with `period`, `documents_uploaded`, `documents_sent`, `signature_requests`,
|
|
|
749
803
|
client.documents.statuses # GET /documents/statuses
|
|
750
804
|
client.documents.list(page: 1, per_page: 20, status: 'pending_signature')
|
|
751
805
|
client.documents.list(tags: ['tag-id-1', 'tag-id-2']) # documents carrying every listed tag
|
|
806
|
+
client.documents.list(envelope_id: 'envelope-id') # documents in an envelope
|
|
752
807
|
client.documents.search('contract') # lightweight GET .../documents/search
|
|
753
808
|
client.documents.upload({ file_path: './contract.pdf' }) # named after the file
|
|
754
809
|
client.documents.upload({ buffer: pdf_bytes, file_name: 'contract.pdf' })
|
|
755
810
|
client.documents.rename('document-id', 'renamed.pdf') # PATCH /documents/{id}
|
|
756
811
|
client.documents.get('document-id') # alias of .details
|
|
812
|
+
client.documents.details('document-id', expand: ['envelope_id', 'envelope'])
|
|
757
813
|
client.documents.wait_until_ready('document-id', max_wait_seconds: 60)
|
|
758
814
|
client.documents.activities('document-id')
|
|
815
|
+
client.documents.activities_page('document-id', sort: '-id', page: 1, per_page: 20)
|
|
759
816
|
client.documents.thumbnail('document-id') # binary PNG/JPEG
|
|
817
|
+
client.documents.thumbnail('document-id', artifact: 'certificated') # rendered signed content
|
|
760
818
|
client.documents.download('document-id', 'certificated') # binary PDF
|
|
761
819
|
client.documents.download('document-id', 'pades') # signed PAdES artifact
|
|
762
820
|
client.documents.download_page('document-id', 'page-id')
|
|
821
|
+
client.documents.download_page('document-id', 'page-id', artifact: 'certificated')
|
|
763
822
|
client.documents.delete('document-id')
|
|
764
823
|
client.documents.verify('signature-hash')
|
|
765
824
|
client.documents.public_info('document-id')
|
|
@@ -783,6 +842,130 @@ client.documents.signing_progress('document-id') # => { signed: 1, total: 2, p
|
|
|
783
842
|
An Array `tags` filter is sent as comma-separated tag IDs. The tag arrays of `replace_tags`/`append_tags` take tag
|
|
784
843
|
IDs.
|
|
785
844
|
|
|
845
|
+
Activities default to twenty per page. `activities` preserves the Array return; `activities_page` exposes the
|
|
846
|
+
pagination headers so callers can traverse every event. Signed thumbnails/pages use `artifact: 'certificated'`
|
|
847
|
+
with workspace credentials. The first render can wait up to thirty seconds, then return `503` with `Retry-After`;
|
|
848
|
+
the SDK does not retry. These renders carry `Cache-Control: no-store`. Certificate pages have no document page
|
|
849
|
+
IDs, and the qualified certificate seal is available in the `pades` artifact.
|
|
850
|
+
|
|
851
|
+
### Envelopes
|
|
852
|
+
|
|
853
|
+
Send up to 20 prepared documents to up to 20 existing signers in one invitation. Each document retains its own
|
|
854
|
+
assignment, status and artifacts. All envelope signers sign in parallel; no `step` is accepted.
|
|
855
|
+
|
|
856
|
+
```ruby
|
|
857
|
+
request = {
|
|
858
|
+
name: 'Agreement and annex',
|
|
859
|
+
signers: [{ id: 'signer-id', verification_method: 'Email', notification_methods: ['Email'] }],
|
|
860
|
+
documents: [
|
|
861
|
+
{ id: 'agreement-id', signer_ids: ['signer-id'] },
|
|
862
|
+
{ id: 'annex-id', signer_ids: ['signer-id'] }
|
|
863
|
+
]
|
|
864
|
+
}
|
|
865
|
+
estimate = client.envelopes.estimate_cost(request)
|
|
866
|
+
envelope = client.envelopes.create(
|
|
867
|
+
request.merge(max_total_credits: estimate.fetch('total_credits')), idempotency_key: 'envelope-request-id'
|
|
868
|
+
)
|
|
869
|
+
# => { 'id' => 'envelope-id', 'name' => 'Agreement and annex', 'message' => nil,
|
|
870
|
+
# 'documents' => [...], 'counts' => { 'pending_signature' => 2 },
|
|
871
|
+
# 'signing_urls' => [...], 'created_at' => '2026-11-11T12:00:00Z' }
|
|
872
|
+
|
|
873
|
+
client.envelopes.list(status: 'open') # { data: [...], meta: { ... } }
|
|
874
|
+
client.envelopes.get(envelope.fetch('id'))
|
|
875
|
+
client.envelopes.update(envelope.fetch('id'), document_ids: %w[annex-id agreement-id], message: nil)
|
|
876
|
+
client.envelopes.activities(envelope.fetch('id')) # paginated events with document_id/document_name
|
|
877
|
+
client.envelopes.resend_notification(envelope.fetch('id'), 'signer-id') # { 'is_sent' => true, ... }
|
|
878
|
+
client.envelopes.add_document(envelope.fetch('id'), id: 'extra-document-id', signer_ids: ['signer-id'])
|
|
879
|
+
client.envelopes.remove_document(envelope.fetch('id'), 'extra-document-id') # cancels and removes that open document
|
|
880
|
+
archive = client.envelopes.download(envelope.fetch('id'), 'original') # ZIP bytes in envelope order
|
|
881
|
+
client.envelopes.cancel(envelope.fetch('id')) # [{ 'id' => ..., 'status' => ..., 'cancelled' => true }]
|
|
882
|
+
client.envelopes.delete(envelope.fetch('id')) # nil; closed envelopes only, documents remain
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
`collect` documents add positioned `entries` whose field signers exactly match `signer_ids`. Every envelope
|
|
886
|
+
signer must appear on a document. A certificate signer signs alone on each virtual document and is charged per
|
|
887
|
+
document; a biometric signer verifies once for the envelope. Preserve the creation idempotency key after an
|
|
888
|
+
ambiguous response. `max_total_credits` prevents creating or charging an envelope above the approved cost.
|
|
889
|
+
|
|
890
|
+
### Scheduled sends and document recipients (staging)
|
|
891
|
+
|
|
892
|
+
These calls are published on `https://api.angry-pisco.stage.assinafy.com.br/v1`, ahead of production.
|
|
893
|
+
Use the matching staging credentials and base URL. Production may return 404 until these routes are deployed.
|
|
894
|
+
|
|
895
|
+
```ruby
|
|
896
|
+
scheduled = client.assignments.schedule(
|
|
897
|
+
'document-id', { signers: [{ id: 'signer-id', sign_as: 'Witness' }], max_total_credits: 1 },
|
|
898
|
+
send_at: (Time.now + 7200).iso8601
|
|
899
|
+
)
|
|
900
|
+
# => { 'id' => 'send-id', 'type' => 'assignment', 'document_ids' => ['document-id'],
|
|
901
|
+
# 'status' => 'pending', 'send_at' => '2026-12-01T12:00:00Z', 'assignment_id' => nil,
|
|
902
|
+
# 'envelope_id' => nil, 'failure_reason' => nil, 'created_at' => '2026-12-01T10:00:00Z',
|
|
903
|
+
# 'processed_at' => nil }
|
|
904
|
+
client.scheduled_sends.list(document_id: 'document-id', per_page: 20) # { data:, meta: }
|
|
905
|
+
client.scheduled_sends.cancel(scheduled.fetch('id')) # status: cancelled; no charge
|
|
906
|
+
# Or send a pending request immediately:
|
|
907
|
+
# client.scheduled_sends.send_now(scheduled.fetch('id')) # status: sent; assignment_id/envelope_id populated
|
|
908
|
+
|
|
909
|
+
client.envelopes.schedule(
|
|
910
|
+
{ name: 'Contract', signers: [{ id: 'signer-id' }],
|
|
911
|
+
documents: [{ id: 'another-document-id', signer_ids: ['signer-id'] }] },
|
|
912
|
+
send_at: (Time.now + 7200).to_i
|
|
913
|
+
) # ScheduledSend with type: envelope
|
|
914
|
+
|
|
915
|
+
client.documents.signer_capacities('document-id') # [{ 'signer_id' => 'signer-id', 'sign_as' => 'Witness' }]
|
|
916
|
+
client.documents.set_watchers('document-id', ['contact-id']) # Array<Signer>; [] clears all
|
|
917
|
+
client.documents.watchers('document-id') # Array<Signer>
|
|
918
|
+
client.documents.notification_history('document-id') # signer_id plus records with delivered_at/opened_at
|
|
919
|
+
client.envelopes.estimate_resend_cost('envelope-id', 'signer-id') # total, breakdown, credit_balance, has_sufficient_credits
|
|
920
|
+
```
|
|
921
|
+
|
|
922
|
+
Scheduling creates no assignment, invitation or charge until delivery. `send_at` accepts Unix seconds or
|
|
923
|
+
ISO 8601 (no offset means UTC), one hour to 90 days ahead. Each document's deadline must be at least two hours
|
|
924
|
+
later. All schedule operations, including listing, need OAuth `documents:write`. Delivery uses the original
|
|
925
|
+
member's permissions and then-current balance, plan and price; preserve `max_total_credits` to bound charges.
|
|
926
|
+
The worker checks about every five minutes. A failed send records a reason and notifies the original member
|
|
927
|
+
(or active owners if they left). Send-now failures leave the request pending; cancel it to prevent a later attempt.
|
|
928
|
+
Only pending sends can be cancelled or sent now. Scheduling does not accept idempotency keys.
|
|
929
|
+
|
|
930
|
+
`sign_as` defaults to `Sign`; other exact values are in `AssignmentResource::SIGNER_CAPACITIES`. It records
|
|
931
|
+
the sender's statement on the certificate and is read separately, not from ordinary assignments or webhooks.
|
|
932
|
+
Watchers are up to ten workspace contacts with email, editable until the document ends. They receive a terminal
|
|
933
|
+
status email without a document link/file, independently of workspace notification policy. Delivery/open times
|
|
934
|
+
are nullable; an open is a hint, not proof a human read the invitation. Reminder estimates do not check eligibility;
|
|
935
|
+
staging limits reminders to one per two minutes and ten per 24 hours, shared across an envelope's documents.
|
|
936
|
+
|
|
937
|
+
### Embedded signing
|
|
938
|
+
|
|
939
|
+
Requires the account's Embed feature and an API key or user session; third-party OAuth cannot create sessions.
|
|
940
|
+
Register exact allowed origins, then mark the signer `embedded: true` with Email or Whatsapp verification:
|
|
941
|
+
|
|
942
|
+
```ruby
|
|
943
|
+
origin = client.accounts.create_embed_origin('https://app.example.com')
|
|
944
|
+
# => { 'id' => 'origin-id', 'origin' => 'https://app.example.com', 'created_at' => '2026-11-11T12:00:00Z' }
|
|
945
|
+
client.accounts.list_embed_origins
|
|
946
|
+
client.accounts.update_embed_origin(origin.fetch('id'), 'https://sign.example.com')
|
|
947
|
+
|
|
948
|
+
assignment = client.assignments.create(
|
|
949
|
+
'document-id', method: 'virtual',
|
|
950
|
+
signers: [{ id: 'signer-id', verification_method: 'Email', notification_methods: ['Email'], embedded: true }]
|
|
951
|
+
)
|
|
952
|
+
session = client.assignments.create_embed_session('document-id', assignment.fetch('id'), 'signer-id')
|
|
953
|
+
# => { 'url' => 'https://app.assinafy.com.br/embed/session-token', 'expires_at' => '2026-11-11T12:05:00Z' }
|
|
954
|
+
# Pass session['url'] only to the intended signer's page and load it in an iframe.
|
|
955
|
+
client.accounts.delete_embed_origin(origin.fetch('id')) # nil; removes that embedding permission
|
|
956
|
+
```
|
|
957
|
+
|
|
958
|
+
Origins have no path, query, fragment or wildcard; HTTPS is required except HTTP localhost/127.0.0.1.
|
|
959
|
+
At most ten origins are allowed. Mint a fresh single-use URL for each frame display; it expires after five
|
|
960
|
+
minutes. `signing_urls` contains `url: nil, embedded: true` for embedded signers; invitations still deliver their
|
|
961
|
+
code. Follow the live [Embedded Signing Guide](https://api.assinafy.com.br/v1/docs) for the `assinafy:hello`
|
|
962
|
+
handshake and validate both `postMessage` origin and iframe window. Confirm completion through a webhook or
|
|
963
|
+
document read; frame events alone do not authorize application actions.
|
|
964
|
+
|
|
965
|
+
`assignments.exchange_embed_session(token, parent_origin:)` is the token-only operation used by the Assinafy
|
|
966
|
+
embed page. An ordinary integration loads the session URL; it does not exchange the token itself or expose the
|
|
967
|
+
returned signer access code. Resend the code through `assignments.resend_notification` from your backend.
|
|
968
|
+
|
|
786
969
|
### Contracts
|
|
787
970
|
|
|
788
971
|
```ruby
|
|
@@ -796,6 +979,7 @@ contract = client.contracts.update(
|
|
|
796
979
|
client.contracts.get('document-id')
|
|
797
980
|
client.contracts.list(status: ['active'], ending_within_days: 30)
|
|
798
981
|
client.contracts.related('document-id')
|
|
982
|
+
client.contracts.related('document-id', expand: 'document') # also includes the parent document
|
|
799
983
|
client.contracts.renew('document-id', term: contract['term'], updated_at: contract['updated_at'])
|
|
800
984
|
client.contracts.terminate('document-id', reason: 'Ended by the parties')
|
|
801
985
|
```
|
|
@@ -818,15 +1002,22 @@ client.signers.delete('signer-id')
|
|
|
818
1002
|
client.signers.find_by_email('alice@example.com') # case-insensitive; nil when no match
|
|
819
1003
|
```
|
|
820
1004
|
|
|
1005
|
+
`signers.update` changes only supplied fields. Explicit `nil` or `''` clears email, WhatsApp number or
|
|
1006
|
+
government ID; full_name cannot be cleared. Verified channels on unfinished requests cannot change, and changing
|
|
1007
|
+
an unverified channel invalidates old invitation links. `confirm_data` only reads email, WhatsApp number and terms;
|
|
1008
|
+
name/government-ID changes belong in workspace signer updates.
|
|
1009
|
+
|
|
821
1010
|
### Signers (self-service, signer-access-code)
|
|
822
1011
|
|
|
823
1012
|
```ruby
|
|
824
1013
|
client.signers.self_data(signer_access_code: 'code') # includes has_signature, has_initial, is_signature_reusable
|
|
825
1014
|
client.signers.accept_terms(signer_access_code: 'code')
|
|
826
1015
|
client.signers.verify_email(verification_code: '123456', signer_access_code: 'code')
|
|
827
|
-
client.signers.confirm_data('document-id', {
|
|
1016
|
+
client.signers.confirm_data('document-id', { email: 'alice@example.com', has_accepted_terms: true }, signer_access_code: 'code')
|
|
828
1017
|
client.signers.upload_signature(png_bytes, signer_access_code: 'code', type: 'signature', content_type: 'image/png')
|
|
829
1018
|
client.signers.download_signature(signer_access_code: 'code', type: 'signature')
|
|
1019
|
+
client.signers.theme(signer_access_code: 'code') # account_name, primary_color, secondary_color, logo
|
|
1020
|
+
client.signers.download_logo(signer_access_code: 'code') # binary image; 404 when unset
|
|
830
1021
|
```
|
|
831
1022
|
|
|
832
1023
|
### Assignments
|
|
@@ -882,9 +1073,19 @@ client.signer_documents.list_as_workspace('signer-id') # same ro
|
|
|
882
1073
|
client.signer_documents.search_as_workspace('signer-id', 'contract')
|
|
883
1074
|
client.signer_documents.sign_multiple(%w[document-id-1 document-id-2], signer_access_code: 'code')
|
|
884
1075
|
client.signer_documents.decline_multiple(%w[document-id-1 document-id-2], decline_reason: 'No', signer_access_code: 'code')
|
|
885
|
-
client.signer_documents.download('signer-id', 'document-id', '
|
|
1076
|
+
client.signer_documents.download('signer-id', 'document-id', signer_access_code: 'code') # original PDF only
|
|
1077
|
+
client.signer_documents.send_certified_copy(signer_access_code: 'code', document_id: 'document-id')
|
|
1078
|
+
# => { 'available' => true, 'notification_method' => 'Email', 'resends_left' => 2, 'sent_to' => 'a***@example.com' }
|
|
1079
|
+
client.signer_documents.download_certified_copy('download-token', pades: false) # binary PDF, token only
|
|
1080
|
+
client.signer_documents.resend_certified_copy('download-token') # delivery metadata as above
|
|
886
1081
|
```
|
|
887
1082
|
|
|
1083
|
+
Signer downloads require the access code and serve only `original`; use the workspace download API for other
|
|
1084
|
+
artifacts. Certified copies are delivered by email or WhatsApp with their own download token. An expired token's
|
|
1085
|
+
`302` is exposed as `ApiError`; the SDK does not follow it. For an envelope, pass `document_id` when selecting a
|
|
1086
|
+
document or requesting its copy; `assignments.signer_document(expand: 'envelope', signer_access_code: 'code')`
|
|
1087
|
+
includes the envelope's remaining documents.
|
|
1088
|
+
|
|
888
1089
|
### Templates
|
|
889
1090
|
|
|
890
1091
|
```ruby
|
|
@@ -899,8 +1100,8 @@ client.templates.download_page('template-id', 'page-id') # binary image bytes
|
|
|
899
1100
|
|
|
900
1101
|
`get`, `create`, `update`, `delete`, and `download_page` are supported by the deployed API beyond the OpenAPI
|
|
901
1102
|
document. `create` requires a source file; the template name defaults to the file's name. Template generation
|
|
902
|
-
needs one entry per role,
|
|
903
|
-
Cost estimation requires `role_id` but can omit the signer ID.
|
|
1103
|
+
needs one entry per role, using a distinct existing signer ID or an `email`/`name` pair;
|
|
1104
|
+
`role_id` comes from the template's `roles`. Cost estimation requires `role_id` but can omit the signer ID.
|
|
904
1105
|
|
|
905
1106
|
### Tags
|
|
906
1107
|
|
|
@@ -930,6 +1131,9 @@ client.fields.validate_multiple(
|
|
|
930
1131
|
)
|
|
931
1132
|
```
|
|
932
1133
|
|
|
1134
|
+
Single and batch field validation preserve explicit `nil` as JSON null. The API decides whether an empty value
|
|
1135
|
+
is allowed by that field; a batch item must still contain its `value` key. Zero is a value.
|
|
1136
|
+
|
|
933
1137
|
### Webhooks
|
|
934
1138
|
|
|
935
1139
|
```ruby
|
|
@@ -942,6 +1146,8 @@ client.webhooks.update_endpoint('webhook-endpoint-id', is_active: false)
|
|
|
942
1146
|
client.webhooks.delete_endpoint('webhook-endpoint-id') # => nil
|
|
943
1147
|
client.webhooks.endpoint_secret('webhook-endpoint-id') # => { 'secret' => 'whsec_...' }
|
|
944
1148
|
client.webhooks.rotate_endpoint_secret('webhook-endpoint-id')
|
|
1149
|
+
client.webhooks.rotate_endpoint_secret('webhook-endpoint-id', keep_previous: true) # 24-hour overlap
|
|
1150
|
+
client.webhooks.test_endpoint('webhook-endpoint-id') # one manual delivery; returns its dispatch entry
|
|
945
1151
|
|
|
946
1152
|
client.webhooks.list_dispatches(endpoint_id: 'webhook-endpoint-id', delivered: false, per_page: 50)
|
|
947
1153
|
client.webhooks.retry_dispatch('dispatch-id')
|
|
@@ -1000,12 +1206,17 @@ The SDK raises one of:
|
|
|
1000
1206
|
|
|
1001
1207
|
All inherit a `#context` Hash with debugging metadata.
|
|
1002
1208
|
|
|
1209
|
+
Use `ApiError#error_code` for actionable refusals such as `PlanRestricted`, `InsufficientScope`,
|
|
1210
|
+
`ContractChanged`, or `CreditCeilingExceeded`. Field validation details remain in `response_data['errors']`,
|
|
1211
|
+
an array of `{ 'field' => ..., 'code' => ..., 'message' => ... }`; localized messages are for display, not branching.
|
|
1212
|
+
|
|
1003
1213
|
## Tests
|
|
1004
1214
|
|
|
1005
1215
|
```bash
|
|
1006
1216
|
bundle exec rake spec # RSpec, including a coverage matrix
|
|
1007
|
-
bundle exec rubocop
|
|
1008
|
-
bundle exec bundler-audit check
|
|
1217
|
+
bundle exec rubocop --cache false # Linting
|
|
1218
|
+
bundle exec bundler-audit check --update # Dependency CVEs
|
|
1219
|
+
rbs -I sig validate # Published signatures (install rbs outside the bundle)
|
|
1009
1220
|
ruby scripts/check_api_contract.rb --file path/to/openapi.json # validate a local contract document
|
|
1010
1221
|
```
|
|
1011
1222
|
|