@instabrain-sdks/api-client 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +1457 -351
  2. package/dist/client/instabrain-client.d.ts +55 -5
  3. package/dist/client/instabrain-client.js +67 -4
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.js +0 -1
  6. package/dist/services/adb.service.d.ts +65 -0
  7. package/dist/services/adb.service.js +87 -0
  8. package/dist/services/application.service.d.ts +2 -3
  9. package/dist/services/application.service.js +5 -52
  10. package/dist/services/auth.service.d.ts +0 -1
  11. package/dist/services/auth.service.js +0 -1
  12. package/dist/services/base.service.d.ts +45 -0
  13. package/dist/services/base.service.js +92 -0
  14. package/dist/services/gigdb.service.d.ts +2 -3
  15. package/dist/services/gigdb.service.js +12 -133
  16. package/dist/services/quote.service.d.ts +2 -3
  17. package/dist/services/quote.service.js +4 -35
  18. package/dist/services/reports.service.d.ts +2 -3
  19. package/dist/services/reports.service.js +6 -86
  20. package/dist/services/secure-sign.service.d.ts +2 -3
  21. package/dist/services/secure-sign.service.js +7 -109
  22. package/dist/types/adb.types.d.ts +154 -0
  23. package/dist/types/adb.types.js +2 -0
  24. package/dist/types/application.types.d.ts +0 -1
  25. package/dist/types/application.types.js +0 -1
  26. package/dist/types/auth.types.d.ts +0 -1
  27. package/dist/types/auth.types.js +0 -1
  28. package/dist/types/beneficiary.types.d.ts +54 -0
  29. package/dist/types/beneficiary.types.js +2 -0
  30. package/dist/types/constants.d.ts +0 -1
  31. package/dist/types/constants.js +0 -1
  32. package/dist/types/enums.d.ts +384 -5
  33. package/dist/types/enums.js +403 -9
  34. package/dist/types/errors.d.ts +0 -1
  35. package/dist/types/errors.js +0 -1
  36. package/dist/types/gigdb.types.d.ts +50 -15
  37. package/dist/types/gigdb.types.js +0 -1
  38. package/dist/types/index.d.ts +2 -1
  39. package/dist/types/index.js +2 -1
  40. package/dist/types/quote.types.d.ts +0 -1
  41. package/dist/types/quote.types.js +0 -1
  42. package/dist/types/reports.types.d.ts +0 -1
  43. package/dist/types/reports.types.js +0 -1
  44. package/dist/types/secure-sign.types.d.ts +0 -1
  45. package/dist/types/secure-sign.types.js +0 -1
  46. package/dist/utils/error-utils.d.ts +0 -1
  47. package/dist/utils/error-utils.js +0 -1
  48. package/dist/utils/http-client.d.ts +0 -1
  49. package/dist/utils/http-client.js +0 -4
  50. package/package.json +2 -3
  51. package/dist/client/instabrain-client.d.ts.map +0 -1
  52. package/dist/client/instabrain-client.js.map +0 -1
  53. package/dist/index.d.ts.map +0 -1
  54. package/dist/index.js.map +0 -1
  55. package/dist/services/application.service.d.ts.map +0 -1
  56. package/dist/services/application.service.js.map +0 -1
  57. package/dist/services/auth.service.d.ts.map +0 -1
  58. package/dist/services/auth.service.js.map +0 -1
  59. package/dist/services/gigdb.service.d.ts.map +0 -1
  60. package/dist/services/gigdb.service.js.map +0 -1
  61. package/dist/services/quote.service.d.ts.map +0 -1
  62. package/dist/services/quote.service.js.map +0 -1
  63. package/dist/services/reports.service.d.ts.map +0 -1
  64. package/dist/services/reports.service.js.map +0 -1
  65. package/dist/services/secure-sign.service.d.ts.map +0 -1
  66. package/dist/services/secure-sign.service.js.map +0 -1
  67. package/dist/types/application.types.d.ts.map +0 -1
  68. package/dist/types/application.types.js.map +0 -1
  69. package/dist/types/auth.types.d.ts.map +0 -1
  70. package/dist/types/auth.types.js.map +0 -1
  71. package/dist/types/constants.d.ts.map +0 -1
  72. package/dist/types/constants.js.map +0 -1
  73. package/dist/types/enums.d.ts.map +0 -1
  74. package/dist/types/enums.js.map +0 -1
  75. package/dist/types/errors.d.ts.map +0 -1
  76. package/dist/types/errors.js.map +0 -1
  77. package/dist/types/gigdb.types.d.ts.map +0 -1
  78. package/dist/types/gigdb.types.js.map +0 -1
  79. package/dist/types/index.d.ts.map +0 -1
  80. package/dist/types/index.js.map +0 -1
  81. package/dist/types/quote.types.d.ts.map +0 -1
  82. package/dist/types/quote.types.js.map +0 -1
  83. package/dist/types/reports.types.d.ts.map +0 -1
  84. package/dist/types/reports.types.js.map +0 -1
  85. package/dist/types/secure-sign.types.d.ts.map +0 -1
  86. package/dist/types/secure-sign.types.js.map +0 -1
  87. package/dist/utils/error-utils.d.ts.map +0 -1
  88. package/dist/utils/error-utils.js.map +0 -1
  89. package/dist/utils/http-client.d.ts.map +0 -1
  90. package/dist/utils/http-client.js.map +0 -1
