@delegance/sdk 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { z } from 'zod';
7
7
  interface DeleganceClientConfig {
8
8
  /** API key for authentication (format: dlg_xxx_sk_xxx) */
9
9
  apiKey: string;
10
- /** Base URL for the Delegance API (default: https://app.delegance.ai) */
10
+ /** Base URL for the Delegance API (default: https://portal.delegancebrokerage.com) */
11
11
  baseUrl?: string;
12
12
  /** Request timeout in milliseconds (default: 30000) */
13
13
  timeout?: number;
@@ -31,14 +31,32 @@ interface PaginatedResponse<T> extends APIResponse<T[]> {
31
31
  hasMore: boolean;
32
32
  };
33
33
  }
34
- declare const CompanySizeSchema: z.ZodEnum<["1", "2-10", "11-25", "26-50", "51-100", "100-499", "500+"]>;
34
+ declare const CompanySizeSchema: z.ZodEnum<{
35
+ 0: "0";
36
+ 1: "1";
37
+ "2-10": "2-10";
38
+ "11-25": "11-25";
39
+ "26-50": "26-50";
40
+ "51-100": "51-100";
41
+ "100-499": "100-499";
42
+ "500+": "500+";
43
+ }>;
35
44
  type CompanySize = z.infer<typeof CompanySizeSchema>;
36
45
  declare const CreateCompanySchema: z.ZodObject<{
37
46
  name: z.ZodString;
38
47
  legalName: z.ZodOptional<z.ZodString>;
39
48
  dba: z.ZodOptional<z.ZodString>;
40
49
  industry: z.ZodString;
41
- companySize: z.ZodEnum<["1", "2-10", "11-25", "26-50", "51-100", "100-499", "500+"]>;
50
+ companySize: z.ZodEnum<{
51
+ 0: "0";
52
+ 1: "1";
53
+ "2-10": "2-10";
54
+ "11-25": "11-25";
55
+ "26-50": "26-50";
56
+ "51-100": "51-100";
57
+ "100-499": "100-499";
58
+ "500+": "500+";
59
+ }>;
42
60
  yearEstablished: z.ZodOptional<z.ZodString>;
43
61
  website: z.ZodOptional<z.ZodString>;
44
62
  fein: z.ZodOptional<z.ZodString>;
@@ -52,66 +70,10 @@ declare const CreateCompanySchema: z.ZodObject<{
52
70
  city: z.ZodString;
53
71
  state: z.ZodString;
54
72
  zip: z.ZodString;
55
- }, "strip", z.ZodTypeAny, {
56
- street: string;
57
- city: string;
58
- state: string;
59
- zip: string;
60
- suite?: string | undefined;
61
- }, {
62
- street: string;
63
- city: string;
64
- state: string;
65
- zip: string;
66
- suite?: string | undefined;
67
- }>>;
73
+ }, z.core.$strip>>;
68
74
  externalId: z.ZodOptional<z.ZodString>;
69
75
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
70
- }, "strip", z.ZodTypeAny, {
71
- name: string;
72
- industry: string;
73
- companySize: "1" | "2-10" | "11-25" | "26-50" | "51-100" | "100-499" | "500+";
74
- contactEmail: string;
75
- legalName?: string | undefined;
76
- dba?: string | undefined;
77
- yearEstablished?: string | undefined;
78
- website?: string | undefined;
79
- fein?: string | undefined;
80
- companyStructure?: string | undefined;
81
- description?: string | undefined;
82
- contactPhone?: string | undefined;
83
- address?: {
84
- street: string;
85
- city: string;
86
- state: string;
87
- zip: string;
88
- suite?: string | undefined;
89
- } | undefined;
90
- externalId?: string | undefined;
91
- metadata?: Record<string, unknown> | undefined;
92
- }, {
93
- name: string;
94
- industry: string;
95
- companySize: "1" | "2-10" | "11-25" | "26-50" | "51-100" | "100-499" | "500+";
96
- contactEmail: string;
97
- legalName?: string | undefined;
98
- dba?: string | undefined;
99
- yearEstablished?: string | undefined;
100
- website?: string | undefined;
101
- fein?: string | undefined;
102
- companyStructure?: string | undefined;
103
- description?: string | undefined;
104
- contactPhone?: string | undefined;
105
- address?: {
106
- street: string;
107
- city: string;
108
- state: string;
109
- zip: string;
110
- suite?: string | undefined;
111
- } | undefined;
112
- externalId?: string | undefined;
113
- metadata?: Record<string, unknown> | undefined;
114
- }>;
76
+ }, z.core.$strip>;
115
77
  type CreateCompanyInput = z.infer<typeof CreateCompanySchema>;
