@instabrain-sdks/api-client 2.6.0 → 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/README.md +540 -74
- package/dist/client/instabrain-client.d.ts +53 -13
- package/dist/client/instabrain-client.js +53 -13
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/dist/services/adb.service.d.ts +1 -1
- package/dist/services/adb.service.js +1 -1
- package/dist/services/application.service.d.ts +9 -2
- package/dist/services/application.service.js +9 -2
- package/dist/services/finalexpense.service.d.ts +1 -1
- package/dist/services/finalexpense.service.js +1 -1
- package/dist/services/gigdb.service.d.ts +19 -8
- package/dist/services/gigdb.service.js +20 -9
- package/dist/services/ibterm.service.d.ts +17 -5
- package/dist/services/ibterm.service.js +17 -5
- package/dist/services/pureterm.service.d.ts +12 -4
- package/dist/services/pureterm.service.js +12 -4
- package/dist/services/reports.service.d.ts +3 -0
- package/dist/services/reports.service.js +3 -0
- package/dist/types/application.types.d.ts +27 -5
- package/dist/types/constants.d.ts +11 -0
- package/dist/types/constants.js +12 -1
- package/dist/types/enums.d.ts +17 -4
- package/dist/types/enums.js +18 -4
- package/dist/types/errors.d.ts +4 -4
- package/dist/types/errors.js +3 -2
- package/dist/types/gigdb.types.d.ts +34 -7
- package/dist/types/ibterm.types.d.ts +9 -0
- package/dist/types/index.d.ts +1 -7
- package/dist/types/index.js +1 -0
- package/dist/types/reports.types.d.ts +78 -18
- package/dist/types/reports.types.js +29 -2
- package/dist/types/webhook.types.d.ts +55 -0
- package/dist/types/webhook.types.js +3 -0
- package/dist/utils/webhook-signature.d.ts +72 -0
- package/dist/utils/webhook-signature.js +172 -0
- package/package.json +19 -13
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ TypeScript SDK for Node.js. All operations go through `InstaBrainClient` — req
|
|
|
7
7
|
**Products covered:** GIGDB, ADB, IB Term, Pure Term.
|
|
8
8
|
|
|
9
9
|
- **GIGDB & ADB** — full client flow: `get*Quote()` → `start*Application()` → `saveEftPayment()` → SecureSign methods → `finalSubmit()`.
|
|
10
|
-
- **IB Term** — client flow ends at `startIBTermApplication()`; use returned `agentLink` / `applicantLink` / `eAppAgentLink` for the InstaBrain frontend.
|
|
10
|
+
- **IB Term** — client flow ends at `startIBTermApplication()`; use returned `agentLink` / `applicantLink` / `eAppAgentLink` for the InstaBrain frontend. The shared `saveEftPayment()` is the one optional exception.
|
|
11
11
|
- **Pure Term** — pre-fill flow: `getPureTermQuote()` → `startPureTermApplication()`; use returned links for the InstaBrain frontend.
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
@@ -60,31 +60,41 @@ Credentials (`userId` and `accessToken`) are provisioned during onboarding.
|
|
|
60
60
|
- [Update quote](#final-expense--update-quote)
|
|
61
61
|
- [Underwriting status (async)](#final-expense--underwriting-status-async)
|
|
62
62
|
- [GIGDB pivot after a decline](#gigdb-pivot--after-a-final-expense-decline)
|
|
63
|
-
9. [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
9. [Generic start application](#generic-start-application)
|
|
64
|
+
10. [Application-status webhooks](#application-status-webhooks)
|
|
65
|
+
- [Registering for webhooks](#registering-for-webhooks)
|
|
66
|
+
- [Your endpoint](#your-endpoint)
|
|
67
|
+
- [Verifying signatures](#verifying-signatures)
|
|
68
|
+
- [Envelope & events](#envelope--events)
|
|
69
|
+
- [Idempotency & ordering](#idempotency--ordering)
|
|
70
|
+
- [Delivery is best-effort](#delivery-is-best-effort)
|
|
71
|
+
11. [Shared methods — GIGDB, ADB & Final Expense](#shared-methods--gigdb-adb--final-expense)
|
|
72
|
+
- [Payment — EFT or credit card](#payment--eft-or-credit-card)
|
|
73
|
+
- [Get credit card iframe URL](#get-credit-card-iframe-url)
|
|
74
|
+
- [Credit card payment status](#credit-card-payment-status)
|
|
75
|
+
- [Save EFT payment](#save-eft-payment)
|
|
76
|
+
- [Prepare docs & get delivery channels](#prepare-docs--get-delivery-channels)
|
|
77
|
+
- [Send PIN & get documents link](#send-pin--get-documents-link)
|
|
78
|
+
- [Resend PIN](#resend-pin)
|
|
79
|
+
- [Verify PIN](#verify-pin)
|
|
80
|
+
- [Final submit](#final-submit)
|
|
81
|
+
12. [Reporting](#reporting)
|
|
82
|
+
- [Request fields](#request-fields-shared-shape)
|
|
83
|
+
- [Filters (`ReportFilterOperator`)](#filters--reportfilteroperator)
|
|
84
|
+
- [`getSales()` filter and sort fields](#getsales-filter-and-sort-fields)
|
|
85
|
+
- [Response shapes](#response-shapes)
|
|
86
|
+
- [`getSales()` sale fields](#getsales-sale-fields)
|
|
87
|
+
13. [Enums & Constants](#enums--constants)
|
|
88
|
+
14. [Beneficiary Reference](#beneficiary-reference)
|
|
79
89
|
- [No extra fields](#variant-1--no-extra-fields)
|
|
80
90
|
- [Named person](#variant-2--named-person)
|
|
81
91
|
- [Named entity](#variant-3--named-entity)
|
|
82
|
-
|
|
92
|
+
15. [Error Handling](#error-handling)
|
|
83
93
|
- [Error class hierarchy](#error-class-hierarchy)
|
|
84
94
|
- [Using `APIValidationError`](#using-apivalidationerror)
|
|
85
95
|
- [`BaseResponse<T>` envelope](#baseresponset-envelope)
|
|
86
96
|
- [Field-level error messages](#field-level-error-messages)
|
|
87
|
-
|
|
97
|
+
16. [Error codes (`APIErrorCode`)](#apierrorcode-reference)
|
|
88
98
|
- [Quote errors](#quote-errors)
|
|
89
99
|
- [Start application errors](#start-application-errors)
|
|
90
100
|
- [Payment & quote update errors](#payment--quote-update-errors)
|
|
@@ -92,10 +102,10 @@ Credentials (`userId` and `accessToken`) are provisioned during onboarding.
|
|
|
92
102
|
- [Final submit errors](#final-submit-errors)
|
|
93
103
|
- [Session](#session)
|
|
94
104
|
- [Deprecated codes (reference only)](#deprecated-codes-reference-only)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
17. [Environment Configuration](#environment-configuration)
|
|
106
|
+
18. [Token Management](#token-management)
|
|
107
|
+
19. [Examples Directory](#examples-directory)
|
|
108
|
+
20. [Support](#support)
|
|
99
109
|
|
|
100
110
|
---
|
|
101
111
|
|
|
@@ -114,7 +124,7 @@ npm install @instabrain-sdks/api-client
|
|
|
114
124
|
## Requirements
|
|
115
125
|
|
|
116
126
|
- Node.js >= 14.0.0
|
|
117
|
-
- TypeScript >= 4.
|
|
127
|
+
- TypeScript >= 4.5 *(optional — the SDK ships with full type definitions; axios's type definitions do not parse on older versions)*
|
|
118
128
|
|
|
119
129
|
In request field tables, **Type** matches the SDK TypeScript definitions. **Required** values:
|
|
120
130
|
|
|
@@ -1116,7 +1126,7 @@ const updatedQuote = await client.updateAdbQuote({
|
|
|
1116
1126
|
|
|
1117
1127
|
**InstaBrain Term** — term life product, no medical exam.
|
|
1118
1128
|
|
|
1119
|
-
This is a **pre-fill flow**: use `getQuote()` and `startIBTermApplication()`, then hand off via `agentLink`, `applicantLink`, and `eAppAgentLink`. Do **not** call
|
|
1129
|
+
This is a **pre-fill flow**: use `getQuote()` and `startIBTermApplication()`, then hand off via `agentLink`, `applicantLink`, and `eAppAgentLink`. Do **not** call SecureSign methods, `finalSubmit()`, or the credit-card iframe for IB Term. The shared [`saveEftPayment()`](#save-eft-payment) is allowed.
|
|
1120
1130
|
|
|
1121
1131
|
- **Eligible ages:** 18–60
|
|
1122
1132
|
- **Not available in:** WY, NY
|
|
@@ -1132,13 +1142,16 @@ This is a **pre-fill flow**: use `getQuote()` and `startIBTermApplication()`, th
|
|
|
1132
1142
|
└── flagProductNotAvailableForState = true → STOP
|
|
1133
1143
|
1. [`getQuote()`](#ib-term--get-quote) Get quote → quoteResponseId
|
|
1134
1144
|
2. [`startIBTermApplication()`](#ib-term--start-application) Start app → agentLink / applicantLink
|
|
1135
|
-
├── isDeclined = true
|
|
1145
|
+
├── isDeclined = true + empty / all-zero opportunityId → STOP (knockout, no application)
|
|
1146
|
+
├── isDeclined = true + real opportunityId → keep the id and any links
|
|
1136
1147
|
└── isQuoteChanged = true → re-present updated premium, then hand off via links
|
|
1137
1148
|
3. [`getExistingIBTermQuote()`](#ib-term--get-existing-quote) [Optional] Re-fetch prior quote for resumed session
|
|
1138
1149
|
|
|
1139
1150
|
→ Direct agent or applicant to agentLink / applicantLink / eAppAgentLink
|
|
1140
1151
|
All remaining steps (underwriting, payment, signing) complete inside the InstaBrain frontend.
|
|
1141
|
-
No further `InstaBrainClient` methods for IB Term
|
|
1152
|
+
No further `InstaBrainClient` methods for IB Term, except the optional shared saveEftPayment()
|
|
1153
|
+
(bank payment, including Pay Later). To follow the outcome, opt in to
|
|
1154
|
+
application-status webhooks on start-application (see Application-status webhooks).
|
|
1142
1155
|
```
|
|
1143
1156
|
|
|
1144
1157
|
---
|
|
@@ -1340,7 +1353,7 @@ Many fields are **optional** — validated only when sent. Backend validation fi
|
|
|
1340
1353
|
|
|
1341
1354
|
**Always required:** `quoteResponseId`, `firstName`, `lastName`, `email`, `phoneNumber`, `isUsCitizenOrIsPermanentResident`, `isPayerAlsoOwnerAndInsured`, `height`, `weight`, `isHoldingValidDriverLicense`, `areListedConditionsNotApplicable`.
|
|
1342
1355
|
|
|
1343
|
-
**Optional — validated when sent:** `address`, `dateOfBirth`, `socialSecurityNumber`, `birthJurisdiction`, `driverLicenseState`, `driverLicenseNumber`, `hasPrimaryCarePhysician` / `physicianDetails`, `tobaccoNicotineUsage`, `hasExistingCoverage` / `existingCoverageData`, `beneficiaryDetails`.
|
|
1356
|
+
**Optional — validated when sent:** `address`, `dateOfBirth`, `socialSecurityNumber`, `birthJurisdiction`, `driverLicenseState`, `driverLicenseNumber`, `hasPrimaryCarePhysician` / `physicianDetails`, `tobaccoNicotineUsage`, `hasExistingCoverage` / `existingCoverageData`, `beneficiaryDetails`, `webhookRegistrationDetails`.
|
|
1344
1357
|
|
|
1345
1358
|
**Conditional:** `childRiderInfo` — required when Dependent Child Rider is on the quote; must not be sent otherwise.
|
|
1346
1359
|
|
|
@@ -1506,6 +1519,25 @@ IB Term accepts only: `Person`, `Trust`, `Insured Estate`, `All Children Of The
|
|
|
1506
1519
|
> Total `insuranceAmount` for entries where `toBeReplaced = false` must not exceed $100,000.
|
|
1507
1520
|
|
|
1508
1521
|
|
|
1522
|
+
***
|
|
1523
|
+
|
|
1524
|
+
### Webhook Registration (optional)
|
|
1525
|
+
|
|
1526
|
+
Opt in to [application-status webhooks](#application-status-webhooks) for the opportunity this call creates. Omit `webhookRegistrationDetails` or pass `null` for no callbacks — both are treated the same.
|
|
1527
|
+
|
|
1528
|
+
| Field | Type | Required | Validation Error |
|
|
1529
|
+
|---|---|---|---|
|
|
1530
|
+
| `webhookRegistrationDetails` | `WebhookRegistrationDetails \| null` | No | — |
|
|
1531
|
+
| `webhookRegistrationDetails.callbackUrl` | `string` | When the object is sent | `Webhook registration callbackUrl is required when webhookRegistrationDetails is provided.` / `callbackUrl must be at most 2048 characters.` / `callbackUrl must be an absolute HTTPS URL.` |
|
|
1532
|
+
| `webhookRegistrationDetails.secretKey` | `string` | When the object is sent | `Webhook registration secretKey is required when webhookRegistrationDetails is provided.` / `secretKey must be between 16 and 256 characters.` |
|
|
1533
|
+
|
|
1534
|
+
- `callbackUrl` must be an absolute **HTTPS** URL, max 2048 characters, in **both sandbox and production** — `http://` is rejected. Use a public HTTPS tunnel for local testing.
|
|
1535
|
+
- `secretKey` is 16–256 characters. Keep it server-side; you need it to verify every delivery.
|
|
1536
|
+
- An empty object `{}` is not a skip — both fields are then required, and the request fails.
|
|
1537
|
+
- Invalid details fail the whole request with `InvalidRequestFormat` under `value.fields['WebhookRegistrationDetails.CallbackUrl']` / `['WebhookRegistrationDetails.SecretKey']`, and **no application is created**.
|
|
1538
|
+
- One callback per opportunity. It cannot be changed after start-application.
|
|
1539
|
+
|
|
1540
|
+
|
|
1509
1541
|
***
|
|
1510
1542
|
|
|
1511
1543
|
### Business Rules
|
|
@@ -1522,7 +1554,12 @@ IB Term accepts only: `Person`, `Trust`, `Insured Estate`, `All Children Of The
|
|
|
1522
1554
|
|
|
1523
1555
|
### Knockout Rules
|
|
1524
1556
|
|
|
1525
|
-
Returns `isDeclined: true` on a successful response — the SDK does **not** throw.
|
|
1557
|
+
Returns `isDeclined: true` on a successful response — the SDK does **not** throw. Read `isDeclined` **together with `opportunityId`**:
|
|
1558
|
+
|
|
1559
|
+
- **Knockout** — `opportunityId` is empty or all-zero. No application exists, no links are returned, and no webhook is registered. Stop.
|
|
1560
|
+
- **Declined after the application was created** — `opportunityId` is a real GUID. Keep it, and keep `agentLink` / `applicantLink` / `eAppAgentLink` if they are present. Trust this response; do not wait for a `Declined` webhook for this call.
|
|
1561
|
+
|
|
1562
|
+
These inputs are knockouts:
|
|
1526
1563
|
|
|
1527
1564
|
- `isPayerAlsoOwnerAndInsured = false`
|
|
1528
1565
|
- `isUsCitizenOrIsPermanentResident = false`
|
|
@@ -1557,14 +1594,14 @@ When `isQuoteChanged = true`, the carrier adjusted the premium. Re-present the u
|
|
|
1557
1594
|
|
|
1558
1595
|
| Field | Type | Description |
|
|
1559
1596
|
|---|---|---|
|
|
1560
|
-
| `opportunityId` | `string` |
|
|
1561
|
-
| `isDeclined` | `boolean` | `true` =
|
|
1597
|
+
| `opportunityId` | `string` | Empty or all-zero UUID on a knockout (no application). Same value as the webhook `opportunityUid` |
|
|
1598
|
+
| `isDeclined` | `boolean` | `true` = declined. Stop only when `opportunityId` is empty or all-zero; otherwise keep the id and links |
|
|
1562
1599
|
| `isQuoteChanged` | `boolean` | `true` = carrier adjusted premium; re-present before handoff |
|
|
1563
1600
|
| `agentLink` | `string\|null` | Agent Conversational UI |
|
|
1564
1601
|
| `applicantLink` | `string\|null` | Applicant Conversational UI |
|
|
1565
1602
|
| `eAppAgentLink` | `string\|null` | Agent E-App |
|
|
1566
1603
|
|
|
1567
|
-
> After a non-declined response, direct the agent or applicant to the appropriate link. All remaining steps (underwriting, payment, signing) complete inside the InstaBrain frontend.
|
|
1604
|
+
> After a non-declined response, direct the agent or applicant to the appropriate link. All remaining steps (underwriting, payment, signing) complete inside the InstaBrain frontend — bank payment can alternatively be saved with the shared [`saveEftPayment()`](#save-eft-payment). To follow the outcome, send `webhookRegistrationDetails` on this start-application call — see [application-status webhooks](#application-status-webhooks) (delivery is best-effort).
|
|
1568
1605
|
|
|
1569
1606
|
|
|
1570
1607
|
***
|
|
@@ -1595,16 +1632,22 @@ const appResp = await client.startIBTermApplication({
|
|
|
1595
1632
|
beneficiaryDetails: {
|
|
1596
1633
|
beneficiaryType: BeneficiaryType.Person,
|
|
1597
1634
|
beneficiaryPerson: { firstName: 'Mary', lastName: 'Smith', relationship: BeneficiaryRelationship.Spouse }
|
|
1635
|
+
},
|
|
1636
|
+
// Optional — receive application-status webhooks for this opportunity
|
|
1637
|
+
webhookRegistrationDetails: {
|
|
1638
|
+
callbackUrl: 'https://partner.example.com/webhooks/instabrain',
|
|
1639
|
+
secretKey: process.env.INSTABRAIN_WEBHOOK_SECRET!
|
|
1598
1640
|
}
|
|
1599
1641
|
});
|
|
1600
1642
|
|
|
1601
|
-
|
|
1602
|
-
|
|
1643
|
+
const ALL_ZERO = '00000000-0000-0000-0000-000000000000';
|
|
1644
|
+
if (appResp.isDeclined && (!appResp.opportunityId || appResp.opportunityId === ALL_ZERO)) {
|
|
1645
|
+
return; // Knockout — no application exists
|
|
1603
1646
|
}
|
|
1604
1647
|
if (appResp.isQuoteChanged) {
|
|
1605
1648
|
// Re-present updated premium before directing to link
|
|
1606
1649
|
}
|
|
1607
|
-
// Hand off to InstaBrain frontend
|
|
1650
|
+
// Hand off to InstaBrain frontend. Persist opportunityId to match webhook deliveries.
|
|
1608
1651
|
console.log('Applicant link:', appResp.applicantLink);
|
|
1609
1652
|
```
|
|
1610
1653
|
|
|
@@ -1692,13 +1735,16 @@ Coverage and benefit-period availability tables are Pure-Term-specific — see [
|
|
|
1692
1735
|
└── flagProductNotAvailableForState = true → STOP (not sold in this state)
|
|
1693
1736
|
2. [`getPureTermQuote()`](#pure-term--get-quote) Get quote → quoteResponseId
|
|
1694
1737
|
3. [`startPureTermApplication()`](#pure-term--start-application) Start app → opportunityId + links
|
|
1695
|
-
├── isDeclined = true
|
|
1738
|
+
├── isDeclined = true + empty / all-zero opportunityId → STOP (knockout, no application)
|
|
1739
|
+
├── isDeclined = true + real opportunityId → keep the id and any links
|
|
1696
1740
|
└── isQuoteChanged = true → re-present updated premium, then hand off via links
|
|
1697
1741
|
|
|
1698
1742
|
[`getPureTermExistingQuote()`](#pure-term--get-existing-quote) (optional) Re-fetch the stored quote
|
|
1699
1743
|
|
|
1700
1744
|
→ Direct agent or applicant to agentLink / applicantLink / eAppAgentLink
|
|
1701
|
-
All remaining steps complete inside the InstaBrain frontend
|
|
1745
|
+
All remaining steps complete inside the InstaBrain frontend (the shared saveEftPayment() is
|
|
1746
|
+
allowed for bank payment). To follow the outcome, opt in to
|
|
1747
|
+
application-status webhooks on start-application (see Application-status webhooks).
|
|
1702
1748
|
```
|
|
1703
1749
|
|
|
1704
1750
|
---
|
|
@@ -1972,7 +2018,7 @@ console.log(existing.selectedQuote.quoteAmount, existing.selectedQuote.benefitPe
|
|
|
1972
2018
|
|
|
1973
2019
|
**Method:** `client.startPureTermApplication(request)` · **Type:** `PureTermStartApplicationReq`
|
|
1974
2020
|
|
|
1975
|
-
A **dedicated** Pure Term endpoint. This is separate from the generic `client.startApplication()
|
|
2021
|
+
A **dedicated** Pure Term endpoint. This is separate from the [generic `client.startApplication()`](#generic-start-application) — do not substitute one for the other.
|
|
1976
2022
|
|
|
1977
2023
|
The backend shares one request contract between IB Term and Pure Term start-application: same fields, same nesting, same optionality, same validation messages. `PureTermStartApplicationReq` is therefore the same structure as `IBTermStartApplicationReq`, and the full field-by-field tables in [IB Term — Start Application](#ib-term--start-application) apply here unchanged. Only the differences are listed below.
|
|
1978
2024
|
|
|
@@ -1984,6 +2030,7 @@ The backend shares one request contract between IB Term and Pure Term start-appl
|
|
|
1984
2030
|
| Field | Type | Required | Description |
|
|
1985
2031
|
|---|---|---|---|
|
|
1986
2032
|
| `quoteResponseId` | `string` | Yes | UUID from `getPureTermQuote()` — must belong to the **Pure Term** product |
|
|
2033
|
+
| `webhookRegistrationDetails` | `WebhookRegistrationDetails \| null` | No | Opt in to [application-status webhooks](#application-status-webhooks). Same rules and messages as [IB Term — Webhook Registration](#webhook-registration-optional) |
|
|
1987
2034
|
| *(all other fields)* | — | — | Identical to [IB Term — Start Application](#ib-term--start-application) |
|
|
1988
2035
|
|
|
1989
2036
|
> `proCode` does **not** apply here — it belongs to the generic `startApplication()` only.
|
|
@@ -1993,7 +2040,7 @@ The backend shares one request contract between IB Term and Pure Term start-appl
|
|
|
1993
2040
|
|
|
1994
2041
|
### Business Rules
|
|
1995
2042
|
|
|
1996
|
-
1. `isDeclined: true` is a valid success response
|
|
2043
|
+
1. `isDeclined: true` is a valid success response — the SDK does **not** throw. Stop only on a knockout (empty or all-zero `opportunityId`); with a real `opportunityId`, keep the id and any links.
|
|
1997
2044
|
2. When `isQuoteChanged = true`, the carrier adjusted the premium. Re-present it before directing the applicant to the link, or call `getPureTermExistingQuote()` to read the updated quote.
|
|
1998
2045
|
3. `quoteResponseId` must belong to Pure Term, otherwise: `QuoteResponseId does not exist or does not belong to the requested product.`
|
|
1999
2046
|
4. `address.state` (when sent) must match the quote state — a mismatch returns `StateMismatchIdentified`.
|
|
@@ -2002,13 +2049,14 @@ The backend shares one request contract between IB Term and Pure Term start-appl
|
|
|
2002
2049
|
7. `physicianDetails.stateCode` rejects both `"Outside Of The USA"` and `"OutsideUSA"`.
|
|
2003
2050
|
8. Pure Term does **not** run the `ApplicationLimitReached` duplicate SSN/email/phone check (that applies to GIGDB, ADB, and Final Expense).
|
|
2004
2051
|
9. Validation returns at most one message per field; `value.fields` keys are PascalCase and may be nested (e.g. `ChildRiderInfo.IsAnyChildTakingMedication`).
|
|
2052
|
+
10. `webhookRegistrationDetails` follows the IB Term rules: omit or `null` for no callbacks; when sent, `callbackUrl` (absolute HTTPS in sandbox and production) and `secretKey` (16–256 characters) are both required. Invalid details fail with `InvalidRequestFormat` and no application is created.
|
|
2005
2053
|
|
|
2006
2054
|
|
|
2007
2055
|
***
|
|
2008
2056
|
|
|
2009
2057
|
### Knockout Rules
|
|
2010
2058
|
|
|
2011
|
-
Any of the following returns HTTP `200` with `isDeclined: true` —
|
|
2059
|
+
Any of the following returns HTTP `200` with `isDeclined: true` and an empty or all-zero `opportunityId` — no application exists, and no webhook is registered. The SDK does **not** throw; check the fields explicitly. When `isDeclined` is `true` with a **real** `opportunityId`, the application was declined after it was created — keep the id and any returned links, and do not wait for a `Declined` webhook for this call.
|
|
2012
2060
|
|
|
2013
2061
|
- `isUsCitizenOrIsPermanentResident = false`
|
|
2014
2062
|
- `isPayerAlsoOwnerAndInsured = false`
|
|
@@ -2039,14 +2087,14 @@ Start Application is one shared service across both Term products, so the code s
|
|
|
2039
2087
|
|
|
2040
2088
|
| Field | Type | Description |
|
|
2041
2089
|
|---|---|---|
|
|
2042
|
-
| `opportunityId` | `string` |
|
|
2043
|
-
| `isDeclined` | `boolean` | `true` =
|
|
2090
|
+
| `opportunityId` | `string` | Empty or all-zero UUID on a knockout (no application). Same value as the webhook `opportunityUid` |
|
|
2091
|
+
| `isDeclined` | `boolean` | `true` = declined. Stop only when `opportunityId` is empty or all-zero; otherwise keep the id and links |
|
|
2044
2092
|
| `isQuoteChanged` | `boolean` | `true` = carrier adjusted premium; re-present before handoff |
|
|
2045
2093
|
| `agentLink` | `string \| null` | Agent Conversational UI |
|
|
2046
2094
|
| `applicantLink` | `string \| null` | Applicant Conversational UI |
|
|
2047
2095
|
| `eAppAgentLink` | `string \| null` | Agent E-App |
|
|
2048
2096
|
|
|
2049
|
-
> After a non-declined response, direct the agent or applicant to the appropriate link. All remaining steps (underwriting, payment, signing) complete inside the InstaBrain frontend. Do not pass this `opportunityId` to `finalSubmit()`, the SecureSign methods, or the credit-card iframe.
|
|
2097
|
+
> After a non-declined response, direct the agent or applicant to the appropriate link. All remaining steps (underwriting, payment, signing) complete inside the InstaBrain frontend — bank payment can alternatively be saved with the shared [`saveEftPayment()`](#save-eft-payment). Do not pass this `opportunityId` to `finalSubmit()`, the SecureSign methods, or the credit-card iframe. To follow the outcome, send `webhookRegistrationDetails` on this start-application call — see [application-status webhooks](#application-status-webhooks) (delivery is best-effort).
|
|
2050
2098
|
|
|
2051
2099
|
|
|
2052
2100
|
***
|
|
@@ -2094,18 +2142,24 @@ const appResp = await client.startPureTermApplication({
|
|
|
2094
2142
|
lastName: 'Doe',
|
|
2095
2143
|
relationship: BeneficiaryRelationship.Spouse
|
|
2096
2144
|
}
|
|
2145
|
+
},
|
|
2146
|
+
// Optional — receive application-status webhooks for this opportunity
|
|
2147
|
+
webhookRegistrationDetails: {
|
|
2148
|
+
callbackUrl: 'https://partner.example.com/webhooks/instabrain',
|
|
2149
|
+
secretKey: process.env.INSTABRAIN_WEBHOOK_SECRET!
|
|
2097
2150
|
}
|
|
2098
2151
|
// childRiderInfo — send ONLY when the Dependent Child Rider is on the quote
|
|
2099
2152
|
});
|
|
2100
2153
|
|
|
2101
|
-
|
|
2102
|
-
|
|
2154
|
+
const ALL_ZERO = '00000000-0000-0000-0000-000000000000';
|
|
2155
|
+
if (appResp.isDeclined && (!appResp.opportunityId || appResp.opportunityId === ALL_ZERO)) {
|
|
2156
|
+
return; // Knockout — no application exists
|
|
2103
2157
|
}
|
|
2104
2158
|
if (appResp.isQuoteChanged) {
|
|
2105
2159
|
const updated = await client.getPureTermExistingQuote(appResp.opportunityId);
|
|
2106
2160
|
// Re-present updated premium before directing to link
|
|
2107
2161
|
}
|
|
2108
|
-
// Hand off to InstaBrain frontend
|
|
2162
|
+
// Hand off to InstaBrain frontend. Persist opportunityId to match webhook deliveries.
|
|
2109
2163
|
console.log('Applicant link:', appResp.applicantLink);
|
|
2110
2164
|
```
|
|
2111
2165
|
|
|
@@ -2869,9 +2923,273 @@ await client.saveEftPayment({ opportunityId: gigdbOpportunityId, /* … */ } as
|
|
|
2869
2923
|
|
|
2870
2924
|
---
|
|
2871
2925
|
|
|
2926
|
+
## Generic Start Application
|
|
2927
|
+
|
|
2928
|
+
**Method:** `client.startApplication(request)` · **Type:** `ThirdPartyStartApplicationReq` · **Endpoint:** `POST /api/ThirdPartyStartApp/start-application`
|
|
2929
|
+
|
|
2930
|
+
The older, generic start-application endpoint. It starts an application from a quote and returns `opportunityId` plus links for the InstaBrain frontend. Pass `proCode` to start a specific product variant.
|
|
2931
|
+
|
|
2932
|
+
> For IB Term and Pure Term, InstaBrain recommends the dedicated [`startIBTermApplication()`](#ib-term--start-application) and [`startPureTermApplication()`](#pure-term--start-application), which carry the full request contract.
|
|
2933
|
+
|
|
2934
|
+
|
|
2935
|
+
***
|
|
2936
|
+
|
|
2937
|
+
### Request Fields
|
|
2938
|
+
|
|
2939
|
+
| Field | Type | Required | Description |
|
|
2940
|
+
|---|---|---|---|
|
|
2941
|
+
| `quoteResponseId` | `string` | Yes | UUID from the product quote response |
|
|
2942
|
+
| `firstName` | `string \| null` | Yes — pass `null` if not collected | Overrides the first name given on the quote |
|
|
2943
|
+
| `lastName` | `string \| null` | Yes — pass `null` if not collected | Overrides the last name given on the quote |
|
|
2944
|
+
| `email` | `string \| null` | Yes — pass `null` if not collected | Applicant email |
|
|
2945
|
+
| `phoneNumber` | `string \| null` | Yes — pass `null` if not collected | Applicant phone |
|
|
2946
|
+
| `proCode` | `string \| null` | No | Product variant code. Omit to start the base product; contact InstaBrain support for the correct code |
|
|
2947
|
+
| `webhookRegistrationDetails` | `WebhookRegistrationDetails \| null` | No | Opt in to [application-status webhooks](#application-status-webhooks). Same rules and messages as [IB Term — Webhook Registration](#webhook-registration-optional) |
|
|
2948
|
+
|
|
2949
|
+
|
|
2950
|
+
***
|
|
2951
|
+
|
|
2952
|
+
### Response
|
|
2953
|
+
|
|
2954
|
+
| Field | Type | Description |
|
|
2955
|
+
|---|---|---|
|
|
2956
|
+
| `opportunityId` | `string` | GUID of the created application. Same value as the webhook `opportunityUid` — persist it |
|
|
2957
|
+
| `agentLink` | `string \| null` | Agent Conversational UI |
|
|
2958
|
+
| `applicantLink` | `string \| null` | Applicant Conversational UI |
|
|
2959
|
+
| `eAppAgentLink` | `string \| null` | Agent E-App |
|
|
2960
|
+
| `isDeclined` | `boolean` | Normally `false` on this route's success path |
|
|
2961
|
+
| `isQuoteChanged` | `boolean` | Normally `false` on this route's success path |
|
|
2962
|
+
|
|
2963
|
+
> Consumer-facing platforms should always use `applicantLink`. `agentLink` and `eAppAgentLink` are for agent-facing interfaces only.
|
|
2964
|
+
|
|
2965
|
+
|
|
2966
|
+
***
|
|
2967
|
+
|
|
2968
|
+
### Error Codes
|
|
2969
|
+
|
|
2970
|
+
| Code | When |
|
|
2971
|
+
|---|---|
|
|
2972
|
+
| `InvalidRequestFormat` | Any validation failure, including invalid `webhookRegistrationDetails` — inspect `value.fields` |
|
|
2973
|
+
|
|
2974
|
+
> This route does not return `ApplicationLimitReached`. An invalid or expired token surfaces as `AuthenticationError`.
|
|
2975
|
+
|
|
2976
|
+
|
|
2977
|
+
***
|
|
2978
|
+
|
|
2979
|
+
### Example
|
|
2980
|
+
|
|
2981
|
+
```typescript
|
|
2982
|
+
const appResp = await client.startApplication({
|
|
2983
|
+
quoteResponseId,
|
|
2984
|
+
firstName: 'Jane',
|
|
2985
|
+
lastName: 'Doe',
|
|
2986
|
+
email: 'jane.doe@example.com',
|
|
2987
|
+
phoneNumber: '5551234567',
|
|
2988
|
+
// Optional — receive application-status webhooks for this opportunity
|
|
2989
|
+
webhookRegistrationDetails: {
|
|
2990
|
+
callbackUrl: 'https://partner.example.com/webhooks/instabrain',
|
|
2991
|
+
secretKey: process.env.INSTABRAIN_WEBHOOK_SECRET!
|
|
2992
|
+
}
|
|
2993
|
+
});
|
|
2994
|
+
|
|
2995
|
+
// Persist opportunityId — webhook deliveries carry it as opportunityUid.
|
|
2996
|
+
console.log(appResp.opportunityId, appResp.applicantLink);
|
|
2997
|
+
```
|
|
2998
|
+
|
|
2999
|
+
---
|
|
3000
|
+
|
|
3001
|
+
## Application-status Webhooks
|
|
3002
|
+
|
|
3003
|
+
InstaBrain can POST application-status events — payment, documents signed, policy issued, declined, pivoted — to an HTTPS endpoint you run. This is not a method you call: you opt in on start-application, and InstaBrain calls you.
|
|
3004
|
+
|
|
3005
|
+
```
|
|
3006
|
+
1. start…Application({ …, webhookRegistrationDetails }) → persist opportunityId
|
|
3007
|
+
2. InstaBrain POSTs each event to your callbackUrl
|
|
3008
|
+
3. verifyWebhookSignature(rawBody, timestamp, signature, secretKey)
|
|
3009
|
+
├── false → respond 401
|
|
3010
|
+
└── true → parse JSON, store eventId (dedupe), respond 2xx fast, process asynchronously
|
|
3011
|
+
```
|
|
3012
|
+
|
|
3013
|
+
Delivery is **best-effort** — see [Delivery is best-effort](#delivery-is-best-effort).
|
|
3014
|
+
|
|
3015
|
+
|
|
3016
|
+
***
|
|
3017
|
+
|
|
3018
|
+
### Registering for Webhooks
|
|
3019
|
+
|
|
3020
|
+
Send `webhookRegistrationDetails` on start-application. Only three methods accept it:
|
|
3021
|
+
|
|
3022
|
+
| Method | Registers webhooks |
|
|
3023
|
+
|---|---|
|
|
3024
|
+
| [`startIBTermApplication()`](#ib-term--start-application) | Yes |
|
|
3025
|
+
| [`startPureTermApplication()`](#pure-term--start-application) | Yes |
|
|
3026
|
+
| [`startApplication()`](#generic-start-application) (generic) | Yes |
|
|
3027
|
+
| `startAdbApplication()`, `startGigdbApplication()`, `startFinalExpenseApplication()` | **No** — the field is silently ignored: no error, and no callbacks |
|
|
3028
|
+
|
|
3029
|
+
```typescript
|
|
3030
|
+
webhookRegistrationDetails: {
|
|
3031
|
+
callbackUrl: 'https://partner.example.com/webhooks/instabrain', // absolute HTTPS, max 2048
|
|
3032
|
+
secretKey: process.env.INSTABRAIN_WEBHOOK_SECRET! // 16–256 characters
|
|
3033
|
+
}
|
|
3034
|
+
```
|
|
3035
|
+
|
|
3036
|
+
- Omit the field or pass `null` for no callbacks — both are treated the same. An empty object `{}` fails validation.
|
|
3037
|
+
- `callbackUrl` must be an absolute **HTTPS** URL in **both sandbox and production** — `http://` is rejected. For local testing, use a public HTTPS tunnel.
|
|
3038
|
+
- Invalid details fail the whole request with `InvalidRequestFormat` (messages under `value.fields['WebhookRegistrationDetails.CallbackUrl']` / `['WebhookRegistrationDetails.SecretKey']`), and **no application is created**. The limits are also exported, for reference, as `WEBHOOK_REGISTRATION_LIMITS`.
|
|
3039
|
+
- A knockout decline (empty or all-zero `opportunityId`) registers nothing.
|
|
3040
|
+
- One callback per opportunity. There is no API to change the URL or secret after start-application, so keep a copy of the secret.
|
|
3041
|
+
- If registration itself fails after the application was created, start-application still succeeds. If you opted in and receive no events, contact InstaBrain.
|
|
3042
|
+
|
|
3043
|
+
|
|
3044
|
+
***
|
|
3045
|
+
|
|
3046
|
+
### Your Endpoint
|
|
3047
|
+
|
|
3048
|
+
InstaBrain sends `POST {callbackUrl}` with `Content-Type: application/json` and waits up to **30 seconds** for a response. Store the `eventId`, return **2xx** straight away, and do the real work asynchronously.
|
|
3049
|
+
|
|
3050
|
+
| Your response | What InstaBrain does |
|
|
3051
|
+
|---|---|
|
|
3052
|
+
| `2xx` | Delivered. No retry |
|
|
3053
|
+
| `429` or `5xx` | Retried |
|
|
3054
|
+
| No HTTP response — connection or other transport failure | Retried |
|
|
3055
|
+
| Any other `4xx` | **Not retried** — the event is dropped |
|
|
3056
|
+
|
|
3057
|
+
- Retries: up to **5** after the first attempt, waiting **1, 2, 4, 8, and 16 minutes**.
|
|
3058
|
+
- **Every attempt is signed afresh**: a retry carries a new `X-InstaBrain-Timestamp` and `X-InstaBrain-Signature`. The body and `eventId` stay the same.
|
|
3059
|
+
- Return a 4xx only for a request you want dropped — such as a failed signature check. A bug in your handler should surface as a 5xx, so the event is retried.
|
|
3060
|
+
|
|
3061
|
+
**Where deliveries come from**
|
|
3062
|
+
|
|
3063
|
+
- Deliveries are sent server-to-server from InstaBrain's backend. They don't come from a browser, or from any API you call.
|
|
3064
|
+
- If your endpoint restricts inbound traffic by IP, contact [helpdesk@instabrain.io](mailto:helpdesk@instabrain.io) for InstaBrain's outbound IP addresses (sandbox and production), and allowlist them **before** you register a `callbackUrl`. A blocked delivery counts as a transport failure: it is retried 5 times over about 31 minutes and then dropped, and you never receive an error.
|
|
3065
|
+
- An IP allowlist is extra protection only. Always verify every delivery with `verifyWebhookSignature()`.
|
|
3066
|
+
|
|
3067
|
+
| Header | `WEBHOOK_HEADERS` key | Value |
|
|
3068
|
+
|---|---|---|
|
|
3069
|
+
| `X-InstaBrain-Timestamp` | `TIMESTAMP` | Unix time in seconds (UTC), plain digits — e.g. `1757588400` |
|
|
3070
|
+
| `X-InstaBrain-Signature` | `SIGNATURE` | Lowercase hex HMAC-SHA256 of `{timestamp}.{rawBody}` |
|
|
3071
|
+
| `X-InstaBrain-Event-Id` | `EVENT_ID` | Same value as the body `eventId`. **Not covered by the signature** |
|
|
3072
|
+
| `Content-Type` | — | Always `application/json` |
|
|
3073
|
+
|
|
3074
|
+
`WEBHOOK_HEADERS` holds the lowercase names Node.js uses for `req.headers`.
|
|
3075
|
+
|
|
3076
|
+
|
|
3077
|
+
***
|
|
3078
|
+
|
|
3079
|
+
### Verifying Signatures
|
|
3080
|
+
|
|
3081
|
+
Verify **every** delivery before trusting it, with `verifyWebhookSignature()`. It computes HMAC-SHA256 of `{timestamp}.{rawBody}` with your `secretKey`, compares it to `X-InstaBrain-Signature` in constant time, and checks the timestamp is within 5 minutes of now.
|
|
3082
|
+
|
|
3083
|
+
```typescript
|
|
3084
|
+
import express from 'express';
|
|
3085
|
+
import { verifyWebhookSignature, WEBHOOK_HEADERS } from '@instabrain-sdks/api-client';
|
|
3086
|
+
|
|
3087
|
+
const app = express();
|
|
3088
|
+
|
|
3089
|
+
// express.raw() on this route, ahead of any app-wide express.json(), keeps req.body as the
|
|
3090
|
+
// exact bytes InstaBrain signed.
|
|
3091
|
+
app.post('/webhooks/instabrain', express.raw({ type: 'application/json' }), (req, res) => {
|
|
3092
|
+
const ok = verifyWebhookSignature(
|
|
3093
|
+
req.body, // raw Buffer — never re-stringified JSON
|
|
3094
|
+
req.headers[WEBHOOK_HEADERS.TIMESTAMP],
|
|
3095
|
+
req.headers[WEBHOOK_HEADERS.SIGNATURE],
|
|
3096
|
+
process.env.INSTABRAIN_WEBHOOK_SECRET!
|
|
3097
|
+
);
|
|
3098
|
+
if (!ok) {
|
|
3099
|
+
res.sendStatus(401);
|
|
3100
|
+
return;
|
|
3101
|
+
}
|
|
3102
|
+
|
|
3103
|
+
const event = JSON.parse(req.body.toString('utf8'));
|
|
3104
|
+
// 1. Skip if event.eventId was already stored; otherwise store it.
|
|
3105
|
+
// 2. Respond 2xx now, and handle event.data.event asynchronously.
|
|
3106
|
+
res.sendStatus(200);
|
|
3107
|
+
});
|
|
3108
|
+
```
|
|
3109
|
+
|
|
3110
|
+
**Pass the body exactly as received.** Parsing and re-stringifying it (`JSON.stringify(JSON.parse(body))`) can change spacing or escaping and break the signature — and because compact bodies often survive the round trip, the bug can stay hidden until production. The helper accepts a `string`, `Buffer`, `Uint8Array`, or `ArrayBuffer`. In fetch-style handlers (e.g. Next.js route handlers), pass `await req.text()` as the body and read the headers with `req.headers.get(WEBHOOK_HEADERS.TIMESTAMP)` and `req.headers.get(WEBHOOK_HEADERS.SIGNATURE)` — bracket access on a fetch `Headers` object returns `undefined`, which fails verification.
|
|
3111
|
+
|
|
3112
|
+
| Outcome | When | What to do |
|
|
3113
|
+
|---|---|---|
|
|
3114
|
+
| Returns `true` | Signature matches and the timestamp is within tolerance | Parse the body and handle the event |
|
|
3115
|
+
| Returns `false` | Missing, malformed, stale, or wrong signature or timestamp | Respond `401` |
|
|
3116
|
+
| Throws `TypeError` | Empty `secretKey`, a body that is not a string or bytes (e.g. an already-parsed object), or invalid options | If it happens on every InstaBrain delivery, fix your setup. Your framework answers `500`, so InstaBrain retries — but only 5 times over about 31 minutes; after that the event is lost. A stray request with a non-JSON `Content-Type` or no body can also land here, because body parsers then leave `req.body` as `{}` or `undefined` — one `TypeError` alone is not proof of misconfiguration |
|
|
3117
|
+
|
|
3118
|
+
- The timestamp window is **300 seconds** in either direction. Because every retry is signed afresh, a legitimate delivery never falls outside it. Keep your server clock in sync: a clock more than 5 minutes off rejects every delivery.
|
|
3119
|
+
- Options: `{ toleranceSeconds }` changes the window (`Infinity` disables it); `{ nowSeconds }` overrides the clock, in **seconds**, for tests.
|
|
3120
|
+
- Uppercase hex signatures are accepted.
|
|
3121
|
+
- `TypeError` is a standard JavaScript error, **not** an `InstaBrainError`.
|
|
3122
|
+
- Keep `secretKey` server-side. Never log it, and never build start-application requests in a browser.
|
|
3123
|
+
|
|
3124
|
+
|
|
3125
|
+
***
|
|
3126
|
+
|
|
3127
|
+
### Envelope & Events
|
|
3128
|
+
|
|
3129
|
+
Every delivery is one JSON envelope (camelCase). The SDK deliberately does **not** type the payload — InstaBrain may add events and fields over time. Parse it after verifying, and ignore what you don't recognise.
|
|
3130
|
+
|
|
3131
|
+
| Field | Type | Description |
|
|
3132
|
+
|---|---|---|
|
|
3133
|
+
| `eventId` | `string` (GUID) | Unique per event; retries reuse it. Deduplicate on this |
|
|
3134
|
+
| `webhookType` | `string` | Always `applicationStatus` |
|
|
3135
|
+
| `sequenceNo` | `number` | Order of events **for this `opportunityUid`**, starting at 1 |
|
|
3136
|
+
| `occurredOn` | `string` (ISO-8601, UTC) | When the event happened |
|
|
3137
|
+
| `product` | `string` | Webhook product code — see below |
|
|
3138
|
+
| `opportunityUid` | `string` (GUID) | Same value as the start-application `opportunityId` |
|
|
3139
|
+
| `data` | `object` | Event-specific fields. Always includes `data.event` |
|
|
3140
|
+
| `eventHistory` | `array \| null` | `null` on non-final events. On final events, the earlier envelopes for this opportunity (possibly `[]`), excluding the current one |
|
|
3141
|
+
|
|
3142
|
+
**`product` codes:** `InstaTerm` (IB Term), `InstaPureTerm` (Pure Term), `InstaADB` (ADB), `InstaGIGDB` (GIGDB), `InstaFinalExpense` (Final Expense). These are webhook codes. They match the quote-response `productName` for every product except Pure Term, whose quote `productName` is `"InstaBrain Pure Term"` — so don't treat the two strings as interchangeable. Tolerate values not in this list.
|
|
3143
|
+
|
|
3144
|
+
| `data.event` | Final? | When | Other `data` fields |
|
|
3145
|
+
|---|---|---|---|
|
|
3146
|
+
| `Payment` | No | **IB Term / Pure Term:** payment collected. **ADB / GIGDB / Final Expense:** payment details stored | `paymentMethod`: `EFT` or `CreditCard` |
|
|
3147
|
+
| `DocumentsSigned` | No | Applicant PIN verified / documents signed | — |
|
|
3148
|
+
| `PolicyIssued` | Yes | Policy issued, including scheduled issue | `policyNumber`, `faceAmount`, `premiumAmount`, `paymentFrequency` (nullable), `isPolicyScheduled`, `effectiveDate` (nullable) |
|
|
3149
|
+
| `Declined` | Yes | Declined after the application exists | — |
|
|
3150
|
+
| `Pivoted` | Yes | The application moved to an alternative product | `pivotFromUid`, `pivotToUid`, `pivotFromProductCode`, `pivotToProductCode` |
|
|
3151
|
+
|
|
3152
|
+
- **`Declined` is not a hard stop.** When the product allows a pivot, `Pivoted` can follow `Declined` on the same `opportunityUid` — keep accepting events.
|
|
3153
|
+
- **A `Declined` webhook is not the start-application `isDeclined`.** Trust the start-application response for that call; a `Declined` POST is not guaranteed at start-application time.
|
|
3154
|
+
- **On `Pivoted`**, the event is posted for the *source* `opportunityUid`, and the same `callbackUrl` and `secretKey` are copied to the new application. Later events arrive with `opportunityUid = pivotToUid`, and its `sequenceNo` starts again at 1. If you look up the secret per opportunity, map `pivotToUid` to the same secret.
|
|
3155
|
+
|
|
3156
|
+
Example — a `Payment` delivery:
|
|
3157
|
+
|
|
3158
|
+
```json
|
|
3159
|
+
{
|
|
3160
|
+
"eventId": "9c2e1f4a-1111-2222-3333-444455556666",
|
|
3161
|
+
"webhookType": "applicationStatus",
|
|
3162
|
+
"sequenceNo": 1,
|
|
3163
|
+
"occurredOn": "2026-09-11T06:00:00Z",
|
|
3164
|
+
"product": "InstaTerm",
|
|
3165
|
+
"opportunityUid": "7a1b2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
|
|
3166
|
+
"data": { "event": "Payment", "paymentMethod": "EFT" },
|
|
3167
|
+
"eventHistory": null
|
|
3168
|
+
}
|
|
3169
|
+
```
|
|
3170
|
+
|
|
3171
|
+
|
|
3172
|
+
***
|
|
3173
|
+
|
|
3174
|
+
### Idempotency & Ordering
|
|
3175
|
+
|
|
3176
|
+
- The same event can arrive more than once — after a retry, for example. **Deduplicate on the `eventId` inside the verified body**, and store it before you return 2xx.
|
|
3177
|
+
- Don't rely on the `X-InstaBrain-Event-Id` header alone: it carries the same value, but the signature does not cover it.
|
|
3178
|
+
- Use `sequenceNo`, not arrival order, to order events for an opportunity.
|
|
3179
|
+
- Final events carry `eventHistory`, so you can rebuild earlier stages without having stored every POST.
|
|
3180
|
+
|
|
3181
|
+
|
|
3182
|
+
***
|
|
3183
|
+
|
|
3184
|
+
### Delivery is Best-Effort
|
|
3185
|
+
|
|
3186
|
+
A successful start-application does not guarantee delivery. Events can be missed — for example when your endpoint answers with a non-retryable 4xx, when retries run out, or when registration fails after the application was created. Treat webhooks as best-effort notifications rather than a guaranteed feed. If you opted in and see no events for an opportunity, contact InstaBrain.
|
|
3187
|
+
|
|
3188
|
+
---
|
|
3189
|
+
|
|
2872
3190
|
## Shared methods — GIGDB, ADB & Final Expense
|
|
2873
3191
|
|
|
2874
|
-
These methods apply to **GIGDB, ADB, and Final Expense**. IB Term and Pure Term use the frontend links returned by Start Application and do **not** call these.
|
|
3192
|
+
These methods apply to **GIGDB, ADB, and Final Expense**. IB Term and Pure Term use the frontend links returned by Start Application and do **not** call these — with one exception: [`saveEftPayment()`](#save-eft-payment) applies to **every product**, including IB Term and Pure Term. The credit-card iframe, the SecureSign methods, and `finalSubmit()` remain GIGDB / ADB / Final Expense only.
|
|
2875
3193
|
|
|
2876
3194
|
---
|
|
2877
3195
|
|
|
@@ -3023,7 +3341,7 @@ Each maps to a distinct `APIErrorCode` with its own `getUserFriendlyMessage()`.
|
|
|
3023
3341
|
**Method:** `client.saveEftPayment(request)` · **Type:** `ThirdPartyEftPaymentReq`
|
|
3024
3342
|
|
|
3025
3343
|
|
|
3026
|
-
Saves bank account details for premium payment
|
|
3344
|
+
Saves bank account details for premium payment — shared by **every product**. Call after Start Application and, for full-flow products, before Prepare Docs. Once saved, quote updates are blocked. Send `payLaterDate` to schedule the draft for a future date ([Pay Later](#pay-later)).
|
|
3027
3345
|
|
|
3028
3346
|
|
|
3029
3347
|
***
|
|
@@ -3036,8 +3354,26 @@ Saves bank account details for premium payment. Call after Start Application, be
|
|
|
3036
3354
|
| `accountHolderName` | `string` | Yes | `Account holder name is required.` / `Account holder name must be 100 characters or fewer.` / `Account holder name may only contain letters, spaces, hyphens, and apostrophes.` |
|
|
3037
3355
|
| `routingNumber` | `string` | Yes | `Routing number is required.` / `Routing number must be 9 digits.` |
|
|
3038
3356
|
| `accountNumber` | `string` | Yes | `Account number is required.` / `Account number must be 4 to 17 digits.` |
|
|
3357
|
+
| `payLaterDate` | `string` (`yyyy-MM-dd`) | No | `Pay later is not available for this opportunity.` (`PayLaterNotAvailable`) / `PayLaterDate must be after today and within the pay later window for this opportunity.` (`InvalidPaymentScheduledDate`) |
|
|
3039
3358
|
|
|
3040
|
-
> `accountHolderName`
|
|
3359
|
+
> `accountHolderName` must be at most 100 characters **and** pass the name format rules — in practice about **35** characters: letters, spaces, hyphens, apostrophes, and `*`; no consecutive special characters; and it must end with a letter. A name that fails these rules, including one longer than about 35 characters, returns `Account holder name may only contain letters, spaces, hyphens, and apostrophes.`
|
|
3360
|
+
|
|
3361
|
+
|
|
3362
|
+
***
|
|
3363
|
+
|
|
3364
|
+
### Pay Later
|
|
3365
|
+
|
|
3366
|
+
Send `payLaterDate` to schedule the bank draft for a future date; omit it to draft immediately. There is no separate flag — sending the date is the opt-in.
|
|
3367
|
+
|
|
3368
|
+
- **Format:** `yyyy-MM-dd`, date only. Don't send a time or a UTC offset: an offset can shift the value to a different day before the date part is taken.
|
|
3369
|
+
- **"Today" is the current UTC date,** not your local date. In the US evening UTC is often already the next day, so a local "tomorrow" can be "today" in UTC — and be rejected. Compute the date in UTC.
|
|
3370
|
+
- **Earliest:** tomorrow (UTC). Today or earlier returns `InvalidPaymentScheduledDate`.
|
|
3371
|
+
- **Latest:** whichever comes first of the platform's pay later window — **30 days** after today (UTC) by default — and the applicant's next birthday. The birthday itself is allowed.
|
|
3372
|
+
- **On the applicant's birthday (UTC date)** no `payLaterDate` is accepted. Omit it to draft immediately, or retry the next day (UTC), when the full window applies again.
|
|
3373
|
+
- **`Time-Zone` header:** the SDK doesn't send one. If you add one through `InstaBrainConfig.headers`, it cannot widen the range — and when its date differs from the UTC date, dates beyond the window (30 days by default) after the header's date are rejected too.
|
|
3374
|
+
- **Availability:** when Pay Later is switched off on the platform, any `payLaterDate` returns `PayLaterNotAvailable`. Retry without it to draft immediately. The switch is environment-wide — despite the message wording ("…for this opportunity"), it is not specific to the opportunity.
|
|
3375
|
+
|
|
3376
|
+
The SDK does not check the window itself: it depends on per-opportunity data and server settings. Handle the two error codes below instead.
|
|
3041
3377
|
|
|
3042
3378
|
|
|
3043
3379
|
***
|
|
@@ -3048,6 +3384,7 @@ Saves bank account details for premium payment. Call after Start Application, be
|
|
|
3048
3384
|
2. **EFT and credit card are mutually exclusive per `opportunityId`.** A successful payment that already exists — a prior EFT save, or a card that has already been charged — returns `PaymentAlreadyMade`. After a successful EFT save, [`getCcPaymentIframeUrl()`](#get-credit-card-iframe-url) returns `EftPaymentAlreadyCompleted`.
|
|
3049
3385
|
3. **No application-readiness gate here.** Unlike `getCcPaymentIframeUrl()`, this endpoint does not require Start Application to be fully complete at request validation — it only checks that the opportunity exists and that payment has not already completed. Still call it after Start Application in the integration flow.
|
|
3050
3386
|
4. A successful save **satisfies the payment prerequisite for [`finalSubmit()`](#final-submit)** — no charge runs again at final submit, and neither `paymentNotMade` nor `LatestPaymentNotSuccessful` will be returned for payment reasons.
|
|
3387
|
+
5. **Pay Later** is EFT only — see [Pay Later](#pay-later) for the allowed range.
|
|
3051
3388
|
|
|
3052
3389
|
|
|
3053
3390
|
***
|
|
@@ -3056,8 +3393,11 @@ Saves bank account details for premium payment. Call after Start Application, be
|
|
|
3056
3393
|
|
|
3057
3394
|
| Code | When |
|
|
3058
3395
|
|---|---|
|
|
3059
|
-
| `InvalidRequestFormat` |
|
|
3396
|
+
| `InvalidRequestFormat` | A format failure on `opportunityId`, `accountHolderName`, `routingNumber`, or `accountNumber`, or `opportunityId` does not exist — inspect `value.fields`. `payLaterDate` failures use the two codes below |
|
|
3060
3397
|
| `PaymentAlreadyMade` | A successful payment already exists for this opportunity (prior EFT save, or a card already charged) |
|
|
3398
|
+
| `InvalidPaymentScheduledDate` | `payLaterDate` is outside the allowed range — see [Pay Later](#pay-later). Message under `value.fields.PayLaterDate` |
|
|
3399
|
+
| `PayLaterNotAvailable` | `payLaterDate` was sent while Pay Later is switched off on the platform. Retry without it. Message under `value.fields.PayLaterDate` |
|
|
3400
|
+
| `ErrorInSaveEftPaymentDetails` | The EFT details could not be saved |
|
|
3061
3401
|
|
|
3062
3402
|
> A credit card that was only **captured** and not yet charged does not trigger `PaymentAlreadyMade` at request validation. Do not rely on that edge case — treat the two payment methods as mutually exclusive.
|
|
3063
3403
|
|
|
@@ -3066,7 +3406,18 @@ Saves bank account details for premium payment. Call after Start Application, be
|
|
|
3066
3406
|
|
|
3067
3407
|
### Response
|
|
3068
3408
|
|
|
3069
|
-
`flagStatus: true` with `value
|
|
3409
|
+
`flagStatus: true` on success, with `value` holding a confirmation message and per-field validation results:
|
|
3410
|
+
|
|
3411
|
+
```json
|
|
3412
|
+
{
|
|
3413
|
+
"message": "Account Details saved successfully!",
|
|
3414
|
+
"accountNameValidation": { "flagAnswerValidation": true, "answerValidationMessage": null },
|
|
3415
|
+
"accountNumberValidation": { "flagAnswerValidation": true, "answerValidationMessage": null },
|
|
3416
|
+
"routingNumberValidation": { "flagAnswerValidation": true, "answerValidationMessage": null }
|
|
3417
|
+
}
|
|
3418
|
+
```
|
|
3419
|
+
|
|
3420
|
+
> `saveEftPayment()` is typed `Promise<boolean>` for backward compatibility, but at runtime it resolves to this `value` object. Treat any resolved value as success — failures throw.
|
|
3070
3421
|
|
|
3071
3422
|
|
|
3072
3423
|
***
|
|
@@ -3083,6 +3434,33 @@ await client.saveEftPayment({
|
|
|
3083
3434
|
// After this point, quote updates are blocked
|
|
3084
3435
|
```
|
|
3085
3436
|
|
|
3437
|
+
**Pay Later** — draft on a future date, computed in UTC:
|
|
3438
|
+
|
|
3439
|
+
```typescript
|
|
3440
|
+
import { APIErrorCode, APIValidationError } from '@instabrain-sdks/api-client';
|
|
3441
|
+
|
|
3442
|
+
// Earliest allowed date is tomorrow in UTC — 'yyyy-MM-dd'
|
|
3443
|
+
const tomorrowUtc = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString().slice(0, 10);
|
|
3444
|
+
|
|
3445
|
+
try {
|
|
3446
|
+
await client.saveEftPayment({
|
|
3447
|
+
opportunityId,
|
|
3448
|
+
accountHolderName: 'Jane Doe',
|
|
3449
|
+
routingNumber: '021000021',
|
|
3450
|
+
accountNumber: '123456789012',
|
|
3451
|
+
payLaterDate: tomorrowUtc
|
|
3452
|
+
});
|
|
3453
|
+
} catch (err) {
|
|
3454
|
+
if (err instanceof APIValidationError && err.isErrorType(APIErrorCode.PayLaterNotAvailable)) {
|
|
3455
|
+
// Pay Later is switched off — save again without payLaterDate to draft now
|
|
3456
|
+
} else if (err instanceof APIValidationError && err.isErrorType(APIErrorCode.InvalidPaymentScheduledDate)) {
|
|
3457
|
+
console.log(err.response?.value?.fields?.PayLaterDate); // outside the allowed range
|
|
3458
|
+
} else {
|
|
3459
|
+
throw err;
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
```
|
|
3463
|
+
|
|
3086
3464
|
---
|
|
3087
3465
|
|
|
3088
3466
|
## Prepare Docs & Get Delivery Channels
|
|
@@ -3482,34 +3860,74 @@ All three methods accept `AgentPortalReq`.
|
|
|
3482
3860
|
| Field | Type | Required | Description |
|
|
3483
3861
|
|---|---|---|---|
|
|
3484
3862
|
| `pageSize` | `number` | Yes | Items per page — do not pass `0` or `null` |
|
|
3485
|
-
| `pageIndex` | `number` | Yes | Page
|
|
3486
|
-
| `startDate` | `string` (ISO) | Conditional | Start of date range —
|
|
3863
|
+
| `pageIndex` | `number` | Yes | Page to retrieve; the first page is `1` — do not pass `0` or `null` |
|
|
3864
|
+
| `startDate` | `string` (ISO) | Conditional | Start of date range — send together with `endDate`; otherwise use `dayCount` |
|
|
3487
3865
|
| `endDate` | `string` (ISO) | Conditional | End of date range — required with `startDate` |
|
|
3488
|
-
| `dayCount` | `number` | Conditional | Last N days —
|
|
3489
|
-
| `userTimeZone` | `string` | No | IANA
|
|
3490
|
-
| `sort.value` | `string` | No |
|
|
3866
|
+
| `dayCount` | `number` | Conditional | Last N days — use when `startDate`/`endDate` are not sent (for `getSales()`, sending neither returns all sales up to today) |
|
|
3867
|
+
| `userTimeZone` | `string` | No | IANA time zone the dates are read in, e.g. `"America/Chicago"`; defaults to UTC |
|
|
3868
|
+
| `sort.value` | `string` | No | Field to sort by (not case sensitive) — see [`getSales()` sort fields](#getsales-filter-and-sort-fields) |
|
|
3491
3869
|
| `sort.sortDescending` | `boolean` | No | `true` = descending order |
|
|
3492
|
-
| `filters[]` | `object[]` | No | `{ field, operator, value }` — see
|
|
3870
|
+
| `filters[]` | `object[]` | No | `{ field, operator, value }` — see [Filters](#filters--reportfilteroperator) below |
|
|
3493
3871
|
| `searchParam` | `string` | No | Text search across all response fields except `riders` |
|
|
3494
3872
|
|
|
3495
3873
|
|
|
3496
3874
|
***
|
|
3497
3875
|
|
|
3498
|
-
### Filters — `
|
|
3876
|
+
### Filters — `ReportFilterOperator`
|
|
3877
|
+
|
|
3878
|
+
Each `filters[]` item has three required fields: `field`, `operator` and `value`. `value` is always a string. Filters are combined with **AND** — except in `getSales()`, where `agentName` and `agencyName` sent together return sales matching either one.
|
|
3879
|
+
|
|
3880
|
+
The API takes **string** operators. Pass a `ReportFilterOperator` member or the literal string:
|
|
3881
|
+
|
|
3882
|
+
| `ReportFilterOperator` member | Value sent | Meaning | `value` format | Example `value` |
|
|
3883
|
+
|---|---|---|---|---|
|
|
3884
|
+
| `Equal` | `'eq'` | Equals | A single value | `"25000"` |
|
|
3885
|
+
| `GreaterThan` / `GreaterThanOrEqual` | `'gt'` / `'gte'` | Greater than / or equal | A single number | `"1000"` |
|
|
3886
|
+
| `LessThan` / `LessThanOrEqual` | `'lt'` / `'lte'` | Less than / or equal | A single number | `"1000"` |
|
|
3887
|
+
| `Like` | `'like'` | Contains the text | A single text value | `"Jane"` |
|
|
3888
|
+
| `In` | `'IN'` | Matches any of the values | Comma-separated values | `"Preferred, Standard"` |
|
|
3889
|
+
| `Between` | `'between'` | Within a date range (inclusive) | Two comma-separated dates: start, end | `"2026-11-01, 2026-11-03"` |
|
|
3890
|
+
|
|
3891
|
+
For `between`, the dates are read in `userTimeZone` and the end date includes the whole day. The `availableFilters` list in each response uses the same string operators; an entry whose `value` is `null` accepts any value.
|
|
3892
|
+
|
|
3893
|
+
```typescript
|
|
3894
|
+
import { ReportFilterOperator } from '@instabrain-sdks/api-client';
|
|
3895
|
+
|
|
3896
|
+
const sales = await client.getSales({
|
|
3897
|
+
dayCount: 90,
|
|
3898
|
+
pageIndex: 1,
|
|
3899
|
+
pageSize: 20,
|
|
3900
|
+
sort: { value: 'createdOn', sortDescending: true },
|
|
3901
|
+
filters: [
|
|
3902
|
+
{ field: 'proTitle', operator: ReportFilterOperator.In, value: 'InstaBrain Pure Term, InstaBrain Guaranteed Issue' },
|
|
3903
|
+
{ field: 'rateClass', operator: 'IN', value: 'Preferred Plus, Preferred' },
|
|
3904
|
+
],
|
|
3905
|
+
});
|
|
3906
|
+
```
|
|
3907
|
+
|
|
3908
|
+
> **`SQLOperator` is deprecated.** Its numeric values (`SQLOperator.In` = `9`, …) are not what the API accepts: a filter sent with a number is answered with **HTTP 500**. Replace `SQLOperator.X` with `ReportFilterOperator.X` (`Equal`, `GreaterThan`, `GreaterThanOrEqual`, `LessThan`, `LessThanOrEqual`, `In`); `Contains` becomes `Like`. `NotEqual`, `StartsWith`, `EndsWith` and `NotIn` have no API equivalent. The enum still compiles and will be removed in the next major version.
|
|
3909
|
+
|
|
3910
|
+
|
|
3911
|
+
***
|
|
3912
|
+
|
|
3913
|
+
### `getSales()` filter and sort fields
|
|
3914
|
+
|
|
3915
|
+
Send a filter only with one of these fields, written exactly as shown. The response's `availableFilters` may list other fields; they are not supported as filters.
|
|
3499
3916
|
|
|
3500
|
-
|
|
|
3917
|
+
| Field | Operators | Value |
|
|
3501
3918
|
|---|---|---|
|
|
3502
|
-
| `
|
|
3503
|
-
| `
|
|
3504
|
-
| `
|
|
3505
|
-
| `
|
|
3506
|
-
| `
|
|
3507
|
-
| `
|
|
3508
|
-
| `
|
|
3509
|
-
| `
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3919
|
+
| `proTitle` | `IN` | Comma-separated product titles, e.g. `InstaBrain Pure Term, InstaBrain Guaranteed Issue` |
|
|
3920
|
+
| `rateClass` | `IN` | Comma-separated rate classes: `Preferred Plus`, `Preferred`, `Standard Extra`, `Standard`, `Guaranteed`, `Rated C`, `Rated D` |
|
|
3921
|
+
| `paymentMethod` | `eq`, `IN` | Payment method **code**: `302` (Credit Card) or `303` (EFT); with `IN`, e.g. `302, 303`. The response shows the name (`EFT`), but the filter takes only the code. |
|
|
3922
|
+
| `salesDate` | `between` | `start, end` dates, e.g. `2026-11-01, 2026-11-03` |
|
|
3923
|
+
| `targetPremium` | `eq`, `gt`, `gte`, `lt`, `lte` | A number |
|
|
3924
|
+
| `faceAmount` | `eq`, `gt`, `gte`, `lt`, `lte` | A number |
|
|
3925
|
+
| `agentName` | `like`, `IN` | Text contained in the agent's full name; with `IN`, a comma-separated list |
|
|
3926
|
+
| `agencyName` | `like`, `IN` | Text contained in the agency name; with `IN`, a comma-separated list |
|
|
3927
|
+
|
|
3928
|
+
**Sort fields** (`sort.value`, not case sensitive): `createdOn`, `policyNumber`, `proTitle`, `firstName`, `age`, `faceAmount`, `targetPremium`, `paymentAmount`, `paymentCreatedOn`, `userFirstName` (the agent's first name) and `agencyName`. Other fields, such as `applicationStatus` and `rateClass`, cannot be used for sorting.
|
|
3929
|
+
|
|
3930
|
+
For `getProspects()` and `getApplications()`, use the fields and operators returned in the response's `availableFilters`.
|
|
3513
3931
|
|
|
3514
3932
|
|
|
3515
3933
|
***
|
|
@@ -3522,7 +3940,54 @@ All three methods accept `AgentPortalReq`.
|
|
|
3522
3940
|
| `getSales()` | `{ applicationCount: number, salesReport: ThirdPartySalesReport[], totalPremiumAmount: number }` |
|
|
3523
3941
|
| `getApplications()` | `{ applicationCount: number, applications: ThirdPartyApplicationsReport[] }` |
|
|
3524
3942
|
|
|
3525
|
-
> `applicationStatus` format: `"{Status} {RateClass}: {Assessment Factor}"
|
|
3943
|
+
> **`getApplications()`** — `applicationStatus` format: `"{Status} - {RateClass} : {Assessment Factor}"`, e.g. `"InProgress - Preferred : Drug Use"`. The rate class and assessment factor are included only when available. Unlike `getSales()`, `getApplications()` keeps the rate class inside `applicationStatus`.
|
|
3944
|
+
|
|
3945
|
+
|
|
3946
|
+
***
|
|
3947
|
+
|
|
3948
|
+
### `getSales()` sale fields
|
|
3949
|
+
|
|
3950
|
+
> **Changed (backend IBS-185, SDK 2.8.0):** in each `salesReport` item the rate class is **no longer part of `applicationStatus`**. It is returned in the separate `rateClass` field.
|
|
3951
|
+
>
|
|
3952
|
+
> **Migration:** if your integration parses the rate class out of the `getSales()` `applicationStatus`, read `rateClass` instead. If you only display `applicationStatus`, no code change is needed, but the text no longer contains the rate class.
|
|
3953
|
+
|
|
3954
|
+
**`applicationStatus`** — the single current status of the policy: `{Status}`, followed by ` : {Assessment Factor}` (a colon with a space on each side) only when an assessment factor applies.
|
|
3955
|
+
|
|
3956
|
+
| Example | Meaning |
|
|
3957
|
+
|---|---|
|
|
3958
|
+
| `"Approved : Drug Use"` | Status with an assessment factor |
|
|
3959
|
+
| `"Placed (Inforce)"` | Status only (no assessment factor, no separator) |
|
|
3960
|
+
|
|
3961
|
+
- When an **After-Sale status** has been received for the policy, `applicationStatus` returns it: `Submitted`, `Approved`, `Issued`, `Placed (Inforce)`, `Not Taken (Inforce)`, `Declined`, `Closed`, `Terminated`, `Lapsed`.
|
|
3962
|
+
- Otherwise it returns the normal application status (e.g. `Approved`, `Scheduled`), unchanged from before.
|
|
3963
|
+
- `Approved` can come from either source. Treat `applicationStatus` as the single current status and do not assume only `Approved` / `Scheduled` will be returned.
|
|
3964
|
+
- Assessment factors: `Diabetes`, `Health`, `Smoking Cessation Medication`, `ChildRider`, `Weight change`, `Primary Physician`, `Prequalification`, `Beneficiary`, `Other Life Insurance`, `Driving`, `Travel`, `Personal Info`, `Lifestyle`, `Height and Weight`, `Drug Use`, `Medical and/or Lifestyle Factors – 3rd Party + Follow-Ups`, `Employment`, `Medical and/or Lifestyle Factors in 3rd Party Data`, `Medical and/or Lifestyle Factors`.
|
|
3965
|
+
|
|
3966
|
+
Fields on each `ThirdPartySalesReport` added or changed in 2.8.0 (all optional and nullable, response-only):
|
|
3967
|
+
|
|
3968
|
+
| Field | Type | Description |
|
|
3969
|
+
|---|---|---|
|
|
3970
|
+
| `applicationStatus` | `string \| null` | Current status as described above — **without** the rate class. |
|
|
3971
|
+
| `rateClass` | `string \| null` | Rate class of the policy: `Preferred Plus`, `Preferred`, `Standard`, `Standard Extra`, `Guaranteed`, `Rated C`, `Rated D`. `null` when no rate class applies. |
|
|
3972
|
+
| `pivotSourceOpportunityUid` | `string \| null` | Opportunity UID of the first application in a Pivot chain. For Term → Pure Term → Accidental Death Benefit, the ADB sale carries the Term application's UID. `null` when the sale was not pivoted. |
|
|
3973
|
+
| `pivotedFrom` | `string \| null` | Title of the product this application was pivoted from, e.g. `InstaBrain Final Expense`. `null` when not pivoted. |
|
|
3974
|
+
| `pivotReason` | `string \| null` | Why the source application was declined, which started the Pivot flow. `null` when not pivoted. |
|
|
3975
|
+
| `paymentEffectiveDate` | `string \| null` | Effective date of the policy, date only (`yyyy-MM-dd`). `null` when not available. |
|
|
3976
|
+
|
|
3977
|
+
Sorting by `applicationStatus` or `rateClass` is not supported. To list sales of given rate classes, filter on `rateClass` with `IN` — see [`getSales()` filter and sort fields](#getsales-filter-and-sort-fields).
|
|
3978
|
+
|
|
3979
|
+
```typescript
|
|
3980
|
+
const sales = await client.getSales({ dayCount: 30, pageIndex: 1, pageSize: 20 });
|
|
3981
|
+
|
|
3982
|
+
for (const sale of sales.salesReport ?? []) {
|
|
3983
|
+
console.log(sale.policyNumber, sale.applicationStatus, sale.rateClass);
|
|
3984
|
+
// e.g. "IB0000123456" "Approved : Drug Use" "Standard"
|
|
3985
|
+
|
|
3986
|
+
if (sale.pivotedFrom) {
|
|
3987
|
+
console.log(`Pivoted from ${sale.pivotedFrom} (${sale.pivotReason})`);
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
```
|
|
3526
3991
|
|
|
3527
3992
|
---
|
|
3528
3993
|
|
|
@@ -3883,7 +4348,10 @@ Some enum members remain in the package for backward compatibility but are **not
|
|
|
3883
4348
|
|
|
3884
4349
|
| Code | String Value | Products | When |
|
|
3885
4350
|
|---|---|---|---|
|
|
3886
|
-
| `PaymentAlreadyMade` | `'PaymentAlreadyMade'` | ADB, GIGDB, Final Expense | `update*Quote()` or `saveEftPayment()` when a **successful** payment already exists — a prior EFT save, or a card already charged. A card that was only captured and not yet charged does not trigger this |
|
|
4351
|
+
| `PaymentAlreadyMade` | `'PaymentAlreadyMade'` | All (`saveEftPayment()`); ADB, GIGDB, Final Expense (`update*Quote()`) | `update*Quote()` or `saveEftPayment()` when a **successful** payment already exists — a prior EFT save, or a card already charged. A card that was only captured and not yet charged does not trigger this |
|
|
4352
|
+
| `InvalidPaymentScheduledDate` | `'InvalidPaymentScheduledDate'` | All | `saveEftPayment()` — `payLaterDate` is outside the allowed range: today (UTC) or earlier, beyond the pay later window (30 days by default), after the applicant's next birthday, or sent on the birthday (UTC). Message under `value.fields.PayLaterDate` — see [Pay Later](#pay-later) |
|
|
4353
|
+
| `PayLaterNotAvailable` | `'PayLaterNotAvailable'` | All | `saveEftPayment()` — `payLaterDate` was sent while Pay Later is switched off on the platform. Retry without it to draft immediately. Message under `value.fields.PayLaterDate` |
|
|
4354
|
+
| `ErrorInSaveEftPaymentDetails` | `'ErrorInSaveEftPaymentDetails'` | All | `saveEftPayment()` — the EFT details could not be saved |
|
|
3887
4355
|
| `EftPaymentAlreadyCompleted` | `'EftPaymentAlreadyCompleted'` | ADB, GIGDB, Final Expense | `getCcPaymentIframeUrl()` after a successful EFT save — the two methods are mutually exclusive per opportunity |
|
|
3888
4356
|
| `ApplicationNotReady` | `'ApplicationNotReady'` | ADB, GIGDB, Final Expense | `getCcPaymentIframeUrl()` or `prepareDocsAndGetDeliveryChannels()` before Start Application has completed successfully. **Retryable** — complete Start Application, then call again |
|
|
3889
4357
|
|
|
@@ -3938,12 +4406,10 @@ Not documented as active responses. Kept on `APIErrorCode` for older integration
|
|
|
3938
4406
|
| `HeightNotValid` | `'HeightNotValid'` |
|
|
3939
4407
|
| `DocumentsNotViewed` | `'DocumentsNotViewed'` |
|
|
3940
4408
|
| `ThirdPartyQuoteError` | `'ThirdPartyQuoteError'` |
|
|
3941
|
-
| `ErrorInSaveEftPaymentDetails` | `'ErrorInSaveEftPaymentDetails'` |
|
|
3942
4409
|
| `InvalidBirthCountry` | `'InvalidBirthCountry'` |
|
|
3943
4410
|
| `InvalidBirthState` | `'InvalidBirthState'` |
|
|
3944
4411
|
| `InvalidResidenceState` | `'InvalidResidenceState'` |
|
|
3945
4412
|
| `OneOfTheExistingCoveragesQuestionsNotFound` | `'OneOfTheExistingCoveragesQuestionsNotFound'` |
|
|
3946
|
-
| `InvalidPaymentScheduledDate` | `'InvalidPaymentScheduledDate'` |
|
|
3947
4413
|
| `InvalidQuoteParameters` | `'InvalidQuoteParameters'` |
|
|
3948
4414
|
| `InvalidStateCode` | `'InvalidStateCode'` |
|
|
3949
4415
|
| `InvalidAdbAgeRange` | `'InvalidAdbAgeRange'` |
|