package/README.md CHANGED
@@ -1,9 +1,40 @@
1
- # InstaBrain Node.js SDK
1
+ # @instabrain-sdks/api-client
2
2
 
3
- [![npm version](https://badge.fury.io/js/instabrain.svg)](https://badge.fury.io/js/instabrain)
4
- [![License: Commercial](https://img.shields.io/badge/License-Commercial-red.svg)]()
3
+ [npm version](https://badge.fury.io/js/%40instabrain-sdks%2Fapi-client)
5
4
 
6
- Official Node.js SDK for the InstaBrain API - Insurance quotes and application processing made simple.
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
+ ---
7
38
 
8
39
  ## Installation
9
40
 
@@ -11,523 +42,1598 @@ Official Node.js SDK for the InstaBrain API - Insurance quotes and application p
11
42
  npm install @instabrain-sdks/api-client
12
43
  ```
13
44
 
14
- ## Quick Start
15
-
16
- ```typescript
17
- import { InstaBrainClient,
18
- Gender,
19
- PaymentFrequency,
20
- RateClass,
21
- HealthClass,
22
- ThirdPartyQuoteReq,
23
- ThirdPartyStartApplicationReq,
24
- ThirdPartyGigdbQuoteRequest,
25
- ThirdPartyGigdbUpdateQuoteReq,
26
- ThirdPartyGigdbAppReq,
27
- ThirdPartyEftPaymentReq,
28
- ThirdPartySendPinReq,
29
- ThirdPartyVerifyPinReq,
30
- AgentPortalReq }
31
- from '@instabrain-sdks/api-client';
45
+ > **Note:** This is a restricted-access package. Access must be granted during the InstaBrain onboarding process.
32
46
 
33
- // Create a client instance
34
- const client = InstaBrainClient.forEnvironment('production');
47
+ ---
35
48
 
36
- // Authenticate
37
- await client.authenticate(12345, 'your-access-token-uuid');
49
+ ## Requirements
38
50
 
39
- // Get a quote
40
- const quote = await client.getQuote(quoteReq);
51
+ - Node.js >= 14.0.0
52
+ - TypeScript >= 4.0 *(optional - the SDK ships with full type definitions)*
41
53
 
42
- // Start an application
43
- const application = await client.startApplication(startApplicationReq);
54
+ ---
44
55
 
45
- // Get reporting data
46
- const reportingReq : AgentPortalReq = {
47
- "startDate": null,
48
- "endDate": null,
49
- "dayCount": 10,
50
- "pageSize": 10,
51
- "pageIndex": 1
52
- };
53
- const prospects = await client.getProspects(reportingReq);
54
- const sales = await client.getSales(reportingReq);
55
- const applications = await client.getApplications(reportingReq);
56
-
57
- console.log(`Dashboard Summary:`);
58
- console.log(`- Prospects: ${prospects.prospectCount}`);
59
- console.log(`- Sales: ${sales.applicationCount} ($${sales.totalPremiumAmount})`);
60
- console.log(`- Applications: ${applications.applicationCount}`);
61
-
62
- // GIGDB Product (Guaranteed Issue — ages 50-85, $5k-$25k)
63
- const gigdbQuote = await client.getGigdbQuote(gigdbQuoteReq);
64
- const gigdbApp = await client.startGigdbApplication(gigdbAppReq);
65
- const eftPayment = await client.saveEftPayment(eftPaymentReq);
66
-
67
- // Update GIGDB quote (change face amount or payment frequency)
68
- const updatedQuote = await client.updateGigdbQuote({
69
- opportunityId: gigdbApp.opportunityId,
70
- faceAmount: 20000,
71
- paymentFreq: PaymentFrequency.Annual
72
- });
56
+ ## Authentication
73
57
 
74
- // Get existing GIGDB quote (when isQuoteChanged=true)
75
- const existingQuote = await client.getExistingGigdbQuote(gigdbApp.opportunityId);
76
-
77
- // Secure Sign flow (shared across all products)
78
- const docs = await client.prepareDocsAndGetDeliveryChannels(gigdbApp.opportunityId);
79
- if (!docs.isSignCompleted) {
80
- const pin = await client.sendPinAndGetDocumentsLink({
81
- opportunityId: gigdbApp.opportunityId,
82
- flagSendSms: docs.isSmsAvailable,
83
- flagSendEmail: docs.isEmailAvailable
84
- });
85
- await client.verifyPin({
86
- opportunityId: gigdbApp.opportunityId,
87
- pin: '123456',
88
- isScriptReadConfirmed: true
89
- });
90
- }
91
- const result = await client.finalSubmit(gigdbApp.opportunityId);
92
- console.log('Policy Number:', result.policyNumber || 'pending');
93
- ```
58
+ Credentials are issued during onboarding:
94
59
 
95
- ## Features
96
60
 
97
- - ✅ **TypeScript Support** - Full type safety with TypeScript definitions
98
- - ✅ **Environment Management** - Easy switching between production and sandbox
99
- - ✅ **Automatic JWT Management** - Handles authentication tokens automatically
100
- - ✅ **Error Handling** - Comprehensive error handling with custom error types
101
- - ✅ **Request Validation** - Built-in validation for API requests
102
- - ✅ **Comprehensive Testing** - Well-tested with Jest
103
- - ✅ **GIGDB Product Support** - Guaranteed Issue quotes, applications, and EFT payments
104
- - ✅ **GIGDB Quote Management** - Update quotes and get existing quotes for GIGDB opportunities
105
- - ✅ **Secure Sign & Final Submit** - Document signing flow and carrier submission (shared across all products)
106
- - ✅ **Modern Promise API** - Uses async/await patterns
61
+ | Credential | Type | Description |
62
+ | ------------- | --------------- | ------------------------ |
63
+ | `userId` | `number` | Your account user ID |
64
+ | `accessToken` | `string` (UUID) | Your secret access token |
107
65
 
108
- ## API Reference
109
66
 
110
- ### Authentication
67
+ ```typescript
68
+ import { InstaBrainClient } from '@instabrain-sdks/api-client';
111
69
 
112
- #### `authenticate(userId: number, accessToken: string): Promise<string>`
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
+ ```
113
75
 
114
- Authenticate with the InstaBrain API and obtain a JWT token.
76
+ > Call `authenticate()` once at startup. The returned JWT is stored internally - every subsequent API call uses it automatically.
115
77
 
116
- ```typescript
117
- const jwtToken = await client.authenticate(12345, 'uuid-access-token');
118
- ```
78
+ ---
119
79
 
120
- ### IB Term Quote Flow
80
+ ## Product Comparison
121
81
 
122
- #### `getQuote(request: ThirdPartyQuoteReq): Promise<ThirdPartyQuoteResp>`
123
82
 
124
- Get an IB Term insurance quote based on the provided parameters.
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)* |
125
97
 
126
- ```typescript
127
- const quoteReq : ThirdPartyQuoteReq = {
128
- faceAmount: 500000,
129
- benefitPeriod: 20,
130
- flagTobaccoUse: false,
131
- gender: Gender.Female,
132
- stateCode: 'NY',
133
- zipCode: '10001',
134
- rateClass: RateClass.Preferred,
135
- healthClass: HealthClass.Preferred,
136
- height: { feet: 5, inches: 6 },
137
- weightInLbs: 140,
138
- age: 30,
139
- paymentFreq: PaymentFrequency.Annual,
140
- firstName: 'Jane',
141
- lastName: 'Smith',
142
- email: 'jane.smith@example.com',
143
- phoneNum: '555-0123'
144
- };
145
- const quote = await client.getQuote(quoteReq);
146
- ```
147
98
 
148
- #### `startApplication(request: ThirdPartyStartApplicationReq): Promise<ThirdPartyStartAppResp>`
99
+ ---
149
100
 
150
- Start an IB Term insurance application from a quote.
101
+ ## GIGDB Flow
151
102
 
152
- ```typescript
153
- const startApplicationReq : ThirdPartyStartApplicationReq = {
154
- quoteResponseId: quote.selectedQuote.quoteResponseId,
155
- firstName: 'John',
156
- lastName: 'Doe',
157
- email: 'john.doe@example.com',
158
- phoneNumber: '555-1234'
159
- };
160
- const application = await client.startApplication(startApplicationReq);
103
+ > **Not available in:** NY, MT
161
104
 
162
- // Access the generated links
163
- console.log('Agent Link:', application.agentLink);
164
- console.log('Applicant Link:', application.applicantLink);
165
- ```
105
+ GIGDB (Guaranteed Issue Graded Death Benefit) is a simplified-issue whole life product for ages 50–85 with no medical exam.
166
106
 
167
- ### GIGDB (Guaranteed Issue)
107
+ ### Complete flow
168
108
 
169
- #### `getGigdbQuote(request: ThirdPartyGigdbQuoteRequest): Promise<ThirdPartyQuoteResp>`
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
+ ```
170
127
 
171
- Get a Guaranteed Issue quote (ages 50-85, face amount $5k-$25k).
128
+ ### Step 1 - `getGigdbQuote(request: ThirdPartyGigdbQuoteRequest)`
172
129
 
173
130
  ```typescript
174
- const gigdbQuoteReq: ThirdPartyGigdbQuoteRequest = {
131
+ import { InstaBrainClient, Gender, PaymentFrequency } from '@instabrain-sdks/api-client';
132
+
133
+ const quoteResp = await client.getGigdbQuote({
175
134
  faceAmount: 15000,
176
135
  gender: Gender.Female,
177
136
  stateCode: 'TX',
178
137
  age: 65,
179
- dateOfBirth: '1961-01-15',
138
+ dateOfBirth: null,
180
139
  paymentFreq: PaymentFrequency.Monthly,
140
+ isSmoker: false,
181
141
  firstName: 'Jane',
182
- lastName: 'Smith',
183
- email: 'jane.smith@example.com',
184
- phoneNum: '555-0123',
185
- isSmoker: false
186
- };
187
- const quote = await client.getGigdbQuote(gigdbQuoteReq);
188
- ```
142
+ lastName: 'Doe',
143
+ email: 'jane.doe@example.com',
144
+ phoneNum: null
145
+ });
189
146
 
190
- #### `startGigdbApplication(request: ThirdPartyGigdbAppReq): Promise<ThirdPartyStartAppResp>`
147
+ const { quoteResponseId, quoteAmount } = quoteResp.selectedQuote;
148
+ ```
191
149
 
192
- Start a GIGDB application. Note: `isDeclined: true` is a valid response (knockout), not an error.
150
+ ### Step 2 - `startGigdbApplication(request: ThirdPartyGigdbAppReq)`
193
151
 
194
152
  ```typescript
195
- const gigdbAppReq: ThirdPartyGigdbAppReq = {
196
- quoteResponseId: quote.selectedQuote.quoteResponseId,
153
+ import { BeneficiaryType, BeneficiaryRelationship } from '@instabrain-sdks/api-client';
154
+
155
+ const appResp = await client.startGigdbApplication({
156
+ quoteResponseId: quoteResp.selectedQuote.quoteResponseId,
197
157
  firstName: 'Jane',
198
- lastName: 'Smith',
199
- email: 'jane.smith@example.com',
200
- phoneNumber: '555-0123',
158
+ lastName: 'Doe',
159
+ email: 'jane.doe@example.com',
160
+ phoneNumber: '5551234567',
201
161
  isUsCitizen: true,
202
162
  isPayerAlsoOwnerAndInsured: true,
203
- isSmoker: false,
204
- dateOfBirth: '1961-01-15',
205
- socialSecurityNumber: '123456789',
163
+ isLegalUsResident: true,
206
164
  address: {
207
165
  addressLine1: '123 Main St',
208
- city: 'Dallas',
166
+ city: 'Austin',
209
167
  state: 'TX',
210
- zipcode: '75001'
168
+ zipcode: '73301'
211
169
  },
170
+ dateOfBirth: '1958-06-15',
171
+ socialSecurityNumber: '123-45-6789',
212
172
  birthJurisdiction: {
213
- country: 'US',
214
- state: 'TX'
173
+ state: 'TX',
174
+ country: 'US'
215
175
  },
176
+ isSmoker: false,
177
+ nicotineInfo: null,
216
178
  hasExistingCoverage: false,
217
- existingCoverageData: null,
218
179
  willOtherCoverageBeReplacedOrFinanced: null,
180
+ existingCoverageData: null,
219
181
  beneficiaryDetails: {
220
- beneficiaryType: 'Person',
182
+ beneficiaryType: BeneficiaryType.Person,
221
183
  beneficiaryPerson: {
222
184
  firstName: 'John',
223
- lastName: 'Smith',
224
- relationship: 'Spouse'
225
- },
226
- namedEntity: null
185
+ lastName: 'Doe',
186
+ relationship: BeneficiaryRelationship.Spouse
187
+ }
227
188
  }
228
- };
229
- const app = await client.startGigdbApplication(gigdbAppReq);
230
- console.log('Opportunity ID:', app.opportunityId);
231
- console.log('Declined:', app.isDeclined);
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;
232
199
  ```
233
200
 
234
- #### `updateGigdbQuote(request: ThirdPartyGigdbUpdateQuoteReq): Promise<ThirdPartyQuoteResp>`
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?* |
235
217
 
236
- Update a GIGDB quote with a different face amount or payment frequency.
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):
237
247
 
238
248
  ```typescript
239
- const updateReq: ThirdPartyGigdbUpdateQuoteReq = {
240
- opportunityId: app.opportunityId,
241
- faceAmount: 20000,
242
- paymentFreq: PaymentFrequency.Annual
243
- };
244
- const updatedQuote = await client.updateGigdbQuote(updateReq);
245
- console.log('Updated face amount:', updatedQuote.selectedQuote.faceAmount);
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
+ }
246
275
  ```
247
276
 
248
- #### `getExistingGigdbQuote(opportunityId: string): Promise<ThirdPartyQuoteResp>`
277
+ ### Step 4 - `updateGigdbQuote` (optional - must be called BEFORE `saveEftPayment`)
249
278
 
250
- Get the existing quote for a GIGDB opportunity. Use when `isQuoteChanged=true` after `startGigdbApplication`.
279
+ If the applicant wants to change the face amount or payment frequency after the application has started:
251
280
 
252
281
  ```typescript
253
- const existingQuote = await client.getExistingGigdbQuote(app.opportunityId);
254
- console.log('Current quote:', existingQuote.selectedQuote.quoteAmount);
282
+ const updatedQuoteResp = await client.updateGigdbQuote({
283
+ opportunityId,
284
+ faceAmount: 20000,
285
+ paymentFreq: PaymentFrequency.Annually
286
+ });
287
+ // updatedQuoteResp.selectedQuote.quoteAmount reflects the new premium
255
288
  ```
256
289
 
257
- #### `saveEftPayment(request: ThirdPartyEftPaymentReq): Promise<boolean>`
290
+ > **Important:** The quote cannot be updated after EFT payment details are saved. `updateGigdbQuote()` must be called before `saveEftPayment()`.
258
291
 
259
- Returns `true` when payment details saved successfully.
292
+ ### Step 5 - `saveEftPayment(request: ThirdPartyEftPaymentReq)`
260
293
 
261
294
  ```typescript
262
- const eftReq: ThirdPartyEftPaymentReq = {
263
- opportunityId: app.opportunityId,
264
- accountHolderName: 'Jane Smith',
295
+ await client.saveEftPayment({
296
+ opportunityId,
297
+ accountHolderName: 'Jane Doe',
265
298
  routingNumber: '021000021',
266
299
  accountNumber: '123456789'
267
- };
268
- const success = await client.saveEftPayment(eftReq);
269
- console.log('Payment saved:', success);
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
+
270
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"`.
271
349
 
272
- ### Secure Sign (Document Signing)
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
+ }
273
359
 
274
- The signing flow is shared across all products. Call after EFT payment has been saved.
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.
275
366
 
276
- #### `prepareDocsAndGetDeliveryChannels(opportunityId: string): Promise<ThirdPartyPrepareDocsResp>`
367
+ ### Step 0a - `getAdbOccupationOptions(query?: string)` (CA only)
277
368
 
278
- Prepare the signing package and check available delivery channels. If `isSignCompleted` is true, skip directly to `finalSubmit()`.
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.
279
370
 
280
371
  ```typescript
281
- const docs = await client.prepareDocsAndGetDeliveryChannels(app.opportunityId);
282
- console.log('SMS available:', docs.isSmsAvailable);
283
- console.log('Already signed:', docs.isSignCompleted);
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();
284
378
  ```
285
379
 
286
- #### `sendPinAndGetDocumentsLink(request: ThirdPartySendPinReq): Promise<ThirdPartySendPinResp>`
380
+ > Skip this call entirely for non-CA states — `occupation` should be omitted from the application request when the state is not CA.
287
381
 
288
- Send a verification PIN via SMS and/or Email and receive the documents link.
382
+ ### Step 1 - `getAdbQuote(request: ThirdPartyAdbQuoteRequest)`
289
383
 
290
384
  ```typescript
291
- const pinResp = await client.sendPinAndGetDocumentsLink({
292
- opportunityId: app.opportunityId,
293
- flagSendSms: true,
294
- flagSendEmail: true
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'
295
397
  });
296
- console.log('Documents link:', pinResp.link);
297
- console.log('Script to read:', pinResp.script);
398
+
399
+ const { quoteResponseId } = quoteResp.selectedQuote;
298
400
  ```
299
401
 
300
- #### `resendPin(request: ThirdPartyResendPinReq): Promise<ThirdPartyResendPinResp>`
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)
301
407
 
302
- Resend the verification PIN if the signer did not receive it.
408
+ ### Step 2 - `startAdbApplication(request: ThirdPartyAdbAppReq)`
303
409
 
304
410
  ```typescript
305
- const resendResp = await client.resendPin({
306
- opportunityId: app.opportunityId,
307
- flagSendSms: true,
308
- flagSendEmail: false
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
+ }
309
438
  });
310
- console.log('PIN resent:', resendResp.flagPinSent);
439
+
440
+ if (appResp.isDeclined) {
441
+ // Valid knockout - stop the flow
442
+ return;
443
+ }
444
+
445
+ const { opportunityId } = appResp;
311
446
  ```
312
447
 
313
- #### `verifyPin(request: ThirdPartyVerifyPinReq): Promise<ThirdPartyVerifyPinResp>`
448
+ **Knockout rules - returns `isDeclined: true` (not an error, not thrown):**
449
+
450
+ - `isPayerAlsoOwnerAndInsured === false` → declined
451
+ - `isUsCitizen === false` AND `isLegalUsResident === false` → declined
314
452
 
315
- Verify the PIN entered by the signer to complete document signing.
453
+ **California residents — `occupation` field required:**
316
454
 
317
455
  ```typescript
318
- const verifyResp = await client.verifyPin({
319
- opportunityId: app.opportunityId,
320
- pin: '123456',
321
- isScriptReadConfirmed: true
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
+ // ...
322
461
  });
323
- console.log('Verified:', verifyResp.isVerified);
324
462
  ```
325
463
 
326
- ### Final Submit
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()`
327
467
 
328
- #### `finalSubmit(opportunityId: string): Promise<ThirdPartyFinalSubmitResp>`
468
+ **District of Columbia residents — three top-level ACA acknowledgement booleans required:**
329
469
 
330
- Submit the application to the carrier for a final underwriting decision. Call after the signing flow is complete. Note: `policyNumber: null` means the carrier has not yet issued a number (pending decision) — this is not an error.
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?* |
331
477
 
332
478
  ```typescript
333
- const result = await client.finalSubmit(app.opportunityId);
334
- console.log('Policy Number:', result.policyNumber || 'pending carrier decision');
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
+ });
335
486
  ```
336
487
 
337
- ### Reports
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?* |
338
497
 
339
- #### `getProspects(request?: AgentPortalReq): Promise<ThirdPartyProspectsResp>`
498
+ **ADB response differences from GIGDB/IB Term:**
340
499
 
341
- Get prospects data - quotes that haven't been converted to applications yet.
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"`.
342
508
 
343
509
  ```typescript
344
- const portalReq : AgentPortalReq = {
345
- "startDate": null,
346
- "endDate": null,
347
- "dayCount": 10,
348
- "pageSize": 10,
349
- "pageIndex": 1
350
- };
351
- const prospects = await client.getProspects(portalReq);
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
+ });
352
518
 
353
- console.log(`Found ${prospects.prospectCount} prospects`);
519
+ const { quoteResponseId, quoteAmount } = updatedQuote.selectedQuote;
354
520
  ```
355
521
 
356
- #### `getSales(request?: AgentPortalReq): Promise<ThirdPartySalesReportRes>`
522
+ ### Step 3a - `getExistingAdbQuote(opportunityId: string)` (optional)
357
523
 
358
- Get sales data - completed/sold policies.
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.
359
525
 
360
526
  ```typescript
361
- const salesReq : AgentPortalReq = {
362
- "startDate": null,
363
- "endDate": null,
364
- "dayCount": 10,
365
- "pageSize": 10,
366
- "pageIndex": 1
367
- };
368
- const sales = await client.getSales(salesReq);
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
369
556
 
370
- console.log(`Total sales: ${sales.applicationCount}`);
371
- console.log(`Total premium: $${sales.totalPremiumAmount}`);
557
+ ### Complete flow
558
+
559
+ ```
560
+ getQuote()
561
+ ↓
562
+ startApplication()
563
+ ↓
564
+ prepareDocsAndGetDeliveryChannels()
565
+ ↓
566
+ sendPinAndGetDocumentsLink() → verifyPin()
567
+ ↓
568
+ finalSubmit()
372
569
  ```
373
570
 
374
- #### `getApplications(request?: AgentPortalReq): Promise<ThirdPartyApplicationReportRes>`
571
+ ### Step 1 - `getQuote(request: ThirdPartyQuoteReq)`
375
572
 
376
- Get applications data - applications in progress.
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
377
578
 
378
579
  ```typescript
379
- const applicationsReq : AgentPortalReq = {
380
- "startDate": null,
381
- "endDate": null,
382
- "dayCount": 10,
383
- "pageSize": 10,
384
- "pageIndex": 1
385
- };
386
- const applications = await client.getApplications(applicationsReq);
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
+ });
387
602
 
