@instabrain-sdks/api-client 2.2.1 → 2.2.2

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.
Files changed (2) hide show
  1. package/README.md +1639 -1639
  2. package/package.json +54 -54
package/README.md CHANGED
@@ -1,1639 +1,1639 @@
1
- # @instabrain-sdks/api-client
2
-
3
- [npm version](https://badge.fury.io/js/%40instabrain-sdks%2Fapi-client)
4
-
5
- TypeScript/Node.js SDK for integrating with the InstaBrain insurance platform. Covers three products: **GIGDB** (Guaranteed Issue Graded Death Benefit), **ADB** (Accidental Death Benefit), and IB Term life insurance.
6
-
7
- **Primary products for third-party integration: GIGDB and ADB.**
8
-
9
- Credentials (`userId` and `accessToken`) are provisioned during onboarding.
10
-
11
- ---
12
-
13
- ## Table of Contents
14
-
15
- 1. [Installation](#installation)
16
- 2. [Requirements](#requirements)
17
- 3. [Authentication](#authentication)
18
- 4. [Product Comparison](#product-comparison)
19
- 5. [GIGDB Flow](#gigdb-flow)
20
- 6. [ADB Flow](#adb-flow)
21
- 7. [IB Term Flow](#ib-term-flow)
22
- 8. [Secure Sign Flow](#secure-sign-flow)
23
- 9. [Final Submit](#final-submit)
24
- 10. [Reporting API](#reporting-api)
25
- 11. [Request Type Reference](#request-type-reference)
26
- 12. [Response Type Reference](#response-type-reference)
27
- 13. [Enums and Constants](#enums-and-constants)
28
- 14. [Beneficiary Reference](#beneficiary-reference)
29
- 15. [Error Handling](#error-handling)
30
- 16. [APIErrorCode Reference](#apierrorcode-reference)
31
- 17. [Environment Configuration](#environment-configuration)
32
- 18. [Token Management](#token-management)
33
- 19. [Examples Directory](#examples-directory)
34
- 20. [Changelog](#changelog)
35
- 21. [Support](#support)
36
-
37
- ---
38
-
39
- ## Installation
40
-
41
- ```bash
42
- npm install @instabrain-sdks/api-client
43
- ```
44
-
45
- > **Note:** This is a restricted-access package. Access must be granted during the InstaBrain onboarding process.
46
-
47
- ---
48
-
49
- ## Requirements
50
-
51
- - Node.js >= 14.0.0
52
- - TypeScript >= 4.0 *(optional - the SDK ships with full type definitions)*
53
-
54
- ---
55
-
56
- ## Authentication
57
-
58
- Credentials are issued during onboarding:
59
-
60
-
61
- | Credential | Type | Description |
62
- | ------------- | --------------- | ------------------------ |
63
- | `userId` | `number` | Your account user ID |
64
- | `accessToken` | `string` (UUID) | Your secret access token |
65
-
66
-
67
- ```typescript
68
- import { InstaBrainClient } from '@instabrain-sdks/api-client';
69
-
70
- const client = InstaBrainClient.forEnvironment('sandbox');
71
- const jwt = await client.authenticate(userId, accessToken);
72
- // JWT is stored internally and automatically attached to all subsequent calls
73
- // No need to manually set it after authenticate()
74
- ```
75
-
76
- > Call `authenticate()` once at startup. The returned JWT is stored internally - every subsequent API call uses it automatically.
77
-
78
- ---
79
-
80
- ## Product Comparison
81
-
82
-
83
- | Feature | GIGDB | ADB | IB Term |
84
- | -------------------- | ------------------------- | ------------------------------- | --------------------------------------------- |
85
- | Eligible ages | 50–85 | 20–59 | 18–60 |
86
- | Face amount | $5,000–$25,000 | $50,000-$300,000 | $50,000–$1,000,000 (age-scaled) |
87
- | Medical exam | No | No | No (build chart used) |
88
- | Smoker/tobacco field | `isSmoker` (required) | N/A | `flagTobaccoUse` (required) |
89
- | Birth jurisdiction | Yes (`birthJurisdiction`) | No | No |
90
- | App response type | `ThirdPartyStartAppResp` | `ThirdPartyAdbStartAppResp` | `ThirdPartyStartAppResp` |
91
- | `isDeclined` | Yes | Yes | No |
92
- | `isQuoteChanged` | Yes | No | No |
93
- | Response links | None | None | `agentLink`, `eAppAgentLink`, `applicantLink` |
94
- | EFT method | `saveEftPayment()` | `saveEftPayment()` | N/A |
95
- | Unavailable states | NY, MT | MA, NH, AK *(CA: next release)* | WY, NY |
96
- | Status | **Primary** | **Primary** | Secondary *(not fully live yet)* |
97
-
98
-
99
- ---
100
-
101
- ## GIGDB Flow
102
-
103
- > **Not available in:** NY, MT
104
-
105
- GIGDB (Guaranteed Issue Graded Death Benefit) is a simplified-issue whole life product for ages 50–85 with no medical exam.
106
-
107
- ### Complete flow
108
-
109
- ```
110
- getGigdbQuote()
111
- ↓
112
- startGigdbApplication()
113
- ↓
114
- [if isDeclined = true] → stop - applicant not eligible
115
- [if isQuoteChanged = true] → getExistingGigdbQuote() (conditional)
116
- ↓
117
- updateGigdbQuote() ← optional; MUST be called before saveEftPayment
118
- ↓
119
- saveEftPayment() ← quote cannot be updated after this point
120
- ↓
121
- prepareDocsAndGetDeliveryChannels()
122
- ↓
123
- sendPinAndGetDocumentsLink() → verifyPin()
124
- ↓
125
- finalSubmit()
126
- ```
127
-
128
- ### Step 1 - `getGigdbQuote(request: ThirdPartyGigdbQuoteRequest)`
129
-
130
- ```typescript
131
- import { InstaBrainClient, Gender, PaymentFrequency } from '@instabrain-sdks/api-client';
132
-
133
- const quoteResp = await client.getGigdbQuote({
134
- faceAmount: 15000,
135
- gender: Gender.Female,
136
- stateCode: 'TX',
137
- age: 65,
138
- dateOfBirth: null,
139
- paymentFreq: PaymentFrequency.Monthly,
140
- isSmoker: false,
141
- firstName: 'Jane',
142
- lastName: 'Doe',
143
- email: 'jane.doe@example.com',
144
- phoneNum: null
145
- });
146
-
147
- const { quoteResponseId, quoteAmount } = quoteResp.selectedQuote;
148
- ```
149
-
150
- ### Step 2 - `startGigdbApplication(request: ThirdPartyGigdbAppReq)`
151
-
152
- ```typescript
153
- import { BeneficiaryType, BeneficiaryRelationship } from '@instabrain-sdks/api-client';
154
-
155
- const appResp = await client.startGigdbApplication({
156
- quoteResponseId: quoteResp.selectedQuote.quoteResponseId,
157
- firstName: 'Jane',
158
- lastName: 'Doe',
159
- email: 'jane.doe@example.com',
160
- phoneNumber: '5551234567',
161
- isUsCitizen: true,
162
- isPayerAlsoOwnerAndInsured: true,
163
- isLegalUsResident: true,
164
- address: {
165
- addressLine1: '123 Main St',
166
- city: 'Austin',
167
- state: 'TX',
168
- zipcode: '73301'
169
- },
170
- dateOfBirth: '1958-06-15',
171
- socialSecurityNumber: '123-45-6789',
172
- birthJurisdiction: {
173
- state: 'TX',
174
- country: 'US'
175
- },
176
- isSmoker: false,
177
- nicotineInfo: null,
178
- hasExistingCoverage: false,
179
- willOtherCoverageBeReplacedOrFinanced: null,
180
- existingCoverageData: null,
181
- beneficiaryDetails: {
182
- beneficiaryType: BeneficiaryType.Person,
183
- beneficiaryPerson: {
184
- firstName: 'John',
185
- lastName: 'Doe',
186
- relationship: BeneficiaryRelationship.Spouse
187
- }
188
- }
189
- });
190
-
191
- if (appResp.isDeclined) {
192
- // Valid knockout - the applicant did not meet eligibility criteria.
193
- // This is NOT an error - do not throw.
194
- console.log('Application declined');
195
- return;
196
- }
197
-
198
- const { opportunityId, isQuoteChanged } = appResp;
199
- ```
200
-
201
- `**isDeclined: true**` - the applicant did not meet eligibility criteria. This is a valid response, not an error. Stop the flow.
202
-
203
- `**isQuoteChanged: true**` - the carrier adjusted the premium based on application data. Proceed to Step 3.
204
-
205
- #### State-specific Other Insurance fields (Q-08)
206
-
207
- > Third-party integrations must display the exact regulated question text below to applicants — paraphrasing is not sufficient. Source: Confluence page 687800321 (GIGDB Start Application API).
208
-
209
- When `hasExistingCoverage === true`, the following per-coverage flags are required for specific states:
210
-
211
- | State | Field on `existingCoverages[]` | Type | Exact applicant-facing question text |
212
- |-----------|------------------------------------|-----------|---------------------------------------|
213
- | MA | `requestsYieldIndices` | `boolean` | *Would you like to request yield indices for cash value policies?* |
214
- | OK | `notifyPresentInsurer` | `boolean` | *Please notify my present insurer(s) regarding this transaction?* |
215
- | DE / GA | `wantsPolicySummary` | `boolean` | *Do you want a policy summary statement from your existing insurer?* |
216
- | FL | `wantsComparativeInformationForm` | `boolean` | *Indicate whether or not you wish a Comparative Information Form from the proposed company and your existing insurer or insurers?* |
217
-
218
- For **RI** or **WV**, set `existingCoverageData.areExistingPoliciesIssuedByFidelity: boolean`.
219
- > Question text: *"Are any of your existing policies issued by Fidelity Life Association?"*
220
-
221
- When `willOtherCoverageBeReplacedOrFinanced === true` and the state is **KS** or **WA**, populate the new top-level `willOtherCoverageBeReplacedOrFinancedData` object:
222
-
223
- - **KS** → `areReplacedPoliciesIssuedByFidelity: boolean`
224
- > Question text: *"Are any of the policies you are considering replacing issued by Fidelity Life Association?"*
225
- - **WA** → `otherInsuranceReplacementData` — all 7 booleans are required; each `specify*` string is required when its boolean is `true`. See `GigdbOtherInsuranceReplacementData` for the full field list.
226
-
227
- ##### WA `otherInsuranceReplacementData` — exact question text per field
228
-
229
- | Field | Exact applicant-facing question text |
230
- |---|---|
231
- | `mayReduceBenefitsIncreasePremiums` | *Can there be reduced benefits or increased premiums in later years?* |
232
- | `specifyReduceBenefitsIncreasePremiums` | *Please explain* |
233
- | `hasNewPolicyCharges` | *Are there penalties, set up or surrender charges for the new policy?* |
234
- | `specifyNewPolicyCharges` | *Please explain, emphasizing any extra cost for early withdrawal.* |
235
- | `hasPriorPolicyCharges` | *Will there be penalties or surrender charges under the existing insurance as a result of the proposed transaction?* |
236
- | `specifyPriorPolicyCharges` | *Please explain* |
237
- | `hasTaxConsequences` | *Are there adverse tax consequences from the replacement under current tax law?* |
238
- | `specifyTaxConsequences` | *Please explain* |
239
- | `hasInterestConsiderations` | *Are interest earnings a consideration in this replacement?* |
240
- | `specifyInterestConsiderations` | *Please explain what portions of premiums or contributions will produce limited or no earnings. As pertinent, include the need for minimum deposits to enhance earnings, and the reduction of earnings that may result from set up charges, policy fees, and other factors.* |
241
- | `hasMinRequirementsBeforeInterest` | *Are minimum amounts required to be on deposit before excess interest will be paid?* |
242
- | `specifyMinRequirementsBeforeInterest`| *Please explain* |
243
- | `hasOtherAdverseEffects` | *Are there other short or long term effects from the replacement that might be materially adverse?* |
244
- | `specifyOtherAdverseEffects` | *Please explain* |
245
-
246
- Example WA payload (replacement disclosure):
247
-
248
- ```typescript
249
- willOtherCoverageBeReplacedOrFinancedData: {
250
- otherInsuranceReplacementData: {
251
- mayReduceBenefitsIncreasePremiums: true,
252
- specifyReduceBenefitsIncreasePremiums: 'Premiums may rise after year 5',
253
- hasNewPolicyCharges: true,
254
- specifyNewPolicyCharges: 'Surrender charges in years 1-3',
255
- hasPriorPolicyCharges: false,
256
- hasTaxConsequences: false,
257
- hasInterestConsiderations: true,
258
- specifyInterestConsiderations: 'Lower guaranteed rate on new policy',
259
- hasMinRequirementsBeforeInterest: false,
260
- hasOtherAdverseEffects: false
261
- }
262
- }
263
- ```
264
-
265
- ### Step 3 - Handle quote change (conditional)
266
-
267
- ```typescript
268
- let currentQuote = quoteResp.selectedQuote;
269
-
270
- if (isQuoteChanged) {
271
- const updatedQuoteResp = await client.getExistingGigdbQuote(opportunityId);
272
- currentQuote = updatedQuoteResp.selectedQuote;
273
- // Show the updated premium to the applicant before continuing
274
- }
275
- ```
276
-
277
- ### Step 4 - `updateGigdbQuote` (optional - must be called BEFORE `saveEftPayment`)
278
-
279
- If the applicant wants to change the face amount or payment frequency after the application has started:
280
-
281
- ```typescript
282
- const updatedQuoteResp = await client.updateGigdbQuote({
283
- opportunityId,
284
- faceAmount: 20000,
285
- paymentFreq: PaymentFrequency.Annually
286
- });
287
- // updatedQuoteResp.selectedQuote.quoteAmount reflects the new premium
288
- ```
289
-
290
- > **Important:** The quote cannot be updated after EFT payment details are saved. `updateGigdbQuote()` must be called before `saveEftPayment()`.
291
-
292
- ### Step 5 - `saveEftPayment(request: ThirdPartyEftPaymentReq)`
293
-
294
- ```typescript
295
- await client.saveEftPayment({
296
- opportunityId,
297
- accountHolderName: 'Jane Doe',
298
- routingNumber: '021000021',
299
- accountNumber: '123456789'
300
- });
301
- // After this point, the quote can no longer be updated.
302
- ```
303
-
304
- ### Steps 6–7 - Secure Sign → Final Submit
305
-
306
- See [Secure Sign Flow](#secure-sign-flow) and [Final Submit](#final-submit).
307
-
308
- ---
309
-
310
- ## ADB Flow
311
-
312
- > **Not available in:** MA, NH, AK
313
- >
314
- > **CA:** Supported. The ADB application requires the `occupation` field for California residents — populate it via `getAdbOccupationOptions()`.
315
-
316
- ADB (Accidental Death Benefit) provides coverage for accidental deaths for ages 20–59.
317
-
318
- ### Complete flow
319
-
320
- ```
321
- getAdbRiderDetails() ← check state availability & collect riderCodes
322
- ↓
323
- getAdbOccupationOptions() ← CA only — lookup occupation labels for the application
324
- ↓
325
- getAdbQuote()
326
- ↓
327
- startAdbApplication()
328
- ↓
329
- [if isDeclined = true] → stop - applicant not eligible
330
- ↓
331
- updateAdbQuote() ← optional — MUST be before saveEftPayment
332
- ↓
333
- getExistingAdbQuote() ← optional — fetch the current quote after update
334
- ↓
335
- saveEftPayment() ← shared with GIGDB; quote cannot be updated after this point
336
- ↓
337
- prepareDocsAndGetDeliveryChannels()
338
- ↓
339
- sendPinAndGetDocumentsLink() → verifyPin()
340
- ↓
341
- finalSubmit()
342
- ```
343
-
344
- ### Step 0 - `getAdbRiderDetails(stateCode: string)` (optional pre-step)
345
-
346
- Call before `getAdbQuote()` to check whether ADB is available in the applicant's state and to retrieve the `riderCode` values to pass into the quote request. Skip this step only if you already know which riders (if any) are available for the state.
347
-
348
- > **Note:** California (`CA`) is not supported — the API will return a 400 error for `stateCode = "CA"`.
349
-
350
- ```typescript
351
- import { InstaBrainClient } from '@instabrain-sdks/api-client';
352
-
353
- const riderDetails = await client.getAdbRiderDetails('TX');
354
-
355
- if (riderDetails.flagProductNotAvailableForState) {
356
- // ADB not available in this state — do not proceed to quote
357
- return;
358
- }
359
-
360
- // Collect riderCodes the user wants to include (may be an empty array)
361
- const selectedRiderCodes = riderDetails.riders.map(r => r.riderCode);
362
- // Pass selectedRiderCodes into ThirdPartyAdbQuoteRequest.riders
363
- ```
364
-
365
- > **Note:** `riders` may be an empty array even when `flagProductNotAvailableForState = false` — this means no optional riders are configured for that state.
366
-
367
- ### Step 0a - `getAdbOccupationOptions(query?: string)` (CA only)
368
-
369
- Search occupation labels for the ADB product. Required only when `address.state === "CA"` on the application — the `occupation` field on `ThirdPartyAdbAppReq` must be populated with one or more labels returned by this endpoint.
370
-
371
- ```typescript
372
- // Filter to a short list
373
- const matches = await client.getAdbOccupationOptions('nurse');
374
- // ['Registered Nurse', 'Nurse Practitioner', 'Licensed Practical Nurse', ...]
375
-
376
- // Or fetch the full list (omit the query)
377
- const allOccupations = await client.getAdbOccupationOptions();
378
- ```
379
-
380
- > Skip this call entirely for non-CA states — `occupation` should be omitted from the application request when the state is not CA.
381
-
382
- ### Step 1 - `getAdbQuote(request: ThirdPartyAdbQuoteRequest)`
383
-
384
- ```typescript
385
- import { InstaBrainClient, Gender, PaymentFrequency, AdbRiderType } from '@instabrain-sdks/api-client';
386
-
387
- const quoteResp = await client.getAdbQuote({
388
- faceAmount: 100000,
389
- gender: Gender.Male,
390
- stateCode: 'TX',
391
- age: 35,
392
- paymentFreq: PaymentFrequency.Monthly,
393
- riders: [AdbRiderType.FamilyADB],
394
- firstName: 'John',
395
- lastName: 'Smith',
396
- email: 'john.smith@example.com'
397
- });
398
-
399
- const { quoteResponseId } = quoteResp.selectedQuote;
400
- ```
401
-
402
- **Rider notes:**
403
-
404
- - `riders` is `AdbRiderType[]` - use the ADB-specific enum: `AdbRiderType.FamilyADB`, `AdbRiderType.ReturnOfPremium`, `AdbRiderType.InflationBenefit`
405
- - Do **not** reuse the Term product's `RiderType` enum — those values (`'ADB Rider'`, `'Dependent Child Rider'`) are display titles, not ADB rider codes
406
- - Rider availability varies by state - see [ADB Rider Availability](#adb-rider-availability)
407
-
408
- ### Step 2 - `startAdbApplication(request: ThirdPartyAdbAppReq)`
409
-
410
- ```typescript
411
- import { BeneficiaryType, BeneficiaryRelationship } from '@instabrain-sdks/api-client';
412
-
413
- const appResp = await client.startAdbApplication({
414
- quoteResponseId: quoteResp.selectedQuote.quoteResponseId,
415
- firstName: 'John',
416
- lastName: 'Smith',
417
- email: 'john.smith@example.com',
418
- phoneNumber: '5559876543',
419
- isUsCitizen: true,
420
- isPayerAlsoOwnerAndInsured: true, // must be true - knockout if false
421
- address: {
422
- addressLine1: '456 Oak Ave',
423
- city: 'Dallas',
424
- state: 'TX',
425
- zipcode: '75201'
426
- },
427
- dateOfBirth: '1988-03-20',
428
- socialSecurityNumber: '987-65-4321',
429
- hasExistingCoverage: false,
430
- beneficiaryDetails: {
431
- beneficiaryType: BeneficiaryType.Person,
432
- beneficiaryPerson: {
433
- firstName: 'Mary',
434
- lastName: 'Smith',
435
- relationship: BeneficiaryRelationship.Spouse
436
- }
437
- }
438
- });
439
-
440
- if (appResp.isDeclined) {
441
- // Valid knockout - stop the flow
442
- return;
443
- }
444
-
445
- const { opportunityId } = appResp;
446
- ```
447
-
448
- **Knockout rules - returns `isDeclined: true` (not an error, not thrown):**
449
-
450
- - `isPayerAlsoOwnerAndInsured === false` → declined
451
- - `isUsCitizen === false` AND `isLegalUsResident === false` → declined
452
-
453
- **California residents — `occupation` field required:**
454
-
455
- ```typescript
456
- const appResp = await client.startAdbApplication({
457
- // ...same fields as above, with CA address...
458
- address: { addressLine1: '...', city: 'Los Angeles', state: 'CA', zipcode: '90001' },
459
- occupation: ['Registered Nurse'], // populate from getAdbOccupationOptions()
460
- // ...
461
- });
462
- ```
463
-
464
- - `occupation` is an optional `string[]` on `ThirdPartyAdbAppReq`
465
- - Required only when `address.state === "CA"` — omit for all other states
466
- - Values must come from `getAdbOccupationOptions()`
467
-
468
- **District of Columbia residents — three top-level ACA acknowledgement booleans required:**
469
-
470
- > Third-party integrations must display the exact regulated question text below to applicants — paraphrasing is not sufficient. Source: Confluence page 699924481 (ADB Start Application API).
471
-
472
- | Field | Exact applicant-facing question text |
473
- |---|---|
474
- | `hasMedicalCoverage` | *Do you have comprehensive medical coverage including the minimum essential coverage required by the Affordable Care Act (ACA) or are you treated as having minimum essential coverage due to your status as a bona fide resident of any possession of the United States?* |
475
- | `understandsBenefits` | *Do you understand most supplemental only policies may not pay full benefits if your ACA compliant minimum essential coverage plan is not in force?* |
476
- | `understandsLimitedBenefits`| *Do you understand that the benefits provided under this policy may be limited?* |
477
-
478
- ```typescript
479
- await client.startAdbApplication({
480
- // ...same fields as above...
481
- address: { addressLine1: '100 7th St NW', city: 'Washington', state: 'DC', zipcode: '20001' },
482
- hasMedicalCoverage: true, // ACA minimum essential coverage
483
- understandsBenefits: true, // supplemental policy benefits acknowledgement
484
- understandsLimitedBenefits: true // limited benefits acknowledgement
485
- });
486
- ```
487
-
488
- **OK / FL / DE residents with existing coverage — per-coverage acknowledgement:**
489
-
490
- When `hasExistingCoverage === true`, set the corresponding flag on each `existingCoverages[]` item. Display the exact regulated question text:
491
-
492
- | State | Field on `existingCoverages[]` | Exact applicant-facing question text |
493
- |-------|------------------------------------|---------------------------------------|
494
- | OK | `notifyPresentInsurer` | *Please notify my present insurer(s) regarding this transaction?* |
495
- | FL | `wantsComparativeInformationForm` | *Indicate whether or not you wish a Comparative Information Form from the proposed company and your existing insurer or insurers?* |
496
- | DE | `wantsPolicySummary` | *Do you want a policy summary statement from your existing insurer?* |
497
-
498
- **ADB response differences from GIGDB/IB Term:**
499
-
500
- - Response type is `ThirdPartyAdbStartAppResp` - contains only `opportunityId` and `isDeclined`
501
- - No `agentLink`, `eAppAgentLink`, `applicantLink`
502
- - No `isQuoteChanged`
503
- - No `birthJurisdiction` field in the application request (unlike GIGDB)
504
-
505
- ### Step 3 - `updateAdbQuote(request: ThirdPartyAdbUpdateQuoteReq)` (optional - must be called BEFORE `saveEftPayment`)
506
-
507
- Re-quote an in-flight ADB opportunity with a new `faceAmount`, `paymentFreq`, or `riders` list. The quote cannot be updated after EFT payment details are saved — the API returns `"Quote update is not allowed when payment is already made"`.
508
-
509
- ```typescript
510
- import { PaymentFrequency } from '@instabrain-sdks/api-client';
511
-
512
- const updatedQuote = await client.updateAdbQuote({
513
- opportunityId,
514
- faceAmount: 150000,
515
- paymentFreq: PaymentFrequency.Monthly,
516
- riders: [] // pass [] to clear all riders
517
- });
518
-
519
- const { quoteResponseId, quoteAmount } = updatedQuote.selectedQuote;
520
- ```
521
-
522
- ### Step 3a - `getExistingAdbQuote(opportunityId: string)` (optional)
523
-
524
- Retrieve the current quote for an in-flight ADB opportunity. Useful any time you need to display or re-read the current premium after `updateAdbQuote()` or in the agent portal.
525
-
526
- ```typescript
527
- const currentQuote = await client.getExistingAdbQuote(opportunityId);
528
- console.log(currentQuote.selectedQuote.quoteAmount);
529
- ```
530
-
531
- ### Step 4 - `saveEftPayment(request: ThirdPartyEftPaymentReq)`
532
-
533
- Same shared method as GIGDB — both products use the same `POST /api/ThirdPartyPayment/save-eft-payment` endpoint.
534
-
535
- ```typescript
536
- await client.saveEftPayment({
537
- opportunityId,
538
- accountHolderName: 'John Smith',
539
- routingNumber: '021000021',
540
- accountNumber: '987654321'
541
- });
542
- // After this point, the quote can no longer be updated.
543
- ```
544
-
545
- ### Steps 5–6 - Secure Sign → Final Submit
546
-
547
- See [Secure Sign Flow](#secure-sign-flow) and [Final Submit](#final-submit).
548
-
549
- ---
550
-
551
- ## IB Term Flow
552
-
553
- > **Note:** IB Term is not yet fully available in this SDK release. This section is provided for reference only. Primary products for integration are GIGDB and ADB.
554
- >
555
- > **Not available in:** WY, NY
556
-
557
- ### Complete flow
558
-
559
- ```
560
- getQuote()
561
- ↓
562
- startApplication()
563
- ↓
564
- prepareDocsAndGetDeliveryChannels()
565
- ↓
566
- sendPinAndGetDocumentsLink() → verifyPin()
567
- ↓
568
- finalSubmit()
569
- ```
570
-
571
- ### Step 1 - `getQuote(request: ThirdPartyQuoteReq)`
572
-
573
- Provide exactly one of three mutually exclusive rating inputs:
574
-
575
- - `rateClass` - use `RateClass` enum
576
- - `healthClass` - use `HealthClass` enum *(note: `HealthClass.Preferred` does not exist; valid values: Excellent, Great, Good, Average)*
577
- - `height` + `weightInLbs` - build chart rating
578
-
579
- ```typescript
580
- import { Gender, PaymentFrequency, HealthClass } from '@instabrain-sdks/api-client';
581
-
582
- const quoteResp = await client.getQuote({
583
- faceAmount: 500000,
584
- benefitPeriod: 20,
585
- flagTobaccoUse: false,
586
- gender: Gender.Male,
587
- stateCode: 'TX',
588
- zipCode: null,
589
- healthClass: HealthClass.Great,
590
- rateClass: null,
591
- height: { feet: 5, inches: 10 },
592
- weightInLbs: null,
593
- age: 40,
594
- dateOfBirth: null,
595
- riders: null,
596
- paymentFreq: PaymentFrequency.Monthly,
597
- firstName: 'John',
598
- lastName: null,
599
- email: null,
600
- phoneNum: null
601
- });
602
-
603
- const { quoteResponseId } = quoteResp.selectedQuote;
604
- ```
605
-
606
- **Field priority rules:**
607
-
608
- - `zipCode` takes priority over `stateCode` if both are provided
609
- - `dateOfBirth` takes priority over `age` if both are provided
610
-
611
- ### Step 2 - `startApplication(request: ThirdPartyStartApplicationReq)`
612
-
613
- ```typescript
614
- const appResp = await client.startApplication({
615
- quoteResponseId: quoteResp.selectedQuote.quoteResponseId,
616
- firstName: 'John',
617
- lastName: 'Smith',
618
- email: 'john.smith@example.com',
619
- phoneNumber: '5559876543'
620
- });
621
-
622
- const { opportunityId, agentLink, eAppAgentLink, applicantLink } = appResp;
623
- ```
624
-
625
- **Response links:**
626
-
627
-
628
- | Field | Description |
629
- | --------------- | -------------------------------------------------------------------- |
630
- | `agentLink` | URL for the agent to complete their section in the InstaBrain portal |
631
- | `eAppAgentLink` | Alternate agent URL used in eApp mode (some partner configurations) |
632
- | `applicantLink` | URL sent to the proposed insured for their self-service section |
633
-
634
-
635
- ### Steps 3–4 - Secure Sign → Final Submit
636
-
637
- See [Secure Sign Flow](#secure-sign-flow) and [Final Submit](#final-submit).
638
-
639
- ---
640
-
641
- ## Secure Sign Flow
642
-
643
- Shared across all products. Used to electronically sign application documents after EFT payment.
644
-
645
- ### Complete flow
646
-
647
- ```
648
- prepareDocsAndGetDeliveryChannels(opportunityId)
649
- ↓
650
- [if isSignCompleted = true] → skip directly to finalSubmit()
651
- ↓
652
- sendPinAndGetDocumentsLink()
653
- ↓
654
- [agent reads script aloud; applicant reviews and signs documents via link]
655
- ↓
656
- verifyPin() [or resendPin() if PIN was not received]
657
- ↓
658
- finalSubmit()
659
- ```
660
-
661
- ### Step 1 - `prepareDocsAndGetDeliveryChannels(opportunityId: string)`
662
-
663
- Always call this first in the signing flow. If `isSignCompleted` is `true`, skip directly to `finalSubmit()`.
664
-
665
- ```typescript
666
- const prepResp = await client.prepareDocsAndGetDeliveryChannels(opportunityId);
667
-
668
- if (prepResp.isSignCompleted) {
669
- // Documents already signed - go to finalSubmit()
670
- } else {
671
- console.log('SMS available:', prepResp.isSmsAvailable);
672
- console.log('Email available:', prepResp.isEmailAvailable);
673
- }
674
- ```
675
-
676
- ### Step 2 - `sendPinAndGetDocumentsLink(request: ThirdPartySendPinReq)`
677
-
678
- At least one of `flagSendSms` or `flagSendEmail` must be `true`.
679
-
680
- ```typescript
681
- const pinResp = await client.sendPinAndGetDocumentsLink({
682
- opportunityId,
683
- flagSendSms: true,
684
- flagSendEmail: false
685
- });
686
-
687
- // pinResp.link - URL for the applicant to review and sign documents
688
- // pinResp.scriptHeader - header for the disclosure section
689
- // pinResp.script - array of disclosure statements to read aloud
690
- // pinResp.consentMessage - consent statement with the applicant's name
691
- ```
692
-
693
- ### Step 3 - Agent reads script; applicant signs
694
-
695
- 1. The agent reads each item in `pinResp.script` aloud to the proposed insured
696
- 2. The applicant opens `pinResp.link` in their browser to review and sign documents
697
- 3. *(Non-code step - the SDK does not manage the applicant's browser session)*
698
-
699
- ### Step 4 - `verifyPin(request: ThirdPartyVerifyPinReq)`
700
-
701
- `isScriptReadConfirmed: true` is required - confirms the agent has read the disclosure aloud.
702
-
703
- ```typescript
704
- const verifyResp = await client.verifyPin({
705
- opportunityId,
706
- pin: '123456',
707
- isScriptReadConfirmed: true
708
- });
709
-
710
- if (verifyResp.isVerified) {
711
- // Signing complete - proceed to finalSubmit()
712
- }
713
- ```
714
-
715
- **Optional - `resendPin` (if PIN was not received):**
716
-
717
- ```typescript
718
- await client.resendPin({
719
- opportunityId,
720
- flagSendSms: true,
721
- flagSendEmail: false
722
- });
723
- ```
724
-
725
- ---
726
-
727
- ## Final Submit
728
-
729
- Shared across all products. Submits the completed application to the carrier for underwriting.
730
-
731
- ```typescript
732
- const submitResp = await client.finalSubmit(opportunityId);
733
- console.log('Policy number:', submitResp.policyNumber);
734
- ```
735
-
736
- > `**policyNumber: null**` is normal - the carrier may not issue a policy number immediately (pending underwriting decision). This is **not** an error.
737
-
738
- > **Throws `PaymentNotMade`** if `saveEftPayment()` was not called before this step.
739
-
740
- ---
741
-
742
- ## Reporting API
743
-
744
- Three methods for retrieving data from the agent portal. `pageSize` and `pageIndex` are required.
745
-
746
- ```typescript
747
- import { AgentPortalReq } from '@instabrain-sdks/api-client';
748
-
749
- const request: AgentPortalReq = {
750
- pageSize: 20, // required
751
- pageIndex: 0 // required, 0-based
752
- };
753
- ```
754
-
755
- ### Methods
756
-
757
- ```typescript
758
- // Quotes not yet converted to applications
759
- const prospects = await client.getProspects(request);
760
- // Returns: { prospectCount: number, prospects: ThirdPartyProspectsDetails[] }
761
-
762
- // Completed / sold policies
763
- const sales = await client.getSales(request);
764
- // Returns: { applicationCount: number, salesReport: ThirdPartySalesReport[], totalPremiumAmount: number }
765
-
766
- // Applications in progress
767
- const applications = await client.getApplications(request);
768
- // Returns: { applicationCount: number, applications: ThirdPartyApplicationsReport[] }
769
- ```
770
-
771
- ### Full `AgentPortalReq` field reference
772
-
773
-
774
- | Field | Type | Required | Description |
775
- | -------------- | ------------------------- | -------- | --------------------------------------------- |
776
- | `pageSize` | `number` | **Yes** | Items per page |
777
- | `pageIndex` | `number` | **Yes** | Page index, 0-based |
778
- | `startDate` | `string` (ISO) | No | Start of date range |
779
- | `endDate` | `string` (ISO) | No | End of date range |
780
- | `dayCount` | `number` | No | Alternative to date range - fetch last N days |
781
- | `userTimeZone` | `string` | No | IANA timezone (e.g., `'America/Chicago'`) |
782
- | `sort` | `AgentPortalReqSorting` | No | Sort configuration |
783
- | `filters` | `AgentPortalReqFilters[]` | No | Array of filters |
784
- | `searchParam` | `string` | No | Text search |
785
-
786
-
787
- ### Sorting (`AgentPortalReqSorting`)
788
-
789
- ```typescript
790
- sort: {
791
- value: 'createdOn',
792
- sortDescending: true
793
- }
794
- ```
795
-
796
- ### Filtering (`AgentPortalReqFilters[]`)
797
-
798
- ```typescript
799
- import { SQLOperator } from '@instabrain-sdks/api-client';
800
-
801
- filters: [
802
- {
803
- field: 'stateCode',
804
- operator: SQLOperator.Equal,
805
- value: 'TX'
806
- }
807
- ]
808
- ```
809
-
810
- `**SQLOperator` enum values:**
811
-
812
-
813
- | Enum Member | Numeric Value | Description |
814
- | -------------------- | ------------- | --------------------- |
815
- | `Equal` | `0` | Exact match |
816
- | `NotEqual` | `1` | Not equal |
817
- | `GreaterThan` | `2` | Greater than |
818
- | `GreaterThanOrEqual` | `3` | Greater than or equal |
819
- | `LessThan` | `4` | Less than |
820
- | `LessThanOrEqual` | `5` | Less than or equal |
821
- | `Contains` | `6` | Contains substring |
822
- | `StartsWith` | `7` | Starts with |
823
- | `EndsWith` | `8` | Ends with |
824
- | `In` | `9` | In list |
825
- | `NotIn` | `10` | Not in list |
826
-
827
-
828
- ---
829
-
830
- ## Request Type Reference
831
-
832
- ### `ThirdPartyGigdbQuoteRequest`
833
-
834
-
835
- | Field | Type | Required | Constraints |
836
- | ------------- | ------------------ | -------- | ----------- |
837
- | `faceAmount` | `number | null` | Yes |
838
- | `gender` | `Gender` | Yes | |
839
- | `stateCode` | `string | null` | Yes |
840
- | `age` | `number | null` | Yes* |
841
- | `dateOfBirth` | `string | null` | Yes* |
842
- | `paymentFreq` | `PaymentFrequency` | Yes | |
843
- | `isSmoker` | `boolean | null` | Yes |
844
- | `firstName` | `string | null` | No |
845
- | `lastName` | `string | null` | No |
846
- | `email` | `string | null` | No |
847
- | `phoneNum` | `string | null` | No |
848
-
849
-
850
- ### `ThirdPartyGigdbAppReq`
851
-
852
-
853
- | Field | Type | Required | Constraints |
854
- | --------------------------------------- | -------------------------- | -------- | --------------------------------------------------- |
855
- | `quoteResponseId` | `string` | Yes | UUID from quote response |
856
- | `firstName` | `string | null` | No |
857
- | `lastName` | `string | null` | No |
858
- | `email` | `string | null` | No |
859
- | `phoneNumber` | `string | null` | No |
860
- | `isUsCitizen` | `boolean | null` | Yes |
861
- | `isPayerAlsoOwnerAndInsured` | `boolean | null` | Yes |
862
- | `isLegalUsResident` | `boolean | null` | No |
863
- | `address` | `GigdbAddress` | Yes | See sub-fields below |
864
- | `dateOfBirth` | `string | null` | Yes |
865
- | `socialSecurityNumber` | `string | null` | Yes |
866
- | `birthJurisdiction` | `GigdbBirthJurisdiction` | Yes | See sub-fields below |
867
- | `isSmoker` | `boolean | null` | Yes |
868
- | `nicotineInfo` | `GigdbNicotineInfo | null` | No |
869
- | `hasExistingCoverage` | `boolean | null` | Yes |
870
- | `willOtherCoverageBeReplacedOrFinanced` | `boolean | null` | No |
871
- | `existingCoverageData` | `GigdbExistingCoverageData | null` | No |
872
- | `willOtherCoverageBeReplacedOrFinancedData` | `GigdbWillOtherCoverageBeReplacedOrFinancedData | null` | No | Required when `address.state` is `"KS"` or `"WA"` AND `willOtherCoverageBeReplacedOrFinanced === true` |
873
- | `beneficiaryDetails` | `BeneficiaryDetails` | Yes | See [Beneficiary Reference](#beneficiary-reference) |
874
-
875
-
876
- `**GigdbAddress`:**
877
-
878
-
879
- | Field | Type |
880
- | -------------- | ------- |
881
- | `addressLine1` | `string |
882
- | `city` | `string |
883
- | `state` | `string |
884
- | `zipcode` | `string |
885
-
886
-
887
- `**GigdbBirthJurisdiction`:**
888
-
889
-
890
- | Field | Type | Description |
891
- | --------- | ------- | ----------- |
892
- | `state` | `string | null` |
893
- | `country` | `string | null` |
894
-
895
-
896
- `**GigdbExistingCoverageData`:**
897
-
898
-
899
- | Field | Type | Required | Notes |
900
- | --------------------------------------- | ---------------------------- | -------- | ----- |
901
- | `isExistingPolicyBeingTerminated` | `boolean | null` | No |
902
- | `existingCoverages` | `GigdbExistingCoverageInfo[] | null` | Yes (when `hasExistingCoverage === true`) |
903
- | `areExistingPoliciesIssuedByFidelity` | `boolean | null` | No | Required when `address.state` is `"RI"` or `"WV"` |
904
-
905
-
906
- `**GigdbExistingCoverageInfo`:**
907
-
908
-
909
- | Field | Type | Required | Notes |
910
- | --------------------------------- | ---------------- | -------- | ----- |
911
- | `nameOfTheCompany` | `string | null` | Yes | |
912
- | `insuranceAmount` | `string | null` | Yes | |
913
- | `dateOfIssue` | `string | null` | Yes | `YYYY-MM` |
914
- | `toBeReplaced` | `boolean | null` | Yes | |
915
- | `toBeFinanced` | `boolean | null` | Yes | |
916
- | `requestsYieldIndices` | `boolean | null` | No | Required when `address.state === "MA"` (per-coverage Q-08) |
917
- | `notifyPresentInsurer` | `boolean | null` | No | Required when `address.state === "OK"` (per-coverage Q-08) |
918
- | `wantsPolicySummary` | `boolean | null` | No | Required when `address.state` is `"DE"` or `"GA"` (per-coverage Q-08) |
919
- | `wantsComparativeInformationForm` | `boolean | null` | No | Required when `address.state === "FL"` (per-coverage Q-08) |
920
-
921
-
922
- `**GigdbWillOtherCoverageBeReplacedOrFinancedData`:** *(new — IBS-63)*
923
-
924
-
925
- | Field | Type | Required | Notes |
926
- | -------------------------------------- | ------------------------------------- | -------- | ----- |
927
- | `areReplacedPoliciesIssuedByFidelity` | `boolean | null` | No | Required when `address.state === "KS"` AND `willOtherCoverageBeReplacedOrFinanced === true` |
928
- | `otherInsuranceReplacementData` | `GigdbOtherInsuranceReplacementData | null` | No | Required when `address.state === "WA"` AND `willOtherCoverageBeReplacedOrFinanced === true` |
929
-
930
-
931
- `**GigdbOtherInsuranceReplacementData`:** *(new — IBS-63, WA-only)*
932
-
933
- > All 7 booleans are server-required (must be non-null). For each boolean set to `true`, the paired `specify*` string must be a non-empty explanation. When the boolean is `false`, the paired `specify*` may be omitted or `null`.
934
-
935
- | Field | Type | Required when | Exact applicant-facing question text |
936
- | ------------------------------------------- | ---------------- | ------------------------------------------------- | --- |
937
- | `mayReduceBenefitsIncreasePremiums` | `boolean` | Always (WA) | *Can there be reduced benefits or increased premiums in later years?* |
938
- | `specifyReduceBenefitsIncreasePremiums` | `string | null` | When `mayReduceBenefitsIncreasePremiums === true` | *Please explain* |
939
- | `hasNewPolicyCharges` | `boolean` | Always (WA) | *Are there penalties, set up or surrender charges for the new policy?* |
940
- | `specifyNewPolicyCharges` | `string | null` | When `hasNewPolicyCharges === true` | *Please explain, emphasizing any extra cost for early withdrawal.* |
941
- | `hasPriorPolicyCharges` | `boolean` | Always (WA) | *Will there be penalties or surrender charges under the existing insurance as a result of the proposed transaction?* |
942
- | `specifyPriorPolicyCharges` | `string | null` | When `hasPriorPolicyCharges === true` | *Please explain* |
943
- | `hasTaxConsequences` | `boolean` | Always (WA) | *Are there adverse tax consequences from the replacement under current tax law?* |
944
- | `specifyTaxConsequences` | `string | null` | When `hasTaxConsequences === true` | *Please explain* |
945
- | `hasInterestConsiderations` | `boolean` | Always (WA) | *Are interest earnings a consideration in this replacement?* |
946
- | `specifyInterestConsiderations` | `string | null` | When `hasInterestConsiderations === true` | *Please explain what portions of premiums or contributions will produce limited or no earnings. As pertinent, include the need for minimum deposits to enhance earnings, and the reduction of earnings that may result from set up charges, policy fees, and other factors.* |
947
- | `hasMinRequirementsBeforeInterest` | `boolean` | Always (WA) | *Are minimum amounts required to be on deposit before excess interest will be paid?* |
948
- | `specifyMinRequirementsBeforeInterest` | `string | null` | When `hasMinRequirementsBeforeInterest === true` | *Please explain* |
949
- | `hasOtherAdverseEffects` | `boolean` | Always (WA) | *Are there other short or long term effects from the replacement that might be materially adverse?* |
950
- | `specifyOtherAdverseEffects` | `string | null` | When `hasOtherAdverseEffects === true` | *Please explain* |
951
-
952
-
953
- ### `ThirdPartyGigdbUpdateQuoteReq`
954
-
955
-
956
- | Field | Type | Required | Constraints |
957
- | --------------- | ------------------ | -------- | ------------------------------------ |
958
- | `opportunityId` | `string` | Yes | UUID from start application response |
959
- | `faceAmount` | `number` | Yes | $5,000–$25,000 |
960
- | `paymentFreq` | `PaymentFrequency` | Yes | |
961
-
962
-
963
- > Must be called before `saveEftPayment()`. Cannot update after EFT payment is saved.
964
-
965
- ### `ThirdPartyAdbQuoteRequest`
966
-
967
-
968
- | Field | Type | Required | Constraints |
969
- | ------------- | ------------------ | -------- | --------------------------------------------------------- |
970
- | `faceAmount` | `number` | Yes | |
971
- | `gender` | `Gender` | Yes | |
972
- | `stateCode` | `string` | Yes | 2-char US state; not MA, NH, AK; CA not yet supported |
973
- | `age` | `number` | Yes* | 20–59; required if `dateOfBirth` not provided |
974
- | `dateOfBirth` | `string` | Yes* | ISO 8601; required if `age` not provided |
975
- | `paymentFreq` | `PaymentFrequency` | Yes | |
976
- | `riders` | `AdbRiderType[]` | No | Use `AdbRiderType` enum values; availability varies by state |
977
- | `firstName` | `string` | No | Max 35 chars |
978
- | `lastName` | `string` | No | Max 35 chars |
979
- | `email` | `string` | No | Valid email format |
980
- | `phoneNum` | `string` | No | 10-digit numeric |
981
-
982
-
983
- ### `ThirdPartyAdbAppReq`
984
-
985
-
986
- | Field | Type | Required | Constraints |
987
- | --------------------------------------- | ------------------------- | -------- | --------------------------------------------------- |
988
- | `quoteResponseId` | `string` | Yes | UUID from ADB quote response |
989
- | `firstName` | `string` | Yes | Max 35 chars |
990
- | `lastName` | `string` | Yes | Max 35 chars |
991
- | `email` | `string` | Yes | Valid email format |
992
- | `phoneNumber` | `string` | Yes | 10-digit numeric |
993
- | `isUsCitizen` | `boolean` | Yes | |
994
- | `isLegalUsResident` | `boolean` | No | Required when `isUsCitizen = false` |
995
- | `isPayerAlsoOwnerAndInsured` | `boolean` | Yes | Must be `true`; knockout if `false` |
996
- | `address` | `AdbAddress` | Yes | See sub-fields below |
997
- | `dateOfBirth` | `string` | Yes | ISO 8601; age must be 20–59 |
998
- | `socialSecurityNumber` | `string` | Yes | Format: `XXXXXXXXX` (9 digits, no dashes) |
999
- | `hasExistingCoverage` | `boolean` | Yes | |
1000
- | `willOtherCoverageBeReplacedOrFinanced` | `boolean` | No | Required if `hasExistingCoverage = true` |
1001
- | `existingCoverageData` | `AdbExistingCoverageData` | No | Required if `hasExistingCoverage = true` |
1002
- | `occupation` | `string[]` | No | Required when `address.state === "CA"`; values from `getAdbOccupationOptions()` |
1003
- | `hasMedicalCoverage` | `boolean` | No | Required when `address.state === "DC"` (ACA acknowledgement) |
1004
- | `understandsBenefits` | `boolean` | No | Required when `address.state === "DC"` (ACA acknowledgement) |
1005
- | `understandsLimitedBenefits` | `boolean` | No | Required when `address.state === "DC"` (ACA acknowledgement) |
1006
- | `beneficiaryDetails` | `BeneficiaryDetails` | Yes | See [Beneficiary Reference](#beneficiary-reference) |
1007
-
1008
-
1009
- `**AdbAddress`:**
1010
-
1011
-
1012
- | Field | Type | Constraints |
1013
- | -------------- | -------- | ------------------------------------------- |
1014
- | `addressLine1` | `string` | |
1015
- | `city` | `string` | |
1016
- | `state` | `string` | 2-char; must match state used at quote time |
1017
- | `zipcode` | `string` | 5-digit numeric |
1018
-
1019
-
1020
- `**AdbExistingCoverageData`:**
1021
-
1022
-
1023
- | Field | Type | Required | Notes |
1024
- | --------------------------------- | -------------------------- | -------- | ----- |
1025
- | `isExistingPolicyBeingTerminated` | `boolean` | Yes | |
1026
- | `existingCoverages` | `AdbExistingCoverageInfo[]`| Yes | At least one entry required when present |
1027
-
1028
-
1029
- `**AdbExistingCoverageInfo`:**
1030
-
1031
-
1032
- | Field | Type | Required | Notes |
1033
- | --------------------------------- | --------- | -------- | ----- |
1034
- | `nameOfTheCompany` | `string` | Yes | |
1035
- | `insuranceAmount` | `string` | Yes | |
1036
- | `dateOfIssue` | `string` | Yes | `YYYY-MM` |
1037
- | `toBeReplaced` | `boolean` | Yes | |
1038
- | `toBeFinanced` | `boolean` | Yes | |
1039
- | `notifyPresentInsurer` | `boolean` | No | Required when `address.state === "OK"` AND `hasExistingCoverage === true` |
1040
- | `wantsComparativeInformationForm` | `boolean` | No | Required when `address.state === "FL"` AND `hasExistingCoverage === true` |
1041
- | `wantsPolicySummary` | `boolean` | No | Required when `address.state === "DE"` AND `hasExistingCoverage === true` |
1042
-
1043
-
1044
- ### `ThirdPartyEftPaymentReq` (shared - GIGDB and ADB)
1045
-
1046
-
1047
- | Field | Type | Required | Description |
1048
- | ------------------- | -------- | -------- | ------------------------------------ |
1049
- | `opportunityId` | `string` | Yes | UUID from start application response |
1050
- | `accountHolderName` | `string | null` | Yes |
1051
- | `routingNumber` | `string | null` | Yes |
1052
- | `accountNumber` | `string | null` | Yes |
1053
-
1054
-
1055
- > Use `saveEftPayment()` for both GIGDB and ADB — both products share the same `POST /api/ThirdPartyPayment/save-eft-payment` endpoint.
1056
-
1057
- ### `ThirdPartyQuoteReq` (IB Term - Secondary)
1058
-
1059
-
1060
- | Field | Type | Required | Constraints |
1061
- | ---------------- | ---------------------------------- | -------- | ----------------------------------------------- |
1062
- | `faceAmount` | `number` | Yes | See age-based limits below |
1063
- | `benefitPeriod` | `number` | Yes | 10, 20, or 30 (age-dependent - see table below) |
1064
- | `flagTobaccoUse` | `boolean` | Yes | |
1065
- | `gender` | `Gender` | Yes | |
1066
- | `stateCode` | `string | null` | Yes* |
1067
- | `zipCode` | `string | null` | Yes* |
1068
- | `rateClass` | `RateClass | null` | Yes* |
1069
- | `healthClass` | `HealthClass | null` | Yes* |
1070
- | `height` | `{ feet: number, inches: number }` | Yes* | Required if `weightInLbs` provided |
1071
- | `weightInLbs` | `number | null` | Yes* |
1072
- | `age` | `number | null` | Yes* |
1073
- | `dateOfBirth` | `string | null` | Yes* |
1074
- | `riders` | `ThirdPartyQuoteReqRider[] | null` | No |
1075
- | `paymentFreq` | `PaymentFrequency` | Yes | |
1076
- | `firstName` | `string | null` | No |
1077
- | `lastName` | `string | null` | No |
1078
- | `email` | `string | null` | No |
1079
- | `phoneNum` | `string | null` | No |
1080
-
1081
-
1082
- **Face amount limits (age-based):**
1083
-
1084
-
1085
- | Age | Min | Max |
1086
- | -------- | ------- | ---------- |
1087
- | Up to 55 | $50,000 | $1,000,000 |
1088
- | 56 | $50,000 | $900,000 |
1089
- | 57 | $50,000 | $800,000 |
1090
- | 58 | $50,000 | $700,000 |
1091
- | 59 | $50,000 | $600,000 |
1092
- | 60 | $50,000 | $500,000 |
1093
-
1094
-
1095
- **Benefit period availability:**
1096
-
1097
-
1098
- | Age | Tobacco use | Available periods |
1099
- | -------- | ----------- | ----------------- |
1100
- | Up to 45 | Any | 10, 20, 30 |
1101
- | 45–50 | Non-tobacco | 10, 20, 30 |
1102
- | 45–50 | Tobacco | 10, 20 |
1103
- | 51–60 | Any | 10, 20 |
1104
-
1105
-
1106
- ### `ThirdPartySendPinReq`
1107
-
1108
-
1109
- | Field | Type | Required | Constraints |
1110
- | --------------- | --------- | -------- | --------------------------------------------------------------- |
1111
- | `opportunityId` | `string` | Yes | |
1112
- | `flagSendSms` | `boolean` | Yes | At least one of `flagSendSms` or `flagSendEmail` must be `true` |
1113
- | `flagSendEmail` | `boolean` | Yes | At least one of `flagSendSms` or `flagSendEmail` must be `true` |
1114
-
1115
-
1116
- ### `ThirdPartyResendPinReq`
1117
-
1118
-
1119
- | Field | Type | Required | Constraints |
1120
- | --------------- | --------- | -------- | ----------------------------------------- |
1121
- | `opportunityId` | `string` | Yes | |
1122
- | `flagSendSms` | `boolean` | Yes | At least one delivery flag must be `true` |
1123
- | `flagSendEmail` | `boolean` | Yes | At least one delivery flag must be `true` |
1124
-
1125
-
1126
- ### `ThirdPartyVerifyPinReq`
1127
-
1128
-
1129
- | Field | Type | Required | Constraints |
1130
- | ----------------------- | --------- | -------- | -------------------------------------------------- |
1131
- | `opportunityId` | `string` | Yes | |
1132
- | `pin` | `string` | Yes | PIN entered by the signer |
1133
- | `isScriptReadConfirmed` | `boolean` | Yes | Must be `true`; confirms disclosure was read aloud |
1134
-
1135
-
1136
- ---
1137
-
1138
- ## Response Type Reference
1139
-
1140
- ### `BaseResponse<T>`
1141
-
1142
- All InstaBrain API responses are wrapped in this envelope:
1143
-
1144
- ```typescript
1145
- interface BaseResponse<T> {
1146
- flagStatus: boolean; // true = success, false = API-level error
1147
- value: T; // the actual response data
1148
- error: string | null; // error message when flagStatus = false
1149
- errorCode?: string; // error code when flagStatus = false
1150
- }
1151
- ```
1152
-
1153
- The SDK unwraps this envelope automatically - integrators receive `value` directly. When `flagStatus = false`, the SDK throws `APIValidationError`. You never check `flagStatus` manually.
1154
-
1155
- ### `ThirdPartyQuoteResp`
1156
-
1157
- Returned by `getGigdbQuote()`, `getAdbQuote()`, `getQuote()`, `updateGigdbQuote()`, `getExistingGigdbQuote()`.
1158
-
1159
- ```typescript
1160
- interface ThirdPartyQuoteResp {
1161
- productName: string | null;
1162
- selectedQuote: Quote;
1163
- }
1164
- ```
1165
-
1166
- **Key `Quote` fields:**
1167
-
1168
-
1169
- | Field | Type | Description |
1170
- | ------------------- | ------------- | -------------------------------------- |
1171
- | `quoteResponseId` | `string` | UUID - pass to `startXxxApplication()` |
1172
- | `quoteAmount` | `number | null` |
1173
- | `faceAmount` | `number` | Coverage amount |
1174
- | `benefitPeriod` | `number | null` |
1175
- | `paymentFrequency` | `string | null` |
1176
- | `isMedicalRequired` | `boolean` | Whether a medical exam is required |
1177
- | `selectedRiders` | `RidersList[] | null` |
1178
-
1179
-
1180
- ### `ThirdPartyStartAppResp` (GIGDB, IB Term)
1181
-
1182
- Returned by `startGigdbApplication()` and `startApplication()`.
1183
-
1184
-
1185
- | Field | Type | Description |
1186
- | ---------------- | --------- | --------------------------------------------- |
1187
- | `opportunityId` | `string` | UUID - used for all subsequent calls |
1188
- | `agentLink` | `string | null` |
1189
- | `eAppAgentLink` | `string | null` |
1190
- | `applicantLink` | `string | null` |
1191
- | `isDeclined` | `boolean` | `true` = valid knockout (GIGDB); not an error |
1192
- | `isQuoteChanged` | `boolean` | `true` = premium was adjusted (GIGDB) |
1193
-
1194
-
1195
- ### `AdbRiderDetailsResp` (ADB only)
1196
-
1197
- Returned by `getAdbRiderDetails()`.
1198
-
1199
- | Field | Type | Description |
1200
- |---|---|---|
1201
- | `riders` | `AdbRiderResp[]` | Available riders for the state. May be empty even when product is available. |
1202
- | `flagProductNotAvailableForState` | `boolean` | `true` = ADB not available in this state; stop. `false` = available; proceed to quote. |
1203
-
1204
- ### `AdbRiderResp`
1205
-
1206
- | Field | Type | Description |
1207
- |---|---|---|
1208
- | `riderCode` | `AdbRiderType` | Pass into `ThirdPartyAdbQuoteRequest.riders` to include this rider in the quote. Values: `FamilyADB`, `ReturnOfPremium`, `InflationBenefit`. |
1209
- | `riderTitle` | `string` | Display title for UI rendering. |
1210
- | `riderDescription` | `string` | Display description for UI rendering. |
1211
-
1212
- ### `ThirdPartyAdbStartAppResp` (ADB only)
1213
-
1214
- Returned by `startAdbApplication()`. Contains only two fields - no links, no `isQuoteChanged`:
1215
-
1216
-
1217
- | Field | Type | Description |
1218
- | --------------- | --------- | ------------------------------------------ |
1219
- | `opportunityId` | `string` | UUID - empty GUID when `isDeclined = true` |
1220
- | `isDeclined` | `boolean` | `true` = knockout; stop the flow |
1221
-
1222
-
1223
- ### `ThirdPartyPrepareDocsResp`
1224
-
1225
-
1226
- | Field | Type | Description |
1227
- | ------------------ | --------- | ---------------------------------- |
1228
- | `isSignCompleted` | `boolean` | If `true`, skip to `finalSubmit()` |
1229
- | `isSmsAvailable` | `boolean` | SMS delivery channel available |
1230
- | `isEmailAvailable` | `boolean` | Email delivery channel available |
1231
- | `productName` | `string | null` |
1232
-
1233
-
1234
- ### `ThirdPartySendPinResp`
1235
-
1236
-
1237
- | Field | Type | Description |
1238
- | ---------------- | --------- | ----------- |
1239
- | `link` | `string | null` |
1240
- | `scriptHeader` | `string | null` |
1241
- | `script` | `string[] | null` |
1242
- | `consentMessage` | `string | null` |
1243
-
1244
-
1245
- ### `ThirdPartyResendPinResp`
1246
-
1247
-
1248
- | Field | Type | Description |
1249
- | ------------- | --------- | ----------------------------------- |
1250
- | `flagPinSent` | `boolean` | `true` when PIN resent successfully |
1251
-
1252
-
1253
- ### `ThirdPartyVerifyPinResp`
1254
-
1255
-
1256
- | Field | Type | Description |
1257
- | ------------ | --------- | ------------------------------------------------ |
1258
- | `isVerified` | `boolean` | `true` when PIN matched and documents are signed |
1259
-
1260
-
1261
- ### `ThirdPartyFinalSubmitResp`
1262
-
1263
-
1264
- | Field | Type | Description |
1265
- | -------------- | ------- | ----------- |
1266
- | `policyNumber` | `string | null` |
1267
-
1268
-
1269
- ---
1270
-
1271
- ## Enums and Constants
1272
-
1273
- ### `Gender`
1274
-
1275
-
1276
- | Enum Member | Value |
1277
- | --------------- | ---------- |
1278
- | `Gender.Male` | `'Male'` |
1279
- | `Gender.Female` | `'Female'` |
1280
-
1281
-
1282
- ### `PaymentFrequency`
1283
-
1284
-
1285
- | Enum Member | Value |
1286
- | --------------------------- | ------------ |
1287
- | `PaymentFrequency.Monthly` | `'Monthly'` |
1288
- | `PaymentFrequency.Annually` | `'Annually'` |
1289
-
1290
-
1291
- ### `HealthClass`
1292
-
1293
-
1294
- | Enum Member | Value |
1295
- | ----------------------- | ------------- |
1296
- | `HealthClass.Excellent` | `'Excellent'` |
1297
- | `HealthClass.Great` | `'Great'` |
1298
- | `HealthClass.Good` | `'Good'` |
1299
- | `HealthClass.Average` | `'Average'` |
1300
-
1301
-
1302
- > **Note:** `HealthClass.Preferred` does **not** exist and will cause an API error if used.
1303
-
1304
- ### `RateClass`
1305
-
1306
-
1307
- | Enum Member | Value |
1308
- | ------------------------- | ------------------ |
1309
- | `RateClass.PreferredPlus` | `'Preferred Plus'` |
1310
- | `RateClass.Preferred` | `'Preferred'` |
1311
- | `RateClass.Standard` | `'Standard'` |
1312
- | `RateClass.StandardExtra` | `'Standard Extra'` |
1313
-
1314
-
1315
- > **Note:** Values contain spaces - always use enum members, not raw strings.
1316
-
1317
- ### `RiderType`
1318
-
1319
-
1320
- | Enum Member | Value | Coverage Range |
1321
- | ------------------------------- | ------------------------- | ---------------- |
1322
- | `RiderType.ADBRider` | `'ADB Rider'` | $25,000–$250,000 |
1323
- | `RiderType.DependentChildRider` | `'Dependent Child Rider'` | $5,000–$25,000 |
1324
-
1325
-
1326
- > **Note:** Values contain spaces - always use enum members.
1327
-
1328
- ### `AdbRiderType` (ADB product only)
1329
-
1330
- Rider codes accepted by `ThirdPartyAdbQuoteRequest.riders` and `ThirdPartyAdbUpdateQuoteReq.riders`, and returned by `getAdbRiderDetails()` as `AdbRiderResp.riderCode`.
1331
-
1332
- | Enum Member | Value |
1333
- | ------------------------------ | -------------------- |
1334
- | `AdbRiderType.FamilyADB` | `'FamilyADB'` |
1335
- | `AdbRiderType.ReturnOfPremium` | `'ReturnOfPremium'` |
1336
- | `AdbRiderType.InflationBenefit` | `'InflationBenefit'` |
1337
-
1338
- > **Note:** ADB has its own rider enum. Do NOT reuse the Term product's `RiderType` — those values (`'ADB Rider'`, `'Dependent Child Rider'`) are display titles, not the codes the ADB API expects.
1339
-
1340
- ### `State`
1341
-
1342
- All 50 US states + DC and 12 Canadian provinces/territories:
1343
-
1344
- **US:** `AK`, `AL`, `AR`, `AZ`, `CA`, `CO`, `CT`, `DC`, `DE`, `FL`, `GA`, `HI`, `IA`, `ID`, `IL`, `IN`, `KS`, `KY`, `LA`, `MA`, `MD`, `ME`, `MI`, `MN`, `MO`, `MS`, `MT`, `NC`, `ND`, `NE`, `NH`, `NJ`, `NM`, `NV`, `NY`, `OH`, `OK`, `OR`, `PA`, `RI`, `SC`, `SD`, `TN`, `TX`, `UT`, `VA`, `VT`, `WA`, `WI`, `WV`, `WY`
1345
-
1346
- **Canadian provinces/territories:** `AB`, `BC`, `MB`, `NB`, `NS`, `NT`, `NUNAVUT`, `ON`, `PE`, `PQ`, `SK`, `YT`
1347
-
1348
- ### `Country`
1349
-
1350
- Full ISO country code enum. Common values: `Country.UnitedStates` (`'US'`), `Country.Canada` (`'CA'`). Used in GIGDB's `birthJurisdiction.country`.
1351
-
1352
- ### `BeneficiaryType`
1353
-
1354
-
1355
- | Enum Member | Value |
1356
- | --------------------------------- | ---------------------------------------- |
1357
- | `Person` | `'Person'` |
1358
- | `AllChildrenOfTheInsuredEqually` | `'All Children Of The Insured Equally'` |
1359
- | `AllChildrenOfTheMarriageEqually` | `'All Children Of The Marriage Equally'` |
1360
- | `InsuredEstate` | `'Insured Estate'` |
1361
- | `Business` | `'Business'` |
1362
- | `Corporation` | `'Corporation'` |
1363
- | `CharitableOrganization` | `'Charitable Organization'` |
1364
- | `Employer` | `'Employer'` |
1365
- | `Other` | `'Other'` |
1366
- | `Trust` | `'Trust'` |
1367
-
1368
-
1369
- ### `BeneficiaryRelationship`
1370
-
1371
- 36 values: `Aunt`, `Boyfriend`, `Brother`, `BrotherInLaw`, `CommonLawHusband`, `CommonLawWife`, `Cousin`, `Daughter`, `DaughterInLaw`, `DomesticPartner`, `Father`, `FatherInLaw`, `FatherOfChild`, `Fiance`, `Fiancee`, `FormerSpouse`, `Friend`, `Girlfriend`, `Granddaughter`, `Grandfather`, `Grandmother`, `Grandson`, `Husband`, `LifePartner`, `Mother`, `MotherInLaw`, `MotherOfChild`, `Nephew`, `Niece`, `Sister`, `SisterInLaw`, `Son`, `SonInLaw`, `Spouse`, `Uncle`, `Wife`
1372
-
1373
- ### ADB Rider Availability
1374
-
1375
- #### `ADB_RIDER_AVAILABLE_STATES`
1376
-
1377
- ADB Rider available in: `AL`, `AZ`, `AR`, `CA`*, `CO`, `CT`, `DC`, `DE`, `FL`, `GA`, `HI`, `ID`, `IL`, `IN`, `IA`, `KS`, `KY`, `LA`, `ME`, `MD`, `MI`, `MN`, `MS`, `MO`, `MT`, `NE`, `NV`, `NJ`, `NM`, `NC`, `ND`, `OH`, `OK`, `OR`, `PA`, `RI`, `SC`, `SD`, `TN`, `TX`, `UT`, `VT`, `VA`, `WV`, `WI`
1378
-
1379
- > CA: ADB product support is coming in the next SDK release and is not yet available.
1380
-
1381
- #### `CHILD_RIDER_AVAILABLE_STATES`
1382
-
1383
- Dependent Child Rider available in: `AL`, `AK`, `AZ`, `AR`, `CO`, `CT`, `DC`, `DE`, `GA`, `HI`, `ID`, `IL`, `IN`, `IA`, `KS`, `KY`, `LA`, `MD`, `MA`, `MI`, `MN`, `MS`, `MO`, `MT`, `NE`, `NV`, `NH`, `NJ`, `NM`, `NC`, `OH`, `OK`, `OR`, `PA`, `RI`, `SC`, `TN`, `TX`, `UT`, `VA`, `WV`, `WI`
1384
-
1385
- #### `NO_RIDERS_AVAILABLE_STATES`
1386
-
1387
- No riders available in: `WA`
1388
-
1389
- > **Coming in a future release:** `getAvailableRidersForState(stateCode)` - programmatically query rider availability for a given state.
1390
-
1391
- ---
1392
-
1393
- ## Beneficiary Reference
1394
-
1395
- The `beneficiaryDetails` field uses a TypeScript discriminated union. Required fields differ by `beneficiaryType`. TypeScript enforces the correct shape at compile time.
1396
-
1397
- ### Variant 1 - No extra fields
1398
-
1399
- Used for `InsuredEstate`, `AllChildrenOfTheInsuredEqually`, `AllChildrenOfTheMarriageEqually`:
1400
-
1401
- ```typescript
1402
- beneficiaryDetails: {
1403
- beneficiaryType: BeneficiaryType.InsuredEstate
1404
- }
1405
- ```
1406
-
1407
- ### Variant 2 - Named person
1408
-
1409
- Used when `beneficiaryType = Person`:
1410
-
1411
- ```typescript
1412
- beneficiaryDetails: {
1413
- beneficiaryType: BeneficiaryType.Person,
1414
- beneficiaryPerson: {
1415
- firstName: 'Jane',
1416
- lastName: 'Doe',
1417
- relationship: BeneficiaryRelationship.Spouse
1418
- }
1419
- }
1420
- ```
1421
-
1422
- ### Variant 3 - Named entity (organization)
1423
-
1424
- Used for `Business`, `Corporation`, `CharitableOrganization`, `Employer`, `Other`, `Trust`:
1425
-
1426
- ```typescript
1427
- // Business / Corporation / etc.
1428
- beneficiaryDetails: {
1429
- beneficiaryType: BeneficiaryType.Business,
1430
- namedEntity: {
1431
- name: 'Acme Corp',
1432
- taxId: '12-3456789' // optional
1433
- }
1434
- }
1435
-
1436
- // Trust - trustDate is required (format: YYYY-MM)
1437
- beneficiaryDetails: {
1438
- beneficiaryType: BeneficiaryType.Trust,
1439
- namedEntity: {
1440
- name: 'Smith Family Trust',
1441
- trustDate: '2020-01' // required for Trust only; format: YYYY-MM
1442
- }
1443
- }
1444
- ```
1445
-
1446
- ---
1447
-
1448
- ## Error Handling
1449
-
1450
- ### Error class hierarchy
1451
-
1452
- ```
1453
- InstaBrainError
1454
- ├── AuthenticationError (statusCode: 401 - credentials invalid or session expired)
1455
- ├── ValidationError (statusCode: 400 - request-level validation failure)
1456
- └── APIValidationError (statusCode: 400 - API returned flagStatus: false)
1457
- ```
1458
-
1459
- ### Field reference
1460
-
1461
-
1462
- | Class | `message` | `statusCode` | `errorCode` | `response` |
1463
- | --------------------- | --------- | ------------ | ----------- | ---------- |
1464
- | `InstaBrainError` | Yes | Yes | Yes | Yes |
1465
- | `AuthenticationError` | Yes | `401` | - | - |
1466
- | `ValidationError` | Yes | `400` | Yes | - |
1467
- | `APIValidationError` | Yes | `400` | Yes | Yes |
1468
-
1469
-
1470
- ### Using `APIValidationError`
1471
-
1472
- Thrown when the API returns `flagStatus: false`. Always use `isErrorType(APIErrorCode.X)` for comparison - do **not** compare `errorCode` as a raw string, as the API uses inconsistent casing across error codes.
1473
-
1474
- ```typescript
1475
- import {
1476
- APIValidationError,
1477
- AuthenticationError,
1478
- InstaBrainError,
1479
- APIErrorCode
1480
- } from '@instabrain-sdks/api-client';
1481
-
1482
- try {
1483
- const quoteResp = await client.getGigdbQuote(request);
1484
- } catch (err) {
1485
- if (err instanceof APIValidationError) {
1486
- if (err.isErrorType(APIErrorCode.NotAvailableForState)) {
1487
- console.error('Product not available in this state');
1488
- } else if (err.isErrorType(APIErrorCode.AgeNotFound)) {
1489
- console.error('Age is outside the eligible range for this product');
1490
- } else {
1491
- // getUserFriendlyMessage() returns a human-readable description
1492
- console.error(err.getUserFriendlyMessage());
1493
- }
1494
- } else if (err instanceof AuthenticationError) {
1495
- console.error('Authentication failed - re-authenticate');
1496
- } else if (err instanceof InstaBrainError) {
1497
- console.error(`SDK error: ${err.message} (status: ${err.statusCode})`);
1498
- }
1499
- }
1500
- ```
1501
-
1502
- > `**isDeclined: true` is not an error.** It is a response field on `ThirdPartyStartAppResp` and `ThirdPartyAdbStartAppResp`, indicating the application was declined due to knockout criteria. Always check this field in the response - it is never thrown as an exception.
1503
-
1504
- ---
1505
-
1506
- ## APIErrorCode Reference
1507
-
1508
- Always use `APIErrorCode` enum members with `err.isErrorType()`. Do not compare `errorCode` as a raw string - the API uses inconsistent casing.
1509
-
1510
- ### General / Quote
1511
-
1512
-
1513
- | Enum Member | String Value | Description |
1514
- | ------------------------------------ | -------------------------------------- | ---------------------------------------------------------------- |
1515
- | `StateNotFound` | `'stateNotFound'` | State code not recognized |
1516
- | `RateClassNotFound` | `'RateClassNotFound'` | Rating input required (rateClass, healthClass, or height/weight) |
1517
- | `RiderNotAvailable` | `'RiderNotAvailable'` | Rider not available in this state or for this age |
1518
- | `HeightNotValid` | `'HeightNotValid'` | Height value is not valid |
1519
- | `InvalidRateclass` | `'InvalidRateclass'` | Rate class value not recognized |
1520
- | `InvalidHealthClass` | `'InvalidHealthClass'` | Health class value not recognized |
1521
- | `ZipCodeNotFound` | `'ZipCodeNotFound'` | ZIP code not recognized |
1522
- | `OutsideBuildChart` | `'outsideBuildChart'` | Height/weight combination not eligible |
1523
- | `QuoteNotEligibleForGivenConditions` | `'QuoteNotEligibleForGivenConditions'` | Product not available for this state/age/tobacco combination |
1524
- | `NotAvailableForState` | `'NotAvailableForState'` | Product not available in the specified state |
1525
- | `BenefitPeriodNotAvailable` | `'BenefitPeriodNotAvailable'` | Benefit period not available for this age/tobacco combination |
1526
- | `CoverageNotAvailable` | `'CoverageNotAvailable'` | Coverage amount not available for the given conditions |
1527
- | `RiderFaceAmountNotValid` | `'RiderFaceAmountNotValid'` | Rider coverage amount outside permitted range |
1528
- | `ThirdPartyQuoteError` | `'ThirdPartyQuoteError'` | General quote generation error |
1529
- | `InvalidQuoteParameters` | `'InvalidQuoteParameters'` | Quote parameters are not valid |
1530
- | `InvalidRequestFormat` | `'InvalidRequestFormat'` | Request format invalid; check required fields |
1531
- | `QuoteNotFound` | `'QuoteNotFound'` | No previous quote found; create a quote first |
1532
-
1533
-
1534
- ### GIGDB
1535
-
1536
-
1537
- | Enum Member | String Value | Description |
1538
- | -------------------------------------------- | ---------------------------------------------- | ----------------------------------------------- |
1539
- | `AgeNotFound` | `'AgeNotFound'` | Age outside 50–85 range |
1540
- | `AgentLogout` | `'AgentLogout'` | Agent session expired; re-authenticate |
1541
- | `DataNotFound` | `'dataNotFound'` | Requested data not found |
1542
- | `StateMismatchIdentified` | `'StateMismatchIdentified'` | State mismatch between quote and application |
1543
- | `InvalidBirthCountry` | `'InvalidBirthCountry'` | Birth country not recognized |
1544
- | `InvalidBirthState` | `'InvalidBirthState'` | Birth state not recognized |
1545
- | `InvalidResidenceState` | `'InvalidResidenceState'` | Residence state not valid |
1546
- | `OneOfTheExistingCoveragesQuestionsNotFound` | `'OneOfTheExistingCoveragesQuestionsNotFound'` | Existing coverage questions incomplete |
1547
- | `PaymentAlreadyMade` | `'PaymentAlreadyMade'` | Payment already submitted for this application |
1548
- | `ErrorInSaveEftPaymentDetails` | `'ErrorInSaveEftPaymentDetails'` | Failed to save EFT details; verify account info |
1549
- | `InvalidPaymentScheduledDate` | `'InvalidPaymentScheduledDate'` | Scheduled payment date is not valid |
1550
-
1551
-
1552
- ### ADB
1553
-
1554
-
1555
- | Enum Member | String Value | Description |
1556
- | -------------------- | ---------------------- | ---------------------------------------------------------------------------- |
1557
- | `InvalidStateCode` | `'InvalidStateCode'` | State not supported for ADB (MA, NH, AK unavailable; CA coming next release) |
1558
- | `InvalidAdbAgeRange` | `'InvalidAdbAgeRange'` | Age outside 20–59 range |
1559
-
1560
-
1561
- ### Final Submit
1562
-
1563
-
1564
- | Enum Member | String Value | Description |
1565
- | ---------------- | ------------------ | ------------------------------------------------- |
1566
- | `PaymentNotMade` | `'paymentNotMade'` | EFT payment must be completed before final submit |
1567
-
1568
-
1569
- ### Secure Sign
1570
-
1571
-
1572
- | Enum Member | String Value | Description |
1573
- | -------------------------- | ---------------------------- | -------------------------------------------------------- |
1574
- | `SecureSignRelatedError` | `'SecureSignRelatedError'` | General signing error |
1575
- | `SigningPackageNotCreated` | `'SigningPackageNotCreated'` | No signing package exists; complete previous steps first |
1576
- | `SecureSignPinMismatch` | `'SecureSignPinMismatch'` | PIN entered is incorrect |
1577
- | `PinExpired` | `'PinExpired'` | PIN has expired; request a new one |
1578
- | `DocumentsNotViewed` | `'DocumentsNotViewed'` | All documents must be viewed before verifying PIN |
1579
- | `DocumentsAlreadySigned` | `'DocumentsAlreadySigned'` | Documents already signed for this application |
1580
-
1581
-
1582
- ---
1583
-
1584
- ## Environment Configuration
1585
-
1586
- Pass `'sandbox'` or `'production'` to `InstaBrainClient.forEnvironment()`. The SDK handles all routing internally.
1587
-
1588
- ```typescript
1589
- // Sandbox - for development and testing
1590
- const client = InstaBrainClient.forEnvironment('sandbox');
1591
-
1592
- // Production
1593
- const client = InstaBrainClient.forEnvironment('production');
1594
- ```
1595
-
1596
- > Sandbox credentials are separate from production credentials. Both are provisioned independently during onboarding.
1597
-
1598
- ---
1599
-
1600
- ## Token Management
1601
-
1602
-
1603
- | Method | Signature | Description |
1604
- | ------------------- | ------------------------- | ----------------------------------------------------------- |
1605
- | `isAuthenticated()` | `() => boolean` | Returns `true` if a JWT is currently stored |
1606
- | `getCurrentToken()` | `() => string | null` |
1607
- | `setToken(token)` | `(token: string) => void` | Manually set a JWT (e.g., restored from persistent storage) |
1608
- | `logout()` | `() => void` | Clears the stored JWT |
1609
- | `getBaseUrl()` | `() => string` | Returns the configured base URL (for debugging only) |
1610
-
1611
-
1612
- ---
1613
-
1614
- ## Examples Directory
1615
-
1616
- Working examples are in the `./examples/` directory:
1617
-
1618
-
1619
- | File | Description |
1620
- | ---------------------------- | ---------------------------------------------------- |
1621
- | `basic-usage.ts` | Authentication and basic quote/application flows |
1622
- | `error-handling.ts` | Error catching and handling patterns |
1623
- | `api-constraints-example.ts` | State restrictions, age limits, and validation rules |
1624
- | `reports-example.ts` | Prospects, sales, and applications reporting |
1625
-
1626
-
1627
- ---
1628
-
1629
- ## Changelog
1630
-
1631
- See [CHANGELOG.md](./CHANGELOG.md).
1632
-
1633
- ---
1634
-
1635
- ## Support
1636
-
1637
- - **Email:** [helpdesk@instabrain.io](mailto:helpdesk@instabrain.io)
1638
- - **Website:** [https://www.instabrain.io](https://www.instabrain.io)
1639
-
1
+ # @instabrain-sdks/api-client
2
+
3
+ [npm version](https://badge.fury.io/js/%40instabrain-sdks%2Fapi-client)
4
+
5
+ TypeScript/Node.js SDK for integrating with the InstaBrain insurance platform. Covers three products: **GIGDB** (Guaranteed Issue Guaranteed Death Benefit), **ADB** (Accidental Death Benefit), and IB Term life insurance.
6
+
7
+ **Primary products for third-party integration: GIGDB and ADB.**
8
+
9
+ Credentials (`userId` and `accessToken`) are provisioned during onboarding.
10
+
11
+ ---
12
+
13
+ ## Table of Contents
14
+
15
+ 1. [Installation](#installation)
16
+ 2. [Requirements](#requirements)
17
+ 3. [Authentication](#authentication)
18
+ 4. [Product Comparison](#product-comparison)
19
+ 5. [GIGDB Flow](#gigdb-flow)
20
+ 6. [ADB Flow](#adb-flow)
21
+ 7. [IB Term Flow](#ib-term-flow)
22
+ 8. [Secure Sign Flow](#secure-sign-flow)
23
+ 9. [Final Submit](#final-submit)
24
+ 10. [Reporting API](#reporting-api)
25
+ 11. [Request Type Reference](#request-type-reference)
26
+ 12. [Response Type Reference](#response-type-reference)
27
+ 13. [Enums and Constants](#enums-and-constants)
28
+ 14. [Beneficiary Reference](#beneficiary-reference)
29
+ 15. [Error Handling](#error-handling)
30
+ 16. [APIErrorCode Reference](#apierrorcode-reference)
31
+ 17. [Environment Configuration](#environment-configuration)
32
+ 18. [Token Management](#token-management)
33
+ 19. [Examples Directory](#examples-directory)
34
+ 20. [Changelog](#changelog)
35
+ 21. [Support](#support)
36
+
37
+ ---
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ npm install @instabrain-sdks/api-client
43
+ ```
44
+
45
+ > **Note:** This is a restricted-access package. Access must be granted during the InstaBrain onboarding process.
46
+
47
+ ---
48
+
49
+ ## Requirements
50
+
51
+ - Node.js >= 14.0.0
52
+ - TypeScript >= 4.0 *(optional - the SDK ships with full type definitions)*
53
+
54
+ ---
55
+
56
+ ## Authentication
57
+
58
+ Credentials are issued during onboarding:
59
+
60
+
61
+ | Credential | Type | Description |
62
+ | ------------- | --------------- | ------------------------ |
63
+ | `userId` | `number` | Your account user ID |
64
+ | `accessToken` | `string` (UUID) | Your secret access token |
65
+
66
+
67
+ ```typescript
68
+ import { InstaBrainClient } from '@instabrain-sdks/api-client';
69
+
70
+ const client = InstaBrainClient.forEnvironment('sandbox');
71
+ const jwt = await client.authenticate(userId, accessToken);
72
+ // JWT is stored internally and automatically attached to all subsequent calls
73
+ // No need to manually set it after authenticate()
74
+ ```
75
+
76
+ > Call `authenticate()` once at startup. The returned JWT is stored internally - every subsequent API call uses it automatically.
77
+
78
+ ---
79
+
80
+ ## Product Comparison
81
+
82
+
83
+ | Feature | GIGDB | ADB | IB Term |
84
+ | -------------------- | ------------------------- | ------------------------------- | --------------------------------------------- |
85
+ | Eligible ages | 50–85 | 20–59 | 18–60 |
86
+ | Face amount | $5,000–$25,000 | $50,000-$300,000 | $50,000–$1,000,000 (age-scaled) |
87
+ | Medical exam | No | No | No (build chart used) |
88
+ | Smoker/tobacco field | `isSmoker` (required) | N/A | `flagTobaccoUse` (required) |
89
+ | Birth jurisdiction | Yes (`birthJurisdiction`) | No | No |
90
+ | App response type | `ThirdPartyStartAppResp` | `ThirdPartyAdbStartAppResp` | `ThirdPartyStartAppResp` |
91
+ | `isDeclined` | Yes | Yes | No |
92
+ | `isQuoteChanged` | Yes | No | No |
93
+ | Response links | None | None | `agentLink`, `eAppAgentLink`, `applicantLink` |
94
+ | EFT method | `saveEftPayment()` | `saveEftPayment()` | N/A |
95
+ | Unavailable states | NY, MT | MA, NH, AK *(CA: next release)* | WY, NY |
96
+ | Status | **Primary** | **Primary** | Secondary *(not fully live yet)* |
97
+
98
+
99
+ ---
100
+
101
+ ## GIGDB Flow
102
+
103
+ > **Not available in:** NY, MT
104
+
105
+ GIGDB (Guaranteed Issue Guaranteed Death Benefit) is a simplified-issue whole life product for ages 50–85 with no medical exam.
106
+
107
+ ### Complete flow
108
+
109
+ ```
110
+ getGigdbQuote()
111
+ ↓
112
+ startGigdbApplication()
113
+ ↓
114
+ [if isDeclined = true] → stop - applicant not eligible
115
+ [if isQuoteChanged = true] → getExistingGigdbQuote() (conditional)
116
+ ↓
117
+ updateGigdbQuote() ← optional; MUST be called before saveEftPayment
118
+ ↓
119
+ saveEftPayment() ← quote cannot be updated after this point
120
+ ↓
121
+ prepareDocsAndGetDeliveryChannels()
122
+ ↓
123
+ sendPinAndGetDocumentsLink() → verifyPin()
124
+ ↓
125
+ finalSubmit()
126
+ ```
127
+
128
+ ### Step 1 - `getGigdbQuote(request: ThirdPartyGigdbQuoteRequest)`
129
+
130
+ ```typescript
131
+ import { InstaBrainClient, Gender, PaymentFrequency } from '@instabrain-sdks/api-client';
132
+
133
+ const quoteResp = await client.getGigdbQuote({
134
+ faceAmount: 15000,
135
+ gender: Gender.Female,
136
+ stateCode: 'TX',
137
+ age: 65,
138
+ dateOfBirth: null,
139
+ paymentFreq: PaymentFrequency.Monthly,
140
+ isSmoker: false,
141
+ firstName: 'Jane',
142
+ lastName: 'Doe',
143
+ email: 'jane.doe@example.com',
144
+ phoneNum: null
145
+ });
146
+
147
+ const { quoteResponseId, quoteAmount } = quoteResp.selectedQuote;
148
+ ```
149
+
150
+ ### Step 2 - `startGigdbApplication(request: ThirdPartyGigdbAppReq)`
151
+
152
+ ```typescript
153
+ import { BeneficiaryType, BeneficiaryRelationship } from '@instabrain-sdks/api-client';
154
+
155
+ const appResp = await client.startGigdbApplication({
156
+ quoteResponseId: quoteResp.selectedQuote.quoteResponseId,
157
+ firstName: 'Jane',
158
+ lastName: 'Doe',
159
+ email: 'jane.doe@example.com',
160
+ phoneNumber: '5551234567',
161
+ isUsCitizen: true,
162
+ isPayerAlsoOwnerAndInsured: true,
163
+ isLegalUsResident: true,
164
+ address: {
165
+ addressLine1: '123 Main St',
166
+ city: 'Austin',
167
+ state: 'TX',
168
+ zipcode: '73301'
169
+ },
170
+ dateOfBirth: '1958-06-15',
171
+ socialSecurityNumber: '123-45-6789',
172
+ birthJurisdiction: {
173
+ state: 'TX',
174
+ country: 'US'
175
+ },
176
+ isSmoker: false,
177
+ nicotineInfo: null,
178
+ hasExistingCoverage: false,
179
+ willOtherCoverageBeReplacedOrFinanced: null,
180
+ existingCoverageData: null,
181
+ beneficiaryDetails: {
182
+ beneficiaryType: BeneficiaryType.Person,
183
+ beneficiaryPerson: {
184
+ firstName: 'John',
185
+ lastName: 'Doe',
186
+ relationship: BeneficiaryRelationship.Spouse
187
+ }
188
+ }
189
+ });
190
+
191
+ if (appResp.isDeclined) {
192
+ // Valid knockout - the applicant did not meet eligibility criteria.
193
+ // This is NOT an error - do not throw.
194
+ console.log('Application declined');
195
+ return;
196
+ }
197
+
198
+ const { opportunityId, isQuoteChanged } = appResp;
199
+ ```
200
+
201
+ `**isDeclined: true**` - the applicant did not meet eligibility criteria. This is a valid response, not an error. Stop the flow.
202
+
203
+ `**isQuoteChanged: true**` - the carrier adjusted the premium based on application data. Proceed to Step 3.
204
+
205
+ #### State-specific Other Insurance fields (Q-08)
206
+
207
+ > Third-party integrations must display the exact regulated question text below to applicants — paraphrasing is not sufficient. Source: Confluence page 687800321 (GIGDB Start Application API).
208
+
209
+ When `hasExistingCoverage === true`, the following per-coverage flags are required for specific states:
210
+
211
+ | State | Field on `existingCoverages[]` | Type | Exact applicant-facing question text |
212
+ |-----------|------------------------------------|-----------|---------------------------------------|
213
+ | MA | `requestsYieldIndices` | `boolean` | *Would you like to request yield indices for cash value policies?* |
214
+ | OK | `notifyPresentInsurer` | `boolean` | *Please notify my present insurer(s) regarding this transaction?* |
215
+ | DE / GA | `wantsPolicySummary` | `boolean` | *Do you want a policy summary statement from your existing insurer?* |
216
+ | FL | `wantsComparativeInformationForm` | `boolean` | *Indicate whether or not you wish a Comparative Information Form from the proposed company and your existing insurer or insurers?* |
217
+
218
+ For **RI** or **WV**, set `existingCoverageData.areExistingPoliciesIssuedByFidelity: boolean`.
219
+ > Question text: *"Are any of your existing policies issued by Fidelity Life Association?"*
220
+
221
+ When `willOtherCoverageBeReplacedOrFinanced === true` and the state is **KS** or **WA**, populate the new top-level `willOtherCoverageBeReplacedOrFinancedData` object:
222
+
223
+ - **KS** → `areReplacedPoliciesIssuedByFidelity: boolean`
224
+ > Question text: *"Are any of the policies you are considering replacing issued by Fidelity Life Association?"*
225
+ - **WA** → `otherInsuranceReplacementData` — all 7 booleans are required; each `specify*` string is required when its boolean is `true`. See `GigdbOtherInsuranceReplacementData` for the full field list.
226
+
227
+ ##### WA `otherInsuranceReplacementData` — exact question text per field
228
+
229
+ | Field | Exact applicant-facing question text |
230
+ |---|---|
231
+ | `mayReduceBenefitsIncreasePremiums` | *Can there be reduced benefits or increased premiums in later years?* |
232
+ | `specifyReduceBenefitsIncreasePremiums` | *Please explain* |
233
+ | `hasNewPolicyCharges` | *Are there penalties, set up or surrender charges for the new policy?* |
234
+ | `specifyNewPolicyCharges` | *Please explain, emphasizing any extra cost for early withdrawal.* |
235
+ | `hasPriorPolicyCharges` | *Will there be penalties or surrender charges under the existing insurance as a result of the proposed transaction?* |
236
+ | `specifyPriorPolicyCharges` | *Please explain* |
237
+ | `hasTaxConsequences` | *Are there adverse tax consequences from the replacement under current tax law?* |
238
+ | `specifyTaxConsequences` | *Please explain* |
239
+ | `hasInterestConsiderations` | *Are interest earnings a consideration in this replacement?* |
240
+ | `specifyInterestConsiderations` | *Please explain what portions of premiums or contributions will produce limited or no earnings. As pertinent, include the need for minimum deposits to enhance earnings, and the reduction of earnings that may result from set up charges, policy fees, and other factors.* |
241
+ | `hasMinRequirementsBeforeInterest` | *Are minimum amounts required to be on deposit before excess interest will be paid?* |
242
+ | `specifyMinRequirementsBeforeInterest`| *Please explain* |
243
+ | `hasOtherAdverseEffects` | *Are there other short or long term effects from the replacement that might be materially adverse?* |
244
+ | `specifyOtherAdverseEffects` | *Please explain* |
245
+
246
+ Example WA payload (replacement disclosure):
247
+
248
+ ```typescript
249
+ willOtherCoverageBeReplacedOrFinancedData: {
250
+ otherInsuranceReplacementData: {
251
+ mayReduceBenefitsIncreasePremiums: true,
252
+ specifyReduceBenefitsIncreasePremiums: 'Premiums may rise after year 5',
253
+ hasNewPolicyCharges: true,
254
+ specifyNewPolicyCharges: 'Surrender charges in years 1-3',
255
+ hasPriorPolicyCharges: false,
256
+ hasTaxConsequences: false,
257
+ hasInterestConsiderations: true,
258
+ specifyInterestConsiderations: 'Lower guaranteed rate on new policy',
259
+ hasMinRequirementsBeforeInterest: false,
260
+ hasOtherAdverseEffects: false
261
+ }
262
+ }
263
+ ```
264
+
265
+ ### Step 3 - Handle quote change (conditional)
266
+
267
+ ```typescript
268
+ let currentQuote = quoteResp.selectedQuote;
269
+
270
+ if (isQuoteChanged) {
271
+ const updatedQuoteResp = await client.getExistingGigdbQuote(opportunityId);
272
+ currentQuote = updatedQuoteResp.selectedQuote;
273
+ // Show the updated premium to the applicant before continuing
274
+ }
275
+ ```
276
+
277
+ ### Step 4 - `updateGigdbQuote` (optional - must be called BEFORE `saveEftPayment`)
278
+
279
+ If the applicant wants to change the face amount or payment frequency after the application has started:
280
+
281
+ ```typescript
282
+ const updatedQuoteResp = await client.updateGigdbQuote({
283
+ opportunityId,
284
+ faceAmount: 20000,
285
+ paymentFreq: PaymentFrequency.Annually
286
+ });
287
+ // updatedQuoteResp.selectedQuote.quoteAmount reflects the new premium
288
+ ```
289
+
290
+ > **Important:** The quote cannot be updated after EFT payment details are saved. `updateGigdbQuote()` must be called before `saveEftPayment()`.
291
+
292
+ ### Step 5 - `saveEftPayment(request: ThirdPartyEftPaymentReq)`
293
+
294
+ ```typescript
295
+ await client.saveEftPayment({
296
+ opportunityId,
297
+ accountHolderName: 'Jane Doe',
298
+ routingNumber: '021000021',
299
+ accountNumber: '123456789'
300
+ });
301
+ // After this point, the quote can no longer be updated.
302
+ ```
303
+
304
+ ### Steps 6–7 - Secure Sign → Final Submit
305
+
306
+ See [Secure Sign Flow](#secure-sign-flow) and [Final Submit](#final-submit).
307
+
308
+ ---
309
+
310
+ ## ADB Flow
311
+
312
+ > **Not available in:** MA, NH, AK
313
+ >
314
+ > **CA:** Supported. The ADB application requires the `occupation` field for California residents — populate it via `getAdbOccupationOptions()`.
315
+
316
+ ADB (Accidental Death Benefit) provides coverage for accidental deaths for ages 20–59.
317
+
318
+ ### Complete flow
319
+
320
+ ```
321
+ getAdbRiderDetails() ← check state availability & collect riderCodes
322
+ ↓
323
+ getAdbOccupationOptions() ← CA only — lookup occupation labels for the application
324
+ ↓
325
+ getAdbQuote()
326
+ ↓
327
+ startAdbApplication()
328
+ ↓
329
+ [if isDeclined = true] → stop - applicant not eligible
330
+ ↓
331
+ updateAdbQuote() ← optional — MUST be before saveEftPayment
332
+ ↓
333
+ getExistingAdbQuote() ← optional — fetch the current quote after update
334
+ ↓
335
+ saveEftPayment() ← shared with GIGDB; quote cannot be updated after this point
336
+ ↓
337
+ prepareDocsAndGetDeliveryChannels()
338
+ ↓
339
+ sendPinAndGetDocumentsLink() → verifyPin()
340
+ ↓
341
+ finalSubmit()
342
+ ```
343
+
344
+ ### Step 0 - `getAdbRiderDetails(stateCode: string)` (optional pre-step)
345
+
346
+ Call before `getAdbQuote()` to check whether ADB is available in the applicant's state and to retrieve the `riderCode` values to pass into the quote request. Skip this step only if you already know which riders (if any) are available for the state.
347
+
348
+ > **Note:** California (`CA`) is not supported — the API will return a 400 error for `stateCode = "CA"`.
349
+
350
+ ```typescript
351
+ import { InstaBrainClient } from '@instabrain-sdks/api-client';
352
+
353
+ const riderDetails = await client.getAdbRiderDetails('TX');
354
+
355
+ if (riderDetails.flagProductNotAvailableForState) {
356
+ // ADB not available in this state — do not proceed to quote
357
+ return;
358
+ }
359
+
360
+ // Collect riderCodes the user wants to include (may be an empty array)
361
+ const selectedRiderCodes = riderDetails.riders.map(r => r.riderCode);
362
+ // Pass selectedRiderCodes into ThirdPartyAdbQuoteRequest.riders
363
+ ```
364
+
365
+ > **Note:** `riders` may be an empty array even when `flagProductNotAvailableForState = false` — this means no optional riders are configured for that state.
366
+
367
+ ### Step 0a - `getAdbOccupationOptions(query?: string)` (CA only)
368
+
369
+ Search occupation labels for the ADB product. Required only when `address.state === "CA"` on the application — the `occupation` field on `ThirdPartyAdbAppReq` must be populated with one or more labels returned by this endpoint.
370
+
371
+ ```typescript
372
+ // Filter to a short list
373
+ const matches = await client.getAdbOccupationOptions('nurse');
374
+ // ['Registered Nurse', 'Nurse Practitioner', 'Licensed Practical Nurse', ...]
375
+
376
+ // Or fetch the full list (omit the query)
377
+ const allOccupations = await client.getAdbOccupationOptions();
378
+ ```
379
+
380
+ > Skip this call entirely for non-CA states — `occupation` should be omitted from the application request when the state is not CA.
381
+
382
+ ### Step 1 - `getAdbQuote(request: ThirdPartyAdbQuoteRequest)`
383
+
384
+ ```typescript
385
+ import { InstaBrainClient, Gender, PaymentFrequency, AdbRiderType } from '@instabrain-sdks/api-client';
386
+
387
+ const quoteResp = await client.getAdbQuote({
388
+ faceAmount: 100000,
389
+ gender: Gender.Male,
390
+ stateCode: 'TX',
391
+ age: 35,
392
+ paymentFreq: PaymentFrequency.Monthly,
393
+ riders: [AdbRiderType.FamilyADB],
394
+ firstName: 'John',
395
+ lastName: 'Smith',
396
+ email: 'john.smith@example.com'
397
+ });
398
+
399
+ const { quoteResponseId } = quoteResp.selectedQuote;
400
+ ```
401
+
402
+ **Rider notes:**
403
+
404
+ - `riders` is `AdbRiderType[]` - use the ADB-specific enum: `AdbRiderType.FamilyADB`, `AdbRiderType.ReturnOfPremium`, `AdbRiderType.InflationBenefit`
405
+ - Do **not** reuse the Term product's `RiderType` enum — those values (`'ADB Rider'`, `'Dependent Child Rider'`) are display titles, not ADB rider codes
406
+ - Rider availability varies by state - see [ADB Rider Availability](#adb-rider-availability)
407
+
408
+ ### Step 2 - `startAdbApplication(request: ThirdPartyAdbAppReq)`
409
+
410
+ ```typescript
411
+ import { BeneficiaryType, BeneficiaryRelationship } from '@instabrain-sdks/api-client';
412
+
413
+ const appResp = await client.startAdbApplication({
414
+ quoteResponseId: quoteResp.selectedQuote.quoteResponseId,
415
+ firstName: 'John',
416
+ lastName: 'Smith',
417
+ email: 'john.smith@example.com',
418
+ phoneNumber: '5559876543',
419
+ isUsCitizen: true,
420
+ isPayerAlsoOwnerAndInsured: true, // must be true - knockout if false
421
+ address: {
422
+ addressLine1: '456 Oak Ave',
423
+ city: 'Dallas',
424
+ state: 'TX',
425
+ zipcode: '75201'
426
+ },
427
+ dateOfBirth: '1988-03-20',
428
+ socialSecurityNumber: '987-65-4321',
429
+ hasExistingCoverage: false,
430
+ beneficiaryDetails: {
431
+ beneficiaryType: BeneficiaryType.Person,
432
+ beneficiaryPerson: {
433
+ firstName: 'Mary',
434
+ lastName: 'Smith',
435
+ relationship: BeneficiaryRelationship.Spouse
436
+ }
437
+ }
438
+ });
439
+
440
+ if (appResp.isDeclined) {
441
+ // Valid knockout - stop the flow
442
+ return;
443
+ }
444
+
445
+ const { opportunityId } = appResp;
446
+ ```
447
+
448
+ **Knockout rules - returns `isDeclined: true` (not an error, not thrown):**
449
+
450
+ - `isPayerAlsoOwnerAndInsured === false` → declined
451
+ - `isUsCitizen === false` AND `isLegalUsResident === false` → declined
452
+
453
+ **California residents — `occupation` field required:**
454
+
455
+ ```typescript
456
+ const appResp = await client.startAdbApplication({
457
+ // ...same fields as above, with CA address...
458
+ address: { addressLine1: '...', city: 'Los Angeles', state: 'CA', zipcode: '90001' },
459
+ occupation: ['Registered Nurse'], // populate from getAdbOccupationOptions()
460
+ // ...
461
+ });
462
+ ```
463
+
464
+ - `occupation` is an optional `string[]` on `ThirdPartyAdbAppReq`
465
+ - Required only when `address.state === "CA"` — omit for all other states
466
+ - Values must come from `getAdbOccupationOptions()`
467
+
468
+ **District of Columbia residents — three top-level ACA acknowledgement booleans required:**
469
+
470
+ > Third-party integrations must display the exact regulated question text below to applicants — paraphrasing is not sufficient. Source: Confluence page 699924481 (ADB Start Application API).
471
+
472
+ | Field | Exact applicant-facing question text |
473
+ |---|---|
474
+ | `hasMedicalCoverage` | *Do you have comprehensive medical coverage including the minimum essential coverage required by the Affordable Care Act (ACA) or are you treated as having minimum essential coverage due to your status as a bona fide resident of any possession of the United States?* |
475
+ | `understandsBenefits` | *Do you understand most supplemental only policies may not pay full benefits if your ACA compliant minimum essential coverage plan is not in force?* |
476
+ | `understandsLimitedBenefits`| *Do you understand that the benefits provided under this policy may be limited?* |
477
+
478
+ ```typescript
479
+ await client.startAdbApplication({
480
+ // ...same fields as above...
481
+ address: { addressLine1: '100 7th St NW', city: 'Washington', state: 'DC', zipcode: '20001' },
482
+ hasMedicalCoverage: true, // ACA minimum essential coverage
483
+ understandsBenefits: true, // supplemental policy benefits acknowledgement
484
+ understandsLimitedBenefits: true // limited benefits acknowledgement
485
+ });
486
+ ```
487
+
488
+ **OK / FL / DE residents with existing coverage — per-coverage acknowledgement:**
489
+
490
+ When `hasExistingCoverage === true`, set the corresponding flag on each `existingCoverages[]` item. Display the exact regulated question text:
491
+
492
+ | State | Field on `existingCoverages[]` | Exact applicant-facing question text |
493
+ |-------|------------------------------------|---------------------------------------|
494
+ | OK | `notifyPresentInsurer` | *Please notify my present insurer(s) regarding this transaction?* |
495
+ | FL | `wantsComparativeInformationForm` | *Indicate whether or not you wish a Comparative Information Form from the proposed company and your existing insurer or insurers?* |
496
+ | DE | `wantsPolicySummary` | *Do you want a policy summary statement from your existing insurer?* |
497
+
498
+ **ADB response differences from GIGDB/IB Term:**
499
+
500
+ - Response type is `ThirdPartyAdbStartAppResp` - contains only `opportunityId` and `isDeclined`
501
+ - No `agentLink`, `eAppAgentLink`, `applicantLink`
502
+ - No `isQuoteChanged`
503
+ - No `birthJurisdiction` field in the application request (unlike GIGDB)
504
+
505
+ ### Step 3 - `updateAdbQuote(request: ThirdPartyAdbUpdateQuoteReq)` (optional - must be called BEFORE `saveEftPayment`)
506
+
507
+ Re-quote an in-flight ADB opportunity with a new `faceAmount`, `paymentFreq`, or `riders` list. The quote cannot be updated after EFT payment details are saved — the API returns `"Quote update is not allowed when payment is already made"`.
508
+
509
+ ```typescript
510
+ import { PaymentFrequency } from '@instabrain-sdks/api-client';
511
+
512
+ const updatedQuote = await client.updateAdbQuote({
513
+ opportunityId,
514
+ faceAmount: 150000,
515
+ paymentFreq: PaymentFrequency.Monthly,
516
+ riders: [] // pass [] to clear all riders
517
+ });
518
+
519
+ const { quoteResponseId, quoteAmount } = updatedQuote.selectedQuote;
520
+ ```
521
+
522
+ ### Step 3a - `getExistingAdbQuote(opportunityId: string)` (optional)
523
+
524
+ Retrieve the current quote for an in-flight ADB opportunity. Useful any time you need to display or re-read the current premium after `updateAdbQuote()` or in the agent portal.
525
+
526
+ ```typescript
527
+ const currentQuote = await client.getExistingAdbQuote(opportunityId);
528
+ console.log(currentQuote.selectedQuote.quoteAmount);
529
+ ```
530
+
531
+ ### Step 4 - `saveEftPayment(request: ThirdPartyEftPaymentReq)`
532
+
533
+ Same shared method as GIGDB — both products use the same `POST /api/ThirdPartyPayment/save-eft-payment` endpoint.
534
+
535
+ ```typescript
536
+ await client.saveEftPayment({
537
+ opportunityId,
538
+ accountHolderName: 'John Smith',
539
+ routingNumber: '021000021',
540
+ accountNumber: '987654321'
541
+ });
542
+ // After this point, the quote can no longer be updated.
543
+ ```
544
+
545
+ ### Steps 5–6 - Secure Sign → Final Submit
546
+
547
+ See [Secure Sign Flow](#secure-sign-flow) and [Final Submit](#final-submit).
548
+
549
+ ---
550
+
551
+ ## IB Term Flow
552
+
553
+ > **Note:** IB Term is not yet fully available in this SDK release. This section is provided for reference only. Primary products for integration are GIGDB and ADB.
554
+ >
555
+ > **Not available in:** WY, NY
556
+
557
+ ### Complete flow
558
+
559
+ ```
560
+ getQuote()
561
+ ↓
562
+ startApplication()
563
+ ↓
564
+ prepareDocsAndGetDeliveryChannels()
565
+ ↓
566
+ sendPinAndGetDocumentsLink() → verifyPin()
567
+ ↓
568
+ finalSubmit()
569
+ ```
570
+
571
+ ### Step 1 - `getQuote(request: ThirdPartyQuoteReq)`
572
+
573
+ Provide exactly one of three mutually exclusive rating inputs:
574
+
575
+ - `rateClass` - use `RateClass` enum
576
+ - `healthClass` - use `HealthClass` enum *(note: `HealthClass.Preferred` does not exist; valid values: Excellent, Great, Good, Average)*
577
+ - `height` + `weightInLbs` - build chart rating
578
+
579
+ ```typescript
580
+ import { Gender, PaymentFrequency, HealthClass } from '@instabrain-sdks/api-client';
581
+
582
+ const quoteResp = await client.getQuote({
583
+ faceAmount: 500000,
584
+ benefitPeriod: 20,
585
+ flagTobaccoUse: false,
586
+ gender: Gender.Male,
587
+ stateCode: 'TX',
588
+ zipCode: null,
589
+ healthClass: HealthClass.Great,
590
+ rateClass: null,
591
+ height: { feet: 5, inches: 10 },
592
+ weightInLbs: null,
593
+ age: 40,
594
+ dateOfBirth: null,
595
+ riders: null,
596
+ paymentFreq: PaymentFrequency.Monthly,
597
+ firstName: 'John',
598
+ lastName: null,
599
+ email: null,
600
+ phoneNum: null
601
+ });
602
+
603
+ const { quoteResponseId } = quoteResp.selectedQuote;
604
+ ```
605
+
606
+ **Field priority rules:**
607
+
608
+ - `zipCode` takes priority over `stateCode` if both are provided
609
+ - `dateOfBirth` takes priority over `age` if both are provided
610
+
611
+ ### Step 2 - `startApplication(request: ThirdPartyStartApplicationReq)`
612
+
613
+ ```typescript
614
+ const appResp = await client.startApplication({
615
+ quoteResponseId: quoteResp.selectedQuote.quoteResponseId,
616
+ firstName: 'John',
617
+ lastName: 'Smith',
618
+ email: 'john.smith@example.com',
619
+ phoneNumber: '5559876543'
620
+ });
621
+
622
+ const { opportunityId, agentLink, eAppAgentLink, applicantLink } = appResp;
623
+ ```
624
+
625
+ **Response links:**
626
+
627
+
628
+ | Field | Description |
629
+ | --------------- | -------------------------------------------------------------------- |
630
+ | `agentLink` | URL for the agent to complete their section in the InstaBrain portal |
631
+ | `eAppAgentLink` | Alternate agent URL used in eApp mode (some partner configurations) |
632
+ | `applicantLink` | URL sent to the proposed insured for their self-service section |
633
+
634
+
635
+ ### Steps 3–4 - Secure Sign → Final Submit
636
+
637
+ See [Secure Sign Flow](#secure-sign-flow) and [Final Submit](#final-submit).
638
+
639
+ ---
640
+
641
+ ## Secure Sign Flow
642
+
643
+ Shared across all products. Used to electronically sign application documents after EFT payment.
644
+
645
+ ### Complete flow
646
+
647
+ ```
648
+ prepareDocsAndGetDeliveryChannels(opportunityId)
649
+ ↓
650
+ [if isSignCompleted = true] → skip directly to finalSubmit()
651
+ ↓
652
+ sendPinAndGetDocumentsLink()
653
+ ↓
654
+ [agent reads script aloud; applicant reviews and signs documents via link]
655
+ ↓
656
+ verifyPin() [or resendPin() if PIN was not received]
657
+ ↓
658
+ finalSubmit()
659
+ ```
660
+
661
+ ### Step 1 - `prepareDocsAndGetDeliveryChannels(opportunityId: string)`
662
+
663
+ Always call this first in the signing flow. If `isSignCompleted` is `true`, skip directly to `finalSubmit()`.
664
+
665
+ ```typescript
666
+ const prepResp = await client.prepareDocsAndGetDeliveryChannels(opportunityId);
667
+
668
+ if (prepResp.isSignCompleted) {
669
+ // Documents already signed - go to finalSubmit()
670
+ } else {
671
+ console.log('SMS available:', prepResp.isSmsAvailable);
672
+ console.log('Email available:', prepResp.isEmailAvailable);
673
+ }
674
+ ```
675
+
676
+ ### Step 2 - `sendPinAndGetDocumentsLink(request: ThirdPartySendPinReq)`
677
+
678
+ At least one of `flagSendSms` or `flagSendEmail` must be `true`.
679
+
680
+ ```typescript
681
+ const pinResp = await client.sendPinAndGetDocumentsLink({
682
+ opportunityId,
683
+ flagSendSms: true,
684
+ flagSendEmail: false
685
+ });
686
+
687
+ // pinResp.link - URL for the applicant to review and sign documents
688
+ // pinResp.scriptHeader - header for the disclosure section
689
+ // pinResp.script - array of disclosure statements to read aloud
690
+ // pinResp.consentMessage - consent statement with the applicant's name
691
+ ```
692
+
693
+ ### Step 3 - Agent reads script; applicant signs
694
+
695
+ 1. The agent reads each item in `pinResp.script` aloud to the proposed insured
696
+ 2. The applicant opens `pinResp.link` in their browser to review and sign documents
697
+ 3. *(Non-code step - the SDK does not manage the applicant's browser session)*
698
+
699
+ ### Step 4 - `verifyPin(request: ThirdPartyVerifyPinReq)`
700
+
701
+ `isScriptReadConfirmed: true` is required - confirms the agent has read the disclosure aloud.
702
+
703
+ ```typescript
704
+ const verifyResp = await client.verifyPin({
705
+ opportunityId,
706
+ pin: '123456',
707
+ isScriptReadConfirmed: true
708
+ });
709
+
710
+ if (verifyResp.isVerified) {
711
+ // Signing complete - proceed to finalSubmit()
712
+ }
713
+ ```
714
+
715
+ **Optional - `resendPin` (if PIN was not received):**
716
+
717
+ ```typescript
718
+ await client.resendPin({
719
+ opportunityId,
720
+ flagSendSms: true,
721
+ flagSendEmail: false
722
+ });
723
+ ```
724
+
725
+ ---
726
+
727
+ ## Final Submit
728
+
729
+ Shared across all products. Submits the completed application to the carrier for underwriting.
730
+
731
+ ```typescript
732
+ const submitResp = await client.finalSubmit(opportunityId);
733
+ console.log('Policy number:', submitResp.policyNumber);
734
+ ```
735
+
736
+ > `**policyNumber: null**` is normal - the carrier may not issue a policy number immediately (pending underwriting decision). This is **not** an error.
737
+
738
+ > **Throws `PaymentNotMade`** if `saveEftPayment()` was not called before this step.
739
+
740
+ ---
741
+
742
+ ## Reporting API
743
+
744
+ Three methods for retrieving data from the agent portal. `pageSize` and `pageIndex` are required.
745
+
746
+ ```typescript
747
+ import { AgentPortalReq } from '@instabrain-sdks/api-client';
748
+
749
+ const request: AgentPortalReq = {
750
+ pageSize: 20, // required
751
+ pageIndex: 0 // required, 0-based
752
+ };
753
+ ```
754
+
755
+ ### Methods
756
+
757
+ ```typescript
758
+ // Quotes not yet converted to applications
759
+ const prospects = await client.getProspects(request);
760
+ // Returns: { prospectCount: number, prospects: ThirdPartyProspectsDetails[] }
761
+
762
+ // Completed / sold policies
763
+ const sales = await client.getSales(request);
764
+ // Returns: { applicationCount: number, salesReport: ThirdPartySalesReport[], totalPremiumAmount: number }
765
+
766
+ // Applications in progress
767
+ const applications = await client.getApplications(request);
768
+ // Returns: { applicationCount: number, applications: ThirdPartyApplicationsReport[] }
769
+ ```
770
+
771
+ ### Full `AgentPortalReq` field reference
772
+
773
+
774
+ | Field | Type | Required | Description |
775
+ | -------------- | ------------------------- | -------- | --------------------------------------------- |
776
+ | `pageSize` | `number` | **Yes** | Items per page |
777
+ | `pageIndex` | `number` | **Yes** | Page index, 0-based |
778
+ | `startDate` | `string` (ISO) | No | Start of date range |
779
+ | `endDate` | `string` (ISO) | No | End of date range |
780
+ | `dayCount` | `number` | No | Alternative to date range - fetch last N days |
781
+ | `userTimeZone` | `string` | No | IANA timezone (e.g., `'America/Chicago'`) |
782
+ | `sort` | `AgentPortalReqSorting` | No | Sort configuration |
783
+ | `filters` | `AgentPortalReqFilters[]` | No | Array of filters |
784
+ | `searchParam` | `string` | No | Text search |
785
+
786
+
787
+ ### Sorting (`AgentPortalReqSorting`)
788
+
789
+ ```typescript
790
+ sort: {
791
+ value: 'createdOn',
792
+ sortDescending: true
793
+ }
794
+ ```
795
+
796
+ ### Filtering (`AgentPortalReqFilters[]`)
797
+
798
+ ```typescript
799
+ import { SQLOperator } from '@instabrain-sdks/api-client';
800
+
801
+ filters: [
802
+ {
803
+ field: 'stateCode',
804
+ operator: SQLOperator.Equal,
805
+ value: 'TX'
806
+ }
807
+ ]
808
+ ```
809
+
810
+ `**SQLOperator` enum values:**
811
+
812
+
813
+ | Enum Member | Numeric Value | Description |
814
+ | -------------------- | ------------- | --------------------- |
815
+ | `Equal` | `0` | Exact match |
816
+ | `NotEqual` | `1` | Not equal |
817
+ | `GreaterThan` | `2` | Greater than |
818
+ | `GreaterThanOrEqual` | `3` | Greater than or equal |
819
+ | `LessThan` | `4` | Less than |
820
+ | `LessThanOrEqual` | `5` | Less than or equal |
821
+ | `Contains` | `6` | Contains substring |
822
+ | `StartsWith` | `7` | Starts with |
823
+ | `EndsWith` | `8` | Ends with |
824
+ | `In` | `9` | In list |
825
+ | `NotIn` | `10` | Not in list |
826
+
827
+
828
+ ---
829
+
830
+ ## Request Type Reference
831
+
832
+ ### `ThirdPartyGigdbQuoteRequest`
833
+
834
+
835
+ | Field | Type | Required | Constraints |
836
+ | ------------- | ------------------ | -------- | ----------- |
837
+ | `faceAmount` | `number | null` | Yes |
838
+ | `gender` | `Gender` | Yes | |
839
+ | `stateCode` | `string | null` | Yes |
840
+ | `age` | `number | null` | Yes* |
841
+ | `dateOfBirth` | `string | null` | Yes* |
842
+ | `paymentFreq` | `PaymentFrequency` | Yes | |
843
+ | `isSmoker` | `boolean | null` | Yes |
844
+ | `firstName` | `string | null` | No |
845
+ | `lastName` | `string | null` | No |
846
+ | `email` | `string | null` | No |
847
+ | `phoneNum` | `string | null` | No |
848
+
849
+
850
+ ### `ThirdPartyGigdbAppReq`
851
+
852
+
853
+ | Field | Type | Required | Constraints |
854
+ | --------------------------------------- | -------------------------- | -------- | --------------------------------------------------- |
855
+ | `quoteResponseId` | `string` | Yes | UUID from quote response |
856
+ | `firstName` | `string | null` | No |
857
+ | `lastName` | `string | null` | No |
858
+ | `email` | `string | null` | No |
859
+ | `phoneNumber` | `string | null` | No |
860
+ | `isUsCitizen` | `boolean | null` | Yes |
861
+ | `isPayerAlsoOwnerAndInsured` | `boolean | null` | Yes |
862
+ | `isLegalUsResident` | `boolean | null` | No |
863
+ | `address` | `GigdbAddress` | Yes | See sub-fields below |
864
+ | `dateOfBirth` | `string | null` | Yes |
865
+ | `socialSecurityNumber` | `string | null` | Yes |
866
+ | `birthJurisdiction` | `GigdbBirthJurisdiction` | Yes | See sub-fields below |
867
+ | `isSmoker` | `boolean | null` | Yes |
868
+ | `nicotineInfo` | `GigdbNicotineInfo | null` | No |
869
+ | `hasExistingCoverage` | `boolean | null` | Yes |
870
+ | `willOtherCoverageBeReplacedOrFinanced` | `boolean | null` | No |
871
+ | `existingCoverageData` | `GigdbExistingCoverageData | null` | No |
872
+ | `willOtherCoverageBeReplacedOrFinancedData` | `GigdbWillOtherCoverageBeReplacedOrFinancedData | null` | No | Required when `address.state` is `"KS"` or `"WA"` AND `willOtherCoverageBeReplacedOrFinanced === true` |
873
+ | `beneficiaryDetails` | `BeneficiaryDetails` | Yes | See [Beneficiary Reference](#beneficiary-reference) |
874
+
875
+
876
+ `**GigdbAddress`:**
877
+
878
+
879
+ | Field | Type |
880
+ | -------------- | ------- |
881
+ | `addressLine1` | `string |
882
+ | `city` | `string |
883
+ | `state` | `string |
884
+ | `zipcode` | `string |
885
+
886
+
887
+ `**GigdbBirthJurisdiction`:**
888
+
889
+
890
+ | Field | Type | Description |
891
+ | --------- | ------- | ----------- |
892
+ | `state` | `string | null` |
893
+ | `country` | `string | null` |
894
+
895
+
896
+ `**GigdbExistingCoverageData`:**
897
+
898
+
899
+ | Field | Type | Required | Notes |
900
+ | --------------------------------------- | ---------------------------- | -------- | ----- |
901
+ | `isExistingPolicyBeingTerminated` | `boolean | null` | No |
902
+ | `existingCoverages` | `GigdbExistingCoverageInfo[] | null` | Yes (when `hasExistingCoverage === true`) |
903
+ | `areExistingPoliciesIssuedByFidelity` | `boolean | null` | No | Required when `address.state` is `"RI"` or `"WV"` |
904
+
905
+
906
+ `**GigdbExistingCoverageInfo`:**
907
+
908
+
909
+ | Field | Type | Required | Notes |
910
+ | --------------------------------- | ---------------- | -------- | ----- |
911
+ | `nameOfTheCompany` | `string | null` | Yes | |
912
+ | `insuranceAmount` | `string | null` | Yes | |
913
+ | `dateOfIssue` | `string | null` | Yes | `YYYY-MM` |
914
+ | `toBeReplaced` | `boolean | null` | Yes | |
915
+ | `toBeFinanced` | `boolean | null` | Yes | |
916
+ | `requestsYieldIndices` | `boolean | null` | No | Required when `address.state === "MA"` (per-coverage Q-08) |
917
+ | `notifyPresentInsurer` | `boolean | null` | No | Required when `address.state === "OK"` (per-coverage Q-08) |
918
+ | `wantsPolicySummary` | `boolean | null` | No | Required when `address.state` is `"DE"` or `"GA"` (per-coverage Q-08) |
919
+ | `wantsComparativeInformationForm` | `boolean | null` | No | Required when `address.state === "FL"` (per-coverage Q-08) |
920
+
921
+
922
+ `**GigdbWillOtherCoverageBeReplacedOrFinancedData`:** *(new — IBS-63)*
923
+
924
+
925
+ | Field | Type | Required | Notes |
926
+ | -------------------------------------- | ------------------------------------- | -------- | ----- |
927
+ | `areReplacedPoliciesIssuedByFidelity` | `boolean | null` | No | Required when `address.state === "KS"` AND `willOtherCoverageBeReplacedOrFinanced === true` |
928
+ | `otherInsuranceReplacementData` | `GigdbOtherInsuranceReplacementData | null` | No | Required when `address.state === "WA"` AND `willOtherCoverageBeReplacedOrFinanced === true` |
929
+
930
+
931
+ `**GigdbOtherInsuranceReplacementData`:** *(new — IBS-63, WA-only)*
932
+
933
+ > All 7 booleans are server-required (must be non-null). For each boolean set to `true`, the paired `specify*` string must be a non-empty explanation. When the boolean is `false`, the paired `specify*` may be omitted or `null`.
934
+
935
+ | Field | Type | Required when | Exact applicant-facing question text |
936
+ | ------------------------------------------- | ---------------- | ------------------------------------------------- | --- |
937
+ | `mayReduceBenefitsIncreasePremiums` | `boolean` | Always (WA) | *Can there be reduced benefits or increased premiums in later years?* |
938
+ | `specifyReduceBenefitsIncreasePremiums` | `string | null` | When `mayReduceBenefitsIncreasePremiums === true` | *Please explain* |
939
+ | `hasNewPolicyCharges` | `boolean` | Always (WA) | *Are there penalties, set up or surrender charges for the new policy?* |
940
+ | `specifyNewPolicyCharges` | `string | null` | When `hasNewPolicyCharges === true` | *Please explain, emphasizing any extra cost for early withdrawal.* |
941
+ | `hasPriorPolicyCharges` | `boolean` | Always (WA) | *Will there be penalties or surrender charges under the existing insurance as a result of the proposed transaction?* |
942
+ | `specifyPriorPolicyCharges` | `string | null` | When `hasPriorPolicyCharges === true` | *Please explain* |
943
+ | `hasTaxConsequences` | `boolean` | Always (WA) | *Are there adverse tax consequences from the replacement under current tax law?* |
944
+ | `specifyTaxConsequences` | `string | null` | When `hasTaxConsequences === true` | *Please explain* |
945
+ | `hasInterestConsiderations` | `boolean` | Always (WA) | *Are interest earnings a consideration in this replacement?* |
946
+ | `specifyInterestConsiderations` | `string | null` | When `hasInterestConsiderations === true` | *Please explain what portions of premiums or contributions will produce limited or no earnings. As pertinent, include the need for minimum deposits to enhance earnings, and the reduction of earnings that may result from set up charges, policy fees, and other factors.* |
947
+ | `hasMinRequirementsBeforeInterest` | `boolean` | Always (WA) | *Are minimum amounts required to be on deposit before excess interest will be paid?* |
948
+ | `specifyMinRequirementsBeforeInterest` | `string | null` | When `hasMinRequirementsBeforeInterest === true` | *Please explain* |
949
+ | `hasOtherAdverseEffects` | `boolean` | Always (WA) | *Are there other short or long term effects from the replacement that might be materially adverse?* |
950
+ | `specifyOtherAdverseEffects` | `string | null` | When `hasOtherAdverseEffects === true` | *Please explain* |
951
+
952
+
953
+ ### `ThirdPartyGigdbUpdateQuoteReq`
954
+
955
+
956
+ | Field | Type | Required | Constraints |
957
+ | --------------- | ------------------ | -------- | ------------------------------------ |
958
+ | `opportunityId` | `string` | Yes | UUID from start application response |
959
+ | `faceAmount` | `number` | Yes | $5,000–$25,000 |
960
+ | `paymentFreq` | `PaymentFrequency` | Yes | |
961
+
962
+
963
+ > Must be called before `saveEftPayment()`. Cannot update after EFT payment is saved.
964
+
965
+ ### `ThirdPartyAdbQuoteRequest`
966
+
967
+
968
+ | Field | Type | Required | Constraints |
969
+ | ------------- | ------------------ | -------- | --------------------------------------------------------- |
970
+ | `faceAmount` | `number` | Yes | |
971
+ | `gender` | `Gender` | Yes | |
972
+ | `stateCode` | `string` | Yes | 2-char US state; not MA, NH, AK; CA not yet supported |
973
+ | `age` | `number` | Yes* | 20–59; required if `dateOfBirth` not provided |
974
+ | `dateOfBirth` | `string` | Yes* | ISO 8601; required if `age` not provided |
975
+ | `paymentFreq` | `PaymentFrequency` | Yes | |
976
+ | `riders` | `AdbRiderType[]` | No | Use `AdbRiderType` enum values; availability varies by state |
977
+ | `firstName` | `string` | No | Max 35 chars |
978
+ | `lastName` | `string` | No | Max 35 chars |
979
+ | `email` | `string` | No | Valid email format |
980
+ | `phoneNum` | `string` | No | 10-digit numeric |
981
+
982
+
983
+ ### `ThirdPartyAdbAppReq`
984
+
985
+
986
+ | Field | Type | Required | Constraints |
987
+ | --------------------------------------- | ------------------------- | -------- | --------------------------------------------------- |
988
+ | `quoteResponseId` | `string` | Yes | UUID from ADB quote response |
989
+ | `firstName` | `string` | Yes | Max 35 chars |
990
+ | `lastName` | `string` | Yes | Max 35 chars |
991
+ | `email` | `string` | Yes | Valid email format |
992
+ | `phoneNumber` | `string` | Yes | 10-digit numeric |
993
+ | `isUsCitizen` | `boolean` | Yes | |
994
+ | `isLegalUsResident` | `boolean` | No | Required when `isUsCitizen = false` |
995
+ | `isPayerAlsoOwnerAndInsured` | `boolean` | Yes | Must be `true`; knockout if `false` |
996
+ | `address` | `AdbAddress` | Yes | See sub-fields below |
997
+ | `dateOfBirth` | `string` | Yes | ISO 8601; age must be 20–59 |
998
+ | `socialSecurityNumber` | `string` | Yes | Format: `XXXXXXXXX` (9 digits, no dashes) |
999
+ | `hasExistingCoverage` | `boolean` | Yes | |
1000
+ | `willOtherCoverageBeReplacedOrFinanced` | `boolean` | No | Required if `hasExistingCoverage = true` |
1001
+ | `existingCoverageData` | `AdbExistingCoverageData` | No | Required if `hasExistingCoverage = true` |
1002
+ | `occupation` | `string[]` | No | Required when `address.state === "CA"`; values from `getAdbOccupationOptions()` |
1003
+ | `hasMedicalCoverage` | `boolean` | No | Required when `address.state === "DC"` (ACA acknowledgement) |
1004
+ | `understandsBenefits` | `boolean` | No | Required when `address.state === "DC"` (ACA acknowledgement) |
1005
+ | `understandsLimitedBenefits` | `boolean` | No | Required when `address.state === "DC"` (ACA acknowledgement) |
1006
+ | `beneficiaryDetails` | `BeneficiaryDetails` | Yes | See [Beneficiary Reference](#beneficiary-reference) |
1007
+
1008
+
1009
+ `**AdbAddress`:**
1010
+
1011
+
1012
+ | Field | Type | Constraints |
1013
+ | -------------- | -------- | ------------------------------------------- |
1014
+ | `addressLine1` | `string` | |
1015
+ | `city` | `string` | |
1016
+ | `state` | `string` | 2-char; must match state used at quote time |
1017
+ | `zipcode` | `string` | 5-digit numeric |
1018
+
1019
+
1020
+ `**AdbExistingCoverageData`:**
1021
+
1022
+
1023
+ | Field | Type | Required | Notes |
1024
+ | --------------------------------- | -------------------------- | -------- | ----- |
1025
+ | `isExistingPolicyBeingTerminated` | `boolean` | Yes | |
1026
+ | `existingCoverages` | `AdbExistingCoverageInfo[]`| Yes | At least one entry required when present |
1027
+
1028
+
1029
+ `**AdbExistingCoverageInfo`:**
1030
+
1031
+
1032
+ | Field | Type | Required | Notes |
1033
+ | --------------------------------- | --------- | -------- | ----- |
1034
+ | `nameOfTheCompany` | `string` | Yes | |
1035
+ | `insuranceAmount` | `string` | Yes | |
1036
+ | `dateOfIssue` | `string` | Yes | `YYYY-MM` |
1037
+ | `toBeReplaced` | `boolean` | Yes | |
1038
+ | `toBeFinanced` | `boolean` | Yes | |
1039
+ | `notifyPresentInsurer` | `boolean` | No | Required when `address.state === "OK"` AND `hasExistingCoverage === true` |
1040
+ | `wantsComparativeInformationForm` | `boolean` | No | Required when `address.state === "FL"` AND `hasExistingCoverage === true` |
1041
+ | `wantsPolicySummary` | `boolean` | No | Required when `address.state === "DE"` AND `hasExistingCoverage === true` |
1042
+
1043
+
1044
+ ### `ThirdPartyEftPaymentReq` (shared - GIGDB and ADB)
1045
+
1046
+
1047
+ | Field | Type | Required | Description |
1048
+ | ------------------- | -------- | -------- | ------------------------------------ |
1049
+ | `opportunityId` | `string` | Yes | UUID from start application response |
1050
+ | `accountHolderName` | `string | null` | Yes |
1051
+ | `routingNumber` | `string | null` | Yes |
1052
+ | `accountNumber` | `string | null` | Yes |
1053
+
1054
+
1055
+ > Use `saveEftPayment()` for both GIGDB and ADB — both products share the same `POST /api/ThirdPartyPayment/save-eft-payment` endpoint.
1056
+
1057
+ ### `ThirdPartyQuoteReq` (IB Term - Secondary)
1058
+
1059
+
1060
+ | Field | Type | Required | Constraints |
1061
+ | ---------------- | ---------------------------------- | -------- | ----------------------------------------------- |
1062
+ | `faceAmount` | `number` | Yes | See age-based limits below |
1063
+ | `benefitPeriod` | `number` | Yes | 10, 20, or 30 (age-dependent - see table below) |
1064
+ | `flagTobaccoUse` | `boolean` | Yes | |
1065
+ | `gender` | `Gender` | Yes | |
1066
+ | `stateCode` | `string | null` | Yes* |
1067
+ | `zipCode` | `string | null` | Yes* |
1068
+ | `rateClass` | `RateClass | null` | Yes* |
1069
+ | `healthClass` | `HealthClass | null` | Yes* |
1070
+ | `height` | `{ feet: number, inches: number }` | Yes* | Required if `weightInLbs` provided |
1071
+ | `weightInLbs` | `number | null` | Yes* |
1072
+ | `age` | `number | null` | Yes* |
1073
+ | `dateOfBirth` | `string | null` | Yes* |
1074
+ | `riders` | `ThirdPartyQuoteReqRider[] | null` | No |
1075
+ | `paymentFreq` | `PaymentFrequency` | Yes | |
1076
+ | `firstName` | `string | null` | No |
1077
+ | `lastName` | `string | null` | No |
1078
+ | `email` | `string | null` | No |
1079
+ | `phoneNum` | `string | null` | No |
1080
+
1081
+
1082
+ **Face amount limits (age-based):**
1083
+
1084
+
1085
+ | Age | Min | Max |
1086
+ | -------- | ------- | ---------- |
1087
+ | Up to 55 | $50,000 | $1,000,000 |
1088
+ | 56 | $50,000 | $900,000 |
1089
+ | 57 | $50,000 | $800,000 |
1090
+ | 58 | $50,000 | $700,000 |
1091
+ | 59 | $50,000 | $600,000 |
1092
+ | 60 | $50,000 | $500,000 |
1093
+
1094
+
1095
+ **Benefit period availability:**
1096
+
1097
+
1098
+ | Age | Tobacco use | Available periods |
1099
+ | -------- | ----------- | ----------------- |
1100
+ | Up to 45 | Any | 10, 20, 30 |
1101
+ | 45–50 | Non-tobacco | 10, 20, 30 |
1102
+ | 45–50 | Tobacco | 10, 20 |
1103
+ | 51–60 | Any | 10, 20 |
1104
+
1105
+
1106
+ ### `ThirdPartySendPinReq`
1107
+
1108
+
1109
+ | Field | Type | Required | Constraints |
1110
+ | --------------- | --------- | -------- | --------------------------------------------------------------- |
1111
+ | `opportunityId` | `string` | Yes | |
1112
+ | `flagSendSms` | `boolean` | Yes | At least one of `flagSendSms` or `flagSendEmail` must be `true` |
1113
+ | `flagSendEmail` | `boolean` | Yes | At least one of `flagSendSms` or `flagSendEmail` must be `true` |
1114
+
1115
+
1116
+ ### `ThirdPartyResendPinReq`
1117
+
1118
+
1119
+ | Field | Type | Required | Constraints |
1120
+ | --------------- | --------- | -------- | ----------------------------------------- |
1121
+ | `opportunityId` | `string` | Yes | |
1122
+ | `flagSendSms` | `boolean` | Yes | At least one delivery flag must be `true` |
1123
+ | `flagSendEmail` | `boolean` | Yes | At least one delivery flag must be `true` |
1124
+
1125
+
1126
+ ### `ThirdPartyVerifyPinReq`
1127
+
1128
+
1129
+ | Field | Type | Required | Constraints |
1130
+ | ----------------------- | --------- | -------- | -------------------------------------------------- |
1131
+ | `opportunityId` | `string` | Yes | |
1132
+ | `pin` | `string` | Yes | PIN entered by the signer |
1133
+ | `isScriptReadConfirmed` | `boolean` | Yes | Must be `true`; confirms disclosure was read aloud |
1134
+
1135
+
1136
+ ---
1137
+
1138
+ ## Response Type Reference
1139
+
1140
+ ### `BaseResponse<T>`
1141
+
1142
+ All InstaBrain API responses are wrapped in this envelope:
1143
+
1144
+ ```typescript
1145
+ interface BaseResponse<T> {
1146
+ flagStatus: boolean; // true = success, false = API-level error
1147
+ value: T; // the actual response data
1148
+ error: string | null; // error message when flagStatus = false
1149
+ errorCode?: string; // error code when flagStatus = false
1150
+ }
1151
+ ```
1152
+
1153
+ The SDK unwraps this envelope automatically - integrators receive `value` directly. When `flagStatus = false`, the SDK throws `APIValidationError`. You never check `flagStatus` manually.
1154
+
1155
+ ### `ThirdPartyQuoteResp`
1156
+
1157
+ Returned by `getGigdbQuote()`, `getAdbQuote()`, `getQuote()`, `updateGigdbQuote()`, `getExistingGigdbQuote()`.
1158
+
1159
+ ```typescript
1160
+ interface ThirdPartyQuoteResp {
1161
+ productName: string | null;
1162
+ selectedQuote: Quote;
1163
+ }
1164
+ ```
1165
+
1166
+ **Key `Quote` fields:**
1167
+
1168
+
1169
+ | Field | Type | Description |
1170
+ | ------------------- | ------------- | -------------------------------------- |
1171
+ | `quoteResponseId` | `string` | UUID - pass to `startXxxApplication()` |
1172
+ | `quoteAmount` | `number | null` |
1173
+ | `faceAmount` | `number` | Coverage amount |
1174
+ | `benefitPeriod` | `number | null` |
1175
+ | `paymentFrequency` | `string | null` |
1176
+ | `isMedicalRequired` | `boolean` | Whether a medical exam is required |
1177
+ | `selectedRiders` | `RidersList[] | null` |
1178
+
1179
+
1180
+ ### `ThirdPartyStartAppResp` (GIGDB, IB Term)
1181
+
1182
+ Returned by `startGigdbApplication()` and `startApplication()`.
1183
+
1184
+
1185
+ | Field | Type | Description |
1186
+ | ---------------- | --------- | --------------------------------------------- |
1187
+ | `opportunityId` | `string` | UUID - used for all subsequent calls |
1188
+ | `agentLink` | `string | null` |
1189
+ | `eAppAgentLink` | `string | null` |
1190
+ | `applicantLink` | `string | null` |
1191
+ | `isDeclined` | `boolean` | `true` = valid knockout (GIGDB); not an error |
1192
+ | `isQuoteChanged` | `boolean` | `true` = premium was adjusted (GIGDB) |
1193
+
1194
+
1195
+ ### `AdbRiderDetailsResp` (ADB only)
1196
+
1197
+ Returned by `getAdbRiderDetails()`.
1198
+
1199
+ | Field | Type | Description |
1200
+ |---|---|---|
1201
+ | `riders` | `AdbRiderResp[]` | Available riders for the state. May be empty even when product is available. |
1202
+ | `flagProductNotAvailableForState` | `boolean` | `true` = ADB not available in this state; stop. `false` = available; proceed to quote. |
1203
+
1204
+ ### `AdbRiderResp`
1205
+
1206
+ | Field | Type | Description |
1207
+ |---|---|---|
1208
+ | `riderCode` | `AdbRiderType` | Pass into `ThirdPartyAdbQuoteRequest.riders` to include this rider in the quote. Values: `FamilyADB`, `ReturnOfPremium`, `InflationBenefit`. |
1209
+ | `riderTitle` | `string` | Display title for UI rendering. |
1210
+ | `riderDescription` | `string` | Display description for UI rendering. |
1211
+
1212
+ ### `ThirdPartyAdbStartAppResp` (ADB only)
1213
+
1214
+ Returned by `startAdbApplication()`. Contains only two fields - no links, no `isQuoteChanged`:
1215
+
1216
+
1217
+ | Field | Type | Description |
1218
+ | --------------- | --------- | ------------------------------------------ |
1219
+ | `opportunityId` | `string` | UUID - empty GUID when `isDeclined = true` |
1220
+ | `isDeclined` | `boolean` | `true` = knockout; stop the flow |
1221
+
1222
+
1223
+ ### `ThirdPartyPrepareDocsResp`
1224
+
1225
+
1226
+ | Field | Type | Description |
1227
+ | ------------------ | --------- | ---------------------------------- |
1228
+ | `isSignCompleted` | `boolean` | If `true`, skip to `finalSubmit()` |
1229
+ | `isSmsAvailable` | `boolean` | SMS delivery channel available |
1230
+ | `isEmailAvailable` | `boolean` | Email delivery channel available |
1231
+ | `productName` | `string | null` |
1232
+
1233
+
1234
+ ### `ThirdPartySendPinResp`
1235
+
1236
+
1237
+ | Field | Type | Description |
1238
+ | ---------------- | --------- | ----------- |
1239
+ | `link` | `string | null` |
1240
+ | `scriptHeader` | `string | null` |
1241
+ | `script` | `string[] | null` |
1242
+ | `consentMessage` | `string | null` |
1243
+
1244
+
1245
+ ### `ThirdPartyResendPinResp`
1246
+
1247
+
1248
+ | Field | Type | Description |
1249
+ | ------------- | --------- | ----------------------------------- |
1250
+ | `flagPinSent` | `boolean` | `true` when PIN resent successfully |
1251
+
1252
+
1253
+ ### `ThirdPartyVerifyPinResp`
1254
+
1255
+
1256
+ | Field | Type | Description |
1257
+ | ------------ | --------- | ------------------------------------------------ |
1258
+ | `isVerified` | `boolean` | `true` when PIN matched and documents are signed |
1259
+
1260
+
1261
+ ### `ThirdPartyFinalSubmitResp`
1262
+
1263
+
1264
+ | Field | Type | Description |
1265
+ | -------------- | ------- | ----------- |
1266
+ | `policyNumber` | `string | null` |
1267
+
1268
+
1269
+ ---
1270
+
1271
+ ## Enums and Constants
1272
+
1273
+ ### `Gender`
1274
+
1275
+
1276
+ | Enum Member | Value |
1277
+ | --------------- | ---------- |
1278
+ | `Gender.Male` | `'Male'` |
1279
+ | `Gender.Female` | `'Female'` |
1280
+
1281
+
1282
+ ### `PaymentFrequency`
1283
+
1284
+
1285
+ | Enum Member | Value |
1286
+ | --------------------------- | ------------ |
1287
+ | `PaymentFrequency.Monthly` | `'Monthly'` |
1288
+ | `PaymentFrequency.Annually` | `'Annually'` |
1289
+
1290
+
1291
+ ### `HealthClass`
1292
+
1293
+
1294
+ | Enum Member | Value |
1295
+ | ----------------------- | ------------- |
1296
+ | `HealthClass.Excellent` | `'Excellent'` |
1297
+ | `HealthClass.Great` | `'Great'` |
1298
+ | `HealthClass.Good` | `'Good'` |
1299
+ | `HealthClass.Average` | `'Average'` |
1300
+
1301
+
1302
+ > **Note:** `HealthClass.Preferred` does **not** exist and will cause an API error if used.
1303
+
1304
+ ### `RateClass`
1305
+
1306
+
1307
+ | Enum Member | Value |
1308
+ | ------------------------- | ------------------ |
1309
+ | `RateClass.PreferredPlus` | `'Preferred Plus'` |
1310
+ | `RateClass.Preferred` | `'Preferred'` |
1311
+ | `RateClass.Standard` | `'Standard'` |
1312
+ | `RateClass.StandardExtra` | `'Standard Extra'` |
1313
+
1314
+
1315
+ > **Note:** Values contain spaces - always use enum members, not raw strings.
1316
+
1317
+ ### `RiderType`
1318
+
1319
+
1320
+ | Enum Member | Value | Coverage Range |
1321
+ | ------------------------------- | ------------------------- | ---------------- |
1322
+ | `RiderType.ADBRider` | `'ADB Rider'` | $25,000–$250,000 |
1323
+ | `RiderType.DependentChildRider` | `'Dependent Child Rider'` | $5,000–$25,000 |
1324
+
1325
+
1326
+ > **Note:** Values contain spaces - always use enum members.
1327
+
1328
+ ### `AdbRiderType` (ADB product only)
1329
+
1330
+ Rider codes accepted by `ThirdPartyAdbQuoteRequest.riders` and `ThirdPartyAdbUpdateQuoteReq.riders`, and returned by `getAdbRiderDetails()` as `AdbRiderResp.riderCode`.
1331
+
1332
+ | Enum Member | Value |
1333
+ | ------------------------------ | -------------------- |
1334
+ | `AdbRiderType.FamilyADB` | `'FamilyADB'` |
1335
+ | `AdbRiderType.ReturnOfPremium` | `'ReturnOfPremium'` |
1336
+ | `AdbRiderType.InflationBenefit` | `'InflationBenefit'` |
1337
+
1338
+ > **Note:** ADB has its own rider enum. Do NOT reuse the Term product's `RiderType` — those values (`'ADB Rider'`, `'Dependent Child Rider'`) are display titles, not the codes the ADB API expects.
1339
+
1340
+ ### `State`
1341
+
1342
+ All 50 US states + DC and 12 Canadian provinces/territories:
1343
+
1344
+ **US:** `AK`, `AL`, `AR`, `AZ`, `CA`, `CO`, `CT`, `DC`, `DE`, `FL`, `GA`, `HI`, `IA`, `ID`, `IL`, `IN`, `KS`, `KY`, `LA`, `MA`, `MD`, `ME`, `MI`, `MN`, `MO`, `MS`, `MT`, `NC`, `ND`, `NE`, `NH`, `NJ`, `NM`, `NV`, `NY`, `OH`, `OK`, `OR`, `PA`, `RI`, `SC`, `SD`, `TN`, `TX`, `UT`, `VA`, `VT`, `WA`, `WI`, `WV`, `WY`
1345
+
1346
+ **Canadian provinces/territories:** `AB`, `BC`, `MB`, `NB`, `NS`, `NT`, `NUNAVUT`, `ON`, `PE`, `PQ`, `SK`, `YT`
1347
+
1348
+ ### `Country`
1349
+
1350
+ Full ISO country code enum. Common values: `Country.UnitedStates` (`'US'`), `Country.Canada` (`'CA'`). Used in GIGDB's `birthJurisdiction.country`.
1351
+
1352
+ ### `BeneficiaryType`
1353
+
1354
+
1355
+ | Enum Member | Value |
1356
+ | --------------------------------- | ---------------------------------------- |
1357
+ | `Person` | `'Person'` |
1358
+ | `AllChildrenOfTheInsuredEqually` | `'All Children Of The Insured Equally'` |
1359
+ | `AllChildrenOfTheMarriageEqually` | `'All Children Of The Marriage Equally'` |
1360
+ | `InsuredEstate` | `'Insured Estate'` |
1361
+ | `Business` | `'Business'` |
1362
+ | `Corporation` | `'Corporation'` |
1363
+ | `CharitableOrganization` | `'Charitable Organization'` |
1364
+ | `Employer` | `'Employer'` |
1365
+ | `Other` | `'Other'` |
1366
+ | `Trust` | `'Trust'` |
1367
+
1368
+
1369
+ ### `BeneficiaryRelationship`
1370
+
1371
+ 36 values: `Aunt`, `Boyfriend`, `Brother`, `BrotherInLaw`, `CommonLawHusband`, `CommonLawWife`, `Cousin`, `Daughter`, `DaughterInLaw`, `DomesticPartner`, `Father`, `FatherInLaw`, `FatherOfChild`, `Fiance`, `Fiancee`, `FormerSpouse`, `Friend`, `Girlfriend`, `Granddaughter`, `Grandfather`, `Grandmother`, `Grandson`, `Husband`, `LifePartner`, `Mother`, `MotherInLaw`, `MotherOfChild`, `Nephew`, `Niece`, `Sister`, `SisterInLaw`, `Son`, `SonInLaw`, `Spouse`, `Uncle`, `Wife`
1372
+
1373
+ ### ADB Rider Availability
1374
+
1375
+ #### `ADB_RIDER_AVAILABLE_STATES`
1376
+
1377
+ ADB Rider available in: `AL`, `AZ`, `AR`, `CA`*, `CO`, `CT`, `DC`, `DE`, `FL`, `GA`, `HI`, `ID`, `IL`, `IN`, `IA`, `KS`, `KY`, `LA`, `ME`, `MD`, `MI`, `MN`, `MS`, `MO`, `MT`, `NE`, `NV`, `NJ`, `NM`, `NC`, `ND`, `OH`, `OK`, `OR`, `PA`, `RI`, `SC`, `SD`, `TN`, `TX`, `UT`, `VT`, `VA`, `WV`, `WI`
1378
+
1379
+ > CA: ADB product support is coming in the next SDK release and is not yet available.
1380
+
1381
+ #### `CHILD_RIDER_AVAILABLE_STATES`
1382
+
1383
+ Dependent Child Rider available in: `AL`, `AK`, `AZ`, `AR`, `CO`, `CT`, `DC`, `DE`, `GA`, `HI`, `ID`, `IL`, `IN`, `IA`, `KS`, `KY`, `LA`, `MD`, `MA`, `MI`, `MN`, `MS`, `MO`, `MT`, `NE`, `NV`, `NH`, `NJ`, `NM`, `NC`, `OH`, `OK`, `OR`, `PA`, `RI`, `SC`, `TN`, `TX`, `UT`, `VA`, `WV`, `WI`
1384
+
1385
+ #### `NO_RIDERS_AVAILABLE_STATES`
1386
+
1387
+ No riders available in: `WA`
1388
+
1389
+ > **Coming in a future release:** `getAvailableRidersForState(stateCode)` - programmatically query rider availability for a given state.
1390
+
1391
+ ---
1392
+
1393
+ ## Beneficiary Reference
1394
+
1395
+ The `beneficiaryDetails` field uses a TypeScript discriminated union. Required fields differ by `beneficiaryType`. TypeScript enforces the correct shape at compile time.
1396
+
1397
+ ### Variant 1 - No extra fields
1398
+
1399
+ Used for `InsuredEstate`, `AllChildrenOfTheInsuredEqually`, `AllChildrenOfTheMarriageEqually`:
1400
+
1401
+ ```typescript
1402
+ beneficiaryDetails: {
1403
+ beneficiaryType: BeneficiaryType.InsuredEstate
1404
+ }
1405
+ ```
1406
+
1407
+ ### Variant 2 - Named person
1408
+
1409
+ Used when `beneficiaryType = Person`:
1410
+
1411
+ ```typescript
1412
+ beneficiaryDetails: {
1413
+ beneficiaryType: BeneficiaryType.Person,
1414
+ beneficiaryPerson: {
1415
+ firstName: 'Jane',
1416
+ lastName: 'Doe',
1417
+ relationship: BeneficiaryRelationship.Spouse
1418
+ }
1419
+ }
1420
+ ```
1421
+
1422
+ ### Variant 3 - Named entity (organization)
1423
+
1424
+ Used for `Business`, `Corporation`, `CharitableOrganization`, `Employer`, `Other`, `Trust`:
1425
+
1426
+ ```typescript
1427
+ // Business / Corporation / etc.
1428
+ beneficiaryDetails: {
1429
+ beneficiaryType: BeneficiaryType.Business,
1430
+ namedEntity: {
1431
+ name: 'Acme Corp',
1432
+ taxId: '12-3456789' // optional
1433
+ }
1434
+ }
1435
+
1436
+ // Trust - trustDate is required (format: YYYY-MM)
1437
+ beneficiaryDetails: {
1438
+ beneficiaryType: BeneficiaryType.Trust,
1439
+ namedEntity: {
1440
+ name: 'Smith Family Trust',
1441
+ trustDate: '2020-01' // required for Trust only; format: YYYY-MM
1442
+ }
1443
+ }
1444
+ ```
1445
+
1446
+ ---
1447
+
1448
+ ## Error Handling
1449
+
1450
+ ### Error class hierarchy
1451
+
1452
+ ```
1453
+ InstaBrainError
1454
+ ├── AuthenticationError (statusCode: 401 - credentials invalid or session expired)
1455
+ ├── ValidationError (statusCode: 400 - request-level validation failure)
1456
+ └── APIValidationError (statusCode: 400 - API returned flagStatus: false)
1457
+ ```
1458
+
1459
+ ### Field reference
1460
+
1461
+
1462
+ | Class | `message` | `statusCode` | `errorCode` | `response` |
1463
+ | --------------------- | --------- | ------------ | ----------- | ---------- |
1464
+ | `InstaBrainError` | Yes | Yes | Yes | Yes |
1465
+ | `AuthenticationError` | Yes | `401` | - | - |
1466
+ | `ValidationError` | Yes | `400` | Yes | - |
1467
+ | `APIValidationError` | Yes | `400` | Yes | Yes |
1468
+
1469
+
1470
+ ### Using `APIValidationError`
1471
+
1472
+ Thrown when the API returns `flagStatus: false`. Always use `isErrorType(APIErrorCode.X)` for comparison - do **not** compare `errorCode` as a raw string, as the API uses inconsistent casing across error codes.
1473
+
1474
+ ```typescript
1475
+ import {
1476
+ APIValidationError,
1477
+ AuthenticationError,
1478
+ InstaBrainError,
1479
+ APIErrorCode
1480
+ } from '@instabrain-sdks/api-client';
1481
+
1482
+ try {
1483
+ const quoteResp = await client.getGigdbQuote(request);
1484
+ } catch (err) {
1485
+ if (err instanceof APIValidationError) {
1486
+ if (err.isErrorType(APIErrorCode.NotAvailableForState)) {
1487
+ console.error('Product not available in this state');
1488
+ } else if (err.isErrorType(APIErrorCode.AgeNotFound)) {
1489
+ console.error('Age is outside the eligible range for this product');
1490
+ } else {
1491
+ // getUserFriendlyMessage() returns a human-readable description
1492
+ console.error(err.getUserFriendlyMessage());
1493
+ }
1494
+ } else if (err instanceof AuthenticationError) {
1495
+ console.error('Authentication failed - re-authenticate');
1496
+ } else if (err instanceof InstaBrainError) {
1497
+ console.error(`SDK error: ${err.message} (status: ${err.statusCode})`);
1498
+ }
1499
+ }
1500
+ ```
1501
+
1502
+ > `**isDeclined: true` is not an error.** It is a response field on `ThirdPartyStartAppResp` and `ThirdPartyAdbStartAppResp`, indicating the application was declined due to knockout criteria. Always check this field in the response - it is never thrown as an exception.
1503
+
1504
+ ---
1505
+
1506
+ ## APIErrorCode Reference
1507
+
1508
+ Always use `APIErrorCode` enum members with `err.isErrorType()`. Do not compare `errorCode` as a raw string - the API uses inconsistent casing.
1509
+
1510
+ ### General / Quote
1511
+
1512
+
1513
+ | Enum Member | String Value | Description |
1514
+ | ------------------------------------ | -------------------------------------- | ---------------------------------------------------------------- |
1515
+ | `StateNotFound` | `'stateNotFound'` | State code not recognized |
1516
+ | `RateClassNotFound` | `'RateClassNotFound'` | Rating input required (rateClass, healthClass, or height/weight) |
1517
+ | `RiderNotAvailable` | `'RiderNotAvailable'` | Rider not available in this state or for this age |
1518
+ | `HeightNotValid` | `'HeightNotValid'` | Height value is not valid |
1519
+ | `InvalidRateclass` | `'InvalidRateclass'` | Rate class value not recognized |
1520
+ | `InvalidHealthClass` | `'InvalidHealthClass'` | Health class value not recognized |
1521
+ | `ZipCodeNotFound` | `'ZipCodeNotFound'` | ZIP code not recognized |
1522
+ | `OutsideBuildChart` | `'outsideBuildChart'` | Height/weight combination not eligible |
1523
+ | `QuoteNotEligibleForGivenConditions` | `'QuoteNotEligibleForGivenConditions'` | Product not available for this state/age/tobacco combination |
1524
+ | `NotAvailableForState` | `'NotAvailableForState'` | Product not available in the specified state |
1525
+ | `BenefitPeriodNotAvailable` | `'BenefitPeriodNotAvailable'` | Benefit period not available for this age/tobacco combination |
1526
+ | `CoverageNotAvailable` | `'CoverageNotAvailable'` | Coverage amount not available for the given conditions |
1527
+ | `RiderFaceAmountNotValid` | `'RiderFaceAmountNotValid'` | Rider coverage amount outside permitted range |
1528
+ | `ThirdPartyQuoteError` | `'ThirdPartyQuoteError'` | General quote generation error |
1529
+ | `InvalidQuoteParameters` | `'InvalidQuoteParameters'` | Quote parameters are not valid |
1530
+ | `InvalidRequestFormat` | `'InvalidRequestFormat'` | Request format invalid; check required fields |
1531
+ | `QuoteNotFound` | `'QuoteNotFound'` | No previous quote found; create a quote first |
1532
+
1533
+
1534
+ ### GIGDB
1535
+
1536
+
1537
+ | Enum Member | String Value | Description |
1538
+ | -------------------------------------------- | ---------------------------------------------- | ----------------------------------------------- |
1539
+ | `AgeNotFound` | `'AgeNotFound'` | Age outside 50–85 range |
1540
+ | `AgentLogout` | `'AgentLogout'` | Agent session expired; re-authenticate |
1541
+ | `DataNotFound` | `'dataNotFound'` | Requested data not found |
1542
+ | `StateMismatchIdentified` | `'StateMismatchIdentified'` | State mismatch between quote and application |
1543
+ | `InvalidBirthCountry` | `'InvalidBirthCountry'` | Birth country not recognized |
1544
+ | `InvalidBirthState` | `'InvalidBirthState'` | Birth state not recognized |
1545
+ | `InvalidResidenceState` | `'InvalidResidenceState'` | Residence state not valid |
1546
+ | `OneOfTheExistingCoveragesQuestionsNotFound` | `'OneOfTheExistingCoveragesQuestionsNotFound'` | Existing coverage questions incomplete |
1547
+ | `PaymentAlreadyMade` | `'PaymentAlreadyMade'` | Payment already submitted for this application |
1548
+ | `ErrorInSaveEftPaymentDetails` | `'ErrorInSaveEftPaymentDetails'` | Failed to save EFT details; verify account info |
1549
+ | `InvalidPaymentScheduledDate` | `'InvalidPaymentScheduledDate'` | Scheduled payment date is not valid |
1550
+
1551
+
1552
+ ### ADB
1553
+
1554
+
1555
+ | Enum Member | String Value | Description |
1556
+ | -------------------- | ---------------------- | ---------------------------------------------------------------------------- |
1557
+ | `InvalidStateCode` | `'InvalidStateCode'` | State not supported for ADB (MA, NH, AK unavailable; CA coming next release) |
1558
+ | `InvalidAdbAgeRange` | `'InvalidAdbAgeRange'` | Age outside 20–59 range |
1559
+
1560
+
1561
+ ### Final Submit
1562
+
1563
+
1564
+ | Enum Member | String Value | Description |
1565
+ | ---------------- | ------------------ | ------------------------------------------------- |
1566
+ | `PaymentNotMade` | `'paymentNotMade'` | EFT payment must be completed before final submit |
1567
+
1568
+
1569
+ ### Secure Sign
1570
+
1571
+
1572
+ | Enum Member | String Value | Description |
1573
+ | -------------------------- | ---------------------------- | -------------------------------------------------------- |
1574
+ | `SecureSignRelatedError` | `'SecureSignRelatedError'` | General signing error |
1575
+ | `SigningPackageNotCreated` | `'SigningPackageNotCreated'` | No signing package exists; complete previous steps first |
1576
+ | `SecureSignPinMismatch` | `'SecureSignPinMismatch'` | PIN entered is incorrect |
1577
+ | `PinExpired` | `'PinExpired'` | PIN has expired; request a new one |
1578
+ | `DocumentsNotViewed` | `'DocumentsNotViewed'` | All documents must be viewed before verifying PIN |
1579
+ | `DocumentsAlreadySigned` | `'DocumentsAlreadySigned'` | Documents already signed for this application |
1580
+
1581
+
1582
+ ---
1583
+
1584
+ ## Environment Configuration
1585
+
1586
+ Pass `'sandbox'` or `'production'` to `InstaBrainClient.forEnvironment()`. The SDK handles all routing internally.
1587
+
1588
+ ```typescript
1589
+ // Sandbox - for development and testing
1590
+ const client = InstaBrainClient.forEnvironment('sandbox');
1591
+
1592
+ // Production
1593
+ const client = InstaBrainClient.forEnvironment('production');
1594
+ ```
1595
+
1596
+ > Sandbox credentials are separate from production credentials. Both are provisioned independently during onboarding.
1597
+
1598
+ ---
1599
+
1600
+ ## Token Management
1601
+
1602
+
1603
+ | Method | Signature | Description |
1604
+ | ------------------- | ------------------------- | ----------------------------------------------------------- |
1605
+ | `isAuthenticated()` | `() => boolean` | Returns `true` if a JWT is currently stored |
1606
+ | `getCurrentToken()` | `() => string | null` |
1607
+ | `setToken(token)` | `(token: string) => void` | Manually set a JWT (e.g., restored from persistent storage) |
1608
+ | `logout()` | `() => void` | Clears the stored JWT |
1609
+ | `getBaseUrl()` | `() => string` | Returns the configured base URL (for debugging only) |
1610
+
1611
+
1612
+ ---
1613
+
1614
+ ## Examples Directory
1615
+
1616
+ Working examples are in the `./examples/` directory:
1617
+
1618
+
1619
+ | File | Description |
1620
+ | ---------------------------- | ---------------------------------------------------- |
1621
+ | `basic-usage.ts` | Authentication and basic quote/application flows |
1622
+ | `error-handling.ts` | Error catching and handling patterns |
1623
+ | `api-constraints-example.ts` | State restrictions, age limits, and validation rules |
1624
+ | `reports-example.ts` | Prospects, sales, and applications reporting |
1625
+
1626
+
1627
+ ---
1628
+
1629
+ ## Changelog
1630
+
1631
+ See [CHANGELOG.md](./CHANGELOG.md).
1632
+
1633
+ ---
1634
+
1635
+ ## Support
1636
+
1637
+ - **Email:** [helpdesk@instabrain.io](mailto:helpdesk@instabrain.io)
1638
+ - **Website:** [https://www.instabrain.io](https://www.instabrain.io)
1639
+