@getmanza/sdk 1.1.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,219 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.1.0] - 2026-12-01
11
+
12
+ Mirrors manza-ruby 2.1.0 (getmanza/manza-ruby#31) and replays
13
+ `cassettes-v2.1.0`: synced to the Manza API at getmanza/app `f9c74dc9df`
14
+ (API version still `2026-11-13`, no request migrations). Additive: no SDK
15
+ signature changed.
16
+
17
+ ### Added
18
+
19
+ - `manza.webhookDeliveries`: `list(endpointId, { status, limit, cursor })`
20
+ (`GET /api/webhook_endpoints/:id/deliveries`; `status` failed, pending or
21
+ succeeded, any other a 400 `ManzaValidationError` with `param` `status`),
22
+ `get(id)` (adds `payload` and `response_body`) and `retry(id)` (202
23
+ `{delivery_id, status: "queued"}`; a delivery that has not failed, a
24
+ disabled endpoint or a closed transfer challenge rejects with a 422
25
+ `ManzaValidationError`, `type` `state_error`). Method names follow
26
+ manza-go's `WebhookDeliveries`.
27
+ - `manza.webhookEndpoints.retryFailed(id)`: queues the endpoint's failed
28
+ deliveries of the last 7 days (at most 500), 202 `{status: "queued", count}`.
29
+ - **Beta:** listen sessions. `manza.webhookListeners.create({ events,
30
+ authorizer })` (201 `{id, events, authorizer, expires_at, stream_url,
31
+ signing_secret}`; both default to `[]` and `false`), `close(id)`
32
+ (`DELETE`), and `stream(listener, { lastEventId, signal })`, an async
33
+ iterable over the session's server-sent event stream read with `fetch`
34
+ (no new dependency). It yields a `ListenerEvent` (`id`, `eventType`,
35
+ `eventId`, `body` as the exact JSON text, `streamId`) per `webhook` frame,
36
+ then a `ListenerClosed` (`id`, `reason`) that ends the stream; both carry
37
+ a `type` discriminant (`"webhook"`, `"listener_closed"`). `listener` is
38
+ the create response, its body or the `stream_url`. A dropped connection
39
+ is reopened with `Last-Event-ID` (backoff 0.5s to 10s, at least a 429's
40
+ `Retry-After`); a refused connect, a first connect that fails, a
41
+ non-event-stream answer or a malformed frame (a `webhook` frame missing a
42
+ non-empty `id`, `event_type`, `event_id` or `body`, or a
43
+ `listener_closed` frame whose data is not JSON) rejects. The stream is
44
+ read on the client's base URL: an absolute `stream_url` gives only its
45
+ path and query, and a redirect is never followed, so the API key never
46
+ leaves the API host. Breaking out of the loop, or aborting `signal`,
47
+ closes the connection. Needs the new API key scope
48
+ `webhook_listeners:write` (`WebhookListeners.SCOPE`). Mirrors manza-ruby's
49
+ `WebhookListeners#stream`; where Ruby yields to a block and returns the
50
+ `ListenerClosed`, TypeScript yields it as the last item.
51
+ - `ManzaEntityRestrictedError`, a `ManzaForbiddenError` raised for a 403
52
+ whose `type` is `entity_restricted`: staff keep the entity read-only and
53
+ every endpoint refuses until they lift it.
54
+ - `WebhookEvents` constants for the reversal events:
55
+ `payment_link.refunded`, `payment_link.charged_back`,
56
+ `payment_link.dispute_opened`, `checkout_session.refunded`,
57
+ `checkout_session.charged_back` and `checkout_session.dispute_opened`
58
+ (`dispute_opened` South Africa only; each is sent only to an endpoint
59
+ subscribed to it by name). `Reversal` names the known `kind` (`refund`,
60
+ `chargeback`), `status` (`pending`, `completed`, `cancelled`) and
61
+ `resolution` (`won`) values; all three stay open strings.
62
+ - Documented: `reversed_amount` (a decimal string) on payment links and
63
+ checkout sessions, and `transaction.reversals` on checkout sessions; the
64
+ SDK passes them through unchanged.
65
+
66
+ ### Server behaviour
67
+
68
+ The API changed these without a wire-shape change; the SDK is unchanged.
69
+
70
+ - `invoices.send` on an invoice without a usable `send_to_email` rejects
71
+ with a 422 `ManzaValidationError` with `param` `send_to_email` and leaves
72
+ the invoice as it was (it used to be marked `sent`). An `overdue` invoice
73
+ can be sent: it stays `overdue` and gets `sent_at`.
74
+ - `invoices.create` (and `creditNote`) with a key holding
75
+ `invoices:auto_approve` and no `send_to_email` answers `status: approved`
76
+ with `sent_at: null` (it used to answer `sent`).
77
+ - `invoices.markAsPaid` takes an unsent `approved` invoice.
78
+ - Credit notes: `due_date` is always null (an update that sets one is a
79
+ 422), `status` is one of draft, pending_approval, declined, approved,
80
+ sent or cancelled, `markAsPaid` rejects with a 422 `state_error`, and
81
+ cancelling one in `pending_approval` rejects with a 422 `state_error`.
82
+ - An invoice `reference` over 64 characters rejects with a 422
83
+ `ManzaValidationError` with `param` `reference`.
84
+ - A South African sole trader without a CIPC number can invoice.
85
+ - Transactions: `source_type` may be `bill_payment` (Morocco), and
86
+ `transaction_type` may be `Bill Payment`, `Mobile Top-up`, `Card Payment
87
+ Refund`, `Card Payment Reversed` or `Card Payment Reversal Undone`.
88
+ - The 403s "API access not enabled" and "Feature not enabled" for the API,
89
+ webhooks, payment links and invoicing are gone, as is the flag that gated
90
+ `transfer_method` `instant` in Morocco: `instant` is now always accepted
91
+ there (`standard` still is too). The `ip_not_allowed` 403 has a new
92
+ message.
93
+
94
+ ### Changed (cassettes)
95
+
96
+ The replay pin moves to `cassettes-v2.1.0` (`scripts/fetch-cassettes.ts`).
97
+ Every cassette is re-recorded against staging; the new ones, and the
98
+ changed requests this SDK sends:
99
+
100
+ | Cassette | Request |
101
+ |---|---|
102
+ | `invoices/create` | `POST https://ma.manza.dev/api/invoices` with new dates (`issue_date` `2026-12-01`, `due_date` `2026-12-31`) |
103
+ | `invoices/create_long_reference` | `POST https://ma.manza.dev/api/invoices` with a 65-character `reference`: 422, `param` `reference` |
104
+ | `webhook_deliveries/list` | `GET https://ma.manza.dev/api/webhook_endpoints/fixture-webhook-id/deliveries?limit=10` |
105
+ | `webhook_deliveries/list_invalid_status` | `GET https://ma.manza.dev/api/webhook_endpoints/fixture-webhook-id/deliveries?limit=100&status=bounced`: 400, `param` `status` |
106
+ | `webhook_deliveries/get` | `GET https://ma.manza.dev/api/webhook_deliveries/fixture-webhook-delivery-id` |
107
+ | `webhook_deliveries/retry_not_failed` | `POST https://ma.manza.dev/api/webhook_deliveries/fixture-webhook-delivery-id/retry`: 422 `state_error` |
108
+ | `webhook_endpoints/retry_failed` | `POST https://ma.manza.dev/api/webhook_endpoints/fixture-webhook-id/retry_failed`: 202 |
109
+ | `webhook_endpoints/retry_failed_disabled` | `POST https://ma.manza.dev/api/webhook_endpoints/fixture-disabled-webhook-id/retry_failed`: 422 `state_error` |
110
+ | `webhook_listeners/create` | `POST https://ma.manza.dev/api/webhook_listeners` `{"events":["payment_link.paid"],"authorizer":false}`: 201, then the `DELETE` closing it |
111
+ | `webhook_listeners/close` | `POST https://ma.manza.dev/api/webhook_listeners` `{"events":[],"authorizer":false}`, then `DELETE https://ma.manza.dev/api/webhook_listeners/<id>`: 204 |
112
+
113
+ The stream itself has no cassette: `test/webhook_listener_stream.test.ts`
114
+ tests it against a local socket (`test/sse-stub-server.ts`).
115
+
116
+ ## [2.0.0] - 2026-11-14
117
+
118
+ Mirrors manza-ruby 2.0.0 and replays `cassettes-v2.0.0`: synced to the
119
+ Manza API at getmanza/app `906ec486e5` (API version `2026-11-13`). A major
120
+ release: see Migrating from 1.x below.
121
+
122
+ ### Removed
123
+
124
+ - **Breaking:** `manza.invoices.createPaymentLink` (`POST
125
+ /api/invoices/:id/payment_link`). The API retired the endpoint: ask for
126
+ the link with `generate_payment_link: true` on `invoices.create` or
127
+ `invoices.update` instead.
128
+ - **Breaking:** the v1 transfer-authorization signer.
129
+ `TransferAuthorization` builds only the v2 input (below).
130
+
131
+ ### Changed
132
+
133
+ - **Breaking:** `TransferAuthorization.SIGNATURE_VERSION` is
134
+ `manza.transfer-authorization.v2`, and `signatureInput` takes a required
135
+ `transfer_method` (`string | null`), appended after `client_reference`
136
+ (`""` when `null`):
137
+ `manza.transfer-authorization.v2|payment_id|nonce|amount|currency_code|account_id|payee|client_reference|transfer_method`.
138
+ Leaving it out fails to compile, and throws `ManzaArgumentError` from
139
+ plain JavaScript, before anything is sent. The API verifies v2 for
140
+ every request that is unpinned or sends `Manza-Version: 2026-11-13` or
141
+ later; only `2026-03-27` still verifies v1. Pass the payment's
142
+ `transfer_method` as the API returned it.
143
+ - The example authorizer (`examples/transfer_authorizer`) records the
144
+ create response's `transfer_method` in its ledger, checks it against the
145
+ webhook's `payment.transfer_method`, signs v2, and compares its input
146
+ with the webhook's `signature_input_v2`. `LedgerEntry` has a required
147
+ `transfer_method`; an entry without one reads as `null`.
148
+ - Invoice docs: `account_id` is required on `invoices.create` (without
149
+ one the API answers 422 `state_error`; an account that is not the
150
+ entity's, 422 with `param` `account_id`), and `invoices.update` takes it
151
+ too. An invoice's `status` may be `declined`, and `invoices.delete` also
152
+ takes a `declined` invoice that has no number.
153
+
154
+ ### Added
155
+
156
+ - `ManzaPlanLimitReachedError`, a `ManzaValidationError` thrown for a 422
157
+ whose `type` is `plan_limit_reached` (a plan cap, which the API used to
158
+ answer with a 500). `kind`, `current` and `max` read the cap from the
159
+ error body.
160
+ - `generate_payment_link` on `invoices.create` and `invoices.update`
161
+ (needs the `payment_links:write` scope; taken only while payment links
162
+ are enabled for the entity). Invoice responses carry
163
+ `generate_payment_link` and the embedded `account`.
164
+ - `transfer_method` on `payments.create`: `eft` or `rtc` in South Africa,
165
+ `standard` or `instant` in Morocco; one the market does not offer
166
+ rejects with `ManzaValidationError` with `param` `transfer_method`.
167
+ Payment responses carry `transfer_method` (the rail sent, the provider's
168
+ default when left out, `null` where the market offers no choice).
169
+ - Documented: the authorization `refusal_reason` `rail_limit_exceeded`
170
+ (status `superseded`): an authorized transfer over its rail's limit at
171
+ execution, sent to the approvers; the authorize call rejects with a 422
172
+ `ManzaValidationError` (`state_error`). A non-boolean
173
+ `generate_payment_link` rejects with `ManzaValidationError` (400).
174
+ - Documented: the `payment.authorization_requested` webhook's
175
+ `signature_input_v2` and `payment.transfer_method`, and
176
+ `transferAuthorizer.get()`'s `trust_new_payees` and `new_payee_limit`.
177
+
178
+ ### Fixed (API side, no wire change)
179
+
180
+ - `accounts.listTransactions` and `accounts.getTransaction` return posted
181
+ movements only (getmanza/app 818432457a); the SDK is unchanged.
182
+
183
+ ### Changed (cassettes)
184
+
185
+ - The replay tests pin `cassettes-v2.0.0` (was `v1.3.0`). Every cassette
186
+ was re-recorded against staging; the changed or new requests are
187
+ `invoices/create` (with `account_id`, `generate_payment_link: true` and
188
+ new dates), `invoices/create_invalid_generate_payment_link` (new, 400),
189
+ `invoices/create_without_account` (new, 422 `state_error`),
190
+ `invoices/update` (with `account_id` and `generate_payment_link: true`),
191
+ `payments/create` (with `transfer_method: "standard"`) and
192
+ `payments/create_invalid_transfer_method` (new, 422 on
193
+ `transfer_method`). See manza-ruby's CHANGELOG at 2.0.0.
194
+
195
+ ### Migrating from 1.x
196
+
197
+ - **`createPaymentLink` is gone.** Replace
198
+ `manza.invoices.createPaymentLink(id, { account_id })` with
199
+ `manza.invoices.update(id, { account_id, generate_payment_link: true })`,
200
+ or pass `generate_payment_link: true` on create. `update` resolves to
201
+ the invoice, not a link: the link is made from the invoice's account
202
+ when the invoice is approved, and appears in the invoice's
203
+ `payment_link`. `update` takes only an invoice that is still `draft`,
204
+ `pending_approval` or `declined` (any other rejects with
205
+ `ManzaValidationError`, `state_error`); for an invoice already approved
206
+ or sent, there is no API path to attach a link to it:
207
+ `manza.paymentLinks.create({ account_id, amount, ... })` makes a
208
+ standalone link instead.
209
+ - **`account_id` is required on invoice create.** Pass the account the
210
+ invoice is paid into (`manza.accounts.list()`); 1.x calls without it now
211
+ reject with `ManzaValidationError`.
212
+ - **v2 signatures only.** Add `transfer_method: payment.transfer_method`
213
+ to every `TransferAuthorization.signatureInput` call, and compare with
214
+ the webhook's `signature_input_v2` instead of `signature_input`. A
215
+ client pinned to `Manza-Version: 2026-03-27` (`apiVersion` or
216
+ `MANZA_API_VERSION`) is verified v1 and must stay on `@getmanza/sdk`
217
+ 1.x; unpin it, or pin `2026-11-13`, to move to 2.0.
218
+ - **Plan caps.** A `catch` that tests `instanceof ManzaServerError` around
219
+ creates that may hit a plan cap no longer catches it: test
220
+ `instanceof ManzaPlanLimitReachedError` (or its parent
221
+ `ManzaValidationError`), and do not retry it.
222
+
10
223
  ## [1.1.0]
11
224
 
12
225
  Mirrors manza-ruby 1.3.0 (with 1.2.0) and replays `cassettes-v1.3.0`.
package/README.md CHANGED
@@ -44,9 +44,19 @@ manza.customers.update(id, { ... });
44
44
  manza.customers.delete(id);
45
45
 
46
46
  manza.invoices.list();
47
- manza.invoices.create({ ... });
48
- // state-transition methods exist but the underlying public API is
49
- // not yet wired up — see getmanza/app issue #2174.
47
+ manza.invoices.create({
48
+ customer_id,
49
+ account_id, // required: the account the invoice is paid into
50
+ issue_date: "2026-11-14",
51
+ due_date: "2026-12-14",
52
+ generate_payment_link: true, // a card payment link, made when approved (payment_links:write; payment links enabled for the entity)
53
+ items: [{ description: "Consulting", quantity: 10, unit_price: "150.00" }],
54
+ });
55
+ manza.invoices.update(id, { account_id, generate_payment_link: false });
56
+ manza.invoices.send(id); // approved or overdue; no usable send_to_email → ManzaValidationError (param send_to_email)
57
+ manza.invoices.markAsPaid(id); // sent, overdue or unsent approved
58
+ manza.invoices.cancel(id);
59
+ manza.invoices.creditNote(id); // a credit note's due_date is always null
50
60
 
51
61
  manza.paymentLinks.list();
52
62
  manza.paymentLinks.create({ ... });
@@ -58,6 +68,11 @@ manza.webhookEndpoints.test(id);
58
68
  manza.webhookEndpoints.regenerateSecret(id);
59
69
  manza.webhookEndpoints.enable(id);
60
70
  manza.webhookEndpoints.disable(id);
71
+ manza.webhookEndpoints.retryFailed(id); // 202 {status: "queued", count}: failed deliveries of the last 7 days
72
+
73
+ manza.webhookDeliveries.list(endpointId, { status: "failed" }); // an endpoint's deliveries
74
+ manza.webhookDeliveries.get(id); // adds payload and response_body
75
+ manza.webhookDeliveries.retry(id); // 202; a delivery that has not failed → ManzaValidationError (state_error)
61
76
 
62
77
  manza.checkoutSessions.create({ account_id, amount, success_url, cancel_url });
63
78
  manza.checkoutSessions.get(id);
@@ -72,16 +87,49 @@ manza.beneficiaries.createExternalAccount(beneficiaryId, { account_number });
72
87
  manza.payeeTrustRequests.create({ external_account_ids: [id] });
73
88
  manza.payeeTrustRequests.get(id);
74
89
 
75
- manza.payments.create({ account_id, beneficiary_id, amount: "2500.00", client_reference });
90
+ manza.payments.create({ account_id, beneficiary_id, amount: "2500.00", client_reference, transfer_method: "standard" });
76
91
  // client_reference is unique per entity; a duplicate raises ManzaConflictError
92
+ // transfer_method is the optional rail: eft/rtc (ZA), standard/instant (MA); omitted → the default
77
93
  manza.payments.get(id); // authorization: status, refusal_reason
78
94
  manza.payments.authorize(id, { authorization_id, signature });
79
95
  manza.payments.decline(id, { authorization_id, reason });
80
96
  // manza.transferDrafts is a deprecated alias of manza.payments (same object, /api/payments)
81
97
 
82
- manza.transferAuthorizer.get(); // status, suspension_reason, limits, daily_authorized_total; ManzaNotFoundError: none enrolled
98
+ manza.transferAuthorizer.get(); // status, suspension_reason, limits, daily_authorized_total, trust_new_payees,
99
+ // new_payee_limit; ManzaNotFoundError: none enrolled
100
+ ```
101
+
102
+ `event_type` is an open string. `WebhookEvents` names the reversal events (`PAYMENT_LINK_REFUNDED`, `CHECKOUT_SESSION_CHARGED_BACK`, …; the `*_DISPUTE_OPENED` ones are South Africa only, and every one is sent only to an endpoint that subscribes to it by name). Their `data.reversal`, and each entry of a checkout session's `transaction.reversals` (once paid; an unpaid session's `transaction` is null), carries open-string `kind`, `status` and `resolution`, with the values known today in `Reversal`. Payment links and checkout sessions carry `reversed_amount`.
103
+
104
+ ## Listen sessions (beta)
105
+
106
+ A copy of the entity's webhook events streamed to a local tool, with no public endpoint (what `manza listen` uses). Needs the `webhook_listeners:write` scope (`WebhookListeners.SCOPE`); `authorizer: true` also mirrors transfer-authorization challenges and needs `transfers:authorize`. Beta: this surface may change in a minor release.
107
+
108
+ ```ts
109
+ import { ListenerClosed, ListenerEvent, Webhook } from "@getmanza/sdk";
110
+
111
+ const listener = (await manza.webhookListeners.create({ events: ["payment_link.paid"] })).body as {
112
+ id: string;
113
+ stream_url: string;
114
+ signing_secret: string;
115
+ }; // events: [] = every subscribable event (challenges only with authorizer: true); 12h session
116
+
117
+ for await (const item of manza.webhookListeners.stream(listener)) {
118
+ if (item instanceof ListenerEvent) {
119
+ // id (delivery), eventType, eventId, body (the exact JSON text), streamId
120
+ const timestamp = Math.floor(Date.now() / 1000);
121
+ const signature = await Webhook.sign({ payload: item.body, timestamp, secret: listener.signing_secret });
122
+ // POST item.body to the local server with X-Manza-Signature / X-Manza-Timestamp
123
+ } else if (item instanceof ListenerClosed) {
124
+ console.warn(`listen session ${item.reason}`); // closed, revoked or key_changed; the stream ends here
125
+ }
126
+ }
127
+
128
+ await manza.webhookListeners.close(listener.id);
83
129
  ```
84
130
 
131
+ The stream reconnects a dropped connection with `Last-Event-ID` (0.5s to 10s backoff, honouring a 429's `Retry-After`), so a reconnect neither loses nor repeats a frame the server still keeps (about 5 minutes); pass `{ lastEventId }` to resume after a `streamId` from an earlier run, and `{ signal }` to stop it (breaking out of the loop closes the connection too). A frame counts as seen once the loop asks for the next one, so iterating the same stream again after a `break` resumes with the frame the loop stopped on. It rejects, ending the stream, on a refused connect with the class for its status (`ManzaForbiddenError` for the API's 403, which also answers a reconnect to an expired session, `ManzaAuthenticationError` for a 401, and on the first connect `ManzaRateLimitError` or `ManzaServerError` too), on a first connect that fails (`ManzaConnectionError`), and on a malformed frame. The stream is read on the client's base URL (an absolute `stream_url` gives only its path and query, both sent to the API host) and never follows a redirect, so the key never leaves the API host.
132
+
85
133
  ## Machine-authorized transfers
86
134
 
87
135
  A draft inside your entity's authorization envelope (trusted payee, or a new one when you allow it, within limits) is sent to your enrolled authorizer endpoint as a `payment.authorization_requested` webhook carrying an `authorization.id` and a one-time `nonce`. Your system checks it against its own ledger, signs it and authorizes it with a **different API key** from the one that created it. [`examples/transfer_authorizer/`](examples/transfer_authorizer/) runs the whole flow. The [transfer authorization docs](https://ma.manza.finance/docs/api/transfer-authorization) have the full reference.
@@ -104,9 +152,9 @@ A draft inside your entity's authorization envelope (trusted payee, or a new one
104
152
  await manza.payeeTrustRequests.create({ external_account_ids: ["01a1..."] });
105
153
  ```
106
154
 
107
- `trusted` on `manza.beneficiaries.getExternalAccount` says which it is. The API does not show whether the option is on.
155
+ `trusted` on `manza.beneficiaries.getExternalAccount` says which it is. `trust_new_payees` on `manza.transferAuthorizer.get()` says whether the option is on, and `new_payee_limit` its limit.
108
156
  7. **Run the preflight, then the example** (from `examples/transfer_authorizer/`, after `bun install` at the repository root and filling in `.env`): `bun preflight.ts` checks what the API shows of steps 1–6 and prints a fix for each that fails. What it cannot see, check by hand: that key B is bound to an IP allowlist, and, for a payee not trusted yet, that *Approve transfers to new payees* is on and key A is bound to an IP allowlist too (it warns, it does not fail). Then `bun server.ts` in one terminal, `bun create_transfer.ts` in another (on Node, `npx tsx` in place of `bun`).
109
- 8. **Troubleshooting**: a draft that goes to your approvers instead has an `authorization` with a `refusal_reason`: status `refused` when it did not qualify (`create_transfer.ts` prints the reason in words), or `expired` (`expired`), `superseded` (`stale`; or an approver finalized the draft while its challenge was open, and it executes) or `failed` (`signature_failed`, five invalid signatures) when a challenge was sent and closed without an authorize; `manza.transferAuthorizer.get()` shows a suspension and its `suspension_reason`. An authorize answered 409 `authorization_busy` (a bank-detail edit, trust or trust revocation on the same payee was in flight) is safe to retry. The reasons, and an API error's `type`, are in the [transfer authorization docs](https://ma.manza.finance/docs/api/transfer-authorization).
157
+ 8. **Troubleshooting**: a draft that goes to your approvers instead has an `authorization` with a `refusal_reason`: status `refused` when it did not qualify (`create_transfer.ts` prints the reason in words), or `expired` (`expired`), `superseded` (`stale`; or an approver finalized the draft while its challenge was open, and it executes) or `failed` (`signature_failed`, five invalid signatures) when a challenge was sent and closed without an authorize, and `superseded` (`rail_limit_exceeded`) when an authorized transfer was over its rail's limit at execution, so nothing moved; `manza.transferAuthorizer.get()` shows a suspension and its `suspension_reason`. An authorize answered 409 `authorization_busy` (a bank-detail edit, trust or trust revocation on the same payee was in flight) is safe to retry. The reasons, and an API error's `type`, are in the [transfer authorization docs](https://ma.manza.finance/docs/api/transfer-authorization).
110
158
 
111
159
  ### Verifying the webhook
112
160
 
@@ -128,7 +176,7 @@ try {
128
176
 
129
177
  ### Signing the challenge
130
178
 
131
- Sign the draft from **your own record** of it (not the webhook's `signature_input`, which is there only to compare against) with the endpoint's signing secret:
179
+ Sign the draft from **your own record** of it with the endpoint's signing secret. The SDK builds the v2 input (`manza.transfer-authorization.v2`), which ends with the payment's `transfer_method` (an empty segment when it is `null`); compare it with the webhook's `signature_input_v2`, which is there only to compare against. The webhook's `signature_input` is the v1 string, verified only for clients pinned to `Manza-Version: 2026-03-27`: those stay on `@getmanza/sdk` 1.x. Unpinned, or pinned to `2026-11-13` or later, the API verifies v2.
132
180
 
133
181
  ```ts
134
182
  import { Manza, TransferAuthorization } from "@getmanza/sdk";
@@ -141,6 +189,7 @@ const input = TransferAuthorization.signatureInput({
141
189
  account_id: draft.account_id,
142
190
  payee: TransferAuthorization.payeeFor({ external_account_id: draft.external_account_id }),
143
191
  client_reference: draft.client_reference,
192
+ transfer_method: draft.transfer_method, // required; null signs as ""
144
193
  });
145
194
 
146
195
  const signature = await TransferAuthorization.sign({
@@ -159,7 +208,7 @@ await authorizer.payments.authorize(draft.id, {
159
208
 
160
209
  ## Errors
161
210
 
162
- Ten concrete subclasses; discriminate with `instanceof`.
211
+ Twelve concrete subclasses; discriminate with `instanceof`. A 422 is a `ManzaValidationError`; one whose `type` is `plan_limit_reached` is its subclass `ManzaPlanLimitReachedError`, carrying `kind`, `current` and `max` (a plan cap: retrying does not help). A 403 is a `ManzaForbiddenError`; one whose `type` is `entity_restricted` is its subclass `ManzaEntityRestrictedError`, while staff keep the entity read-only (every endpoint refuses until they lift it).
163
212
 
164
213
  ```ts
165
214
  import { ManzaValidationError, ManzaRateLimitError, ManzaNotFoundError } from "@getmanza/sdk";
package/dist/client.d.ts CHANGED
@@ -9,7 +9,9 @@ import { PaymentLinks } from "./resources/payment_links.js";
9
9
  import { Payments } from "./resources/payments.js";
10
10
  import { TransferAuthorizer } from "./resources/transfer_authorizer.js";
11
11
  import type { TransferDrafts } from "./resources/transfer_drafts.js";
12
+ import { WebhookDeliveries } from "./resources/webhook_deliveries.js";
12
13
  import { WebhookEndpoints } from "./resources/webhook_endpoints.js";
14
+ import { WebhookListeners } from "./resources/webhook_listeners.js";
13
15
  import { ManzaResponse } from "./response.js";
14
16
  export interface ManzaClientOptions {
15
17
  apiKey?: string | undefined;
@@ -44,8 +46,20 @@ export declare class Manza {
44
46
  * same resource, which calls `/api/payments`.
45
47
  */
46
48
  readonly transferDrafts: TransferDrafts;
49
+ readonly webhookDeliveries: WebhookDeliveries;
47
50
  readonly webhookEndpoints: WebhookEndpoints;
51
+ /** Listen sessions (beta). */
52
+ readonly webhookListeners: WebhookListeners;
48
53
  constructor(options?: ManzaClientOptions);
49
54
  request<T = unknown>(method: string, path: string, options?: RequestOptions): Promise<ManzaResponse<T>>;
55
+ /**
56
+ * @internal Opens a streaming GET on the client's base URL (the listen
57
+ * stream). `path` (with any query) is always joined to `baseUrl`, so the
58
+ * API key never leaves the API host, and a redirect is never followed:
59
+ * a 3xx, like any non-2xx, rejects with the error for its status. A
60
+ * transport failure rejects with ManzaConnectionError. Resolves to the
61
+ * raw Response, whose body the caller reads.
62
+ */
63
+ openStream(path: string, headers: Record<string, string>, signal: AbortSignal): Promise<Response>;
50
64
  }
51
65
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAA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D,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,8BAA8B;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;gBAEhC,OAAO,GAAE,kBAAuB;IA2BtC,OAAO,CAAC,CAAC,GAAG,OAAO,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IA0C5B;;;;;;;OAOG;IACG,UAAU,CACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,QAAQ,CAAC;CAqDrB"}
package/dist/errors.d.ts CHANGED
@@ -23,10 +23,22 @@ export declare class ManzaAuthenticationError extends ManzaError {
23
23
  }
24
24
  export declare class ManzaForbiddenError extends ManzaError {
25
25
  }
26
+ export declare class ManzaEntityRestrictedError extends ManzaForbiddenError {
27
+ }
26
28
  export declare class ManzaNotFoundError extends ManzaError {
27
29
  }
28
30
  export declare class ManzaValidationError extends ManzaError {
29
31
  }
32
+ export declare class ManzaPlanLimitReachedError extends ManzaValidationError {
33
+ readonly kind: string | null;
34
+ readonly current: number | null;
35
+ readonly max: number | null;
36
+ constructor(message: string, options?: ManzaErrorOptions & {
37
+ kind?: string | null;
38
+ current?: number | null;
39
+ max?: number | null;
40
+ });
41
+ }
30
42
  export declare class ManzaRateLimitError extends ManzaError {
31
43
  readonly retryAfter: number | null;
32
44
  constructor(message: string, options?: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