388
- console.log(`Applications needing attention: ${applications.applicationCount}`);
603
+ const { quoteResponseId } = quoteResp.selectedQuote;
389
604
  ```
390
605
 
391
- ## Environment Configuration
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
392
610
 
393
- The SDK supports production and sandbox environments:
611
+ ### Step 2 - `startApplication(request: ThirdPartyStartApplicationReq)`
394
612
 
395
613
  ```typescript
396
- // Production environment (default)
397
- const prodClient = InstaBrainClient.forEnvironment('production');
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
+ });
398
621
 
399
- // Sandbox environment for testing
400
- const sandboxClient = InstaBrainClient.forEnvironment('sandbox');
622
+ const { opportunityId, agentLink, eAppAgentLink, applicantLink } = appResp;
401
623
  ```
402
624
 
403
- ## Error Handling
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
+ ---
404
640
 
405
- The SDK provides specific error types for different scenarios:
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()`.
406
664
 
407
665
  ```typescript
408
- import {
409
- InstaBrainError,
410
- AuthenticationError,
411
- ValidationError,
412
- APIValidationError,
413
- APIErrorCode
414
- } from '@instabrain-sdks/api-client';
666
+ const prepResp = await client.prepareDocsAndGetDeliveryChannels(opportunityId);
415
667
 
416
- try {
417
- await client.authenticate(userId, accessToken);
418
- } catch (error) {
419
- if (error instanceof APIValidationError) {
420
- // Business-logic error with a specific error code
421
- console.error('API validation error:', error.errorCode);
422
- console.error('Friendly message:', error.getUserFriendlyMessage());
423
- if (error.isErrorType(APIErrorCode.SecureSignPinMismatch)) {
424
- console.error('PIN did not match — please try again');
425
- }
426
- } else if (error instanceof AuthenticationError) {
427
- console.error('Authentication failed:', error.message);
428
- } else if (error instanceof ValidationError) {
429
- console.error('Validation error:', error.message);
430
- } else if (error instanceof InstaBrainError) {
431
- console.error('API error:', error.message, error.statusCode);
432
- } else {
433
- console.error('Unexpected error:', error);
434
- }
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);
435
673
  }
436
674
  ```
