@@ -34,9 +34,9 @@ import { IntercomClient } from "intercom-client";
34
34
35
35
const client = new IntercomClient ({ token: " YOUR_TOKEN" });
36
36
await client .articles .create ({
37
- title: " Thanks for everything " ,
38
- description: " Description of the Article " ,
39
- body: " Body of the Article " ,
37
+ title: " How to create an account " ,
38
+ description: " Example article about creating an account. " ,
39
+ body: " Here are the steps to create an account. " ,
40
40
author_id: 1295 ,
41
41
state: " published" ,
42
42
});
@@ -87,19 +87,6 @@ client.useRequestOpts({
87
87
88
88
Note that certain request options (such as ` json ` , and certain ` headers ` names cannot be overriden).
89
89
90
- ### Setting the API version
91
-
92
- We version our API (see the "Choose Version" section of the [ API & Webhooks Reference] ( https://developers.intercom.com/intercom-api-reference/reference ) for details). You can specify which version of the API to use when performing API requests using request options:
93
-
94
- ``` typescript
95
- const client = new Client ({ tokenAuth: { token: " my_token" } });
96
- client .useRequestOpts ({
97
- headers: {
98
- " Intercom-Version" : 2.6 ,
99
- },
100
- });
101
- ```
102
-
103
90
### Setting the API base url
104
91
105
92
If you are using the european instance of intercom and would like to call it directly and not be redirected through our US instance, you can set the ` baseUrl ` as follows:
@@ -115,13 +102,13 @@ client.useRequestOpts({
115
102
116
103
### Admins
117
104
118
- #### [ Retrieve admin] ( https://developers.intercom.com/intercom -api-reference/reference/view-an-admin )
105
+ #### [ Retrieve admin] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/admins/retrieveadmin )
119
106
120
107
``` typescript
121
108
const admin = await client .admins .find ({ id: " 123" });
122
109
```
123
110
124
- #### [ Set Admin away] ( https://developers.intercom.com/intercom -api-reference/reference/set-admin-away-mode )
111
+ #### [ Set Admin away] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/admins/setawayadmin )
125
112
126
113
``` typescript
127
114
await client .admins .away ({
@@ -131,7 +118,7 @@ await client.admins.away({
131
118
});
132
119
```
133
120
134
- #### [ List all activity logs] ( https://developers.intercom.com/intercom -api-reference/reference/view-admin-activity-logs )
121
+ #### [ List all activity logs] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/admins/listactivitylogs )
135
122
136
123
``` typescript
137
124
await client .admins .listAllActivityLogs ({
@@ -140,74 +127,74 @@ await client.admins.listAllActivityLogs({
140
127
});
141
128
```
142
129
143
- #### [ List all admins] ( https://developers.intercom.com/intercom -api-reference/reference/list- admins )
130
+ #### [ List all admins] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/ admins/listadmins )
144
131
145
132
``` typescript
146
133
const admins = await client .admins .list ();
147
134
```
148
135
149
136
### Articles
150
137
151
- #### [ Create an article] ( https://developers.intercom.com/intercom -api-reference/reference/create-an-article )
138
+ #### [ Create an article] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/articles/createarticle )
152
139
153
140
``` typescript
154
141
const article = await client .articles .create ({
155
- title: " Thanks for everything " ,
156
- description: " English description " ,
157
- body: " <p>This is the body in html </p>" ,
142
+ title: " How to create an account " ,
143
+ description: " Example article about creating an account. " ,
144
+ body: " <p>Here are the steps to create an account. </p>" ,
158
145
authorId: 1 ,
159
146
state: " published" ,
160
147
parentId: 1 ,
161
148
parentType: " collection" ,
162
149
translatedContent: {
163
150
fr: {
164
- title: " Allez les verts " ,
165
- description: " French description " ,
166
- body: " <p>French body in html </p>" ,
151
+ title: " Comment créer un compte " ,
152
+ description: " Exemple d'article sur la création d'un compte. " ,
153
+ body: " <p>Voici les étapes pour créer un compte. </p>" ,
167
154
author_id: 1 ,
168
155
state: " published" ,
169
156
},
170
157
},
171
158
});
172
159
```
173
160
174
- #### [ Retrieve an article] ( https://developers.intercom.com/intercom -api-reference/reference/retrieve-an-article )
161
+ #### [ Retrieve an article] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/articles/retrievearticle )
175
162
176
163
``` typescript
177
164
const response = await client .articles .find ({ id: " 123" });
178
165
```
179
166
180
- #### [ Update an article] ( https://developers.intercom.com/intercom -api-reference/reference/update-an-article )
167
+ #### [ Update an article] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/articles/updatearticle )
181
168
182
169
``` typescript
183
170
const article = await client .articles .update ({
184
171
id: " 123" ,
185
- title: " Thanks for everything " ,
186
- description: " English description " ,
187
- body: " <p>This is the body in html </p>" ,
172
+ title: " How to create an account " ,
173
+ description: " Example article about creating an account. " ,
174
+ body: " <p>Here are the steps to create an account. </p>" ,
188
175
authorId: 1 ,
189
176
state: " published" ,
190
177
parentId: 1 ,
191
178
parentType: " collection" ,
192
179
translatedContent: {
193
180
fr: {
194
- title: " Allez les verts " ,
195
- description: " French description " ,
196
- body: " <p>French body in html </p>" ,
181
+ title: " Comment créer un compte " ,
182
+ description: " Exemple d'article sur la création d'un compte. " ,
183
+ body: " <p>Voici les étapes pour créer un compte. </p>" ,
197
184
author_id: 1 ,
198
185
state: " published" ,
199
186
},
200
187
},
201
188
});
202
189
```
203
190
204
- #### [ Delete an article] ( https://developers.intercom.com/intercom -api-reference/reference/delete-an-article )
191
+ #### [ Delete an article] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/articles/deletearticle )
205
192
206
193
``` typescript
207
194
await client .articles .delete ({ id: " 123" });
208
195
```
209
196
210
- #### [ List all articles] ( https://developers.intercom.com/intercom -api-reference/reference/list-all- articles )
197
+ #### [ List all articles] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/ articles/listarticles )
211
198
212
199
``` typescript
213
200
const response = await client .articles .list ({
@@ -218,39 +205,39 @@ const response = await client.articles.list({
218
205
219
206
### Companies
220
207
221
- #### [ Create a company] ( https://developers.intercom.com/intercom -api-reference/reference/create-or-update-company )
208
+ #### [ Create a company] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/companies/createorupdatecompany )
222
209
223
210
``` typescript
224
211
const company = await client .companies .create ({
225
212
createdAt: dateToUnixTimestamp (new Date ()),
226
- companyId: " 46029 " ,
227
- name: " BestCompanyInc ." ,
213
+ companyId: " 1234 " ,
214
+ name: " Acme Inc ." ,
228
215
monthlySpend: 9001 ,
229
- plan: " 1. Get pizzaid " ,
216
+ plan: " Premium " ,
230
217
size: 62049 ,
231
- website: " http://the-best.one " ,
232
- industry: " The Best One " ,
218
+ website: " http://acme-example.com " ,
219
+ industry: " Software " ,
233
220
customAttributes: {},
234
221
});
235
222
```
236
223
237
- #### [ Update a company] ( https://developers.intercom.com/intercom -api-reference/reference/update-a-company )
224
+ #### [ Update a company] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/companies/updatecompany )
238
225
239
226
``` typescript
240
227
const company = await client .companies .update ({
241
228
createdAt: dateToUnixTimestamp (new Date ()),
242
- companyId: " 46029 " ,
243
- name: " BestCompanyInc ." ,
229
+ companyId: " 1234 " ,
230
+ name: " Acme Inc ." ,
244
231
monthlySpend: 9001 ,
245
- plan: " 1. Get pizzaid " ,
232
+ plan: " Premium " ,
246
233
size: 62049 ,
247
- website: " http://the-best.one " ,
248
- industry: " The Best One " ,
234
+ website: " http://acme-example.com " ,
235
+ industry: " Software " ,
249
236
customAttributes: {},
250
237
});
251
238
```
252
239
253
- #### [ Retrieve a company] ( https://developers.intercom.com/intercom -api-reference/reference/view-a-company )
240
+ #### [ Retrieve a company] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/companies/retrieveacompanybyid )
254
241
255
242
##### By id
256
243
@@ -268,15 +255,15 @@ const company = await client.companies.find({
268
255
});
269
256
```
270
257
271
- #### [ Delete a company] ( https://developers.intercom.com/intercom -api-reference/reference/delete-a-company )
258
+ #### [ Delete a company] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/companies/deletecompany )
272
259
273
260
``` typescript
274
261
const company = await client .companies .delete ({
275
262
id: 62049 ,
276
263
});
277
264
```
278
265
279
- #### [ List all companies] ( https://developers.intercom.com/intercom -api-reference/reference/list- companies )
266
+ #### [ List all companies] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/ companies/listallcompanies )
280
267
281
268
##### With pagination
282
269
@@ -297,7 +284,7 @@ const companies = await client.companies.list({
297
284
});
298
285
```
299
286
300
- #### [ Scroll over companies] ( https://developers.intercom.com/intercom -api-reference/reference/iterating-over-all- companies )
287
+ #### [ Scroll over companies] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/ companies/scrolloverallcompanies )
301
288
302
289
##### Using infinite scroll
303
290
@@ -313,7 +300,7 @@ const companies = await client.companies.scroll.next({
313
300
});
314
301
```
315
302
316
- #### [ Attach a contact] ( https://developers.intercom.com/intercom -api-reference/reference/attach-contact-to-company )
303
+ #### [ Attach a contact] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/contacts/attachcontacttoacompany )
317
304
318
305
``` typescript
319
306
const response = await client .companies .attachContact ({
@@ -322,7 +309,7 @@ const response = await client.companies.attachContact({
322
309
});
323
310
```
324
311
325
- #### [ Detach a contact] ( https://developers.intercom.com/intercom -api-reference/reference/detach-contact-from-company )
312
+ #### [ Detach a contact] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/contacts/detachcontactfromacompany )
326
313
327
314
``` typescript
328
315
const response = await client .companies .detachContact ({
@@ -331,7 +318,7 @@ const response = await client.companies.detachContact({
331
318
});
332
319
```
333
320
334
- #### [ List attached contacts] ( https://developers.intercom.com/intercom -api-reference/reference/list-company- contacts )
321
+ #### [ List attached contacts] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/ contacts/listattachedcontacts )
335
322
336
323
``` typescript
337
324
const response = await client .companies .listAttachedContacts ({
@@ -341,7 +328,7 @@ const response = await client.companies.listAttachedContacts({
341
328
});
342
329
```
343
330
344
- #### [ List attached segments] ( https://developers.intercom.com/intercom -api-reference/reference/list-attached-segments-1 )
331
+ #### [ List attached segments] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/contacts/listsegmentsforacontact )
345
332
346
333
``` typescript
347
334
const response = await client .companies .listAttachedSegments ({
@@ -351,16 +338,16 @@ const response = await client.companies.listAttachedSegments({
351
338
352
339
### Contacts
353
340
354
- #### [ Create Contact] ( https://developers.intercom.com/intercom -api-reference/reference/create-contact )
341
+ #### [ Create Contact] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/contacts/createcontact )
355
342
356
343
##### With User Role
357
344
358
345
``` typescript
359
346
const user = await client .contacts .createUser ({
360
347
externalId: " 536e564f316c83104c000020" ,
361
- phone: " +48370044567 " ,
362
- name: " Niko Bellic " ,
363
- avatar: " https://nico-from-gta-iv .com/lets_go_bowling .jpg" ,
348
+ phone: " +447778889999 " ,
349
+ name: " Joe Example " ,
350
+ avatar: " https://example .com/photo .jpg" ,
364
351
signedUpAt: 1638203719 ,
365
352
lastSeenAt: 1638203720 ,
366
353
ownerId: " 536e564f316c83104c000021" ,
@@ -372,36 +359,36 @@ const user = await client.contacts.createUser({
372
359
373
360
``` typescript
374
361
const lead = await client .contacts .createLead ({
375
- phone: " +48370044567 " ,
376
- name: " Roman Bellic " ,
377
- avatar: " https://nico-from-gta-iv .com/lets_go_bowling_yey .jpg" ,
362
+ phone: " +447778889999 " ,
363
+ name: " Joe Example " ,
364
+ avatar: " https://example .com/photo .jpg" ,
378
365
signedUpAt: 1638203719 ,
379
366
lastSeenAt: 1638203720 ,
380
367
ownerId: " 536e564f316c83104c000021" ,
381
368
isUnsubscribedFromEmails: true ,
382
369
});
383
370
```
384
371
385
- #### [ Retrieve a Contact] ( https://developers.intercom.com/intercom -api-reference/reference/get-contact )
372
+ #### [ Retrieve a Contact] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/contacts/showcontact )
386
373
387
374
``` typescript
388
375
const response = await client .contacts .find ({ id: " 123" });
389
376
```
390
377
391
- #### [ Update a Contact] ( https://developers.intercom.com/intercom -api-reference/reference/update-contact )
378
+ #### [ Update a Contact] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/contacts/updatecontact )
392
379
393
380
``` typescript
394
381
const response = await client .contacts .update ({
395
382
id: " 123" ,
396
383
role: Role .USER ,
397
- name: " Roman The Bowling Fan " ,
384
+ name: " Jane Example " ,
398
385
customAttributes: {
399
- callBrother : " Hey Niko, it's me – Roman. Let's go bowling! " ,
386
+ billingType : " Monthly " ,
400
387
},
401
388
});
402
389
```
403
390
404
- #### [ Delete a Contact] ( https://developers.intercom.com/intercom -api-reference/reference/delete-contact )
391
+ #### [ Delete a Contact] ( https://developers.intercom.com/docs/references/rest -api/api.intercom.io/contacts/deletecontact )
405
392
406
393
``` typescript
407
394
const response = await client .contacts .delete ({ id: " 123" });
0 commit comments