@gpt-platform/client 0.10.4 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/client/client.gen.d.ts +3 -0
- package/dist/_internal/client/client.gen.d.ts.map +1 -0
- package/dist/_internal/client/index.d.ts +9 -0
- package/dist/_internal/client/index.d.ts.map +1 -0
- package/dist/_internal/client/types.gen.d.ts +118 -0
- package/dist/_internal/client/types.gen.d.ts.map +1 -0
- package/dist/_internal/client/utils.gen.d.ts +34 -0
- package/dist/_internal/client/utils.gen.d.ts.map +1 -0
- package/dist/_internal/client.gen.d.ts +13 -0
- package/dist/_internal/client.gen.d.ts.map +1 -0
- package/dist/_internal/core/auth.gen.d.ts +19 -0
- package/dist/_internal/core/auth.gen.d.ts.map +1 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts +26 -0
- package/dist/_internal/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/params.gen.d.ts +44 -0
- package/dist/_internal/core/params.gen.d.ts.map +1 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts +34 -0
- package/dist/_internal/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/_internal/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/_internal/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/_internal/core/types.gen.d.ts +79 -0
- package/dist/_internal/core/types.gen.d.ts.map +1 -0
- package/dist/_internal/core/utils.gen.d.ts +20 -0
- package/dist/_internal/core/utils.gen.d.ts.map +1 -0
- package/dist/_internal/index.d.ts +3 -0
- package/dist/_internal/index.d.ts.map +1 -0
- package/dist/_internal/sdk.gen.d.ts +7053 -0
- package/dist/_internal/sdk.gen.d.ts.map +1 -0
- package/dist/_internal/types.gen.d.ts +146633 -0
- package/dist/_internal/types.gen.d.ts.map +1 -0
- package/dist/base-client.d.ts +199 -0
- package/dist/base-client.d.ts.map +1 -0
- package/dist/errors/index.d.ts +128 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/events.d.ts +69 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/execution-events.d.ts +95 -0
- package/dist/execution-events.d.ts.map +1 -0
- package/dist/gpt-client.d.ts +2175 -0
- package/dist/gpt-client.d.ts.map +1 -0
- package/dist/index.d.ts +51 -30308
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +775 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +775 -14
- package/dist/index.mjs.map +1 -1
- package/dist/json-api.d.ts +26 -0
- package/dist/json-api.d.ts.map +1 -0
- package/dist/logging.d.ts +22 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/namespace-types.d.ts +79 -0
- package/dist/namespace-types.d.ts.map +1 -0
- package/dist/namespaces/access-grants.d.ts +71 -0
- package/dist/namespaces/access-grants.d.ts.map +1 -0
- package/dist/namespaces/agents.d.ts +1406 -0
- package/dist/namespaces/agents.d.ts.map +1 -0
- package/dist/namespaces/ai.d.ts +407 -0
- package/dist/namespaces/ai.d.ts.map +1 -0
- package/dist/namespaces/audit.d.ts +83 -0
- package/dist/namespaces/audit.d.ts.map +1 -0
- package/dist/namespaces/billing.d.ts +854 -0
- package/dist/namespaces/billing.d.ts.map +1 -0
- package/dist/namespaces/campaigns.d.ts +973 -0
- package/dist/namespaces/campaigns.d.ts.map +1 -0
- package/dist/namespaces/catalog.d.ts +964 -0
- package/dist/namespaces/catalog.d.ts.map +1 -0
- package/dist/namespaces/channels.d.ts +162 -0
- package/dist/namespaces/channels.d.ts.map +1 -0
- package/dist/namespaces/clinical.d.ts +2443 -0
- package/dist/namespaces/clinical.d.ts.map +1 -0
- package/dist/namespaces/communication.d.ts +439 -0
- package/dist/namespaces/communication.d.ts.map +1 -0
- package/dist/namespaces/compliance.d.ts +2310 -0
- package/dist/namespaces/compliance.d.ts.map +1 -0
- package/dist/namespaces/connectors.d.ts +1368 -0
- package/dist/namespaces/connectors.d.ts.map +1 -0
- package/dist/namespaces/content.d.ts +188 -0
- package/dist/namespaces/content.d.ts.map +1 -0
- package/dist/namespaces/crawler.d.ts +408 -0
- package/dist/namespaces/crawler.d.ts.map +1 -0
- package/dist/namespaces/crm-clusters.d.ts +31 -0
- package/dist/namespaces/crm-clusters.d.ts.map +1 -0
- package/dist/namespaces/crm.d.ts +1539 -0
- package/dist/namespaces/crm.d.ts.map +1 -0
- package/dist/namespaces/documents.d.ts +136 -0
- package/dist/namespaces/documents.d.ts.map +1 -0
- package/dist/namespaces/email.d.ts +550 -0
- package/dist/namespaces/email.d.ts.map +1 -0
- package/dist/namespaces/extraction.d.ts +1249 -0
- package/dist/namespaces/extraction.d.ts.map +1 -0
- package/dist/namespaces/identity.d.ts +411 -0
- package/dist/namespaces/identity.d.ts.map +1 -0
- package/dist/namespaces/imports.d.ts +177 -0
- package/dist/namespaces/imports.d.ts.map +1 -0
- package/dist/namespaces/index.d.ts +119 -0
- package/dist/namespaces/index.d.ts.map +1 -0
- package/dist/namespaces/memory.d.ts +105 -0
- package/dist/namespaces/memory.d.ts.map +1 -0
- package/dist/namespaces/models.d.ts +75 -0
- package/dist/namespaces/models.d.ts.map +1 -0
- package/dist/namespaces/permissions.d.ts +75 -0
- package/dist/namespaces/permissions.d.ts.map +1 -0
- package/dist/namespaces/pipeline-executions.d.ts +130 -0
- package/dist/namespaces/pipeline-executions.d.ts.map +1 -0
- package/dist/namespaces/pipelines.d.ts +120 -0
- package/dist/namespaces/pipelines.d.ts.map +1 -0
- package/dist/namespaces/platform.d.ts +1430 -0
- package/dist/namespaces/platform.d.ts.map +1 -0
- package/dist/namespaces/portal.d.ts +198 -0
- package/dist/namespaces/portal.d.ts.map +1 -0
- package/dist/namespaces/projects.d.ts +553 -0
- package/dist/namespaces/projects.d.ts.map +1 -0
- package/dist/namespaces/roles.d.ts +65 -0
- package/dist/namespaces/roles.d.ts.map +1 -0
- package/dist/namespaces/scheduling.d.ts +944 -0
- package/dist/namespaces/scheduling.d.ts.map +1 -0
- package/dist/namespaces/search.d.ts +224 -0
- package/dist/namespaces/search.d.ts.map +1 -0
- package/dist/namespaces/session-notes.d.ts +67 -0
- package/dist/namespaces/session-notes.d.ts.map +1 -0
- package/dist/namespaces/social.d.ts +330 -0
- package/dist/namespaces/social.d.ts.map +1 -0
- package/dist/namespaces/storage.d.ts +378 -0
- package/dist/namespaces/storage.d.ts.map +1 -0
- package/dist/namespaces/support.d.ts +427 -0
- package/dist/namespaces/support.d.ts.map +1 -0
- package/dist/namespaces/threads.d.ts +596 -0
- package/dist/namespaces/threads.d.ts.map +1 -0
- package/dist/namespaces/training.d.ts +358 -0
- package/dist/namespaces/training.d.ts.map +1 -0
- package/dist/namespaces/voice.d.ts +752 -0
- package/dist/namespaces/voice.d.ts.map +1 -0
- package/dist/namespaces/watcher.d.ts +425 -0
- package/dist/namespaces/watcher.d.ts.map +1 -0
- package/dist/namespaces/webhooks-ns.d.ts +3 -0
- package/dist/namespaces/webhooks-ns.d.ts.map +1 -0
- package/dist/pagination.d.ts +57 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/request-builder.d.ts +95 -0
- package/dist/request-builder.d.ts.map +1 -0
- package/dist/security.d.ts +32 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/streaming.d.ts +135 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/utils/retry.d.ts +63 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/webhook-signature.d.ts +109 -0
- package/dist/webhook-signature.d.ts.map +1 -0
- package/llms.txt +40 -1
- package/package.json +286 -36
- package/dist/index.d.mts +0 -30308
|
@@ -0,0 +1,1539 @@
|
|
|
1
|
+
import type { CrmContact, CrmCompany, CrmDeal, CrmActivity, CrmPipeline, CrmPipelineStage, CrmRelationship, CrmRelationshipType, CrmCustomEntity } from "../_internal/types.gen";
|
|
2
|
+
/** Attributes accepted when creating a CRM contact. */
|
|
3
|
+
export type CreateCrmContactAttributes = {
|
|
4
|
+
workspace_id: string;
|
|
5
|
+
first_name?: string;
|
|
6
|
+
last_name?: string;
|
|
7
|
+
email?: string;
|
|
8
|
+
phone?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
date_of_birth?: string;
|
|
11
|
+
sex?: "male" | "female" | "other";
|
|
12
|
+
lifecycle_stage?: string;
|
|
13
|
+
source?: string;
|
|
14
|
+
owner_id?: string;
|
|
15
|
+
avatar_url?: string;
|
|
16
|
+
properties?: Record<string, unknown>;
|
|
17
|
+
tags?: string[];
|
|
18
|
+
portal_user_id?: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
/** Attributes accepted when updating a CRM contact (PATCH semantics). */
|
|
22
|
+
export type UpdateCrmContactAttributes = {
|
|
23
|
+
first_name?: string;
|
|
24
|
+
last_name?: string;
|
|
25
|
+
email?: string;
|
|
26
|
+
phone?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
date_of_birth?: string;
|
|
29
|
+
sex?: "male" | "female" | "other";
|
|
30
|
+
lifecycle_stage?: string;
|
|
31
|
+
owner_id?: string;
|
|
32
|
+
avatar_url?: string;
|
|
33
|
+
properties?: Record<string, unknown>;
|
|
34
|
+
tags?: string[];
|
|
35
|
+
portal_user_id?: string;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
/** Attributes accepted when creating a CRM company. */
|
|
39
|
+
export type CreateCrmCompanyAttributes = {
|
|
40
|
+
workspace_id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
domain?: string;
|
|
43
|
+
industry?: string;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
};
|
|
46
|
+
/** Attributes accepted when updating a CRM company (PATCH semantics). */
|
|
47
|
+
export type UpdateCrmCompanyAttributes = {
|
|
48
|
+
name?: string;
|
|
49
|
+
domain?: string;
|
|
50
|
+
industry?: string;
|
|
51
|
+
employee_count?: number;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
};
|
|
54
|
+
/** Attributes accepted when creating a CRM deal. */
|
|
55
|
+
export type CreateCrmDealAttributes = {
|
|
56
|
+
workspace_id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
value_cents?: number;
|
|
59
|
+
pipeline_id?: string;
|
|
60
|
+
stage_id?: string;
|
|
61
|
+
close_date?: string;
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
};
|
|
64
|
+
/** Attributes accepted when updating a CRM deal (PATCH semantics). */
|
|
65
|
+
export type UpdateCrmDealAttributes = {
|
|
66
|
+
name?: string;
|
|
67
|
+
value_cents?: number;
|
|
68
|
+
stage_id?: string;
|
|
69
|
+
closed_at?: string;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
};
|
|
72
|
+
/** Attributes accepted when creating a CRM activity. */
|
|
73
|
+
export type CreateCrmActivityAttributes = {
|
|
74
|
+
activity_type: string;
|
|
75
|
+
contact_id?: string;
|
|
76
|
+
deal_id?: string;
|
|
77
|
+
note?: string;
|
|
78
|
+
occurred_at?: string;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
};
|
|
81
|
+
/** Attributes accepted when creating a CRM pipeline. */
|
|
82
|
+
export type CreateCrmPipelineAttributes = {
|
|
83
|
+
workspace_id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
};
|
|
87
|
+
/** Attributes accepted when updating a CRM pipeline (PATCH semantics). */
|
|
88
|
+
export type UpdateCrmPipelineAttributes = {
|
|
89
|
+
name?: string;
|
|
90
|
+
[key: string]: unknown;
|
|
91
|
+
};
|
|
92
|
+
/** Attributes accepted when creating a pipeline stage. */
|
|
93
|
+
export type CreateCrmPipelineStageAttributes = {
|
|
94
|
+
pipeline_id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
order?: number;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
};
|
|
99
|
+
/** Attributes accepted when updating a pipeline stage (PATCH semantics). */
|
|
100
|
+
export type UpdateCrmPipelineStageAttributes = {
|
|
101
|
+
name?: string;
|
|
102
|
+
order?: number;
|
|
103
|
+
[key: string]: unknown;
|
|
104
|
+
};
|
|
105
|
+
/** Attributes accepted when creating a relationship type. */
|
|
106
|
+
export type CreateCrmRelationshipTypeAttributes = {
|
|
107
|
+
label: string;
|
|
108
|
+
inverse_label?: string;
|
|
109
|
+
from_entity_type: string;
|
|
110
|
+
to_entity_type: string;
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
};
|
|
113
|
+
/** Attributes accepted when updating a relationship type (PATCH semantics). */
|
|
114
|
+
export type UpdateCrmRelationshipTypeAttributes = {
|
|
115
|
+
label?: string;
|
|
116
|
+
inverse_label?: string;
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
};
|
|
119
|
+
/** Attributes accepted when creating a relationship. */
|
|
120
|
+
export type CreateCrmRelationshipAttributes = {
|
|
121
|
+
relationship_type_id: string;
|
|
122
|
+
from_entity_type: string;
|
|
123
|
+
from_entity_id: string;
|
|
124
|
+
to_entity_type: string;
|
|
125
|
+
to_entity_id: string;
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
};
|
|
128
|
+
/** Attributes accepted when creating a custom entity. */
|
|
129
|
+
export type CreateCrmCustomEntityAttributes = {
|
|
130
|
+
workspace_id: string;
|
|
131
|
+
entity_type: string;
|
|
132
|
+
properties?: Record<string, unknown>;
|
|
133
|
+
[key: string]: unknown;
|
|
134
|
+
};
|
|
135
|
+
/** Attributes accepted when updating a custom entity (PATCH semantics). */
|
|
136
|
+
export type UpdateCrmCustomEntityAttributes = {
|
|
137
|
+
properties?: Record<string, unknown>;
|
|
138
|
+
[key: string]: unknown;
|
|
139
|
+
};
|
|
140
|
+
export type CrmEntityType = "contact" | "custom_entity" | "activity";
|
|
141
|
+
export type CrmExportFormat = "json" | "csv";
|
|
142
|
+
export type CrmExportStatus = "pending" | "processing" | "complete" | "failed";
|
|
143
|
+
export interface CrmDataExportJob {
|
|
144
|
+
id: string;
|
|
145
|
+
workspace_id: string;
|
|
146
|
+
entity_type: CrmEntityType;
|
|
147
|
+
entity_subtype?: string;
|
|
148
|
+
format: CrmExportFormat;
|
|
149
|
+
include: string[];
|
|
150
|
+
status: CrmExportStatus;
|
|
151
|
+
file_url?: string;
|
|
152
|
+
url_expires_at?: string;
|
|
153
|
+
row_count?: number;
|
|
154
|
+
error?: string;
|
|
155
|
+
inserted_at: string;
|
|
156
|
+
updated_at: string;
|
|
157
|
+
}
|
|
158
|
+
export interface CrmExportCreateParams {
|
|
159
|
+
entityType: CrmEntityType;
|
|
160
|
+
entitySubtype?: string;
|
|
161
|
+
format: CrmExportFormat;
|
|
162
|
+
/**
|
|
163
|
+
* Relationship types to embed in contact exports. Valid include keys are
|
|
164
|
+
* determined by your application's CustomEntityType records (via `include_alias`)
|
|
165
|
+
* and AiConfig `export_activity_includes` mapping.
|
|
166
|
+
*
|
|
167
|
+
* Example: if you have a CustomEntityType with `include_alias: "goals"` and
|
|
168
|
+
* AiConfig with `export_activity_includes: {"health_metric": "metrics"}`,
|
|
169
|
+
* then `include: ["goals", "metrics"]` embeds both.
|
|
170
|
+
*
|
|
171
|
+
* Only supported when `entityType` is `"contact"`.
|
|
172
|
+
*/
|
|
173
|
+
include?: string[];
|
|
174
|
+
filters?: AttributeFilter[];
|
|
175
|
+
}
|
|
176
|
+
export type FilterOperator = "eq" | "not_eq" | "contains" | "in" | "lt" | "gt" | "not_null";
|
|
177
|
+
export interface AttributeFilter {
|
|
178
|
+
field: string;
|
|
179
|
+
op: FilterOperator;
|
|
180
|
+
value?: unknown;
|
|
181
|
+
}
|
|
182
|
+
export interface AggregateMetric {
|
|
183
|
+
fn: "count";
|
|
184
|
+
}
|
|
185
|
+
export interface AggregateFieldMetric {
|
|
186
|
+
fn: "avg" | "sum";
|
|
187
|
+
field: string;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* A version snapshot of a CrmCustomEntity.
|
|
191
|
+
* Field names match the CustomEntityVersion Ash resource attributes exactly.
|
|
192
|
+
*/
|
|
193
|
+
export interface CrmCustomEntityVersion {
|
|
194
|
+
id: string;
|
|
195
|
+
version_number: number;
|
|
196
|
+
/** Snapshot of the entity's properties field at the time of the update. */
|
|
197
|
+
attributes: Record<string, unknown>;
|
|
198
|
+
updated_by_user_id?: string;
|
|
199
|
+
/** ISO 8601 timestamp — the resource uses inserted_at (no updated_at). */
|
|
200
|
+
inserted_at: string;
|
|
201
|
+
custom_entity_id: string;
|
|
202
|
+
workspace_id: string;
|
|
203
|
+
}
|
|
204
|
+
import type { RequestOptions } from "../base-client";
|
|
205
|
+
import { RequestBuilder } from "../request-builder";
|
|
206
|
+
/**
|
|
207
|
+
* CRM namespace for contacts, companies, deals, activities, and pipelines.
|
|
208
|
+
*
|
|
209
|
+
* Provides sub-namespaces covering the full CRM entity graph: contacts
|
|
210
|
+
* (people / leads), companies (organisations), deals (opportunities tracked
|
|
211
|
+
* through pipeline stages), activities (interactions and notes), pipelines
|
|
212
|
+
* (workflow definitions), pipeline stages, relationship types, relationships
|
|
213
|
+
* (edges between any two CRM entities), custom entities (ISV-defined entity
|
|
214
|
+
* types), and async data exports.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
219
|
+
*
|
|
220
|
+
* // Create a contact and immediately associate them with a company
|
|
221
|
+
* const contact = await client.crm.contacts.create({
|
|
222
|
+
* workspace_id: 'ws_abc123',
|
|
223
|
+
* first_name: 'Jane',
|
|
224
|
+
* last_name: 'Smith',
|
|
225
|
+
* email: 'jane@example.com',
|
|
226
|
+
* });
|
|
227
|
+
*
|
|
228
|
+
* const company = await client.crm.companies.get('co_xyz');
|
|
229
|
+
*
|
|
230
|
+
* await client.crm.relationships.create({
|
|
231
|
+
* workspace_id: 'ws_abc123',
|
|
232
|
+
* from_entity_type: 'contact',
|
|
233
|
+
* from_entity_id: contact.id,
|
|
234
|
+
* to_entity_type: 'company',
|
|
235
|
+
* to_entity_id: company.id,
|
|
236
|
+
* relationship_type_id: 'reltype_employee',
|
|
237
|
+
* });
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
export declare function createCrmNamespace(rb: RequestBuilder): {
|
|
241
|
+
/**
|
|
242
|
+
* Contacts — people and leads in the CRM.
|
|
243
|
+
*
|
|
244
|
+
* Contacts represent individual people tracked through your sales or
|
|
245
|
+
* marketing funnel. They progress through lifecycle statuses from `lead`
|
|
246
|
+
* through to `customer` or `churned`. Contacts support soft-delete
|
|
247
|
+
* semantics via `archive` / `unarchive` in addition to permanent `delete`.
|
|
248
|
+
*/
|
|
249
|
+
contacts: {
|
|
250
|
+
/**
|
|
251
|
+
* Fetch a single contact by their unique ID.
|
|
252
|
+
*
|
|
253
|
+
* @param id - The unique identifier of the contact to retrieve.
|
|
254
|
+
* @param options - Optional request-level overrides.
|
|
255
|
+
* @returns A promise that resolves to the matching {@link CrmContact}.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
260
|
+
*
|
|
261
|
+
* const contact = await client.crm.contacts.get('con_abc123');
|
|
262
|
+
* console.log(contact.attributes.email);
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
get: (id: string, options?: RequestOptions) => Promise<CrmContact>;
|
|
266
|
+
/**
|
|
267
|
+
* Create a new contact in the CRM.
|
|
268
|
+
*
|
|
269
|
+
* @param attributes - Key/value map of contact attributes. Must include
|
|
270
|
+
* `workspace_id`. Common fields include `first_name`, `last_name`,
|
|
271
|
+
* `email`, `phone`, and `status`.
|
|
272
|
+
* @param options - Optional request-level overrides.
|
|
273
|
+
* @returns A promise that resolves to the newly created {@link CrmContact}.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
278
|
+
*
|
|
279
|
+
* const contact = await client.crm.contacts.create({
|
|
280
|
+
* workspace_id: 'ws_abc123',
|
|
281
|
+
* first_name: 'Jane',
|
|
282
|
+
* last_name: 'Smith',
|
|
283
|
+
* email: 'jane@example.com',
|
|
284
|
+
* status: 'lead',
|
|
285
|
+
* });
|
|
286
|
+
* console.log(contact.id); // 'con_...'
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
create: (attributes: CreateCrmContactAttributes, options?: RequestOptions) => Promise<CrmContact>;
|
|
290
|
+
/**
|
|
291
|
+
* Update an existing contact's attributes.
|
|
292
|
+
*
|
|
293
|
+
* Only the fields present in `attributes` are changed (PATCH semantics).
|
|
294
|
+
*
|
|
295
|
+
* @param id - The unique identifier of the contact to update.
|
|
296
|
+
* @param attributes - Key/value map of attributes to change.
|
|
297
|
+
* @param options - Optional request-level overrides.
|
|
298
|
+
* @returns A promise that resolves to the updated {@link CrmContact}.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
303
|
+
*
|
|
304
|
+
* const contact = await client.crm.contacts.update('con_abc123', {
|
|
305
|
+
* status: 'customer',
|
|
306
|
+
* tags: ['vip', 'enterprise'],
|
|
307
|
+
* });
|
|
308
|
+
* console.log(contact.attributes.status); // 'customer'
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
update: (id: string, attributes: UpdateCrmContactAttributes, options?: RequestOptions) => Promise<CrmContact>;
|
|
312
|
+
/**
|
|
313
|
+
* Permanently delete a contact.
|
|
314
|
+
*
|
|
315
|
+
* This is an irreversible hard delete. For recoverable removal, prefer
|
|
316
|
+
* {@link archive} instead.
|
|
317
|
+
*
|
|
318
|
+
* @param id - The unique identifier of the contact to delete.
|
|
319
|
+
* @param options - Optional request-level overrides.
|
|
320
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
325
|
+
*
|
|
326
|
+
* await client.crm.contacts.delete('con_abc123');
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
330
|
+
/**
|
|
331
|
+
* List active (non-archived) contacts in a workspace.
|
|
332
|
+
*
|
|
333
|
+
* Supports filtering by lifecycle `status`, arbitrary attribute filters
|
|
334
|
+
* using {@link AttributeFilter} predicates, and tag-based filtering.
|
|
335
|
+
* Paginate large result sets with `page` and `pageSize`.
|
|
336
|
+
*
|
|
337
|
+
* @param workspaceId - The ID of the workspace to list contacts from.
|
|
338
|
+
* @param options - Optional filters and pagination:
|
|
339
|
+
* - `status` — restrict to a specific lifecycle stage.
|
|
340
|
+
* - `filters` — array of {@link AttributeFilter} predicates applied
|
|
341
|
+
* server-side to the contact's attribute map.
|
|
342
|
+
* - `tags` — return contacts that have ANY of the given tags (overlap match).
|
|
343
|
+
* - `page` / `pageSize` — pagination controls.
|
|
344
|
+
* @returns A promise that resolves to an array of {@link CrmContact} records.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```typescript
|
|
348
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
349
|
+
*
|
|
350
|
+
* // All qualified leads tagged as 'enterprise'
|
|
351
|
+
* const leads = await client.crm.contacts.listByWorkspace('ws_abc123', {
|
|
352
|
+
* status: 'sales_qualified',
|
|
353
|
+
* tags: ['enterprise'],
|
|
354
|
+
* pageSize: 50,
|
|
355
|
+
* });
|
|
356
|
+
*
|
|
357
|
+
* // Contacts with a deal value over $10,000
|
|
358
|
+
* const highValue = await client.crm.contacts.listByWorkspace('ws_abc123', {
|
|
359
|
+
* filters: [{ field: 'deal_value', op: 'gt', value: 10000 }],
|
|
360
|
+
* });
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
listByWorkspace: (workspaceId: string, options?: {
|
|
364
|
+
name?: string;
|
|
365
|
+
status?: "lead" | "marketing_qualified" | "sales_qualified" | "opportunity" | "customer" | "evangelist" | "churned";
|
|
366
|
+
filters?: AttributeFilter[];
|
|
367
|
+
tags?: string[];
|
|
368
|
+
page?: number;
|
|
369
|
+
pageSize?: number;
|
|
370
|
+
} & RequestOptions) => Promise<CrmContact[]>;
|
|
371
|
+
/**
|
|
372
|
+
* Archive a contact (soft-delete with restore semantics).
|
|
373
|
+
*
|
|
374
|
+
* Archived contacts are hidden from normal list results but are not
|
|
375
|
+
* permanently deleted. They can be recovered at any time with
|
|
376
|
+
* {@link unarchive}. Use this in preference to {@link delete} when you
|
|
377
|
+
* may need to restore the contact later.
|
|
378
|
+
*
|
|
379
|
+
* @param id - The unique identifier of the contact to archive.
|
|
380
|
+
* @param options - Optional request-level overrides.
|
|
381
|
+
* @returns A promise that resolves to the updated {@link CrmContact} with
|
|
382
|
+
* its archived status reflected.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```typescript
|
|
386
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
387
|
+
*
|
|
388
|
+
* const contact = await client.crm.contacts.archive('con_abc123');
|
|
389
|
+
* console.log(contact.attributes.archived); // true
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
archive: (id: string, options?: RequestOptions) => Promise<CrmContact>;
|
|
393
|
+
/**
|
|
394
|
+
* Restore a previously archived contact.
|
|
395
|
+
*
|
|
396
|
+
* Makes the contact visible in normal list results again and clears the
|
|
397
|
+
* archived flag.
|
|
398
|
+
*
|
|
399
|
+
* @param id - The unique identifier of the archived contact to restore.
|
|
400
|
+
* @param workspaceId - The workspace that owns the contact. Required to scope the restore
|
|
401
|
+
* to the correct workspace and prevent cross-workspace data access.
|
|
402
|
+
* @param options - Optional request-level overrides.
|
|
403
|
+
* @returns A promise that resolves to the restored {@link CrmContact}.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```typescript
|
|
407
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
408
|
+
*
|
|
409
|
+
* const contact = await client.crm.contacts.unarchive('con_abc123', 'ws_xyz789');
|
|
410
|
+
* console.log(contact.attributes.archived); // false
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
unarchive: (id: string, workspaceId: string, options?: RequestOptions) => Promise<CrmContact>;
|
|
414
|
+
/**
|
|
415
|
+
* List archived (soft-deleted) contacts for a workspace.
|
|
416
|
+
*
|
|
417
|
+
* Returns only contacts that have been archived via {@link archive}.
|
|
418
|
+
* Permanently deleted contacts are not included.
|
|
419
|
+
*
|
|
420
|
+
* @param workspaceId - The ID of the workspace to query.
|
|
421
|
+
* @param options - Optional pagination controls and request-level overrides.
|
|
422
|
+
* @returns A promise that resolves to an array of archived {@link CrmContact} records.
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```typescript
|
|
426
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
427
|
+
*
|
|
428
|
+
* const archived = await client.crm.contacts.listArchived('ws_abc123', {
|
|
429
|
+
* page: 1,
|
|
430
|
+
* pageSize: 25,
|
|
431
|
+
* });
|
|
432
|
+
* console.log(`${archived.length} archived contacts`);
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
listArchived: (workspaceId: string, options?: {
|
|
436
|
+
page?: number;
|
|
437
|
+
pageSize?: number;
|
|
438
|
+
} & RequestOptions) => Promise<CrmContact[]>;
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* Companies — organisations in the CRM.
|
|
442
|
+
*
|
|
443
|
+
* Companies represent the organisations your contacts belong to. They can
|
|
444
|
+
* be linked to contacts via the {@link relationships} namespace and
|
|
445
|
+
* associated with deals through pipeline stages.
|
|
446
|
+
*/
|
|
447
|
+
companies: {
|
|
448
|
+
/**
|
|
449
|
+
* Fetch a single company by its unique ID.
|
|
450
|
+
*
|
|
451
|
+
* @param id - The unique identifier of the company to retrieve.
|
|
452
|
+
* @param options - Optional request-level overrides.
|
|
453
|
+
* @returns A promise that resolves to the matching {@link CrmCompany}.
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```typescript
|
|
457
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
458
|
+
*
|
|
459
|
+
* const company = await client.crm.companies.get('co_abc123');
|
|
460
|
+
* console.log(company.attributes.name);
|
|
461
|
+
* ```
|
|
462
|
+
*/
|
|
463
|
+
get: (id: string, options?: RequestOptions) => Promise<CrmCompany>;
|
|
464
|
+
/**
|
|
465
|
+
* Create a new company in the CRM.
|
|
466
|
+
*
|
|
467
|
+
* @param attributes - Key/value map of company attributes. Must include
|
|
468
|
+
* `workspace_id`. Common fields include `name`, `domain`, `industry`,
|
|
469
|
+
* and `employee_count`.
|
|
470
|
+
* @param options - Optional request-level overrides.
|
|
471
|
+
* @returns A promise that resolves to the newly created {@link CrmCompany}.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```typescript
|
|
475
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
476
|
+
*
|
|
477
|
+
* const company = await client.crm.companies.create({
|
|
478
|
+
* workspace_id: 'ws_abc123',
|
|
479
|
+
* name: 'Acme Corp',
|
|
480
|
+
* domain: 'acme.com',
|
|
481
|
+
* industry: 'Technology',
|
|
482
|
+
* });
|
|
483
|
+
* console.log(company.id); // 'co_...'
|
|
484
|
+
* ```
|
|
485
|
+
*/
|
|
486
|
+
create: (attributes: CreateCrmCompanyAttributes, options?: RequestOptions) => Promise<CrmCompany>;
|
|
487
|
+
/**
|
|
488
|
+
* Update an existing company's attributes.
|
|
489
|
+
*
|
|
490
|
+
* Only the fields present in `attributes` are changed (PATCH semantics).
|
|
491
|
+
*
|
|
492
|
+
* @param id - The unique identifier of the company to update.
|
|
493
|
+
* @param attributes - Key/value map of attributes to change.
|
|
494
|
+
* @param options - Optional request-level overrides.
|
|
495
|
+
* @returns A promise that resolves to the updated {@link CrmCompany}.
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* ```typescript
|
|
499
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
500
|
+
*
|
|
501
|
+
* const company = await client.crm.companies.update('co_abc123', {
|
|
502
|
+
* employee_count: 500,
|
|
503
|
+
* plan: 'enterprise',
|
|
504
|
+
* });
|
|
505
|
+
* ```
|
|
506
|
+
*/
|
|
507
|
+
update: (id: string, attributes: UpdateCrmCompanyAttributes, options?: RequestOptions) => Promise<CrmCompany>;
|
|
508
|
+
/**
|
|
509
|
+
* Permanently delete a company.
|
|
510
|
+
*
|
|
511
|
+
* @param id - The unique identifier of the company to delete.
|
|
512
|
+
* @param options - Optional request-level overrides.
|
|
513
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* ```typescript
|
|
517
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
518
|
+
*
|
|
519
|
+
* await client.crm.companies.delete('co_abc123');
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
522
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
523
|
+
/**
|
|
524
|
+
* List companies in a workspace with optional pagination.
|
|
525
|
+
*
|
|
526
|
+
* @param workspaceId - The ID of the workspace to list companies from.
|
|
527
|
+
* @param options - Optional pagination controls (`page`, `pageSize`) and
|
|
528
|
+
* request-level overrides.
|
|
529
|
+
* @returns A promise that resolves to an array of {@link CrmCompany} records.
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* ```typescript
|
|
533
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
534
|
+
*
|
|
535
|
+
* const companies = await client.crm.companies.listByWorkspace('ws_abc123', {
|
|
536
|
+
* pageSize: 100,
|
|
537
|
+
* });
|
|
538
|
+
* console.log(companies.map((c) => c.attributes.name));
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
listByWorkspace: (workspaceId: string, options?: {
|
|
542
|
+
page?: number;
|
|
543
|
+
pageSize?: number;
|
|
544
|
+
} & RequestOptions) => Promise<CrmCompany[]>;
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* Deals — sales opportunities tracked through pipeline stages.
|
|
548
|
+
*
|
|
549
|
+
* A deal represents a potential revenue opportunity associated with one or
|
|
550
|
+
* more contacts or companies. Deals move through the stages of a
|
|
551
|
+
* {@link pipelines pipeline} (e.g. Prospecting → Proposal → Closed Won).
|
|
552
|
+
*/
|
|
553
|
+
deals: {
|
|
554
|
+
/**
|
|
555
|
+
* Fetch a single deal by its unique ID.
|
|
556
|
+
*
|
|
557
|
+
* @param id - The unique identifier of the deal to retrieve.
|
|
558
|
+
* @param options - Optional request-level overrides.
|
|
559
|
+
* @returns A promise that resolves to the matching {@link CrmDeal}.
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* ```typescript
|
|
563
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
564
|
+
*
|
|
565
|
+
* const deal = await client.crm.deals.get('deal_abc123');
|
|
566
|
+
* console.log(deal.attributes.value_cents, deal.attributes.stage_id);
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
get: (id: string, options?: RequestOptions) => Promise<CrmDeal>;
|
|
570
|
+
/**
|
|
571
|
+
* Create a new deal.
|
|
572
|
+
*
|
|
573
|
+
* @param attributes - Key/value map of deal attributes. Must include
|
|
574
|
+
* `workspace_id`. Common fields include `name`, `value_cents`,
|
|
575
|
+
* `pipeline_id`, `stage_id`, and `close_date`.
|
|
576
|
+
* @param options - Optional request-level overrides.
|
|
577
|
+
* @returns A promise that resolves to the newly created {@link CrmDeal}.
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* ```typescript
|
|
581
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
582
|
+
*
|
|
583
|
+
* const deal = await client.crm.deals.create({
|
|
584
|
+
* workspace_id: 'ws_abc123',
|
|
585
|
+
* name: 'Enterprise License — Acme Corp',
|
|
586
|
+
* value_cents: 1200000,
|
|
587
|
+
* pipeline_id: 'pipe_sales',
|
|
588
|
+
* stage_id: 'stage_proposal',
|
|
589
|
+
* close_date: '2026-06-30',
|
|
590
|
+
* });
|
|
591
|
+
* console.log(deal.id); // 'deal_...'
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
create: (attributes: CreateCrmDealAttributes, options?: RequestOptions) => Promise<CrmDeal>;
|
|
595
|
+
/**
|
|
596
|
+
* Update an existing deal's attributes.
|
|
597
|
+
*
|
|
598
|
+
* Commonly used to advance a deal through pipeline stages by updating
|
|
599
|
+
* `stage_id`, or to record the final outcome via a `status` field.
|
|
600
|
+
*
|
|
601
|
+
* @param id - The unique identifier of the deal to update.
|
|
602
|
+
* @param attributes - Key/value map of attributes to change.
|
|
603
|
+
* @param options - Optional request-level overrides.
|
|
604
|
+
* @returns A promise that resolves to the updated {@link CrmDeal}.
|
|
605
|
+
*
|
|
606
|
+
* @example
|
|
607
|
+
* ```typescript
|
|
608
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
609
|
+
*
|
|
610
|
+
* // Advance to next stage
|
|
611
|
+
* const deal = await client.crm.deals.update('deal_abc123', {
|
|
612
|
+
* stage_id: 'stage_closed_won',
|
|
613
|
+
* closed_at: new Date().toISOString(),
|
|
614
|
+
* });
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
617
|
+
update: (id: string, attributes: UpdateCrmDealAttributes, options?: RequestOptions) => Promise<CrmDeal>;
|
|
618
|
+
/**
|
|
619
|
+
* Move a deal to a different pipeline stage.
|
|
620
|
+
*
|
|
621
|
+
* @param id - The unique identifier of the deal to move.
|
|
622
|
+
* @param attributes - Must include `stage_id` (the target stage).
|
|
623
|
+
* @param options - Optional request-level overrides.
|
|
624
|
+
* @returns A promise that resolves to the updated {@link CrmDeal}.
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```typescript
|
|
628
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
629
|
+
*
|
|
630
|
+
* const deal = await client.crm.deals.moveStage('deal_abc123', {
|
|
631
|
+
* stage_id: 'stage_closed_won',
|
|
632
|
+
* });
|
|
633
|
+
* ```
|
|
634
|
+
*/
|
|
635
|
+
moveStage: (id: string, attributes: Record<string, unknown>, options?: RequestOptions) => Promise<CrmDeal>;
|
|
636
|
+
/**
|
|
637
|
+
* Permanently delete a deal.
|
|
638
|
+
*
|
|
639
|
+
* @param id - The unique identifier of the deal to delete.
|
|
640
|
+
* @param options - Optional request-level overrides.
|
|
641
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* ```typescript
|
|
645
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
646
|
+
*
|
|
647
|
+
* await client.crm.deals.delete('deal_abc123');
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
651
|
+
/**
|
|
652
|
+
* List deals in a workspace with optional pagination.
|
|
653
|
+
*
|
|
654
|
+
* @param workspaceId - The ID of the workspace to list deals from.
|
|
655
|
+
* @param options - Optional pagination controls and request-level overrides.
|
|
656
|
+
* @returns A promise that resolves to an array of {@link CrmDeal} records.
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* ```typescript
|
|
660
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
661
|
+
*
|
|
662
|
+
* const deals = await client.crm.deals.listByWorkspace('ws_abc123', {
|
|
663
|
+
* page: 1,
|
|
664
|
+
* pageSize: 50,
|
|
665
|
+
* });
|
|
666
|
+
* const total = deals.reduce((sum, d) => sum + (d.attributes.value_cents ?? 0), 0);
|
|
667
|
+
* console.log(`Pipeline value: $${total / 100}`);
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
670
|
+
listByWorkspace: (workspaceId: string, options?: {
|
|
671
|
+
page?: number;
|
|
672
|
+
pageSize?: number;
|
|
673
|
+
} & RequestOptions) => Promise<CrmDeal[]>;
|
|
674
|
+
};
|
|
675
|
+
/**
|
|
676
|
+
* Activities — interactions and notes logged against CRM entities.
|
|
677
|
+
*
|
|
678
|
+
* Activities capture touchpoints such as calls, emails, meetings, and
|
|
679
|
+
* notes. They can be linked to contacts, companies, or deals to build a
|
|
680
|
+
* chronological engagement timeline.
|
|
681
|
+
*/
|
|
682
|
+
activities: {
|
|
683
|
+
/**
|
|
684
|
+
* Fetch a single activity by its unique ID.
|
|
685
|
+
*
|
|
686
|
+
* @param id - The unique identifier of the activity to retrieve.
|
|
687
|
+
* @param options - Optional request-level overrides.
|
|
688
|
+
* @returns A promise that resolves to the matching {@link CrmActivity}.
|
|
689
|
+
*
|
|
690
|
+
* @example
|
|
691
|
+
* ```typescript
|
|
692
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
693
|
+
*
|
|
694
|
+
* const activity = await client.crm.activities.get('act_abc123');
|
|
695
|
+
* console.log(activity.attributes.type, activity.attributes.note);
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
get: (id: string, options?: RequestOptions) => Promise<CrmActivity>;
|
|
699
|
+
/**
|
|
700
|
+
* Create a new activity.
|
|
701
|
+
*
|
|
702
|
+
* @param attributes - Key/value map of activity attributes. Must include
|
|
703
|
+
* `workspace_id` and `type` (e.g. `"call"`, `"email"`, `"meeting"`,
|
|
704
|
+
* `"note"`). Optionally include `contact_id`, `company_id`, or
|
|
705
|
+
* `deal_id` to link the activity to other CRM entities.
|
|
706
|
+
* @param options - Optional request-level overrides.
|
|
707
|
+
* @returns A promise that resolves to the newly created {@link CrmActivity}.
|
|
708
|
+
*
|
|
709
|
+
* @example
|
|
710
|
+
* ```typescript
|
|
711
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
712
|
+
*
|
|
713
|
+
* const activity = await client.crm.activities.create({
|
|
714
|
+
* workspace_id: 'ws_abc123',
|
|
715
|
+
* type: 'call',
|
|
716
|
+
* contact_id: 'con_xyz',
|
|
717
|
+
* deal_id: 'deal_abc123',
|
|
718
|
+
* note: 'Discussed pricing. Follow up next week.',
|
|
719
|
+
* occurred_at: new Date().toISOString(),
|
|
720
|
+
* });
|
|
721
|
+
* ```
|
|
722
|
+
*/
|
|
723
|
+
create: (attributes: CreateCrmActivityAttributes, options?: RequestOptions) => Promise<CrmActivity>;
|
|
724
|
+
/**
|
|
725
|
+
* Update an existing activity's attributes.
|
|
726
|
+
*
|
|
727
|
+
* @param id - The unique identifier of the activity to update.
|
|
728
|
+
* @param attributes - Key/value map of attributes to change.
|
|
729
|
+
* @param options - Optional request-level overrides.
|
|
730
|
+
* @returns A promise that resolves to the updated {@link CrmActivity}.
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* ```typescript
|
|
734
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
735
|
+
*
|
|
736
|
+
* const activity = await client.crm.activities.update('act_abc123', {
|
|
737
|
+
* note: 'Updated notes from follow-up call.',
|
|
738
|
+
* });
|
|
739
|
+
* ```
|
|
740
|
+
*/
|
|
741
|
+
update: (id: string, attributes: Record<string, unknown>, options?: RequestOptions) => Promise<CrmActivity>;
|
|
742
|
+
/**
|
|
743
|
+
* Permanently delete an activity.
|
|
744
|
+
*
|
|
745
|
+
* @param id - The unique identifier of the activity to delete.
|
|
746
|
+
* @param options - Optional request-level overrides.
|
|
747
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
748
|
+
*
|
|
749
|
+
* @example
|
|
750
|
+
* ```typescript
|
|
751
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
752
|
+
*
|
|
753
|
+
* await client.crm.activities.delete('act_abc123');
|
|
754
|
+
* ```
|
|
755
|
+
*/
|
|
756
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
757
|
+
/**
|
|
758
|
+
* List activities in a workspace with optional pagination.
|
|
759
|
+
*
|
|
760
|
+
* @param workspaceId - The ID of the workspace to list activities from.
|
|
761
|
+
* @param options - Optional pagination controls and request-level overrides.
|
|
762
|
+
* @returns A promise that resolves to an array of {@link CrmActivity} records.
|
|
763
|
+
*
|
|
764
|
+
* @example
|
|
765
|
+
* ```typescript
|
|
766
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
767
|
+
*
|
|
768
|
+
* const recentActivities = await client.crm.activities.listByWorkspace('ws_abc123', {
|
|
769
|
+
* pageSize: 20,
|
|
770
|
+
* });
|
|
771
|
+
* ```
|
|
772
|
+
*/
|
|
773
|
+
listByWorkspace: (workspaceId: string, options?: {
|
|
774
|
+
page?: number;
|
|
775
|
+
pageSize?: number;
|
|
776
|
+
} & RequestOptions) => Promise<CrmActivity[]>;
|
|
777
|
+
};
|
|
778
|
+
/**
|
|
779
|
+
* Pipelines — deal workflow stage definitions.
|
|
780
|
+
*
|
|
781
|
+
* A pipeline defines the stages that deals progress through (e.g.
|
|
782
|
+
* "Inbound Sales", "Enterprise Sales"). Each pipeline has an ordered set
|
|
783
|
+
* of stages managed via {@link pipelineStages}.
|
|
784
|
+
*/
|
|
785
|
+
pipelines: {
|
|
786
|
+
/**
|
|
787
|
+
* Fetch a single pipeline by its unique ID.
|
|
788
|
+
*
|
|
789
|
+
* @param id - The unique identifier of the pipeline to retrieve.
|
|
790
|
+
* @param options - Optional request-level overrides.
|
|
791
|
+
* @returns A promise that resolves to the matching {@link CrmPipeline}.
|
|
792
|
+
*
|
|
793
|
+
* @example
|
|
794
|
+
* ```typescript
|
|
795
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
796
|
+
*
|
|
797
|
+
* const pipeline = await client.crm.pipelines.get('pipe_abc123');
|
|
798
|
+
* console.log(pipeline.attributes.name);
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
get: (id: string, options?: RequestOptions) => Promise<CrmPipeline>;
|
|
802
|
+
/**
|
|
803
|
+
* Create a new pipeline.
|
|
804
|
+
*
|
|
805
|
+
* @param attributes - Key/value map of pipeline attributes. Must include
|
|
806
|
+
* `workspace_id` and `name`.
|
|
807
|
+
* @param options - Optional request-level overrides.
|
|
808
|
+
* @returns A promise that resolves to the newly created {@link CrmPipeline}.
|
|
809
|
+
*
|
|
810
|
+
* @example
|
|
811
|
+
* ```typescript
|
|
812
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
813
|
+
*
|
|
814
|
+
* const pipeline = await client.crm.pipelines.create({
|
|
815
|
+
* workspace_id: 'ws_abc123',
|
|
816
|
+
* name: 'Enterprise Sales',
|
|
817
|
+
* });
|
|
818
|
+
* console.log(pipeline.id); // 'pipe_...'
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
|
+
create: (attributes: CreateCrmPipelineAttributes, options?: RequestOptions) => Promise<CrmPipeline>;
|
|
822
|
+
/**
|
|
823
|
+
* Update an existing pipeline's attributes.
|
|
824
|
+
*
|
|
825
|
+
* @param id - The unique identifier of the pipeline to update.
|
|
826
|
+
* @param attributes - Key/value map of attributes to change.
|
|
827
|
+
* @param options - Optional request-level overrides.
|
|
828
|
+
* @returns A promise that resolves to the updated {@link CrmPipeline}.
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* ```typescript
|
|
832
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
833
|
+
*
|
|
834
|
+
* const pipeline = await client.crm.pipelines.update('pipe_abc123', {
|
|
835
|
+
* name: 'SMB Sales',
|
|
836
|
+
* });
|
|
837
|
+
* ```
|
|
838
|
+
*/
|
|
839
|
+
update: (id: string, attributes: UpdateCrmPipelineAttributes, options?: RequestOptions) => Promise<CrmPipeline>;
|
|
840
|
+
/**
|
|
841
|
+
* Permanently delete a pipeline.
|
|
842
|
+
*
|
|
843
|
+
* @param id - The unique identifier of the pipeline to delete.
|
|
844
|
+
* @param options - Optional request-level overrides.
|
|
845
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* ```typescript
|
|
849
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
850
|
+
*
|
|
851
|
+
* await client.crm.pipelines.delete('pipe_abc123');
|
|
852
|
+
* ```
|
|
853
|
+
*/
|
|
854
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
855
|
+
/**
|
|
856
|
+
* List all pipelines in a workspace.
|
|
857
|
+
*
|
|
858
|
+
* @param workspaceId - The ID of the workspace to list pipelines from.
|
|
859
|
+
* @param options - Optional request-level overrides.
|
|
860
|
+
* @returns A promise that resolves to an array of {@link CrmPipeline} records.
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
* ```typescript
|
|
864
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
865
|
+
*
|
|
866
|
+
* const pipelines = await client.crm.pipelines.listByWorkspace('ws_abc123');
|
|
867
|
+
* console.log(pipelines.map((p) => p.attributes.name));
|
|
868
|
+
* ```
|
|
869
|
+
*/
|
|
870
|
+
listByWorkspace: (workspaceId: string, options?: RequestOptions) => Promise<CrmPipeline[]>;
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* Pipeline Stages — ordered stages within a pipeline.
|
|
874
|
+
*
|
|
875
|
+
* Each stage represents one step a deal can occupy within a pipeline
|
|
876
|
+
* (e.g. "Prospecting", "Proposal Sent", "Closed Won"). Stages have an
|
|
877
|
+
* `order` that determines their position in the pipeline flow.
|
|
878
|
+
*/
|
|
879
|
+
pipelineStages: {
|
|
880
|
+
/**
|
|
881
|
+
* Fetch a single pipeline stage by its unique ID.
|
|
882
|
+
*
|
|
883
|
+
* @param id - The unique identifier of the stage to retrieve.
|
|
884
|
+
* @param options - Optional request-level overrides.
|
|
885
|
+
* @returns A promise that resolves to the matching {@link CrmPipelineStage}.
|
|
886
|
+
*
|
|
887
|
+
* @example
|
|
888
|
+
* ```typescript
|
|
889
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
890
|
+
*
|
|
891
|
+
* const stage = await client.crm.pipelineStages.get('stage_abc123');
|
|
892
|
+
* console.log(stage.attributes.name, stage.attributes.order);
|
|
893
|
+
* ```
|
|
894
|
+
*/
|
|
895
|
+
get: (id: string, options?: RequestOptions) => Promise<CrmPipelineStage>;
|
|
896
|
+
/**
|
|
897
|
+
* Create a new stage within a pipeline.
|
|
898
|
+
*
|
|
899
|
+
* @param attributes - Key/value map of stage attributes. Must include
|
|
900
|
+
* `pipeline_id`, `name`, and `order`.
|
|
901
|
+
* @param options - Optional request-level overrides.
|
|
902
|
+
* @returns A promise that resolves to the newly created {@link CrmPipelineStage}.
|
|
903
|
+
*
|
|
904
|
+
* @example
|
|
905
|
+
* ```typescript
|
|
906
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
907
|
+
*
|
|
908
|
+
* const stage = await client.crm.pipelineStages.create({
|
|
909
|
+
* pipeline_id: 'pipe_abc123',
|
|
910
|
+
* name: 'Proposal Sent',
|
|
911
|
+
* order: 2,
|
|
912
|
+
* });
|
|
913
|
+
* console.log(stage.id); // 'stage_...'
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
916
|
+
create: (attributes: CreateCrmPipelineStageAttributes, options?: RequestOptions) => Promise<CrmPipelineStage>;
|
|
917
|
+
/**
|
|
918
|
+
* Update an existing pipeline stage's attributes.
|
|
919
|
+
*
|
|
920
|
+
* @param id - The unique identifier of the stage to update.
|
|
921
|
+
* @param attributes - Key/value map of attributes to change.
|
|
922
|
+
* @param options - Optional request-level overrides.
|
|
923
|
+
* @returns A promise that resolves to the updated {@link CrmPipelineStage}.
|
|
924
|
+
*
|
|
925
|
+
* @example
|
|
926
|
+
* ```typescript
|
|
927
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
928
|
+
*
|
|
929
|
+
* const stage = await client.crm.pipelineStages.update('stage_abc123', {
|
|
930
|
+
* name: 'Contract Review',
|
|
931
|
+
* order: 3,
|
|
932
|
+
* });
|
|
933
|
+
* ```
|
|
934
|
+
*/
|
|
935
|
+
update: (id: string, attributes: UpdateCrmPipelineStageAttributes, options?: RequestOptions) => Promise<CrmPipelineStage>;
|
|
936
|
+
/**
|
|
937
|
+
* Permanently delete a pipeline stage.
|
|
938
|
+
*
|
|
939
|
+
* @param id - The unique identifier of the stage to delete.
|
|
940
|
+
* @param options - Optional request-level overrides.
|
|
941
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
942
|
+
*
|
|
943
|
+
* @example
|
|
944
|
+
* ```typescript
|
|
945
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
946
|
+
*
|
|
947
|
+
* await client.crm.pipelineStages.delete('stage_abc123');
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
951
|
+
/**
|
|
952
|
+
* List all stages belonging to a specific pipeline.
|
|
953
|
+
*
|
|
954
|
+
* @param pipelineId - The ID of the pipeline whose stages to list.
|
|
955
|
+
* @param options - Optional request-level overrides.
|
|
956
|
+
* @returns A promise that resolves to an array of {@link CrmPipelineStage} records.
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
961
|
+
*
|
|
962
|
+
* const stages = await client.crm.pipelineStages.listByPipeline('pipe_abc123');
|
|
963
|
+
* stages.forEach((s) => console.log(s.attributes.name, s.attributes.order));
|
|
964
|
+
* ```
|
|
965
|
+
*/
|
|
966
|
+
listByPipeline: (pipelineId: string, options?: RequestOptions) => Promise<CrmPipelineStage[]>;
|
|
967
|
+
};
|
|
968
|
+
/**
|
|
969
|
+
* Relationship Types — templates that define allowable relationships between CRM entities.
|
|
970
|
+
*
|
|
971
|
+
* A relationship type defines the semantic meaning of an edge in the CRM
|
|
972
|
+
* graph (e.g. "Employee Of", "Referred By", "Reports To"). Once defined,
|
|
973
|
+
* instances of that relationship type can be created via {@link relationships}.
|
|
974
|
+
*/
|
|
975
|
+
relationshipTypes: {
|
|
976
|
+
/**
|
|
977
|
+
* Fetch a single relationship type by its unique ID.
|
|
978
|
+
*
|
|
979
|
+
* @param id - The unique identifier of the relationship type to retrieve.
|
|
980
|
+
* @param options - Optional request-level overrides.
|
|
981
|
+
* @returns A promise that resolves to the matching {@link CrmRelationshipType}.
|
|
982
|
+
*
|
|
983
|
+
* @example
|
|
984
|
+
* ```typescript
|
|
985
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
986
|
+
*
|
|
987
|
+
* const relType = await client.crm.relationshipTypes.get('reltype_abc123');
|
|
988
|
+
* console.log(relType.attributes.label); // 'Employee Of'
|
|
989
|
+
* ```
|
|
990
|
+
*/
|
|
991
|
+
get: (id: string, options?: RequestOptions) => Promise<CrmRelationshipType>;
|
|
992
|
+
/**
|
|
993
|
+
* Create a new relationship type.
|
|
994
|
+
*
|
|
995
|
+
* @param attributes - Key/value map of relationship type attributes.
|
|
996
|
+
* Must include `label` (human-readable name) and optionally
|
|
997
|
+
* `inverse_label` (the name of the reverse direction of the edge).
|
|
998
|
+
* @param options - Optional request-level overrides.
|
|
999
|
+
* @returns A promise that resolves to the newly created {@link CrmRelationshipType}.
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```typescript
|
|
1003
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1004
|
+
*
|
|
1005
|
+
* const relType = await client.crm.relationshipTypes.create({
|
|
1006
|
+
* label: 'Employee Of',
|
|
1007
|
+
* inverse_label: 'Employs',
|
|
1008
|
+
* from_entity_type: 'contact',
|
|
1009
|
+
* to_entity_type: 'company',
|
|
1010
|
+
* });
|
|
1011
|
+
* console.log(relType.id); // 'reltype_...'
|
|
1012
|
+
* ```
|
|
1013
|
+
*/
|
|
1014
|
+
create: (attributes: CreateCrmRelationshipTypeAttributes, options?: RequestOptions) => Promise<CrmRelationshipType>;
|
|
1015
|
+
/**
|
|
1016
|
+
* Update an existing relationship type.
|
|
1017
|
+
*
|
|
1018
|
+
* @param id - The unique identifier of the relationship type to update.
|
|
1019
|
+
* @param attributes - Key/value map of attributes to change.
|
|
1020
|
+
* @param options - Optional request-level overrides.
|
|
1021
|
+
* @returns A promise that resolves to the updated {@link CrmRelationshipType}.
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```typescript
|
|
1025
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1026
|
+
*
|
|
1027
|
+
* const relType = await client.crm.relationshipTypes.update('reltype_abc123', {
|
|
1028
|
+
* label: 'Works At',
|
|
1029
|
+
* });
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
1032
|
+
update: (id: string, attributes: UpdateCrmRelationshipTypeAttributes, options?: RequestOptions) => Promise<CrmRelationshipType>;
|
|
1033
|
+
/**
|
|
1034
|
+
* Permanently delete a relationship type.
|
|
1035
|
+
*
|
|
1036
|
+
* Deleting a relationship type does not automatically delete the
|
|
1037
|
+
* individual relationship instances that use it.
|
|
1038
|
+
*
|
|
1039
|
+
* @param id - The unique identifier of the relationship type to delete.
|
|
1040
|
+
* @param options - Optional request-level overrides.
|
|
1041
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
1042
|
+
*
|
|
1043
|
+
* @example
|
|
1044
|
+
* ```typescript
|
|
1045
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1046
|
+
*
|
|
1047
|
+
* await client.crm.relationshipTypes.delete('reltype_abc123');
|
|
1048
|
+
* ```
|
|
1049
|
+
*/
|
|
1050
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
1051
|
+
/**
|
|
1052
|
+
* List all relationship types defined for the authenticated application.
|
|
1053
|
+
*
|
|
1054
|
+
* Relationship types are application-scoped (not workspace-scoped) so
|
|
1055
|
+
* the same type definitions are available across all workspaces.
|
|
1056
|
+
*
|
|
1057
|
+
* @param options - Optional request-level overrides.
|
|
1058
|
+
* @returns A promise that resolves to an array of all {@link CrmRelationshipType} records.
|
|
1059
|
+
*
|
|
1060
|
+
* @example
|
|
1061
|
+
* ```typescript
|
|
1062
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1063
|
+
*
|
|
1064
|
+
* const types = await client.crm.relationshipTypes.list();
|
|
1065
|
+
* console.log(types.map((t) => t.attributes.label));
|
|
1066
|
+
* ```
|
|
1067
|
+
*/
|
|
1068
|
+
list: (options?: RequestOptions) => Promise<CrmRelationshipType[]>;
|
|
1069
|
+
};
|
|
1070
|
+
/**
|
|
1071
|
+
* Relationships — directed edges between CRM entities.
|
|
1072
|
+
*
|
|
1073
|
+
* A relationship is a typed, directed connection between two CRM entities
|
|
1074
|
+
* (contacts, companies, deals, or custom entities). The edge type is
|
|
1075
|
+
* determined by a {@link relationshipTypes relationship type}. For example,
|
|
1076
|
+
* a "Employee Of" relationship edge from a contact to a company.
|
|
1077
|
+
*/
|
|
1078
|
+
relationships: {
|
|
1079
|
+
/**
|
|
1080
|
+
* Fetch a single relationship by its unique ID.
|
|
1081
|
+
*
|
|
1082
|
+
* @param id - The unique identifier of the relationship to retrieve.
|
|
1083
|
+
* @param options - Optional request-level overrides.
|
|
1084
|
+
* @returns A promise that resolves to the matching {@link CrmRelationship}.
|
|
1085
|
+
*
|
|
1086
|
+
* @example
|
|
1087
|
+
* ```typescript
|
|
1088
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1089
|
+
*
|
|
1090
|
+
* const rel = await client.crm.relationships.get('rel_abc123');
|
|
1091
|
+
* console.log(rel.attributes.from_entity_id, '→', rel.attributes.to_entity_id);
|
|
1092
|
+
* ```
|
|
1093
|
+
*/
|
|
1094
|
+
get: (id: string, options?: RequestOptions) => Promise<CrmRelationship>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Create a new relationship between two CRM entities.
|
|
1097
|
+
*
|
|
1098
|
+
* @param attributes - Key/value map of relationship attributes. Must
|
|
1099
|
+
* include `workspace_id`, `relationship_type_id`, `from_entity_type`,
|
|
1100
|
+
* `from_entity_id`, `to_entity_type`, and `to_entity_id`.
|
|
1101
|
+
* @param options - Optional request-level overrides.
|
|
1102
|
+
* @returns A promise that resolves to the newly created {@link CrmRelationship}.
|
|
1103
|
+
*
|
|
1104
|
+
* @example
|
|
1105
|
+
* ```typescript
|
|
1106
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1107
|
+
*
|
|
1108
|
+
* const rel = await client.crm.relationships.create({
|
|
1109
|
+
* workspace_id: 'ws_abc123',
|
|
1110
|
+
* relationship_type_id: 'reltype_employee',
|
|
1111
|
+
* from_entity_type: 'contact',
|
|
1112
|
+
* from_entity_id: 'con_jane',
|
|
1113
|
+
* to_entity_type: 'company',
|
|
1114
|
+
* to_entity_id: 'co_acme',
|
|
1115
|
+
* });
|
|
1116
|
+
* console.log(rel.id); // 'rel_...'
|
|
1117
|
+
* ```
|
|
1118
|
+
*/
|
|
1119
|
+
create: (attributes: CreateCrmRelationshipAttributes, options?: RequestOptions) => Promise<CrmRelationship>;
|
|
1120
|
+
/**
|
|
1121
|
+
* Permanently delete a relationship edge.
|
|
1122
|
+
*
|
|
1123
|
+
* @param id - The unique identifier of the relationship to delete.
|
|
1124
|
+
* @param options - Optional request-level overrides.
|
|
1125
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* ```typescript
|
|
1129
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1130
|
+
*
|
|
1131
|
+
* await client.crm.relationships.delete('rel_abc123');
|
|
1132
|
+
* ```
|
|
1133
|
+
*/
|
|
1134
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
1135
|
+
/**
|
|
1136
|
+
* List all relationships in a workspace.
|
|
1137
|
+
*
|
|
1138
|
+
* @param workspaceId - The ID of the workspace to list relationships from.
|
|
1139
|
+
* @param options - Optional request-level overrides.
|
|
1140
|
+
* @returns A promise that resolves to an array of {@link CrmRelationship} records.
|
|
1141
|
+
*
|
|
1142
|
+
* @example
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1145
|
+
*
|
|
1146
|
+
* const rels = await client.crm.relationships.listByWorkspace('ws_abc123');
|
|
1147
|
+
* for (const r of rels) {
|
|
1148
|
+
* console.log(r.attributes.from_entity_id, '→', r.attributes.to_entity_id);
|
|
1149
|
+
* }
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
1152
|
+
listByWorkspace: (workspaceId: string, options?: RequestOptions) => Promise<CrmRelationship[]>;
|
|
1153
|
+
};
|
|
1154
|
+
/**
|
|
1155
|
+
* Custom Entities — ISV-defined entity types beyond the built-in CRM entities.
|
|
1156
|
+
*
|
|
1157
|
+
* Custom entities allow ISVs to model domain-specific objects within the
|
|
1158
|
+
* CRM (e.g. "Properties" for a real estate app, "Projects" for a services
|
|
1159
|
+
* firm). Each custom entity has a `type` discriminator, a free-form
|
|
1160
|
+
* `properties` map, and full version history accessible via the nested
|
|
1161
|
+
* `versions` sub-namespace.
|
|
1162
|
+
*/
|
|
1163
|
+
customEntities: {
|
|
1164
|
+
/**
|
|
1165
|
+
* Fetch a single custom entity by its unique ID.
|
|
1166
|
+
*
|
|
1167
|
+
* @param id - The unique identifier of the custom entity to retrieve.
|
|
1168
|
+
* @param options - Optional request-level overrides.
|
|
1169
|
+
* @returns A promise that resolves to the matching {@link CrmCustomEntity}.
|
|
1170
|
+
*
|
|
1171
|
+
* @example
|
|
1172
|
+
* ```typescript
|
|
1173
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1174
|
+
*
|
|
1175
|
+
* const entity = await client.crm.customEntities.get('cen_abc123');
|
|
1176
|
+
* console.log(entity.attributes.type, entity.attributes.properties);
|
|
1177
|
+
* ```
|
|
1178
|
+
*/
|
|
1179
|
+
get: (id: string, options?: RequestOptions) => Promise<CrmCustomEntity>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Create a new custom entity.
|
|
1182
|
+
*
|
|
1183
|
+
* @param attributes - Key/value map of entity attributes. Must include
|
|
1184
|
+
* `workspace_id` and `type` (the ISV-defined entity discriminator).
|
|
1185
|
+
* Include `properties` with your domain-specific fields.
|
|
1186
|
+
* @param options - Optional request-level overrides.
|
|
1187
|
+
* @returns A promise that resolves to the newly created {@link CrmCustomEntity}.
|
|
1188
|
+
*
|
|
1189
|
+
* @example
|
|
1190
|
+
* ```typescript
|
|
1191
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1192
|
+
*
|
|
1193
|
+
* const property = await client.crm.customEntities.create({
|
|
1194
|
+
* workspace_id: 'ws_abc123',
|
|
1195
|
+
* type: 'property',
|
|
1196
|
+
* properties: {
|
|
1197
|
+
* address: '123 Main St',
|
|
1198
|
+
* bedrooms: 3,
|
|
1199
|
+
* price_cents: 49900000,
|
|
1200
|
+
* },
|
|
1201
|
+
* });
|
|
1202
|
+
* console.log(property.id); // 'cen_...'
|
|
1203
|
+
* ```
|
|
1204
|
+
*/
|
|
1205
|
+
create: (attributes: CreateCrmCustomEntityAttributes, options?: RequestOptions) => Promise<CrmCustomEntity>;
|
|
1206
|
+
/**
|
|
1207
|
+
* Update an existing custom entity's attributes.
|
|
1208
|
+
*
|
|
1209
|
+
* Only the fields present in `attributes` are changed (PATCH semantics).
|
|
1210
|
+
* Each update automatically creates a new version snapshot accessible
|
|
1211
|
+
* via {@link customEntities.versions.list}.
|
|
1212
|
+
*
|
|
1213
|
+
* @param id - The unique identifier of the custom entity to update.
|
|
1214
|
+
* @param attributes - Key/value map of attributes to change.
|
|
1215
|
+
* @param options - Optional request-level overrides.
|
|
1216
|
+
* @returns A promise that resolves to the updated {@link CrmCustomEntity}.
|
|
1217
|
+
*
|
|
1218
|
+
* @example
|
|
1219
|
+
* ```typescript
|
|
1220
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1221
|
+
*
|
|
1222
|
+
* const entity = await client.crm.customEntities.update('cen_abc123', {
|
|
1223
|
+
* properties: { status: 'under_offer', price_cents: 47500000 },
|
|
1224
|
+
* });
|
|
1225
|
+
* ```
|
|
1226
|
+
*/
|
|
1227
|
+
update: (id: string, attributes: UpdateCrmCustomEntityAttributes, options?: RequestOptions) => Promise<CrmCustomEntity>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Permanently delete a custom entity.
|
|
1230
|
+
*
|
|
1231
|
+
* @param id - The unique identifier of the custom entity to delete.
|
|
1232
|
+
* @param options - Optional request-level overrides.
|
|
1233
|
+
* @returns A promise that resolves to `true` on successful deletion.
|
|
1234
|
+
*
|
|
1235
|
+
* @example
|
|
1236
|
+
* ```typescript
|
|
1237
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1238
|
+
*
|
|
1239
|
+
* await client.crm.customEntities.delete('cen_abc123');
|
|
1240
|
+
* ```
|
|
1241
|
+
*/
|
|
1242
|
+
delete: (id: string, options?: RequestOptions) => Promise<true>;
|
|
1243
|
+
/**
|
|
1244
|
+
* List custom entities in a workspace with optional type and attribute filters.
|
|
1245
|
+
*
|
|
1246
|
+
* Use `type` to restrict results to a specific ISV-defined entity type,
|
|
1247
|
+
* and `filters` to apply server-side attribute predicates.
|
|
1248
|
+
*
|
|
1249
|
+
* @param workspaceId - The ID of the workspace to list entities from.
|
|
1250
|
+
* @param options - Optional filters and pagination:
|
|
1251
|
+
* - `type` — restrict to entities of this discriminator type.
|
|
1252
|
+
* - `filters` — array of {@link AttributeFilter} predicates applied to
|
|
1253
|
+
* the entity's `properties` map.
|
|
1254
|
+
* - `page` / `pageSize` — pagination controls.
|
|
1255
|
+
* @returns A promise that resolves to an array of {@link CrmCustomEntity} records.
|
|
1256
|
+
*
|
|
1257
|
+
* @example
|
|
1258
|
+
* ```typescript
|
|
1259
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1260
|
+
*
|
|
1261
|
+
* // All properties currently listed for sale
|
|
1262
|
+
* const listings = await client.crm.customEntities.listByWorkspace('ws_abc123', {
|
|
1263
|
+
* type: 'property',
|
|
1264
|
+
* filters: [{ field: 'status', op: 'eq', value: 'listed' }],
|
|
1265
|
+
* pageSize: 50,
|
|
1266
|
+
* });
|
|
1267
|
+
* ```
|
|
1268
|
+
*/
|
|
1269
|
+
listByWorkspace: (workspaceId: string, options?: {
|
|
1270
|
+
type?: string;
|
|
1271
|
+
filters?: AttributeFilter[];
|
|
1272
|
+
page?: number;
|
|
1273
|
+
pageSize?: number;
|
|
1274
|
+
} & RequestOptions) => Promise<CrmCustomEntity[]>;
|
|
1275
|
+
/**
|
|
1276
|
+
* Batch update multiple custom entities in a single atomic transaction.
|
|
1277
|
+
*
|
|
1278
|
+
* More efficient than issuing individual `update` calls when you need to
|
|
1279
|
+
* change many entities at once. All updates succeed or all fail together.
|
|
1280
|
+
*
|
|
1281
|
+
* @param workspaceId - The ID of the workspace that owns the entities.
|
|
1282
|
+
* @param updates - Array of update objects, each containing the entity
|
|
1283
|
+
* `id` and the `attributes` map to apply.
|
|
1284
|
+
* @param options - Optional request-level overrides.
|
|
1285
|
+
* @returns A promise that resolves to an array of the updated {@link CrmCustomEntity} records.
|
|
1286
|
+
*
|
|
1287
|
+
* @example
|
|
1288
|
+
* ```typescript
|
|
1289
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1290
|
+
*
|
|
1291
|
+
* const updated = await client.crm.customEntities.batchUpdate('ws_abc123', [
|
|
1292
|
+
* { id: 'cen_001', attributes: { properties: { status: 'sold' } } },
|
|
1293
|
+
* { id: 'cen_002', attributes: { properties: { status: 'sold' } } },
|
|
1294
|
+
* ]);
|
|
1295
|
+
* console.log(`${updated.length} entities updated`);
|
|
1296
|
+
* ```
|
|
1297
|
+
*/
|
|
1298
|
+
batchUpdate: (workspaceId: string, updates: Array<{
|
|
1299
|
+
id: string;
|
|
1300
|
+
attributes: UpdateCrmCustomEntityAttributes;
|
|
1301
|
+
}>, options?: RequestOptions) => Promise<CrmCustomEntity[]>;
|
|
1302
|
+
/**
|
|
1303
|
+
* Run aggregate queries (count / avg / sum) on custom entity properties.
|
|
1304
|
+
*
|
|
1305
|
+
* Returns one row per distinct value of `group_by` (when provided) or a
|
|
1306
|
+
* single summary row. Useful for building dashboards and reports over
|
|
1307
|
+
* ISV-defined entity data without pulling all records client-side.
|
|
1308
|
+
*
|
|
1309
|
+
* @param workspaceId - The ID of the workspace to aggregate over.
|
|
1310
|
+
* @param params - Aggregation parameters:
|
|
1311
|
+
* - `type` — restrict to a specific entity discriminator type.
|
|
1312
|
+
* - `metrics` — one or more {@link AggregateMetric} or
|
|
1313
|
+
* {@link AggregateFieldMetric} definitions (count, avg, sum).
|
|
1314
|
+
* - `group_by` — optional property name to group results by.
|
|
1315
|
+
* - `filters` — optional {@link AttributeFilter} predicates to apply
|
|
1316
|
+
* before aggregation.
|
|
1317
|
+
* @param options - Optional request-level overrides.
|
|
1318
|
+
* @returns A promise that resolves to an array of result rows, each a
|
|
1319
|
+
* plain object whose keys match the requested metric names plus the
|
|
1320
|
+
* group_by field (if provided).
|
|
1321
|
+
*
|
|
1322
|
+
* @example
|
|
1323
|
+
* ```typescript
|
|
1324
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1325
|
+
*
|
|
1326
|
+
* // Count properties by status
|
|
1327
|
+
* const results = await client.crm.customEntities.aggregate('ws_abc123', {
|
|
1328
|
+
* type: 'property',
|
|
1329
|
+
* metrics: [{ fn: 'count' }],
|
|
1330
|
+
* group_by: 'status',
|
|
1331
|
+
* });
|
|
1332
|
+
* // [{ status: 'listed', count: 42 }, { status: 'sold', count: 18 }]
|
|
1333
|
+
* console.log(results);
|
|
1334
|
+
*
|
|
1335
|
+
* // Average sale price of sold properties
|
|
1336
|
+
* const avgPrice = await client.crm.customEntities.aggregate('ws_abc123', {
|
|
1337
|
+
* type: 'property',
|
|
1338
|
+
* metrics: [{ fn: 'avg', field: 'price_cents' }],
|
|
1339
|
+
* filters: [{ field: 'status', op: 'eq', value: 'sold' }],
|
|
1340
|
+
* });
|
|
1341
|
+
* ```
|
|
1342
|
+
*/
|
|
1343
|
+
aggregate: (workspaceId: string, params: {
|
|
1344
|
+
type?: string;
|
|
1345
|
+
metrics: Array<AggregateMetric | AggregateFieldMetric>;
|
|
1346
|
+
group_by?: string;
|
|
1347
|
+
filters?: AttributeFilter[];
|
|
1348
|
+
}, options?: RequestOptions) => Promise<Array<Record<string, unknown>>>;
|
|
1349
|
+
/**
|
|
1350
|
+
* Version history sub-namespace for a custom entity.
|
|
1351
|
+
*
|
|
1352
|
+
* Every time a custom entity is updated, a {@link CrmCustomEntityVersion}
|
|
1353
|
+
* snapshot is automatically created. These snapshots allow you to audit
|
|
1354
|
+
* changes over time and roll back to any prior state.
|
|
1355
|
+
*/
|
|
1356
|
+
versions: {
|
|
1357
|
+
/**
|
|
1358
|
+
* List all version snapshots for a custom entity, ordered by
|
|
1359
|
+
* `version_number` descending (most recent first).
|
|
1360
|
+
*
|
|
1361
|
+
* @param entityId - The ID of the custom entity whose history to retrieve.
|
|
1362
|
+
* @param options - Optional pagination controls (`page`, `pageSize`) and
|
|
1363
|
+
* request-level overrides.
|
|
1364
|
+
* @returns A promise that resolves to a paginated response object
|
|
1365
|
+
* containing a `data` array of {@link CrmCustomEntityVersion} snapshots
|
|
1366
|
+
* and optional `meta` pagination metadata.
|
|
1367
|
+
*
|
|
1368
|
+
* @example
|
|
1369
|
+
* ```typescript
|
|
1370
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1371
|
+
*
|
|
1372
|
+
* const history = await client.crm.customEntities.versions.list('cen_abc123');
|
|
1373
|
+
* for (const v of history.data) {
|
|
1374
|
+
* console.log(`v${v.version_number} — ${v.inserted_at}`);
|
|
1375
|
+
* }
|
|
1376
|
+
* ```
|
|
1377
|
+
*/
|
|
1378
|
+
list: (entityId: string, options?: {
|
|
1379
|
+
page?: number;
|
|
1380
|
+
pageSize?: number;
|
|
1381
|
+
} & RequestOptions) => Promise<{
|
|
1382
|
+
data: CrmCustomEntityVersion[];
|
|
1383
|
+
meta?: unknown;
|
|
1384
|
+
}>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Fetch a single version snapshot by its ID.
|
|
1387
|
+
*
|
|
1388
|
+
* @param entityId - The ID of the custom entity.
|
|
1389
|
+
* @param versionId - The ID of the specific version snapshot to fetch.
|
|
1390
|
+
* @param options - Optional request-level overrides.
|
|
1391
|
+
* @returns A promise that resolves to the {@link CrmCustomEntityVersion} snapshot.
|
|
1392
|
+
*
|
|
1393
|
+
* @example
|
|
1394
|
+
* ```typescript
|
|
1395
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1396
|
+
*
|
|
1397
|
+
* const snapshot = await client.crm.customEntities.versions.get(
|
|
1398
|
+
* 'cen_abc123',
|
|
1399
|
+
* 'ver_xyz',
|
|
1400
|
+
* );
|
|
1401
|
+
* console.log(snapshot.version_number, snapshot.attributes);
|
|
1402
|
+
* ```
|
|
1403
|
+
*/
|
|
1404
|
+
get: (entityId: string, versionId: string, options?: RequestOptions) => Promise<CrmCustomEntityVersion>;
|
|
1405
|
+
/**
|
|
1406
|
+
* Restore a custom entity to the state captured in a prior version snapshot.
|
|
1407
|
+
*
|
|
1408
|
+
* Creates a new version entry reflecting the rollback so the audit trail
|
|
1409
|
+
* is never broken. The entity's `properties` will match those in the
|
|
1410
|
+
* targeted snapshot after the call completes.
|
|
1411
|
+
*
|
|
1412
|
+
* @param entityId - The ID of the custom entity to restore.
|
|
1413
|
+
* @param versionId - The ID of the version snapshot to restore to.
|
|
1414
|
+
* @param options - Optional request-level overrides.
|
|
1415
|
+
* @returns A promise that resolves to the restored {@link CrmCustomEntity}
|
|
1416
|
+
* with its properties reverted to the snapshot state.
|
|
1417
|
+
*
|
|
1418
|
+
* @example
|
|
1419
|
+
* ```typescript
|
|
1420
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1421
|
+
*
|
|
1422
|
+
* // Undo the last change by restoring to the previous version
|
|
1423
|
+
* const history = await client.crm.customEntities.versions.list('cen_abc123');
|
|
1424
|
+
* const previousVersion = history.data[1]; // index 0 is current
|
|
1425
|
+
*
|
|
1426
|
+
* const restored = await client.crm.customEntities.versions.restore(
|
|
1427
|
+
* 'cen_abc123',
|
|
1428
|
+
* previousVersion.id,
|
|
1429
|
+
* );
|
|
1430
|
+
* console.log('Restored to v' + previousVersion.version_number);
|
|
1431
|
+
* ```
|
|
1432
|
+
*/
|
|
1433
|
+
restore: (entityId: string, versionId: string, options?: RequestOptions) => Promise<CrmCustomEntity>;
|
|
1434
|
+
};
|
|
1435
|
+
};
|
|
1436
|
+
/**
|
|
1437
|
+
* CRM data export — create async export jobs and poll for completion.
|
|
1438
|
+
*
|
|
1439
|
+
* Exports are asynchronous. Call `create` to enqueue the job, then poll
|
|
1440
|
+
* `get` until `status === 'complete'`, at which point `file_url` will be
|
|
1441
|
+
* populated with a pre-signed download URL valid for one hour.
|
|
1442
|
+
*/
|
|
1443
|
+
export: {
|
|
1444
|
+
/**
|
|
1445
|
+
* Create a new data export job.
|
|
1446
|
+
*
|
|
1447
|
+
* The job is queued and processed asynchronously. The method returns
|
|
1448
|
+
* immediately with a job record in `pending` status. Poll {@link get}
|
|
1449
|
+
* until `status === 'complete'`, then download from `file_url`.
|
|
1450
|
+
*
|
|
1451
|
+
* @param workspaceId - The ID of the workspace to export data from.
|
|
1452
|
+
* @param params - Export configuration:
|
|
1453
|
+
* - `entityType` — the CRM entity type to export (`"contact"`,
|
|
1454
|
+
* `"custom_entity"`, or `"activity"`).
|
|
1455
|
+
* - `entitySubtype` — optional discriminator for custom entity types.
|
|
1456
|
+
* - `format` — output format (`"json"` or `"csv"`).
|
|
1457
|
+
* - `include` — optional list of field names to include in the export.
|
|
1458
|
+
* - `filters` — optional {@link AttributeFilter} predicates to restrict
|
|
1459
|
+
* which records are exported.
|
|
1460
|
+
* @param options - Optional request-level overrides.
|
|
1461
|
+
* @returns A promise that resolves to a {@link CrmDataExportJob} in `pending` status.
|
|
1462
|
+
*
|
|
1463
|
+
* @example
|
|
1464
|
+
* ```typescript
|
|
1465
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1466
|
+
*
|
|
1467
|
+
* const job = await client.crm.export.create('ws_abc123', {
|
|
1468
|
+
* entityType: 'contact',
|
|
1469
|
+
* format: 'csv',
|
|
1470
|
+
* include: ['first_name', 'last_name', 'email', 'status'],
|
|
1471
|
+
* filters: [{ field: 'status', op: 'eq', value: 'customer' }],
|
|
1472
|
+
* });
|
|
1473
|
+
* console.log(job.id, job.status); // 'export_...', 'pending'
|
|
1474
|
+
* ```
|
|
1475
|
+
*/
|
|
1476
|
+
create: (workspaceId: string, params: CrmExportCreateParams, options?: RequestOptions) => Promise<CrmDataExportJob>;
|
|
1477
|
+
/**
|
|
1478
|
+
* Get the current status of an export job by its ID.
|
|
1479
|
+
*
|
|
1480
|
+
* When `status === 'complete'`, the `file_url` field is populated with
|
|
1481
|
+
* a pre-signed download link valid for one hour. When `status === 'failed'`,
|
|
1482
|
+
* the `error` field contains a human-readable description of the failure.
|
|
1483
|
+
*
|
|
1484
|
+
* @param jobId - The ID of the export job to retrieve.
|
|
1485
|
+
* @param options - Optional request-level overrides.
|
|
1486
|
+
* @returns A promise that resolves to the {@link CrmDataExportJob} with the latest status.
|
|
1487
|
+
*
|
|
1488
|
+
* @example
|
|
1489
|
+
* ```typescript
|
|
1490
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1491
|
+
*
|
|
1492
|
+
* // Poll until complete
|
|
1493
|
+
* let job = await client.crm.export.get('export_abc123');
|
|
1494
|
+
* while (job.status === 'pending' || job.status === 'processing') {
|
|
1495
|
+
* await new Promise((r) => setTimeout(r, 2000));
|
|
1496
|
+
* job = await client.crm.export.get(job.id);
|
|
1497
|
+
* }
|
|
1498
|
+
*
|
|
1499
|
+
* if (job.status === 'complete' && job.file_url) {
|
|
1500
|
+
* console.log('Download:', job.file_url);
|
|
1501
|
+
* }
|
|
1502
|
+
* ```
|
|
1503
|
+
*/
|
|
1504
|
+
get: (jobId: string, options?: RequestOptions) => Promise<CrmDataExportJob>;
|
|
1505
|
+
/**
|
|
1506
|
+
* List all export jobs for a workspace, most recent first.
|
|
1507
|
+
*
|
|
1508
|
+
* @param workspaceId - The ID of the workspace to list export jobs from.
|
|
1509
|
+
* @param options - Optional request-level overrides.
|
|
1510
|
+
* @returns A promise that resolves to an array of {@link CrmDataExportJob} records.
|
|
1511
|
+
*
|
|
1512
|
+
* @example
|
|
1513
|
+
* ```typescript
|
|
1514
|
+
* const client = new GptClient({ apiKey: 'sk_app_...' });
|
|
1515
|
+
*
|
|
1516
|
+
* const jobs = await client.crm.export.list('ws_abc123');
|
|
1517
|
+
* const completed = jobs.filter((j) => j.status === 'complete');
|
|
1518
|
+
* console.log(`${completed.length} completed exports available`);
|
|
1519
|
+
* ```
|
|
1520
|
+
*/
|
|
1521
|
+
list: (workspaceId: string, options?: RequestOptions) => Promise<CrmDataExportJob[]>;
|
|
1522
|
+
/**
|
|
1523
|
+
* Regenerate the presigned download URL for a completed export job.
|
|
1524
|
+
* Use when the original URL has expired (1-hour TTL). Only works on
|
|
1525
|
+
* jobs with status 'complete'.
|
|
1526
|
+
*
|
|
1527
|
+
* @param jobId - The export job ID
|
|
1528
|
+
* @returns The updated job with a fresh `file_url` and `url_expires_at`
|
|
1529
|
+
*
|
|
1530
|
+
* @example
|
|
1531
|
+
* ```typescript
|
|
1532
|
+
* const refreshed = await client.crm.export.refreshUrl('export_abc123');
|
|
1533
|
+
* console.log(refreshed.file_url); // new presigned URL
|
|
1534
|
+
* ```
|
|
1535
|
+
*/
|
|
1536
|
+
refreshUrl: (jobId: string, options?: RequestOptions) => Promise<CrmDataExportJob>;
|
|
1537
|
+
};
|
|
1538
|
+
};
|
|
1539
|
+
//# sourceMappingURL=crm.d.ts.map
|