116
78
  interface Company {
117
79
  id: string;
@@ -123,13 +85,33 @@ interface Company {
123
85
  website?: string;
124
86
  createdAt: string;
125
87
  }
126
- declare const DocumentTypeSchema: z.ZodEnum<["policy", "loss_run", "financial_statement", "sov", "application", "certificate", "endorsement", "bor", "other"]>;
88
+ declare const DocumentTypeSchema: z.ZodEnum<{
89
+ policy: "policy";
90
+ loss_run: "loss_run";
91
+ financial_statement: "financial_statement";
92
+ sov: "sov";
93
+ application: "application";
94
+ certificate: "certificate";
95
+ endorsement: "endorsement";
96
+ bor: "bor";
97
+ other: "other";
98
+ }>;
127
99
  type DocumentType = z.infer<typeof DocumentTypeSchema>;
128
- declare const DocumentStatusSchema: z.ZodEnum<["pending", "processing", "completed", "processed", "error", "failed"]>;
100
+ declare const DocumentStatusSchema: z.ZodEnum<{
101
+ error: "error";
102
+ pending: "pending";
103
+ processing: "processing";
104
+ completed: "completed";
105
+ processed: "processed";
106
+ failed: "failed";
107
+ }>;
129
108
  type DocumentStatus = z.infer<typeof DocumentStatusSchema>;
130
109
  interface UploadDocumentInput {
131
- /** Company ID to associate the document with */
132
- companyId: string;
110
+ /**
111
+ * Optional. An API key belongs to one company, and the document goes there.
112
+ * Naming any other company answers 403 with `code: 'company_mismatch'`.
113
+ */
114
+ companyId?: string;
133
115
  /** File to upload (Buffer, Blob, or base64 string) */
134
116
  file: Buffer | Blob | string;
135
117
  /** File name */
@@ -189,8 +171,9 @@ interface APIKey {
189
171
  }
190
172
  interface CreateAPIKeyInput {
191
173
  name: string;
192
- scopes?: ('read' | 'write' | 'admin')[];
193
- expiresInDays?: number;
174
+ scopes?: ('read' | 'write' | 'admin' | 'appetite:read' | 'mcp:read' | 'mcp:orin' | 'claims:write')[];
175
+ /** 1 to 365, or 'never' for a read-only key. Omitted: 90 days. */
176
+ expiresInDays?: number | 'never';
194
177
  }
195
178
  interface CreatedAPIKey extends APIKey {
196
179
  /** The full API key - only shown once at creation time */
@@ -200,6 +183,15 @@ declare class DeleganceError extends Error {
200
183
  statusCode: number;
201
184
  traceId?: string | undefined;
202
185
  details?: unknown | undefined;
186
+ /** Machine-readable `reason` from the error body, when the server sent one. */
187
+ reason?: string;
188
+ /**
189
+ * Machine-readable `code` from the error body, when the server sent one
190
+ * (e.g. `company_mismatch` on a 403 for a company the key does not own).
191
+ */
192
+ code?: string;
193
+ /** The parsed error body, for fields a caller needs (portalUrl, hint). */
194
+ body?: Record<string, unknown>;
203
195
  constructor(message: string, statusCode: number, traceId?: string | undefined, details?: unknown | undefined);
204
196
  }
205
197
  declare class AuthenticationError extends DeleganceError {
@@ -215,6 +207,16 @@ declare class RateLimitError extends DeleganceError {
215
207
  retryAfter?: number | undefined;
216
208
  constructor(message: string, retryAfter?: number | undefined, traceId?: string);
217
209
  }
210
+ declare class ForbiddenError extends DeleganceError {
211
+ constructor(message: string, traceId?: string);
212
+ }
213
+ /**
214
+ * The server recognised the request but the capability is not live yet
215
+ * (HTTP 501). Permanent for the current deployment, so it is never retried.
216
+ */
217
+ declare class NotImplementedError extends DeleganceError {
218
+ constructor(message: string, traceId?: string);
219
+ }
218
220
 
219
221
  /**
220
222
  * HTTP Client utilities for the Delegance SDK
@@ -229,7 +231,18 @@ interface RequestOptions {
229
231
  /** If true, body is FormData and shouldn't be JSON stringified */
230
232
  isFormData?: boolean;
231
233
  }
232
- declare const SDK_VERSION = "0.1.0";
234
+ /** Kept equal to package.json "version"; a unit test fails on drift. */
235
+ declare const SDK_VERSION = "0.2.1";
236
+ /**
237
+ * Canonical default API origin (WS0/WS1 shared constant, the SDK-package
238
+ * source of truth; the CLI mirror lives in cli/src/utils/config.ts).
239
+ *
240
+ * Decided for the 0.2.0 publish (2026-09-24): the prod portal is the default
241
+ * host. Callers override it with `baseUrl` or DELEGANCE_BASE_URL. Changing
242
+ * the host is exactly two lines (this constant + the CLI mirror) plus
243
+ * regenerated docs.
244
+ */
245
+ declare const DEFAULT_BASE_URL = "https://portal.delegancebrokerage.com";
233
246
  declare class HttpClient {
234
247
  private config;
235
248
  constructor(config: DeleganceClientConfig);
@@ -256,14 +269,21 @@ declare class HttpClient {
256
269
  */
257
270
 
258
271
  interface ListCompaniesOptions {
259
- /** Include companies created by this API key */
272
+ /**
273
+ * @deprecated A customer API key belongs to one company and cannot create
274
+ * others, so this adds nothing for it.
275
+ */
260
276
  includeCreated?: boolean;
261
277
  }
262
278
  declare class CompaniesModule {
263
279
  private http;
264
280
  constructor(http: HttpClient);
265
281
  /**
266
- * Create a new company
282
+ * Create a new company.
283
+ *
284
+ * @deprecated A customer API key cannot create companies (403
285
+ * `tenant_key_cannot_create`). To open a new account, use
286
+ * `createSignup().createAccount()`.
267
287
  *
268
288
  * @example
269
289
  * ```typescript
@@ -278,19 +298,19 @@ declare class CompaniesModule {
278
298
  */
279
299
  create(input: CreateCompanyInput): Promise<Company>;
280
300
  /**
281
- * List companies accessible to this API key
301
+ * List the company this API key belongs to. A key belongs to one company.
282
302
  *
283
303
  * @example
284
304
  * ```typescript
285
- * const companies = await client.companies.list();
286
- *
287
- * // Include companies created via this API key
288
- * const allCompanies = await client.companies.list({ includeCreated: true });
305
+ * const [company] = await client.companies.list();
289
306
  * ```
290
307
  */
291
308
  list(options?: ListCompaniesOptions): Promise<Company[]>;
292
309
  /**
293
- * Get a company by ID
310
+ * Get a company by ID.
311
+ *
312
+ * @deprecated The server has no `GET /api/v1/companies/{id}` route, so this
313
+ * returns 404. Use `list()`, which returns the key's own company.
294
314
  *
295
315
  * @example
296
316
  * ```typescript
@@ -299,7 +319,10 @@ declare class CompaniesModule {
299
319
  */
300
320
  get(companyId: string): Promise<Company>;
301
321
  /**
302
- * Create a company if it doesn't exist (using externalId for deduplication)
322
+ * Create a company if it doesn't exist (using externalId for deduplication).
323
+ *
324
+ * @deprecated A customer API key cannot create companies. Use
325
+ * `createSignup().createAccount()` for a new account.
303
326
  *
304
327
  * @example
305
328
  * ```typescript
@@ -370,7 +393,6 @@ declare class DocumentsModule {
370
393
  * import fs from 'fs';
371
394
  *
372
395
  * const doc = await client.documents.upload({
373
- * companyId: 'company-uuid',
374
396
  * file: fs.readFileSync('./policy.pdf'),
375
397
  * fileName: 'GL-2025.pdf',
376
398
  * documentType: 'policy'
@@ -386,8 +408,8 @@ declare class DocumentsModule {
386
408
  * @example
387
409
  * ```typescript
388
410
  * const docs = await client.documents.uploadBatch([
389
- * { companyId, file: buffer1, fileName: 'policy1.pdf' },
390
- * { companyId, file: buffer2, fileName: 'policy2.pdf' }
411
+ * { file: buffer1, fileName: 'policy1.pdf' },
412
+ * { file: buffer2, fileName: 'policy2.pdf' }
391
413
  * ]);
392
414
  * ```
393
415
  */
@@ -829,6 +851,49 @@ interface ListPoliciesResponse {
829
851
  count: number;
830
852
  traceId: string;
831
853
  }
854
+ type CancellationReason = 'replaced' | 'business_closed' | 'sold' | 'not_needed' | 'other';
855
+ interface CancellationRequestInput {
856
+ /** YYYY-MM-DD; coverage ends at 12:01 AM that day. */
857
+ requestedEffectiveDate: string;
858
+ reason: CancellationReason;
859
+ /** Required when reason is 'replaced'. */
860
+ replacementPolicyId?: string;
861
+ }
862
+ interface CancellationSignInput {
863
+ signerName: string;
864
+ signerTitle: string;
865
+ /** The signer attests they may bind the named insured. Must be true. */
866
+ attestAuthority: true;
867
+ /** From the 202 that emailed the code. Omit both to (re)send a code. */
868
+ stepUpId?: string;
869
+ /** The 6-digit code from the email. */
870
+ code?: string;
871
+ }
872
+ /** 202: a code went to the signer's email. 200: signed. */
873
+ type CancellationSignResult = {
874
+ stepUpRequired: true;
875
+ stepUpId: string;
876
+ action: 'sign';
877
+ channel: 'email';
878
+ sentTo: string;
879
+ expiresAt: string | null;
880
+ requestId: string;
881
+ } | {
882
+ status: 'signed';
883
+ requestId: string;
884
+ };
885
+ interface CancellationStatus {
886
+ id: string;
887
+ policyId?: string;
888
+ status: string;
889
+ requestedEffectiveDate: string;
890
+ reason: string;
891
+ /** Claims-made continuity verdict: 'continuous', 'prior_acts_gap', 'unknown', ... */
892
+ continuity: string;
893
+ confirmedEffectiveDate?: string | null;
894
+ confirmationNumber?: string | null;
895
+ updatedAt?: string;
896
+ }
832
897
  declare class PoliciesModule {
833
898
  private http;
834
899
  constructor(http: HttpClient);
@@ -865,6 +930,28 @@ declare class PoliciesModule {
865
930
  policy: Policy;
866
931
  coverages: PolicyCoverage[];
867
932
  } | null>;
933
+ /**
934
+ * Ask to cancel a policy. The request waits for the insured's signature,
935
+ * collected at `signatureUrl` by an owner or admin; a broker reviews the
936
+ * claims-made continuity check before anything reaches the carrier.
937
+ */
938
+ requestCancellation(policyId: string, input: CancellationRequestInput, opts?: {
939
+ idempotencyKey?: string;
940
+ }): Promise<{
941
+ request: CancellationStatus;
942
+ signatureUrl: string;
943
+ signEndpoint?: string;
944
+ }>;
945
+ /**
946
+ * Sign a cancellation request as an owner or admin. Signing needs a step-up
947
+ * code: call once without `code` to email it (202 with `stepUpId`), then
948
+ * again with `stepUpId` and `code`.
949
+ */
950
+ signCancellation(requestId: string, input: CancellationSignInput, opts?: {
951
+ idempotencyKey?: string;
952
+ }): Promise<CancellationSignResult>;
953
+ /** One cancellation request's status. */
954
+ getCancellation(requestId: string): Promise<CancellationStatus>;
868
955
  }
869
956
 
870
957
  /**
@@ -1136,10 +1223,23 @@ interface RotateResult {
1136
1223
  rotationId: string;
1137
1224
  status: 'rotating';
1138
1225
  }
1226
+ /**
1227
+ * Scopes the server accepts. `appetite:read`, `mcp:*` and `claims:write` are
1228
+ * opt-in and never implied. `claims:write` can be created only while signed
1229
+ * in to the portal; an API-key call that asks for it gets a 403.
1230
+ */
1231
+ type ApiKeyScope = 'read' | 'write' | 'admin' | 'appetite:read' | 'mcp:read' | 'mcp:orin' | 'claims:write';
1232
+ declare const API_KEY_SCOPES: readonly ApiKeyScope[];
1139
1233
  interface CreateApiKeyInput {
1140
1234
  name: string;
1141
- scopes: ('read' | 'write' | 'admin')[];
1142
- expiresInDays?: number;
1235
+ scopes: ApiKeyScope[];
1236
+ /**
1237
+ * Days until the key expires, 1 to 365. Omitted: 90 days. `'never'`: no
1238
+ * expiry, allowed only for a read-only key. A key with `write`, `admin` or
1239
+ * `claims:write` must expire, or the server answers 400
1240
+ * `write_key_requires_expiry`.
1241
+ */
1242
+ expiresInDays?: number | 'never';
1143
1243
  }
1144
1244
  interface ListApiKeysOptions {
1145
1245
  limit?: number;
@@ -1492,6 +1592,23 @@ interface OnboardingStatus {
1492
1592
  */
1493
1593
  nextStep: OnboardingNextStep | null;
1494
1594
  }
1595
+ /** The five onboarding states of the frozen WS1 contract. */
1596
+ type OnboardingState = 'created' | 'awaiting_verification' | 'documents_pending' | 'processing' | 'ready';
1597
+ /** Data payload of `GET /api/v1/onboarding/state`. */
1598
+ interface OnboardingStateData {
1599
+ state: OnboardingState;
1600
+ verified: boolean;
1601
+ capabilities: string[];
1602
+ verification: {
1603
+ challengeIssued: boolean;
1604
+ sentTo: string | null;
1605
+ };
1606
+ documents: {
1607
+ total: number;
1608
+ processing: number;
1609
+ processed: number;
1610
+ };
1611
+ }
1495
1612
  declare class OnboardingModule {
1496
1613
  private http;
1497
1614
  constructor(http: HttpClient);
@@ -1514,6 +1631,805 @@ declare class OnboardingModule {
1514
1631
  * ```
1515
1632
  */
1516
1633
  status(): Promise<OnboardingStatus>;
1634
+ /** Poll the canonical onboarding state machine. Callable pre-verification. */
1635
+ state(): Promise<OnboardingStateData>;
1636
+ /**
1637
+ * Issue (or re-issue) the human verification challenge. Delegance emails a
1638
+ * confirmation link to the company contact email. Hand that link to a human;
1639
+ * the agent cannot self-verify.
1640
+ */
1641
+ requestVerification(): Promise<{
1642
+ state: OnboardingState;
1643
+ sentTo: string;
1644
+ }>;
1645
+ /** Poll state() until `target` is reached or `timeoutMs` elapses. */
1646
+ waitForState(target: OnboardingState, options?: {
1647
+ intervalMs?: number;
1648
+ timeoutMs?: number;
1649
+ }): Promise<OnboardingStateData>;
1650
+ }
1651
+
1652
+ /**
1653
+ * Appetite Module
1654
+ *
1655
+ * Carrier appetite matching: which carriers will write a given risk.
1656
+ *
1657
+ * Contract (POST /api/v1/appetite/match):
1658
+ * - warm cache hit -> 200 with the full validated result
1659
+ * - cold -> 202 with a job id; poll GET /api/v1/appetite/match/:jobId
1660
+ *
1661
+ * Requires an API key carrying the `appetite:read` scope. That scope is not
1662
+ * implied by `read` or `write`. The endpoint answers 404 while the partner
1663
+ * API is disabled for the deployment.
1664
+ */
1665
+
1666
+ interface AppetiteMatchInput {
1667
+ /** Two-letter US state code (required). */
1668
+ state: string;
1669
+ /** One of industry, businessDescription, naicsCode, or sicCode is required. */
1670
+ industry?: string;
1671
+ businessDescription?: string;
1672
+ naicsCode?: string;
1673
+ sicCode?: string;
1674
+ coverageTypes?: string[];
1675
+ carriers?: string[];
1676
+ marketSize?: 'Small Business' | 'Middle Market';
1677
+ productFilter?: 'off' | 'boost' | 'strict';
1678
+ annualRevenue?: number;
1679
+ annualPayroll?: number;
1680
+ propertyValue?: number;
1681
+ /** Callers may only raise the quality floor. */
1682
+ minFit?: 'possible' | 'strong';
1683
+ topK?: number;
1684
+ minScore?: number;
1685
+ }
1686
+ interface AppetiteMatch {
1687
+ carrier: string;
1688
+ classDescription: string;
1689
+ industryCategory: string;
1690
+ product: string;
1691
+ appetite: 'Target' | 'Acceptable' | 'Limited' | 'Not Available';
1692
+ score: number;
1693
+ matchDetails: {
1694
+ codeMatchScore: number;
1695
+ semanticScore: number;
1696
+ stateMatch: boolean;
1697
+ };
1698
+ classCode: string;
1699
+ sicCode: string;
1700
+ naicsCode: string;
1701
+ limits: string;
1702
+ notes: string;
1703
+ marketSize: string;
1704
+ }
1705
+ interface CarrierAppetiteResult {
1706
+ carrier: string;
1707
+ overallStatus: 'acceptable' | 'targeted' | 'limited' | 'declined' | 'unknown';
1708
+ confidence: number;
1709
+ bestMatch: AppetiteMatch;
1710
+ allMatches: AppetiteMatch[];
1711
+ productsAvailable: string[];
1712
+ warnings: string[];
1713
+ }
1714
+ interface AppetiteMatchResult {
1715
+ matches: AppetiteMatch[];
1716
+ carrierResults: CarrierAppetiteResult[];
1717
+ suggestedCarriers: string[];
1718
+ warnings: string[];
1719
+ metadata: Record<string, unknown> & {
1720
+ validated?: boolean;
1721
+ };
1722
+ }
1723
+ /** Result of `appetite.match()`: either a finished result or a queued job. */
1724
+ type AppetiteMatchStart = ({
1725
+ status: 'succeeded';
1726
+ cached: true;
1727
+ jobId: null;
1728
+ traceId: string;
1729
+ } & AppetiteMatchResult) | {
1730
+ status: 'queued';
1731
+ jobId: string;
1732
+ statusUrl: string;
1733
+ estimatedSeconds: number;
1734
+ traceId: string;
1735
+ };
1736
+ type AppetiteJobStatus = {
1737
+ status: 'queued' | 'running';
1738
+ jobId: string;
1739
+ estimatedSeconds: number;
1740
+ traceId: string;
1741
+ } | ({
1742
+ status: 'succeeded';
1743
+ jobId: string;
1744
+ cached: false;
1745
+ traceId: string;
1746
+ } & AppetiteMatchResult) | {
1747
+ status: 'failed';
1748
+ jobId: string;
1749
+ errorCode: string;
1750
+ retryable: boolean;
1751
+ retryAfterSeconds?: number;
1752
+ traceId: string;
1753
+ };
1754
+ interface WaitForMatchOptions {
1755
+ intervalMs?: number;
1756
+ timeoutMs?: number;
1757
+ }
1758
+ declare class AppetiteModule {
1759
+ private http;
1760
+ constructor(http: HttpClient);
1761
+ /**
1762
+ * Start an appetite match. Returns the result directly on a warm cache hit,
1763
+ * or a queued job to poll with `getMatch()`.
1764
+ *
1765
+ * @example
1766
+ * ```typescript
1767
+ * const start = await client.appetite.match({ state: 'CA', industry: 'restaurant' });
1768
+ * const result = start.status === 'succeeded'
1769
+ * ? start
1770
+ * : await client.appetite.waitForMatch(start.jobId);
1771
+ * ```
1772
+ */
1773
+ match(input: AppetiteMatchInput): Promise<AppetiteMatchStart>;
1774
+ /** Read a match job. Unknown, expired, and other-tenant ids all raise NotFoundError. */
1775
+ getMatch(jobId: string): Promise<AppetiteJobStatus>;
1776
+ /**
1777
+ * Poll a job until it succeeds. Throws on a failed job (with the sanitized
1778
+ * errorCode) or on timeout.
1779
+ */
1780
+ waitForMatch(jobId: string, options?: WaitForMatchOptions): Promise<Extract<AppetiteJobStatus, {
1781
+ status: 'succeeded';
1782
+ }>>;
1783
+ }
1784
+
1785
+ /**
1786
+ * Leads Module
1787
+ *
1788
+ * Send a prospect business to Delegance (POST /api/v1/leads). Needs the
1789
+ * `write` scope. Idempotent on `externalId`, and a lead whose contact email
1790
+ * already belongs to a company returns that company instead of a duplicate.
1791
+ */
1792
+
1793
+ interface LeadAddress {
1794
+ street: string;
1795
+ suite?: string;
1796
+ city: string;
1797
+ /** Two-letter state code. */
1798
+ state: string;
1799
+ /** 5-digit or ZIP+4. */
1800
+ zip: string;
1801
+ }
1802
+ interface CreateLeadInput {
1803
+ name: string;
1804
+ contactEmail: string;
1805
+ legalName?: string;
1806
+ industry?: string;
1807
+ contactPhone?: string;
1808
+ website?: string;
1809
+ companySize?: string;
1810
+ description?: string;
1811
+ sicCode?: string;
1812
+ naicsCode?: string;
1813
+ state?: string;
1814
+ address?: LeadAddress;
1815
+ externalId?: string;
1816
+ source?: string;
1817
+ sourceDetail?: Record<string, unknown>;
1818
+ notes?: string;
1819
+ metadata?: Record<string, unknown>;
1820
+ }
1821
+ interface CreateLeadResult {
1822
+ success: boolean;
1823
+ companyId: string;
1824
+ message: string;
1825
+ traceId: string;
1826
+ }
1827
+ declare class LeadsModule {
1828
+ private http;
1829
+ constructor(http: HttpClient);
1830
+ /**
1831
+ * Create a lead.
1832
+ *
1833
+ * @example
1834
+ * ```typescript
1835
+ * const { companyId } = await client.leads.create({
1836
+ * name: 'Riverbend Bakery',
1837
+ * contactEmail: 'owner@riverbend.example',
1838
+ * state: 'TX',
1839
+ * externalId: 'crm-4411',
1840
+ * });
1841
+ * ```
1842
+ */
1843
+ create(input: CreateLeadInput): Promise<CreateLeadResult>;
1844
+ }
1845
+
1846
+ /**
1847
+ * Instant Quotes Module: real carrier premiums over the API.
1848
+ *
1849
+ * Needs a key with a person behind it (from `delegance signup`, or created in
1850
+ * the portal while signed in). Flow: `start` returns the questions, `submit`
1851
+ * files the answers with the carriers, `status` / `waitForQuotes` return
1852
+ * premiums as carriers answer, `bind` requests a bind on one offer.
1853
+ *
1854
+ * `submit` and `bind` send an Idempotency-Key. Pass your own to make a retry
1855
+ * across process restarts land on the same request; otherwise one is made per
1856
+ * call and reused by the SDK's own retries.
1857
+ */
1858
+
1859
+ interface InstantQuestionOption {
1860
+ value: string;
1861
+ label: string;
1862
+ }
1863
+ interface InstantQuestion {
1864
+ id: string;
1865
+ label: string;
1866
+ type: string;
1867
+ options?: InstantQuestionOption[];
1868
+ required: boolean;
1869
+ group?: string;
1870
+ /** Answered from the insured's own account data. Shown and editable. */
1871
+ prefill?: unknown;
1872
+ /** Inferred by a source. Counts only after the insured confirms it. */
1873
+ suggested?: {
1874
+ value: unknown;
1875
+ route?: string;
1876
+ confidence?: string;
1877
+ };
1878
+ /** Required only while visible. */
1879
+ requiredIfShown?: boolean;
1880
+ /** Shown only when the named question's answer is one of `equals`. */
1881
+ showIf?: {
1882
+ questionId: string;
1883
+ equals: string[];
1884
+ };
1885
+ [key: string]: unknown;
1886
+ }
1887
+ interface InstantSession {
1888
+ submissionId: string;
1889
+ sessionVersion: string;
1890
+ decision: string;
1891
+ eligibleCarriers: {
1892
+ carrierId: string;
1893
+ name: string;
1894
+ }[];
1895
+ questions: InstantQuestion[];
1896
+ }
1897
+ interface InstantSubmitResult {
1898
+ quotes: {
1899
+ carrierId: string;
1900
+ carrierName: string;
1901
+ premium: number | null;
1902
+ status: string;
1903
+ }[];
1904
+ /** `missing` names the value that would bring a carrier dropped by a data floor back. */
1905
+ partialFailures: {
1906
+ carrierId: string;
1907
+ reason: string;
1908
+ missing?: string;
1909
+ }[];
1910
+ acordCoverages: string[];
1911
+ status: 'submitted' | 'acord_pending' | 'no_carriers';
1912
+ /** The broker task, when ACORD lines were queued (`acord_pending`). */
1913
+ brokerTaskId?: string;
1914
+ /** On a replace: the earlier requests closed on our side, per coverage. */
1915
+ superseded?: {
1916
+ policyType: string;
1917
+ submissionIds: string[];
1918
+ carriers: string[];
1919
+ }[];
1920
+ /** On a replace: coverages whose earlier request stayed open (nothing new was filed for them). */
1921
+ restored?: string[];
1922
+ replaceNotice?: string;
1923
+ }
1924
+ interface CarrierQuote {
1925
+ opportunityId: string;
1926
+ carrierId: string;
1927
+ carrierName: string;
1928
+ coverage: string | null;
1929
+ state: string;
1930
+ marketStatus: string;
1931
+ premium: number | null;
1932
+ quoteNumber: string | null;
1933
+ bindable: boolean | null;
1934
+ /**
1935
+ * Human-readable limits, e.g. "$1M per occurrence / $2M aggregate" or
1936
+ * "Statutory / $1M employers liability". Null when the carrier sent none.
1937
+ * Absent on older servers.
1938
+ */
1939
+ limits?: string | null;
1940
+ /**
1941
+ * Deductible in dollars; 0 means none. Today only cyber quotes carry one
1942
+ * (the retention); every other line returns null. Absent on older servers.
1943
+ */
1944
+ deductible?: number | null;
1945
+ /**
1946
+ * The carrier result status (`needs_info`, `declined`, `failed`, ...). A
1947
+ * REFERRED quote with `needs_info` is closed: the carrier needs answers.
1948
+ * Absent on older servers.
1949
+ */
1950
+ resultStatus?: string | null;
1951
+ /**
1952
+ * Why the carrier did not price, in the carrier's own words (a decline) or
1953
+ * a plain sentence (needs info, referral). Null otherwise. Absent on older
1954
+ * servers.
1955
+ */
1956
+ message?: string | null;
1957
+ }
1958
+ interface InstantQuoteStatus {
1959
+ submissionId: string;
1960
+ coverages: string[];
1961
+ expiresAt: string | null;
1962
+ submitted: boolean;
1963
+ submitStatus: 'not_submitted' | 'in_progress' | 'completed';
1964
+ carrierQuotes: CarrierQuote[];
1965
+ allCarriersResolved: boolean;
1966
+ awaitingBrokerReviewCount: number;
1967
+ /** When coverage would start, as an ISO date (YYYY-MM-DD). Absent on older servers. */
1968
+ effectiveDate?: string | null;
1969
+ /** The newest broker task on this submission; null when none. Absent when the server could not read it. */
1970
+ brokerReview?: {
1971
+ taskId: string;
1972
+ status: string;
1973
+ createdAt: string;
1974
+ } | null;
1975
+ }
1976
+ /** ACORD questions a broker needs after a `no_carriers` result. */
1977
+ interface BrokerHandoffQuestions {
1978
+ submissionId: string;
1979
+ coverages: string[];
1980
+ questions: InstantQuestion[];
1981
+ /** True when this submission is already with a broker; `questions` is empty. */
1982
+ alreadyHandedOff: boolean;
1983
+ brokerTaskId?: string | null;
1984
+ }
1985
+ interface BrokerHandoffResult {
1986
+ status: 'broker_review';
1987
+ submissionId: string;
1988
+ brokerTaskId: string | null;
1989
+ coverages: string[];
1990
+ /** Required questions left blank. The broker asks them. */
1991
+ unansweredRequired: number;
1992
+ alreadyHandedOff: boolean;
1993
+ }
1994
+ /**
1995
+ * Premium financing at the point of sale. Present only when Delegance has the
1996
+ * lane switched on. Terms are the LENDER's, reported once the insured starts
1997
+ * financing; they are null before that.
1998
+ */
1999
+ interface FinancingOffer {
2000
+ available: boolean;
2001
+ availability: 'provider_confirmed' | 'precheck_passed' | 'unavailable';
2002
+ provider: string;
2003
+ lender: string;
2004
+ reason: string | null;
2005
+ /** The portal finance checkout (sign in to the portal to use it). */
2006
+ checkoutUrl: string | null;
2007
+ premiumFinal: boolean;
2008
+ terms: {
2009
+ aprBps: number | null;
2010
+ downPaymentCents: number | null;
2011
+ amountFinancedCents: number | null;
2012
+ financeChargeCents: number | null;
2013
+ installmentCents: number | null;
2014
+ numberOfInstallments: number | null;
2015
+ totalOfPaymentsCents: number | null;
2016
+ agreementUrl: string | null;
2017
+ providerQuoteRef: string | null;
2018
+ providerQuoteStatus: string | null;
2019
+ } | null;
2020
+ applicationStatus: string | null;
2021
+ disclosure: string;
2022
+ }
2023
+ interface BindRequestResult {
2024
+ bindRequestId: string;
2025
+ status: string;
2026
+ carrierName: string;
2027
+ coverage: string;
2028
+ premium: number | null;
2029
+ existing: boolean;
2030
+ next: string;
2031
+ /** Fast bind only: 'A' opens the carrier's own checkout, 'C' goes to a broker. */
2032
+ tier?: 'A' | 'C';
2033
+ /** Tier C: why the offer could not use the carrier checkout. */
2034
+ reasons?: string[];
2035
+ /** Tier A: the carrier's checkout page. The policy is bound only when the carrier confirms. */
2036
+ checkoutUrl?: string;
2037
+ /** Point-of-sale premium financing, when offered. */
2038
+ financing?: FinancingOffer;
2039
+ }
2040
+ /** The first fast-bind call emails a code; send it back with `stepUpId`. */
2041
+ interface BindStepUpRequired {
2042
+ stepUpRequired: true;
2043
+ stepUpId: string;
2044
+ channel: 'email';
2045
+ sentTo: string;
2046
+ expiresAt: string | null;
2047
+ }
2048
+ interface FastBindInput {
2049
+ /** You confirm the application answers are accurate. Required by fast bind. */
2050
+ attest?: boolean;
2051
+ stepUpId?: string;
2052
+ code?: string;
2053
+ idempotencyKey?: string;
2054
+ }
2055
+ declare class InstantQuotesModule {
2056
+ private http;
2057
+ constructor(http: HttpClient);
2058
+ /**
2059
+ * `fresh: true` always mints a new submission instead of reusing a warm
2060
+ * session for the same coverages. Use it with `submit({ replace: true })`
2061
+ * to re-quote coverage that already has a request with carriers.
2062
+ */
2063
+ start(coverages: string[], opts?: {
2064
+ fresh?: boolean;
2065
+ }): Promise<InstantSession>;
2066
+ submit(input: {
2067
+ submissionId: string;
2068
+ sessionVersion: string;
2069
+ answers: Record<string, unknown>;
2070
+ /**
2071
+ * Close the earlier request for the same coverage and re-quote. Without
2072
+ * it, a submit while one is with carriers returns 409
2073
+ * `active_request_exists`. A carrier may still see the earlier
2074
+ * application: CoverForce has no withdraw call.
2075
+ */
2076
+ replace?: boolean;
2077
+ }, opts?: {
2078
+ idempotencyKey?: string;
2079
+ }): Promise<InstantSubmitResult>;
2080
+ status(submissionId: string): Promise<InstantQuoteStatus>;
2081
+ /** Polls `status` until every visible carrier resolved, or the timeout. */
2082
+ waitForQuotes(submissionId: string, opts?: {
2083
+ timeoutMs?: number;
2084
+ intervalMs?: number;
2085
+ onPoll?: (s: InstantQuoteStatus) => void;
2086
+ }): Promise<InstantQuoteStatus>;
2087
+ /**
2088
+ * After a `no_carriers` submit: the ACORD questions a broker needs to place
2089
+ * the risk with a non-instant market. Pass the answers you submitted so
2090
+ * facts you already gave are not asked again.
2091
+ */
2092
+ brokerHandoffQuestions(submissionId: string, instantAnswers?: Record<string, unknown>): Promise<BrokerHandoffQuestions>;
2093
+ /**
2094
+ * Hands a `no_carriers` submission to a Delegance broker as a non-instant
2095
+ * request, with whatever ACORD answers you have. `complete: false` says you
2096
+ * stopped early; the broker asks the rest. A repeat call returns the same
2097
+ * broker task.
2098
+ */
2099
+ brokerHandoff(submissionId: string, input: {
2100
+ answers: Record<string, unknown>;
2101
+ instantAnswers?: Record<string, unknown>;
2102
+ complete?: boolean;
2103
+ }, opts?: {
2104
+ idempotencyKey?: string;
2105
+ }): Promise<BrokerHandoffResult>;
2106
+ /** Requests a bind on one offer. A licensed broker reviews it; nothing is charged. */
2107
+ bind(submissionId: string, opportunityId: string, opts?: {
2108
+ idempotencyKey?: string;
2109
+ }): Promise<BindRequestResult>;
2110
+ /**
2111
+ * Bind through fast bind: an owner or admin attests the answers, gets a
2112
+ * 6-digit code by email (the first call returns `stepUpRequired`), then calls
2113
+ * again with `stepUpId` and `code`. A tier A offer returns `checkoutUrl`;
2114
+ * any other offer goes to a broker.
2115
+ */
2116
+ bindWithStepUp(submissionId: string, opportunityId: string, input?: FastBindInput): Promise<BindRequestResult | BindStepUpRequired>;
2117
+ }
2118
+
2119
+ /**
2120
+ * Payments Module: premium payment requests and Stripe checkout links.
2121
+ *
2122
+ * A payment request exists after a broker reviews a bind and records the
2123
+ * carrier's final premium. `checkout` returns a hosted Stripe URL to pay it.
2124
+ */
2125
+
2126
+ interface PaymentRequest {
2127
+ id: string;
2128
+ /** Cents. */
2129
+ amount: number;
2130
+ currency: string;
2131
+ description: string | null;
2132
+ status: string;
2133
+ dueDate?: string;
2134
+ createdAt: string;
2135
+ payable: boolean;
2136
+ }
2137
+ declare class PaymentsModule {
2138
+ private http;
2139
+ constructor(http: HttpClient);
2140
+ list(): Promise<PaymentRequest[]>;
2141
+ checkout(paymentRequestId: string, opts?: {
2142
+ idempotencyKey?: string;
2143
+ }): Promise<{
2144
+ checkoutUrl: string;
2145
+ }>;
2146
+ }
2147
+
2148
+ /**
2149
+ * Bonds Module: surety bond quotes.
2150
+ *
2151
+ * `start` matches the bond and returns its questions, `answer` submits them
2152
+ * (starting pricing when complete), `status` returns the premium and the
2153
+ * surety's apply link. Buying a bond is never automated: a quoted bond hands
2154
+ * off to the surety's apply page.
2155
+ *
2156
+ * Responses pass through the bond quote service as-is (snake_case fields such
2157
+ * as `session_id`, `missing_required`, `apply_url`).
2158
+ */
2159
+
2160
+ interface StartBondQuoteInput {
2161
+ /** Two-letter state, e.g. 'TX'. */
2162
+ state?: string;
2163
+ /** Bond name or keyword, e.g. 'notary', 'contractor license'. */
2164
+ bondName?: string;
2165
+ entityId?: string;
2166
+ contractAmount?: string | number;
2167
+ bondAmount?: string | number;
2168
+ }
2169
+ type BondToolResult = Record<string, unknown>;
2170
+ declare class BondsModule {
2171
+ private http;
2172
+ constructor(http: HttpClient);
2173
+ start(input: StartBondQuoteInput): Promise<BondToolResult>;
2174
+ answer(sessionId: string, answers: Record<string, unknown>, opts?: {
2175
+ idempotencyKey?: string;
2176
+ }): Promise<BondToolResult>;
2177
+ status(sessionId: string): Promise<BondToolResult>;
2178
+ }
2179
+
2180
+ /**
2181
+ * Claims Module: file and track claims.
2182
+ *
2183
+ * Needs a key with the `claims:write` scope, minted by `delegance signup` or
2184
+ * by a signed-in portal user. The claims disclaimer must be accepted once in
2185
+ * the portal by the key's user; until then `file` throws with
2186
+ * reason `gate_not_acknowledged` and `body.portalUrl`.
2187
+ */
2188
+
2189
+ interface ClaimSummary {
2190
+ claimId: string;
2191
+ status: 'open' | 'in_progress' | 'resolved' | string;
2192
+ summary: string | null;
2193
+ incidentDate: string | null;
2194
+ policyId: string | null;
2195
+ openedAt: string;
2196
+ lastActivityAt: string;
2197
+ resolvedAt: string | null;
2198
+ }
2199
+ interface FileClaimInput {
2200
+ description: string;
2201
+ /** YYYY-MM-DD. */
2202
+ incidentDate?: string;
2203
+ policyId?: string;
2204
+ }
2205
+ declare class ClaimsModule {
2206
+ private http;
2207
+ constructor(http: HttpClient);
2208
+ file(input: FileClaimInput, opts?: {
2209
+ idempotencyKey?: string;
2210
+ }): Promise<ClaimSummary & {
2211
+ created: boolean;
2212
+ portalUrl: string;
2213
+ message: string;
2214
+ }>;
2215
+ list(opts?: {
2216
+ status?: 'open' | 'in_progress' | 'resolved';
2217
+ limit?: number;
2218
+ }): Promise<ClaimSummary[]>;
2219
+ get(claimId: string): Promise<ClaimSummary>;
2220
+ }
2221
+
2222
+ /**
2223
+ * Feedback Module: report a bug, an idea, or a question to Delegance.
2224
+ *
2225
+ * Any API key may report. The server scrubs credentials from the message and
2226
+ * keeps only known context fields, but send no secrets: the context is for
2227
+ * the command name, exit code, trace id, and versions.
2228
+ */
2229
+
2230
+ type FeedbackType = 'bug' | 'idea' | 'question';
2231
+ /** Matches the server cap; longer messages are refused, not cut. */
2232
+ declare const FEEDBACK_MESSAGE_MAX = 500;
2233
+ interface FeedbackContext {
2234
+ /** Command path only, e.g. "quote submit". Never arguments. */
2235
+ command?: string;
2236
+ exitCode?: number;
2237
+ /** The traceId from an error response, if the failure returned one. */
2238
+ traceId?: string;
2239
+ /** ISO timestamp of the failed command. */
2240
+ at?: string;
2241
+ cliVersion?: string;
2242
+ sdkVersion?: string;
2243
+ }
2244
+ interface SubmitFeedbackInput {
2245
+ /** Defaults to 'bug'. */
2246
+ type?: FeedbackType;
2247
+ message: string;
2248
+ context?: FeedbackContext;
2249
+ }
2250
+ declare class FeedbackModule {
2251
+ private http;
2252
+ constructor(http: HttpClient);
2253
+ /**
2254
+ * File a report. Returns the reference id Delegance uses to find it.
2255
+ *
2256
+ * Each call sends one Idempotency-Key, and the client's automatic retries of
2257
+ * that call reuse it, so a lost response never files the report twice. Pass
2258
+ * your own key to make a retry of your own (a second call) safe as well.
2259
+ */
2260
+ submit(input: SubmitFeedbackInput, opts?: {
2261
+ idempotencyKey?: string;
2262
+ }): Promise<{
2263
+ id: string;
2264
+ }>;
2265
+ }
2266
+
2267
+ /**
2268
+ * Signup Module: commercial insurance from a terminal, step one.
2269
+ *
2270
+ * Signup is a device-code exchange. No API key exists yet, so this module
2271
+ * runs unauthenticated except for `enroll` and `requestVerification`, which
2272
+ * use the one-time bootstrap key the signup returns.
2273
+ *
2274
+ * 1. createAccount unverified company + bootstrap key
2275
+ * 2. enroll register SHA-256(deviceSecret) against that key
2276
+ * 3. requestVerification emails the confirm link to the contact email
2277
+ * 4. exchange poll with the plaintext deviceSecret; after the human
2278
+ * clicks the link it returns a user-bound API key
2279
+ *
2280
+ * The device secret never leaves the terminal except to `exchange`, and the
2281
+ * bootstrap key is revoked server-side once the email is confirmed.
2282
+ */
2283
+
2284
+ interface CreateAccountInput {
2285
+ name: string;
2286
+ contactEmail: string;
2287
+ industry: string;
2288
+ /** Employee band: '0', '1', '2-10', '11-25', '26-50', '51-100', '100-499', '500+'. */
2289
+ companySize: string;
2290
+ /** One or two sentences on what the business does; feeds carrier class matching. */
2291
+ description?: string;
2292
+ website?: string;
2293
+ contactPhone?: string;
2294
+ address?: {
2295
+ street: string;
2296
+ suite?: string;
2297
+ city: string;
2298
+ state: string;
2299
+ zip: string;
2300
+ };
2301
+ }
2302
+ interface CreateAccountResult {
2303
+ companyId: string;
2304
+ bootstrapKey: string;
2305
+ /** e.g. 'address_not_saved': the account exists but the server could not store part of it. */
2306
+ warnings?: string[];
2307
+ }
2308
+ interface EnrollResult {
2309
+ enrollmentId: string;
2310
+ expiresAt: string;
2311
+ }
2312
+ type ExchangeResult = {
2313
+ status: 'pending';
2314
+ } | {
2315
+ status: 'ready';
2316
+ apiKey: string;
2317
+ keyPrefix: string;
2318
+ companyId: string;
2319
+ };
2320
+ /** 32 random bytes as hex, and its SHA-256. */
2321
+ declare function newDeviceSecret(): {
2322
+ secret: string;
2323
+ hash: string;
2324
+ };
2325
+ declare class SignupModule {
2326
+ private makeHttp;
2327
+ constructor(makeHttp: (apiKey: string) => HttpClient);
2328
+ /** Creates the unverified company. Retries safely: sends an Idempotency-Key. */
2329
+ createAccount(input: CreateAccountInput, opts?: {
2330
+ idempotencyKey?: string;
2331
+ }): Promise<CreateAccountResult>;
2332
+ enroll(bootstrapKey: string, input: {
2333
+ deviceSecretHash: string;
2334
+ firstName: string;
2335
+ lastName: string;
2336
+ }): Promise<EnrollResult>;
2337
+ requestVerification(bootstrapKey: string): Promise<{
2338
+ sentTo?: string;
2339
+ }>;
2340
+ /**
2341
+ * One poll. `pending` until the email link is clicked. Throws with
2342
+ * `reason` = already_collected | account_exists (409) or expired (410).
2343
+ */
2344
+ exchange(enrollmentId: string, deviceSecret: string): Promise<ExchangeResult>;
2345
+ /**
2346
+ * Polls `exchange` until the key is ready or `timeoutMs` passes. A 429 waits
2347
+ * the server's Retry-After and keeps polling.
2348
+ */
2349
+ waitForKey(enrollmentId: string, deviceSecret: string, opts?: {
2350
+ timeoutMs?: number;
2351
+ intervalMs?: number;
2352
+ onPoll?: () => void;
2353
+ }): Promise<ExchangeResult>;
2354
+ }
2355
+
2356
+ interface PollOptions {
2357
+ timeoutMs?: number;
2358
+ intervalMs?: number;
2359
+ onPoll?: () => void;
2360
+ }
2361
+
2362
+ /**
2363
+ * Auth Module: sign a terminal in with the browser, and inspect or refresh
2364
+ * the key it holds.
2365
+ *
2366
+ * Browser login is a device authorization (the same device-secret exchange
2367
+ * as signup):
2368
+ *
2369
+ * 1. start send SHA-256(deviceSecret); get a short code and a portal URL
2370
+ * 2. (human) a signed-in portal user opens the URL and approves the code
2371
+ * 3. waitForKey poll with the plaintext deviceSecret until the key is ready
2372
+ *
2373
+ * The device secret never leaves the terminal except to the token poll, and
2374
+ * the key can be collected once.
2375
+ */
2376
+
2377
+ interface DeviceLoginStart {
2378
+ loginId: string;
2379
+ /** Shown as XXXX-XXXX; the portal page asks the human to match it. */
2380
+ userCode: string;
2381
+ verificationUri: string;
2382
+ verificationUriComplete: string;
2383
+ expiresAt: string;
2384
+ /** Seconds between polls. */
2385
+ interval: number;
2386
+ }
2387
+ type DeviceLoginPoll = {
2388
+ status: 'pending';
2389
+ } | {
2390
+ status: 'ready';
2391
+ apiKey: string;
2392
+ keyPrefix: string;
2393
+ companyId: string;
2394
+ scopes: string[];
2395
+ expiresAt: string | null;
2396
+ };
2397
+ interface ApiKeyInfo {
2398
+ keyPrefix: string;
2399
+ origin: string | null;
2400
+ scopes: string[];
2401
+ companyId: string;
2402
+ userBound: boolean;
2403
+ /** ISO time, or null for a key that never expires. */
2404
+ expiresAt: string | null;
2405
+ /** True for CLI keys, which `refresh()` can extend. */
2406
+ refreshable: boolean;
2407
+ createdAt: string | null;
2408
+ }
2409
+ declare class DeviceLoginModule {
2410
+ private makeHttp;
2411
+ constructor(makeHttp: (apiKey: string) => HttpClient);
2412
+ start(input: {
2413
+ deviceSecretHash: string;
2414
+ deviceName: string;
2415
+ }): Promise<DeviceLoginStart>;
2416
+ /**
2417
+ * One poll. `pending` until the portal user approves. Throws with `reason`
2418
+ * = access_denied (403), already_collected (409), or expired (410).
2419
+ */
2420
+ poll(loginId: string, deviceSecret: string): Promise<DeviceLoginPoll>;
2421
+ /** Polls until the key is ready or `timeoutMs` passes (then returns `pending`). */
2422
+ waitForKey(loginId: string, deviceSecret: string, opts?: PollOptions): Promise<DeviceLoginPoll>;
2423
+ }
2424
+ declare class AuthModule {
2425
+ private http;
2426
+ constructor(http: HttpClient);
2427
+ /** The calling key: prefix, origin, scopes, company, and expiry. */
2428
+ keyInfo(): Promise<ApiKeyInfo>;
2429
+ /** Extend a CLI key to 90 days from now. Throws `not_refreshable` (400) for portal keys. */
2430
+ refresh(): Promise<{
2431
+ expiresAt: string;
2432
+ }>;
1517
2433
  }
1518
2434
 
1519
2435
  /**
@@ -1527,7 +2443,7 @@ declare class OnboardingModule {
1527
2443
  *
1528
2444
  * const client = new DeleganceClient({
1529
2445
  * apiKey: 'dlg_xxx_sk_xxx',
1530
- * baseUrl: 'https://app.delegance.ai'
2446
+ * baseUrl: 'https://portal.delegancebrokerage.com'
1531
2447
  * });
1532
2448
  *
1533
2449
  * // Create a company
@@ -1574,6 +2490,22 @@ declare class DeleganceClient {
1574
2490
  readonly knowledge: KnowledgeModule;
1575
2491
  /** Onboarding module for checking developer setup status */
1576
2492
  readonly onboarding: OnboardingModule;
2493
+ /** Appetite module for carrier appetite matching (needs the appetite:read scope) */
2494
+ readonly appetite: AppetiteModule;
2495
+ /** Leads module for sending prospect businesses to Delegance */
2496
+ readonly leads: LeadsModule;
2497
+ /** Instant quotes: questions, carrier premiums, and bind requests */
2498
+ readonly instantQuotes: InstantQuotesModule;
2499
+ /** Premium payment requests and Stripe checkout links */
2500
+ readonly payments: PaymentsModule;
2501
+ /** Surety bond quotes */
2502
+ readonly bonds: BondsModule;
2503
+ /** File and track claims (needs the claims:write scope) */
2504
+ readonly claims: ClaimsModule;
2505
+ /** Report a bug, an idea, or a question to Delegance */
2506
+ readonly feedback: FeedbackModule;
2507
+ /** The calling key: info and refresh */
2508
+ readonly auth: AuthModule;
1577
2509
  /**
1578
2510
  * Create a new Delegance client
1579
2511
  *
@@ -1603,7 +2535,7 @@ declare class DeleganceClient {
1603
2535
  *
1604
2536
  * Reads from:
1605
2537
  * - DELEGANCE_API_KEY - Required API key
1606
- * - DELEGANCE_BASE_URL - Optional base URL (default: https://app.delegance.ai)
2538
+ * - DELEGANCE_BASE_URL - Optional base URL (default: https://portal.delegancebrokerage.com)
1607
2539
  *
1608
2540
  * @example
1609
2541
  * ```typescript
@@ -1612,5 +2544,36 @@ declare class DeleganceClient {
1612
2544
  * ```
1613
2545
  */
1614
2546
  declare function createClientFromEnv(): DeleganceClient;
2547
+ /**
2548
+ * Signup runs before any API key exists, so it lives outside DeleganceClient.
2549
+ *
2550
+ * @example
2551
+ * ```typescript
2552
+ * const signup = createSignup();
2553
+ * const { bootstrapKey } = await signup.createAccount({ ... });
2554
+ * ```
2555
+ */
2556
+ declare function createSignup(config?: {
2557
+ baseUrl?: string;
2558
+ timeout?: number;
2559
+ retries?: number;
2560
+ }): SignupModule;
2561
+ /**
2562
+ * Browser login for an existing customer (`delegance auth login`). No API key
2563
+ * yet: the device secret is the credential.
2564
+ *
2565
+ * ```typescript
2566
+ * const login = createDeviceLogin();
2567
+ * const device = newDeviceSecret();
2568
+ * const start = await login.start({ deviceSecretHash: device.hash, deviceName: 'laptop' });
2569
+ * // show start.userCode and open start.verificationUriComplete
2570
+ * const result = await login.waitForKey(start.loginId, device.secret);
2571
+ * ```
2572
+ */
2573
+ declare function createDeviceLogin(config?: {
2574
+ baseUrl?: string;
2575
+ timeout?: number;
2576
+ retries?: number;
2577
+ }): DeviceLoginModule;
1615
2578
 
1616
- export { type APIKey, type APIResponse, type ApiKey, ApiKeysModule, AuthenticationError, type COI, COIModule, type Carrier, type CertificateHolder, type ChatMessage, ChatModule, type ChatOptions, type ChatResponse, CompaniesModule, type Company, type CompanySize, CompanySizeSchema, type CreateAPIKeyInput, type CreateApiKeyInput, type CreateCompanyInput, CreateCompanySchema, type CreatedAPIKey, type CreatedApiKey, type DailyUsage, type DailyUsageOptions, DeleganceClient, type DeleganceClientConfig, DeleganceError, type Document, type DocumentFacts, type DocumentStatus, DocumentStatusSchema, type DocumentType, DocumentTypeSchema, type DocumentWithExtraction, DocumentsModule, type ExtractedPolicy, type GenerateCOIRequest, type GenerateCOIResponse, type GetPolicyResponse, type GetQuoteResponse, type GetSOVResponse, type IdempotencyOptions, KnowledgeModule, type KnowledgeSearchResult, type ListApiKeysOptions, type ListCOIsResponse, type ListCarriersResponse, type ListCompaniesOptions, type ListDocumentsOptions, type ListNotecardsOptions, type ListPoliciesOptions, type ListPoliciesResponse, type ListQuotesOptions, type ListQuotesResponse, type ListSOVsOptions, type ListSOVsResponse, type MeterUsage, NotFoundError, type Notecard, OnboardingModule, type OnboardingNextStep, type OnboardingStatus, type PaginatedResponse, PoliciesModule, type Policy, type PolicyCoverage, type Quote, type QuoteRequest, QuotesModule, RateLimitError, type RateLimitStatus, type RotateResult, SDK_VERSION, type SOV, type SOVLocation, SOVModule, type SearchInput, type SubmitQuoteResponse, type UploadDocumentInput, type UploadSOVRequest, type UploadSOVResponse, UsageModule, type UsageSummary, ValidationError, type WaitForExtractionOptions, createClientFromEnv };
2579
+ export { type APIKey, type APIResponse, API_KEY_SCOPES, type ApiKey, type ApiKeyInfo, type ApiKeyScope, ApiKeysModule, type AppetiteJobStatus, type AppetiteMatch, type AppetiteMatchInput, type AppetiteMatchResult, type AppetiteMatchStart, AppetiteModule, AuthModule, AuthenticationError, type BindRequestResult, type BindStepUpRequired, type BondToolResult, BondsModule, type BrokerHandoffQuestions, type BrokerHandoffResult, type COI, COIModule, type CancellationReason, type CancellationRequestInput, type CancellationSignInput, type CancellationSignResult, type CancellationStatus, type Carrier, type CarrierAppetiteResult, type CarrierQuote, type CertificateHolder, type ChatMessage, ChatModule, type ChatOptions, type ChatResponse, type ClaimSummary, ClaimsModule, CompaniesModule, type Company, type CompanySize, CompanySizeSchema, type CreateAPIKeyInput, type CreateAccountInput, type CreateAccountResult, type CreateApiKeyInput, type CreateCompanyInput, CreateCompanySchema, type CreateLeadInput, type CreateLeadResult, type CreatedAPIKey, type CreatedApiKey, DEFAULT_BASE_URL, type DailyUsage, type DailyUsageOptions, DeleganceClient, type DeleganceClientConfig, DeleganceError, DeviceLoginModule, type DeviceLoginPoll, type DeviceLoginStart, type Document, type DocumentFacts, type DocumentStatus, DocumentStatusSchema, type DocumentType, DocumentTypeSchema, type DocumentWithExtraction, DocumentsModule, type EnrollResult, type ExchangeResult, type ExtractedPolicy, FEEDBACK_MESSAGE_MAX, type FastBindInput, type FeedbackContext, FeedbackModule, type FeedbackType, type FileClaimInput, type FinancingOffer, ForbiddenError, type GenerateCOIRequest, type GenerateCOIResponse, type GetPolicyResponse, type GetQuoteResponse, type GetSOVResponse, type IdempotencyOptions, type InstantQuestion, type InstantQuestionOption, type InstantQuoteStatus, InstantQuotesModule, type InstantSession, type InstantSubmitResult, KnowledgeModule, type KnowledgeSearchResult, type LeadAddress, LeadsModule, type ListApiKeysOptions, type ListCOIsResponse, type ListCarriersResponse, type ListCompaniesOptions, type ListDocumentsOptions, type ListNotecardsOptions, type ListPoliciesOptions, type ListPoliciesResponse, type ListQuotesOptions, type ListQuotesResponse, type ListSOVsOptions, type ListSOVsResponse, type MeterUsage, NotFoundError, NotImplementedError, type Notecard, OnboardingModule, type OnboardingNextStep, type OnboardingState, type OnboardingStateData, type OnboardingStatus, type PaginatedResponse, type PaymentRequest, PaymentsModule, PoliciesModule, type Policy, type PolicyCoverage, type Quote, type QuoteRequest, QuotesModule, RateLimitError, type RateLimitStatus, type RotateResult, SDK_VERSION, type SOV, type SOVLocation, SOVModule, type SearchInput, SignupModule, type StartBondQuoteInput, type SubmitFeedbackInput, type SubmitQuoteResponse, type UploadDocumentInput, type UploadSOVRequest, type UploadSOVResponse, UsageModule, type UsageSummary, ValidationError, type WaitForExtractionOptions, type WaitForMatchOptions, createClientFromEnv, createDeviceLogin, createSignup, newDeviceSecret };