437
675
 
438
- ## Types and Enums
676
+ ### Step 2 - `sendPinAndGetDocumentsLink(request: ThirdPartySendPinReq)`
439
677
 
440
- ### Gender
678
+ At least one of `flagSendSms` or `flagSendEmail` must be `true`.
441
679
 
442
680
  ```typescript
443
- enum Gender {
444
- Male = 1,
445
- Female = 2
446
- }
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
447
691
  ```
448
692
 
449
- ### Payment Frequency
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.
450
702
 
451
703
  ```typescript
452
- enum PaymentFrequency {
453
- Annual = 1,
454
- Monthly = 12
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()
455
712
  }
456
713
  ```
457
714
 
458
- ### Rate Class
715
+ **Optional - `resendPin` (if PIN was not received):**
459
716
 
460
717
  ```typescript
461
- enum RateClass {
462
- Standard = 'Standard',
463
- Preferred = 'Preferred',
464
- PreferredPlus = 'Preferred Plus',
465
- SuperPreferred = 'Super Preferred'
466
- }
718
+ await client.resendPin({
719
+ opportunityId,
720
+ flagSendSms: true,
721
+ flagSendEmail: false
722
+ });
467
723
  ```
468
724
 
469
- ### Health Class
725
+ ---
726
+
727
+ ## Final Submit
728
+
729
+ Shared across all products. Submits the completed application to the carrier for underwriting.
470
730
 
471
731
  ```typescript
472
- enum HealthClass {
473
- Standard = 'Standard',
474
- Preferred = 'Preferred',
475
- Excellent = 'Excellent',
476
- PreferredPlus = 'Preferred Plus',
477
- SuperPreferred = 'Super Preferred'
478
- }
732
+ const submitResp = await client.finalSubmit(opportunityId);
733
+ console.log('Policy number:', submitResp.policyNumber);
479
734
  ```
480
735
 
481
- ## Advanced Usage
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
482
743
 
483
- ### Manual Token Management
744
+ Three methods for retrieving data from the agent portal. `pageSize` and `pageIndex` are required.
484
745
 
485
746
  ```typescript
486
- // Set a token manually (if you have one from elsewhere)
487
- client.setToken('your-jwt-token');
747
+ import { AgentPortalReq } from '@instabrain-sdks/api-client';
488
748
 
489
- // Check authentication status
490
- if (client.isAuthenticated()) {
491
- // Make API calls
492
- }
749
+ const request: AgentPortalReq = {
750
+ pageSize: 20, // required
751
+ pageIndex: 0 // required, 0-based
752
+ };
753
+ ```
754
+
755
+ ### Methods
493
756
 
494
- // Get current token
495
- const currentToken = client.getCurrentToken();
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 }
496
765
 
497
- // Logout (clear token)
498
- client.logout();
766
+ // Applications in progress
767
+ const applications = await client.getApplications(request);
768
+ // Returns: { applicationCount: number, applications: ThirdPartyApplicationsReport[] }
499
769
  ```
500
770
 
501
- ### Base URL
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`)
502
788
 
503
789
  ```typescript
504
- // Get current base URL
505
- const currentUrl = client.getBaseUrl();
790
+ sort: {
791
+ value: 'createdOn',
792
+ sortDescending: true
793
+ }
506
794
  ```
507
795
 
508
- ## Examples
796
+ ### Filtering (`AgentPortalReqFilters[]`)
509
797
 
510
- Check out the [examples](./examples) directory for more detailed usage examples:
798
+ ```typescript
799
+ import { SQLOperator } from '@instabrain-sdks/api-client';
511
800
 
512
- - [Basic Usage](./examples/basic-usage.ts) - Complete workflow from authentication to application
513
- - [Error Handling](./examples/error-handling.ts) - Comprehensive error handling patterns
514
- - [Environment Switching](./examples/environment-switching.ts) - Working with different environments
801
+ filters: [
802
+ {
803
+ field: 'stateCode',
804
+ operator: SQLOperator.Equal,
805
+ value: 'TX'
806
+ }
807
+ ]
808
+ ```
515
809
 
516
- ## Requirements
810
+ `**SQLOperator` enum values:**
517
811
 
518
- - Node.js 14.0.0 or higher
519
- - TypeScript 4.0 or higher (for TypeScript projects)
520
812
 
521
- ## License
522
- This software is proprietary and confidential. Unauthorized copying, distribution, or modification is strictly prohibited.
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 |
523
826
 
524
- ## Support
525
827
 
526
- For technical support and questions:
828
+ ---
527
829
 
528
- - **Email**: helpdesk@instabrain.io
529
- - **Website**: https://www.instabrain.io
830
+ ## Request Type Reference
530
831
 
531
- ## Changelog
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)
532
1639
 
533
- See [CHANGELOG.md](CHANGELOG.md) for a list of changes in each version.