= {};
+ if (phrase != null) {
+ _queryParams.phrase = phrase;
+ }
+
+ if (state != null) {
+ _queryParams.state = state;
+ }
+
+ if (helpCenterId != null) {
+ _queryParams.help_center_id = helpCenterId.toString();
+ }
+
+ if (highlight != null) {
+ _queryParams.highlight = highlight.toString();
+ }
+
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "articles/search",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ArticleSearchResponse, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/search");
+ }
+}
diff --git a/src/api/resources/articles/client/index.ts b/src/api/resources/articles/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/articles/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/articles/client/requests/DeleteArticleRequest.ts b/src/api/resources/articles/client/requests/DeleteArticleRequest.ts
new file mode 100644
index 00000000..43cfd9e2
--- /dev/null
+++ b/src/api/resources/articles/client/requests/DeleteArticleRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * article_id: 1
+ * }
+ */
+export interface DeleteArticleRequest {
+ /** The unique identifier for the article which is given by Intercom. */
+ article_id: number;
+}
diff --git a/src/api/resources/articles/client/requests/FindArticleRequest.ts b/src/api/resources/articles/client/requests/FindArticleRequest.ts
new file mode 100644
index 00000000..b333b0d8
--- /dev/null
+++ b/src/api/resources/articles/client/requests/FindArticleRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * article_id: 1
+ * }
+ */
+export interface FindArticleRequest {
+ /** The unique identifier for the article which is given by Intercom. */
+ article_id: number;
+}
diff --git a/src/api/resources/articles/client/requests/ListArticlesRequest.ts b/src/api/resources/articles/client/requests/ListArticlesRequest.ts
new file mode 100644
index 00000000..598bdacf
--- /dev/null
+++ b/src/api/resources/articles/client/requests/ListArticlesRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {}
+ */
+export interface ListArticlesRequest {
+ /** The page of results to fetch. Defaults to first page */
+ page?: number;
+ /** How many results to display per page. Defaults to 15 */
+ per_page?: number;
+}
diff --git a/src/api/resources/articles/client/requests/SearchArticlesRequest.ts b/src/api/resources/articles/client/requests/SearchArticlesRequest.ts
new file mode 100644
index 00000000..3416dd98
--- /dev/null
+++ b/src/api/resources/articles/client/requests/SearchArticlesRequest.ts
@@ -0,0 +1,21 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * phrase: "Getting started",
+ * state: "published",
+ * help_center_id: 1,
+ * highlight: true
+ * }
+ */
+export interface SearchArticlesRequest {
+ /** The phrase within your articles to search for. */
+ phrase?: string;
+ /** The state of the Articles returned. One of `published`, `draft` or `all`. */
+ state?: string;
+ /** The ID of the Help Center to search in. */
+ help_center_id?: number;
+ /** Return a highlighted version of the matching content within your articles. Refer to the response schema for more details. */
+ highlight?: boolean;
+}
diff --git a/src/api/resources/articles/client/requests/UpdateArticleRequest.ts b/src/api/resources/articles/client/requests/UpdateArticleRequest.ts
new file mode 100644
index 00000000..36209811
--- /dev/null
+++ b/src/api/resources/articles/client/requests/UpdateArticleRequest.ts
@@ -0,0 +1,47 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * article_id: 1,
+ * title: "Christmas is here!",
+ * body: "New gifts in store for the jolly season
"
+ * }
+ *
+ * @example
+ * {
+ * article_id: 1,
+ * title: "Christmas is here!",
+ * body: "New gifts in store for the jolly season
"
+ * }
+ */
+export interface UpdateArticleRequest {
+ /** The unique identifier for the article which is given by Intercom. */
+ article_id: number;
+ /** The title of the article.For multilingual articles, this will be the title of the default language's content. */
+ title?: string;
+ /** The description of the article. For multilingual articles, this will be the description of the default language's content. */
+ description?: string;
+ /** The content of the article. For multilingual articles, this will be the body of the default language's content. */
+ body?: string;
+ /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */
+ author_id?: number;
+ /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */
+ state?: UpdateArticleRequest.State;
+ /** The id of the article's parent collection or section. An article without this field stands alone. */
+ parent_id?: string;
+ /** The type of parent, which can either be a `collection` or `section`. */
+ parent_type?: string;
+ translated_content?: Intercom.ArticleTranslatedContent;
+}
+
+export namespace UpdateArticleRequest {
+ /** Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */
+ export const State = {
+ Published: "published",
+ Draft: "draft",
+ } as const;
+ export type State = (typeof State)[keyof typeof State];
+}
diff --git a/src/api/resources/articles/client/requests/index.ts b/src/api/resources/articles/client/requests/index.ts
new file mode 100644
index 00000000..9376442d
--- /dev/null
+++ b/src/api/resources/articles/client/requests/index.ts
@@ -0,0 +1,5 @@
+export type { DeleteArticleRequest } from "./DeleteArticleRequest.js";
+export type { FindArticleRequest } from "./FindArticleRequest.js";
+export type { ListArticlesRequest } from "./ListArticlesRequest.js";
+export type { SearchArticlesRequest } from "./SearchArticlesRequest.js";
+export type { UpdateArticleRequest } from "./UpdateArticleRequest.js";
diff --git a/src/api/resources/articles/index.ts b/src/api/resources/articles/index.ts
new file mode 100644
index 00000000..d9adb1af
--- /dev/null
+++ b/src/api/resources/articles/index.ts
@@ -0,0 +1,2 @@
+export * from "./client/index.js";
+export * from "./types/index.js";
diff --git a/src/api/resources/articles/types/Article.ts b/src/api/resources/articles/types/Article.ts
new file mode 100644
index 00000000..02667c69
--- /dev/null
+++ b/src/api/resources/articles/types/Article.ts
@@ -0,0 +1,10 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * The Articles API is a central place to gather all information and take actions on your articles. Articles can live within collections and sections, or alternatively they can stand alone.
+ */
+export interface Article extends Intercom.ArticleListItem {
+ statistics?: Intercom.ArticleStatistics;
+}
diff --git a/src/api/resources/articles/types/ArticleListItem.ts b/src/api/resources/articles/types/ArticleListItem.ts
new file mode 100644
index 00000000..426c862a
--- /dev/null
+++ b/src/api/resources/articles/types/ArticleListItem.ts
@@ -0,0 +1,49 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * The data returned about your articles when you list them.
+ */
+export interface ArticleListItem {
+ /** The type of object - `article`. */
+ type?: "article";
+ /** The unique identifier for the article which is given by Intercom. */
+ id: string;
+ /** The id of the workspace which the article belongs to. */
+ workspace_id: string;
+ /** The title of the article. For multilingual articles, this will be the title of the default language's content. */
+ title: string;
+ /** The description of the article. For multilingual articles, this will be the description of the default language's content. */
+ description?: string;
+ /** The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. */
+ body?: string;
+ /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */
+ author_id: number;
+ /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */
+ state: ArticleListItem.State;
+ /** The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. */
+ created_at: number;
+ /** The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. */
+ updated_at: number;
+ /** The URL of the article. For multilingual articles, this will be the URL of the default language's content. */
+ url?: string;
+ /** The id of the article's parent collection or section. An article without this field stands alone. */
+ parent_id?: number;
+ /** The ids of the article's parent collections or sections. An article without this field stands alone. */
+ parent_ids?: number[];
+ /** The type of parent, which can either be a `collection` or `section`. */
+ parent_type?: string;
+ /** The default locale of the help center. This field is only returned for multilingual help centers. */
+ default_locale?: string;
+ translated_content?: Intercom.ArticleTranslatedContent;
+}
+
+export namespace ArticleListItem {
+ /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */
+ export const State = {
+ Published: "published",
+ Draft: "draft",
+ } as const;
+ export type State = (typeof State)[keyof typeof State];
+}
diff --git a/src/api/resources/articles/types/ArticleSearchHighlights.ts b/src/api/resources/articles/types/ArticleSearchHighlights.ts
new file mode 100644
index 00000000..c80f22fa
--- /dev/null
+++ b/src/api/resources/articles/types/ArticleSearchHighlights.ts
@@ -0,0 +1,61 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * The highlighted results of an Article search. In the examples provided my search query is always "my query".
+ */
+export interface ArticleSearchHighlights {
+ /** The ID of the corresponding article. */
+ article_id?: string;
+ /** An Article title highlighted. */
+ highlighted_title?: ArticleSearchHighlights.HighlightedTitle.Item[];
+ /** An Article description and body text highlighted. */
+ highlighted_summary?: ArticleSearchHighlights.HighlightedSummary.Item[][];
+}
+
+export namespace ArticleSearchHighlights {
+ export type HighlightedTitle = HighlightedTitle.Item[];
+
+ export namespace HighlightedTitle {
+ /**
+ * A highlighted article title.
+ */
+ export interface Item {
+ /** The type of text - `highlight` or `plain`. */
+ type?: Item.Type;
+ /** The text of the title. */
+ text?: string;
+ }
+
+ export namespace Item {
+ /** The type of text - `highlight` or `plain`. */
+ export const Type = {
+ Highlight: "highlight",
+ Plain: "plain",
+ } as const;
+ export type Type = (typeof Type)[keyof typeof Type];
+ }
+ }
+
+ export type HighlightedSummary = HighlightedSummary.Item[];
+
+ export namespace HighlightedSummary {
+ /**
+ * An instance of highlighted summary text.
+ */
+ export interface Item {
+ /** The type of text - `highlight` or `plain`. */
+ type?: Item.Type;
+ /** The text of the title. */
+ text?: string;
+ }
+
+ export namespace Item {
+ /** The type of text - `highlight` or `plain`. */
+ export const Type = {
+ Highlight: "highlight",
+ Plain: "plain",
+ } as const;
+ export type Type = (typeof Type)[keyof typeof Type];
+ }
+ }
+}
diff --git a/src/api/resources/articles/types/ArticleSearchResponse.ts b/src/api/resources/articles/types/ArticleSearchResponse.ts
new file mode 100644
index 00000000..349062a8
--- /dev/null
+++ b/src/api/resources/articles/types/ArticleSearchResponse.ts
@@ -0,0 +1,28 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * The results of an Article search
+ */
+export interface ArticleSearchResponse {
+ /** The type of the object - `list`. */
+ type?: "list";
+ /** The total number of Articles matching the search query */
+ total_count?: number;
+ /** An object containing the results of the search. */
+ data?: ArticleSearchResponse.Data;
+ pages?: Intercom.CursorPages;
+}
+
+export namespace ArticleSearchResponse {
+ /**
+ * An object containing the results of the search.
+ */
+ export interface Data {
+ /** An array of Article objects */
+ articles?: Intercom.Article[];
+ /** A corresponding array of highlighted Article content */
+ highlights?: Intercom.ArticleSearchHighlights[];
+ }
+}
diff --git a/src/api/resources/articles/types/InternalArticle.ts b/src/api/resources/articles/types/InternalArticle.ts
new file mode 100644
index 00000000..dec37b5f
--- /dev/null
+++ b/src/api/resources/articles/types/InternalArticle.ts
@@ -0,0 +1,8 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * The Internal Articles API is a central place to gather all information and take actions on your internal articles.
+ */
+export type InternalArticle = Intercom.InternalArticleListItem;
diff --git a/src/api/resources/articles/types/index.ts b/src/api/resources/articles/types/index.ts
new file mode 100644
index 00000000..ac1a15f9
--- /dev/null
+++ b/src/api/resources/articles/types/index.ts
@@ -0,0 +1,5 @@
+export * from "./Article.js";
+export * from "./ArticleListItem.js";
+export * from "./ArticleSearchHighlights.js";
+export * from "./ArticleSearchResponse.js";
+export * from "./InternalArticle.js";
diff --git a/src/api/resources/awayStatusReasons/client/Client.ts b/src/api/resources/awayStatusReasons/client/Client.ts
new file mode 100644
index 00000000..22df5064
--- /dev/null
+++ b/src/api/resources/awayStatusReasons/client/Client.ts
@@ -0,0 +1,92 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace AwayStatusReasonsClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+/**
+ * Everything about your Away Status Reasons
+ */
+export class AwayStatusReasonsClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: AwayStatusReasonsClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * Returns a list of all away status reasons configured for the workspace, including deleted ones.
+ *
+ * @param {AwayStatusReasonsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.awayStatusReasons.listAwayStatusReasons()
+ */
+ public listAwayStatusReasons(
+ requestOptions?: AwayStatusReasonsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__listAwayStatusReasons(requestOptions));
+ }
+
+ private async __listAwayStatusReasons(
+ requestOptions?: AwayStatusReasonsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "away_status_reasons",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.AwayStatusReason[], rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/away_status_reasons");
+ }
+}
diff --git a/src/api/resources/awayStatusReasons/client/index.ts b/src/api/resources/awayStatusReasons/client/index.ts
new file mode 100644
index 00000000..cb0ff5c3
--- /dev/null
+++ b/src/api/resources/awayStatusReasons/client/index.ts
@@ -0,0 +1 @@
+export {};
diff --git a/src/api/resources/awayStatusReasons/index.ts b/src/api/resources/awayStatusReasons/index.ts
new file mode 100644
index 00000000..914b8c3c
--- /dev/null
+++ b/src/api/resources/awayStatusReasons/index.ts
@@ -0,0 +1 @@
+export * from "./client/index.js";
diff --git a/src/api/resources/calls/client/Client.ts b/src/api/resources/calls/client/Client.ts
new file mode 100644
index 00000000..956fcfa5
--- /dev/null
+++ b/src/api/resources/calls/client/Client.ts
@@ -0,0 +1,405 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace CallsClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+/**
+ * Everything about your Calls
+ */
+export class CallsClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: CallsClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * Retrieve a paginated list of calls.
+ *
+ * @param {Intercom.ListCallsRequest} request
+ * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.calls.listCalls({
+ * page: 1,
+ * per_page: 1
+ * })
+ */
+ public listCalls(
+ request: Intercom.ListCallsRequest = {},
+ requestOptions?: CallsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__listCalls(request, requestOptions));
+ }
+
+ private async __listCalls(
+ request: Intercom.ListCallsRequest = {},
+ requestOptions?: CallsClient.RequestOptions,
+ ): Promise> {
+ const { page, per_page: perPage } = request;
+ const _queryParams: Record = {};
+ if (page != null) {
+ _queryParams.page = page.toString();
+ }
+
+ if (perPage != null) {
+ _queryParams.per_page = perPage.toString();
+ }
+
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "calls",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.CallList, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls");
+ }
+
+ /**
+ * Retrieve a single call by id.
+ *
+ * @param {Intercom.ShowCallRequest} request
+ * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.calls.showCall({
+ * call_id: "call_id"
+ * })
+ */
+ public showCall(
+ request: Intercom.ShowCallRequest,
+ requestOptions?: CallsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__showCall(request, requestOptions));
+ }
+
+ private async __showCall(
+ request: Intercom.ShowCallRequest,
+ requestOptions?: CallsClient.RequestOptions,
+ ): Promise> {
+ const { call_id: callId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `calls/${core.url.encodePathParam(callId)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Call, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls/{call_id}");
+ }
+
+ /**
+ * Redirects to a signed URL for the call's recording if it exists.
+ *
+ * @param {Intercom.ShowCallRecordingRequest} request
+ * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.calls.showCallRecording({
+ * call_id: "call_id"
+ * })
+ */
+ public showCallRecording(
+ request: Intercom.ShowCallRecordingRequest,
+ requestOptions?: CallsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__showCallRecording(request, requestOptions));
+ }
+
+ private async __showCallRecording(
+ request: Intercom.ShowCallRecordingRequest,
+ requestOptions?: CallsClient.RequestOptions,
+ ): Promise> {
+ const { call_id: callId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `calls/${core.url.encodePathParam(callId)}/recording`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: undefined, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls/{call_id}/recording");
+ }
+
+ /**
+ * Returns the transcript for the specified call as a downloadable text file.
+ *
+ * @param {Intercom.ShowCallTranscriptRequest} request
+ * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.calls.showCallTranscript({
+ * call_id: "call_id"
+ * })
+ */
+ public showCallTranscript(
+ request: Intercom.ShowCallTranscriptRequest,
+ requestOptions?: CallsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__showCallTranscript(request, requestOptions));
+ }
+
+ private async __showCallTranscript(
+ request: Intercom.ShowCallTranscriptRequest,
+ requestOptions?: CallsClient.RequestOptions,
+ ): Promise> {
+ const { call_id: callId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `calls/${core.url.encodePathParam(callId)}/transcript`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ responseType: "text",
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as string, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls/{call_id}/transcript");
+ }
+
+ /**
+ * Retrieve calls by a list of conversation ids and include transcripts when available.
+ * A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned.
+ *
+ * @param {Intercom.ListCallsWithTranscriptsRequest} request
+ * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.calls.listCallsWithTranscripts({
+ * conversation_ids: ["64619700005694", "64619700005695"]
+ * })
+ */
+ public listCallsWithTranscripts(
+ request: Intercom.ListCallsWithTranscriptsRequest,
+ requestOptions?: CallsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__listCallsWithTranscripts(request, requestOptions));
+ }
+
+ private async __listCallsWithTranscripts(
+ request: Intercom.ListCallsWithTranscriptsRequest,
+ requestOptions?: CallsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "calls/search",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.ListCallsWithTranscriptsResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/calls/search");
+ }
+}
diff --git a/src/api/resources/calls/client/index.ts b/src/api/resources/calls/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/calls/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/calls/client/requests/ListCallsRequest.ts b/src/api/resources/calls/client/requests/ListCallsRequest.ts
new file mode 100644
index 00000000..74c29012
--- /dev/null
+++ b/src/api/resources/calls/client/requests/ListCallsRequest.ts
@@ -0,0 +1,15 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * page: 1,
+ * per_page: 1
+ * }
+ */
+export interface ListCallsRequest {
+ /** The page of results to fetch. Defaults to first page */
+ page?: number;
+ /** How many results to display per page. Defaults to 25. Max 25. */
+ per_page?: number;
+}
diff --git a/src/api/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts b/src/api/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts
new file mode 100644
index 00000000..92d644c1
--- /dev/null
+++ b/src/api/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * conversation_ids: ["64619700005694", "64619700005695"]
+ * }
+ */
+export interface ListCallsWithTranscriptsRequest {
+ /** A list of conversation ids to fetch calls for. Maximum 20. */
+ conversation_ids: string[];
+}
diff --git a/src/api/resources/calls/client/requests/ShowCallRecordingRequest.ts b/src/api/resources/calls/client/requests/ShowCallRecordingRequest.ts
new file mode 100644
index 00000000..7b9543df
--- /dev/null
+++ b/src/api/resources/calls/client/requests/ShowCallRecordingRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * call_id: "call_id"
+ * }
+ */
+export interface ShowCallRecordingRequest {
+ /** The id of the call */
+ call_id: string;
+}
diff --git a/src/api/resources/calls/client/requests/ShowCallRequest.ts b/src/api/resources/calls/client/requests/ShowCallRequest.ts
new file mode 100644
index 00000000..52c4cd8c
--- /dev/null
+++ b/src/api/resources/calls/client/requests/ShowCallRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * call_id: "call_id"
+ * }
+ */
+export interface ShowCallRequest {
+ /** The id of the call to retrieve */
+ call_id: string;
+}
diff --git a/src/api/resources/calls/client/requests/ShowCallTranscriptRequest.ts b/src/api/resources/calls/client/requests/ShowCallTranscriptRequest.ts
new file mode 100644
index 00000000..9c2bbe4e
--- /dev/null
+++ b/src/api/resources/calls/client/requests/ShowCallTranscriptRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * call_id: "call_id"
+ * }
+ */
+export interface ShowCallTranscriptRequest {
+ /** The id of the call */
+ call_id: string;
+}
diff --git a/src/api/resources/calls/client/requests/index.ts b/src/api/resources/calls/client/requests/index.ts
new file mode 100644
index 00000000..08b2eb9c
--- /dev/null
+++ b/src/api/resources/calls/client/requests/index.ts
@@ -0,0 +1,5 @@
+export type { ListCallsRequest } from "./ListCallsRequest.js";
+export type { ListCallsWithTranscriptsRequest } from "./ListCallsWithTranscriptsRequest.js";
+export type { ShowCallRecordingRequest } from "./ShowCallRecordingRequest.js";
+export type { ShowCallRequest } from "./ShowCallRequest.js";
+export type { ShowCallTranscriptRequest } from "./ShowCallTranscriptRequest.js";
diff --git a/src/api/resources/calls/index.ts b/src/api/resources/calls/index.ts
new file mode 100644
index 00000000..d9adb1af
--- /dev/null
+++ b/src/api/resources/calls/index.ts
@@ -0,0 +1,2 @@
+export * from "./client/index.js";
+export * from "./types/index.js";
diff --git a/src/api/resources/calls/types/Call.ts b/src/api/resources/calls/types/Call.ts
new file mode 100644
index 00000000..33b20803
--- /dev/null
+++ b/src/api/resources/calls/types/Call.ts
@@ -0,0 +1,42 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * Represents a phone call in Intercom
+ */
+export interface Call {
+ /** String representing the object's type. Always has the value `call`. */
+ type?: string;
+ /** The id of the call. */
+ id?: string;
+ /** The id of the conversation associated with the call, if any. */
+ conversation_id?: string;
+ /** The id of the admin associated with the call, if any. */
+ admin_id?: string;
+ /** The id of the contact associated with the call, if any. */
+ contact_id?: string;
+ /** The current state of the call. */
+ state?: string;
+ initiated_at?: Intercom.Datetime;
+ answered_at?: Intercom.Datetime;
+ ended_at?: Intercom.Datetime;
+ created_at?: Intercom.Datetime;
+ updated_at?: Intercom.Datetime;
+ /** API URL to download or redirect to the call recording if available. */
+ recording_url?: string;
+ /** API URL to download or redirect to the call transcript if available. */
+ transcription_url?: string;
+ /** The type of call. */
+ call_type?: string;
+ /** The direction of the call. */
+ direction?: string;
+ /** The reason for the call end, if applicable. */
+ ended_reason?: string;
+ /** The phone number involved in the call, in E.164 format. */
+ phone?: string;
+ /** API URL to the AI Agent (Fin) call recording if available. */
+ fin_recording_url?: string;
+ /** API URL to the AI Agent (Fin) call transcript if available. */
+ fin_transcription_url?: string;
+}
diff --git a/src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts b/src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts
new file mode 100644
index 00000000..f37c83bc
--- /dev/null
+++ b/src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts
@@ -0,0 +1,21 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+export interface ListCallsWithTranscriptsResponse {
+ type?: string;
+ data?: ListCallsWithTranscriptsResponse.Data.Item[];
+}
+
+export namespace ListCallsWithTranscriptsResponse {
+ export type Data = Data.Item[];
+
+ export namespace Data {
+ export interface Item extends Intercom.Call {
+ /** The call transcript if available, otherwise an empty array. */
+ transcript?: Record[];
+ /** The status of the transcript if available. */
+ transcript_status?: string;
+ }
+ }
+}
diff --git a/src/api/resources/calls/types/index.ts b/src/api/resources/calls/types/index.ts
new file mode 100644
index 00000000..a7b7c7f7
--- /dev/null
+++ b/src/api/resources/calls/types/index.ts
@@ -0,0 +1,2 @@
+export * from "./Call.js";
+export * from "./ListCallsWithTranscriptsResponse.js";
diff --git a/src/api/resources/companies/client/Client.ts b/src/api/resources/companies/client/Client.ts
new file mode 100644
index 00000000..db9cb03e
--- /dev/null
+++ b/src/api/resources/companies/client/Client.ts
@@ -0,0 +1,1004 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace CompaniesClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+/**
+ * Everything about your Companies
+ */
+export class CompaniesClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: CompaniesClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * You can fetch a single company by passing in `company_id` or `name`.
+ *
+ * `https://api.intercom.io/companies?name={name}`
+ *
+ * `https://api.intercom.io/companies?company_id={company_id}`
+ *
+ * You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter.
+ *
+ * `https://api.intercom.io/companies?tag_id={tag_id}`
+ *
+ * `https://api.intercom.io/companies?segment_id={segment_id}`
+ *
+ * @param {Intercom.RetrieveCompanyRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.companies.retrieve({
+ * name: "my company",
+ * company_id: "12345",
+ * tag_id: "678910",
+ * segment_id: "98765",
+ * page: 1,
+ * per_page: 1
+ * })
+ */
+ public retrieve(
+ request: Intercom.RetrieveCompanyRequest = {},
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__retrieve(request, requestOptions));
+ }
+
+ private async __retrieve(
+ request: Intercom.RetrieveCompanyRequest = {},
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const { name, company_id: companyId, tag_id: tagId, segment_id: segmentId, page, per_page: perPage } = request;
+ const _queryParams: Record = {};
+ if (name != null) {
+ _queryParams.name = name;
+ }
+
+ if (companyId != null) {
+ _queryParams.company_id = companyId;
+ }
+
+ if (tagId != null) {
+ _queryParams.tag_id = tagId;
+ }
+
+ if (segmentId != null) {
+ _queryParams.segment_id = segmentId;
+ }
+
+ if (page != null) {
+ _queryParams.page = page.toString();
+ }
+
+ if (perPage != null) {
+ _queryParams.per_page = perPage.toString();
+ }
+
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "companies",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.CompaniesRetrieveResponse, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies");
+ }
+
+ /**
+ * You can create or update a company.
+ *
+ * Companies will be only visible in Intercom when there is at least one associated user.
+ *
+ * Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated.
+ *
+ * {% admonition type="warning" name="Using `company_id`" %}
+ * You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company.
+ * {% /admonition %}
+ *
+ * @param {Intercom.CreateOrUpdateCompanyRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.companies.createOrUpdate({
+ * name: "my company",
+ * company_id: "company_remote_id",
+ * remote_created_at: 1374138000
+ * })
+ *
+ * @example
+ * await client.companies.createOrUpdate()
+ */
+ public createOrUpdate(
+ request?: Intercom.CreateOrUpdateCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__createOrUpdate(request, requestOptions));
+ }
+
+ private async __createOrUpdate(
+ request?: Intercom.CreateOrUpdateCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "companies",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request != null ? request : undefined,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies");
+ }
+
+ /**
+ * You can fetch a single company.
+ *
+ * @param {Intercom.FindCompanyRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.companies.find({
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632"
+ * })
+ */
+ public find(
+ request: Intercom.FindCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions));
+ }
+
+ private async __find(
+ request: Intercom.FindCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const { company_id: companyId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `companies/${core.url.encodePathParam(companyId)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{company_id}");
+ }
+
+ /**
+ * You can update a single company using the Intercom provisioned `id`.
+ *
+ * {% admonition type="warning" name="Using `company_id`" %}
+ * When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company.
+ * {% /admonition %}
+ *
+ * @param {Intercom.UpdateCompanyRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.companies.update({
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632",
+ * body: {
+ * name: "my company",
+ * website: "http://www.mycompany.com/"
+ * }
+ * })
+ *
+ * @example
+ * await client.companies.update({
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632",
+ * body: {}
+ * })
+ */
+ public update(
+ request: Intercom.UpdateCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions));
+ }
+
+ private async __update(
+ request: Intercom.UpdateCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const { company_id: companyId, body: _body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `companies/${core.url.encodePathParam(companyId)}`,
+ ),
+ method: "PUT",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body != null ? _body : undefined,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/companies/{company_id}");
+ }
+
+ /**
+ * You can delete a single company.
+ *
+ * @param {Intercom.DeleteCompanyRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.companies.delete({
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632"
+ * })
+ */
+ public delete(
+ request: Intercom.DeleteCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions));
+ }
+
+ private async __delete(
+ request: Intercom.DeleteCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const { company_id: companyId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `companies/${core.url.encodePathParam(companyId)}`,
+ ),
+ method: "DELETE",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.DeletedCompanyObject, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/companies/{company_id}");
+ }
+
+ /**
+ * You can fetch a list of all contacts that belong to a company.
+ *
+ * @param {Intercom.ListAttachedContactsRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.companies.listAttachedContacts({
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632"
+ * })
+ */
+ public listAttachedContacts(
+ request: Intercom.ListAttachedContactsRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__listAttachedContacts(request, requestOptions));
+ }
+
+ private async __listAttachedContacts(
+ request: Intercom.ListAttachedContactsRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const { company_id: companyId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `companies/${core.url.encodePathParam(companyId)}/contacts`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.CompanyAttachedContacts, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/companies/{company_id}/contacts",
+ );
+ }
+
+ /**
+ * You can fetch a list of all segments that belong to a company.
+ *
+ * @param {Intercom.ListSegmentsAttachedToCompanyRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.companies.listAttachedSegments({
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632"
+ * })
+ */
+ public listAttachedSegments(
+ request: Intercom.ListSegmentsAttachedToCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__listAttachedSegments(request, requestOptions));
+ }
+
+ private async __listAttachedSegments(
+ request: Intercom.ListSegmentsAttachedToCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const { company_id: companyId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `companies/${core.url.encodePathParam(companyId)}/segments`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.CompanyAttachedSegments, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/companies/{company_id}/segments",
+ );
+ }
+
+ /**
+ * You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first.
+ *
+ * Note that the API does not include companies who have no associated users in list responses.
+ *
+ * When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies).
+ * {% admonition type="warning" name="Pagination" %}
+ * You can use pagination to limit the number of results returned. The default is `20` results per page.
+ * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param.
+ * {% /admonition %}
+ *
+ * @param {Intercom.ListCompaniesRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.companies.list({
+ * page: 1,
+ * per_page: 1,
+ * order: "desc"
+ * })
+ */
+ public async list(
+ request: Intercom.ListCompaniesRequest = {},
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (request: Intercom.ListCompaniesRequest): Promise> => {
+ const { page, per_page: perPage, order } = request;
+ const _queryParams: Record = {};
+ if (page != null) {
+ _queryParams.page = page.toString();
+ }
+ if (perPage != null) {
+ _queryParams.per_page = perPage.toString();
+ }
+ if (order != null) {
+ _queryParams.order = order;
+ }
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "companies/list",
+ ),
+ method: "POST",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.CompanyList, rawResponse: _response.rawResponse };
+ }
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies/list");
+ },
+ );
+ let _offset = request?.page != null ? request?.page : 1;
+ const dataWithRawResponse = await list(request).withRawResponse();
+ return new core.Page({
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) => (response?.data ?? []).length > 0,
+ getItems: (response) => response?.data ?? [],
+ loadPage: (_response) => {
+ _offset += 1;
+ return list(core.setObjectProperty(request, "page", _offset));
+ },
+ });
+ }
+
+ /**
+ * The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset.
+ *
+ * - Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
+ * - If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
+ * - If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
+ *
+ * {% admonition type="info" name="Scroll Parameter" %}
+ * You can get the first page of companies by simply sending a GET request to the scroll endpoint.
+ * For subsequent requests you will need to use the scroll parameter from the response.
+ * {% /admonition %}
+ * {% admonition type="danger" name="Scroll network timeouts" %}
+ * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message:
+ * "Request failed due to an internal network error. Please restart the scroll operation."
+ * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll.
+ * {% /admonition %}
+ *
+ * @param {Intercom.ScrollCompaniesRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.companies.scroll({
+ * scroll_param: "scroll_param"
+ * })
+ */
+ public async scroll(
+ request: Intercom.ScrollCompaniesRequest = {},
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Intercom.ScrollCompaniesRequest,
+ ): Promise> => {
+ const { scroll_param: scrollParam } = request;
+ const _queryParams: Record = {};
+ if (scrollParam != null) {
+ _queryParams.scroll_param = scrollParam;
+ }
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "companies/scroll",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.CompanyScroll | undefined,
+ rawResponse: _response.rawResponse,
+ };
+ }
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/scroll");
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
+ return new core.Page({
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.scroll_param != null &&
+ !(typeof response?.scroll_param === "string" && response?.scroll_param === ""),
+ getItems: (response) => response?.data ?? [],
+ loadPage: (response) => {
+ return list(core.setObjectProperty(request, "scroll_param", response?.scroll_param));
+ },
+ });
+ }
+
+ /**
+ * You can attach a company to a single contact.
+ *
+ * @param {Intercom.AttachContactToCompanyRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.companies.attachContact({
+ * contact_id: "contact_id",
+ * id: "6762f09a1bb69f9f2193bb34"
+ * })
+ *
+ * @example
+ * await client.companies.attachContact({
+ * contact_id: "contact_id",
+ * id: "58a430d35458202d41b1e65b"
+ * })
+ *
+ * @example
+ * await client.companies.attachContact({
+ * contact_id: "contact_id",
+ * id: "123"
+ * })
+ */
+ public attachContact(
+ request: Intercom.AttachContactToCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__attachContact(request, requestOptions));
+ }
+
+ private async __attachContact(
+ request: Intercom.AttachContactToCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId, ..._body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/companies`,
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/contacts/{contact_id}/companies",
+ );
+ }
+
+ /**
+ * You can detach a company from a single contact.
+ *
+ * @param {Intercom.DetachContactFromCompanyRequest} request
+ * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.companies.detachContact({
+ * contact_id: "58a430d35458202d41b1e65b",
+ * company_id: "58a430d35458202d41b1e65b"
+ * })
+ */
+ public detachContact(
+ request: Intercom.DetachContactFromCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__detachContact(request, requestOptions));
+ }
+
+ private async __detachContact(
+ request: Intercom.DetachContactFromCompanyRequest,
+ requestOptions?: CompaniesClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId, company_id: companyId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/companies/${core.url.encodePathParam(companyId)}`,
+ ),
+ method: "DELETE",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "DELETE",
+ "/contacts/{contact_id}/companies/{company_id}",
+ );
+ }
+}
diff --git a/src/api/resources/companies/client/index.ts b/src/api/resources/companies/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/companies/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/companies/client/requests/AttachContactToCompanyRequest.ts b/src/api/resources/companies/client/requests/AttachContactToCompanyRequest.ts
new file mode 100644
index 00000000..95995f1a
--- /dev/null
+++ b/src/api/resources/companies/client/requests/AttachContactToCompanyRequest.ts
@@ -0,0 +1,27 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "contact_id",
+ * id: "6762f09a1bb69f9f2193bb34"
+ * }
+ *
+ * @example
+ * {
+ * contact_id: "contact_id",
+ * id: "58a430d35458202d41b1e65b"
+ * }
+ *
+ * @example
+ * {
+ * contact_id: "contact_id",
+ * id: "123"
+ * }
+ */
+export interface AttachContactToCompanyRequest {
+ /** The unique identifier for the contact which is given by Intercom */
+ contact_id: string;
+ /** The unique identifier for the company which is given by Intercom */
+ id: string;
+}
diff --git a/src/api/resources/companies/client/requests/DeleteCompanyRequest.ts b/src/api/resources/companies/client/requests/DeleteCompanyRequest.ts
new file mode 100644
index 00000000..89d10288
--- /dev/null
+++ b/src/api/resources/companies/client/requests/DeleteCompanyRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632"
+ * }
+ */
+export interface DeleteCompanyRequest {
+ /** The unique identifier for the company which is given by Intercom */
+ company_id: string;
+}
diff --git a/src/api/resources/companies/client/requests/DetachContactFromCompanyRequest.ts b/src/api/resources/companies/client/requests/DetachContactFromCompanyRequest.ts
new file mode 100644
index 00000000..6b35eccd
--- /dev/null
+++ b/src/api/resources/companies/client/requests/DetachContactFromCompanyRequest.ts
@@ -0,0 +1,15 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "58a430d35458202d41b1e65b",
+ * company_id: "58a430d35458202d41b1e65b"
+ * }
+ */
+export interface DetachContactFromCompanyRequest {
+ /** The unique identifier for the contact which is given by Intercom */
+ contact_id: string;
+ /** The unique identifier for the company which is given by Intercom */
+ company_id: string;
+}
diff --git a/src/api/resources/companies/client/requests/FindCompanyRequest.ts b/src/api/resources/companies/client/requests/FindCompanyRequest.ts
new file mode 100644
index 00000000..6be81172
--- /dev/null
+++ b/src/api/resources/companies/client/requests/FindCompanyRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632"
+ * }
+ */
+export interface FindCompanyRequest {
+ /** The unique identifier for the company which is given by Intercom */
+ company_id: string;
+}
diff --git a/src/api/resources/companies/client/requests/ListAttachedContactsRequest.ts b/src/api/resources/companies/client/requests/ListAttachedContactsRequest.ts
new file mode 100644
index 00000000..544f392f
--- /dev/null
+++ b/src/api/resources/companies/client/requests/ListAttachedContactsRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632"
+ * }
+ */
+export interface ListAttachedContactsRequest {
+ /** The unique identifier for the company which is given by Intercom */
+ company_id: string;
+}
diff --git a/src/api/resources/companies/client/requests/ListCompaniesRequest.ts b/src/api/resources/companies/client/requests/ListCompaniesRequest.ts
new file mode 100644
index 00000000..ff355c19
--- /dev/null
+++ b/src/api/resources/companies/client/requests/ListCompaniesRequest.ts
@@ -0,0 +1,18 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * page: 1,
+ * per_page: 1,
+ * order: "desc"
+ * }
+ */
+export interface ListCompaniesRequest {
+ /** The page of results to fetch. Defaults to first page */
+ page?: number;
+ /** How many results to return per page. Defaults to 15 */
+ per_page?: number;
+ /** `asc` or `desc`. Return the companies in ascending or descending order. Defaults to desc */
+ order?: string;
+}
diff --git a/src/api/resources/companies/client/requests/ListSegmentsAttachedToCompanyRequest.ts b/src/api/resources/companies/client/requests/ListSegmentsAttachedToCompanyRequest.ts
new file mode 100644
index 00000000..36c2e57f
--- /dev/null
+++ b/src/api/resources/companies/client/requests/ListSegmentsAttachedToCompanyRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632"
+ * }
+ */
+export interface ListSegmentsAttachedToCompanyRequest {
+ /** The unique identifier for the company which is given by Intercom */
+ company_id: string;
+}
diff --git a/src/api/resources/companies/client/requests/RetrieveCompanyRequest.ts b/src/api/resources/companies/client/requests/RetrieveCompanyRequest.ts
new file mode 100644
index 00000000..a3314297
--- /dev/null
+++ b/src/api/resources/companies/client/requests/RetrieveCompanyRequest.ts
@@ -0,0 +1,27 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * name: "my company",
+ * company_id: "12345",
+ * tag_id: "678910",
+ * segment_id: "98765",
+ * page: 1,
+ * per_page: 1
+ * }
+ */
+export interface RetrieveCompanyRequest {
+ /** The `name` of the company to filter by. */
+ name?: string;
+ /** The `company_id` of the company to filter by. */
+ company_id?: string;
+ /** The `tag_id` of the company to filter by. */
+ tag_id?: string;
+ /** The `segment_id` of the company to filter by. */
+ segment_id?: string;
+ /** The page of results to fetch. Defaults to first page */
+ page?: number;
+ /** How many results to display per page. Defaults to 15 */
+ per_page?: number;
+}
diff --git a/src/api/resources/companies/client/requests/ScrollCompaniesRequest.ts b/src/api/resources/companies/client/requests/ScrollCompaniesRequest.ts
new file mode 100644
index 00000000..56661c7f
--- /dev/null
+++ b/src/api/resources/companies/client/requests/ScrollCompaniesRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * scroll_param: "scroll_param"
+ * }
+ */
+export interface ScrollCompaniesRequest {
+ /** */
+ scroll_param?: string;
+}
diff --git a/src/api/resources/companies/client/requests/UpdateCompanyRequest.ts b/src/api/resources/companies/client/requests/UpdateCompanyRequest.ts
new file mode 100644
index 00000000..6bb331ec
--- /dev/null
+++ b/src/api/resources/companies/client/requests/UpdateCompanyRequest.ts
@@ -0,0 +1,25 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632",
+ * body: {
+ * name: "my company",
+ * website: "http://www.mycompany.com/"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632",
+ * body: {}
+ * }
+ */
+export interface UpdateCompanyRequest {
+ /** The unique identifier for the company which is given by Intercom */
+ company_id: string;
+ body?: Intercom.UpdateCompanyRequestBody;
+}
diff --git a/src/api/resources/companies/client/requests/index.ts b/src/api/resources/companies/client/requests/index.ts
new file mode 100644
index 00000000..3c6204dc
--- /dev/null
+++ b/src/api/resources/companies/client/requests/index.ts
@@ -0,0 +1,10 @@
+export type { AttachContactToCompanyRequest } from "./AttachContactToCompanyRequest.js";
+export type { DeleteCompanyRequest } from "./DeleteCompanyRequest.js";
+export type { DetachContactFromCompanyRequest } from "./DetachContactFromCompanyRequest.js";
+export type { FindCompanyRequest } from "./FindCompanyRequest.js";
+export type { ListAttachedContactsRequest } from "./ListAttachedContactsRequest.js";
+export type { ListCompaniesRequest } from "./ListCompaniesRequest.js";
+export type { ListSegmentsAttachedToCompanyRequest } from "./ListSegmentsAttachedToCompanyRequest.js";
+export type { RetrieveCompanyRequest } from "./RetrieveCompanyRequest.js";
+export type { ScrollCompaniesRequest } from "./ScrollCompaniesRequest.js";
+export type { UpdateCompanyRequest } from "./UpdateCompanyRequest.js";
diff --git a/src/api/resources/companies/index.ts b/src/api/resources/companies/index.ts
new file mode 100644
index 00000000..d9adb1af
--- /dev/null
+++ b/src/api/resources/companies/index.ts
@@ -0,0 +1,2 @@
+export * from "./client/index.js";
+export * from "./types/index.js";
diff --git a/src/api/resources/companies/types/CompaniesRetrieveResponse.ts b/src/api/resources/companies/types/CompaniesRetrieveResponse.ts
new file mode 100644
index 00000000..97513a72
--- /dev/null
+++ b/src/api/resources/companies/types/CompaniesRetrieveResponse.ts
@@ -0,0 +1,17 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+export type CompaniesRetrieveResponse =
+ | Intercom.CompaniesRetrieveResponse.Company
+ | Intercom.CompaniesRetrieveResponse.List;
+
+export namespace CompaniesRetrieveResponse {
+ export interface Company extends Intercom.Company {
+ type: "company";
+ }
+
+ export interface List extends Intercom.CompanyList {
+ type: "list";
+ }
+}
diff --git a/src/api/resources/companies/types/Company.ts b/src/api/resources/companies/types/Company.ts
new file mode 100644
index 00000000..cb26b686
--- /dev/null
+++ b/src/api/resources/companies/types/Company.ts
@@ -0,0 +1,75 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * Companies allow you to represent organizations using your product. Each company will have its own description and be associated with contacts. You can fetch, create, update and list companies.
+ */
+export interface Company {
+ /** Value is `company` */
+ type?: "company";
+ /** The Intercom defined id representing the company. */
+ id: string;
+ /** The name of the company. */
+ name: string;
+ /** The Intercom defined code of the workspace the company is associated to. */
+ app_id: string;
+ plan?: Company.Plan;
+ /** The company id you have defined for the company. */
+ company_id: string;
+ /** The time the company was created by you. */
+ remote_created_at?: number;
+ /** The time the company was added in Intercom. */
+ created_at: number;
+ /** The last time the company was updated. */
+ updated_at: number;
+ /** The time the company last recorded making a request. */
+ last_request_at?: number;
+ /** The number of employees in the company. */
+ size?: number;
+ /** The URL for the company website. */
+ website?: string;
+ /** The industry that the company operates in. */
+ industry?: string;
+ /** How much revenue the company generates for your business. */
+ monthly_spend: number;
+ /** How many sessions the company has recorded. */
+ session_count: number;
+ /** The number of users in the company. */
+ user_count: number;
+ /** The custom attributes you have set on the company. */
+ custom_attributes?: Record;
+ /** The list of tags associated with the company */
+ tags?: Company.Tags;
+ /** The list of segments associated with the company */
+ segments?: Company.Segments;
+}
+
+export namespace Company {
+ export interface Plan {
+ /** Value is always "plan" */
+ type?: string;
+ /** The id of the plan */
+ id?: string;
+ /** The name of the plan */
+ name?: string;
+ }
+
+ /**
+ * The list of tags associated with the company
+ */
+ export interface Tags {
+ /** The type of the object */
+ type?: "tag.list";
+ tags?: unknown[];
+ }
+
+ /**
+ * The list of segments associated with the company
+ */
+ export interface Segments {
+ /** The type of the object */
+ type?: "segment.list";
+ segments?: Intercom.Segment[];
+ }
+}
diff --git a/src/api/resources/companies/types/index.ts b/src/api/resources/companies/types/index.ts
new file mode 100644
index 00000000..7e2092d3
--- /dev/null
+++ b/src/api/resources/companies/types/index.ts
@@ -0,0 +1,2 @@
+export * from "./CompaniesRetrieveResponse.js";
+export * from "./Company.js";
diff --git a/src/api/resources/contacts/client/Client.ts b/src/api/resources/contacts/client/Client.ts
new file mode 100644
index 00000000..f5ec64f4
--- /dev/null
+++ b/src/api/resources/contacts/client/Client.ts
@@ -0,0 +1,1484 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace ContactsClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+/**
+ * Everything about your contacts
+ */
+export class ContactsClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: ContactsClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * You can fetch a list of companies that are associated to a contact.
+ *
+ * @param {Intercom.ListAttachedCompaniesRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.contacts.listAttachedCompanies({
+ * contact_id: "63a07ddf05a32042dffac965",
+ * page: 1,
+ * per_page: 1
+ * })
+ */
+ public async listAttachedCompanies(
+ request: Intercom.ListAttachedCompaniesRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Intercom.ListAttachedCompaniesRequest,
+ ): Promise> => {
+ const { contact_id: contactId, page, per_page: perPage } = request;
+ const _queryParams: Record = {};
+ if (page != null) {
+ _queryParams.page = page.toString();
+ }
+ if (perPage != null) {
+ _queryParams.per_page = perPage.toString();
+ }
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/companies`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.ContactAttachedCompanies,
+ rawResponse: _response.rawResponse,
+ };
+ }
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/contacts/{contact_id}/companies",
+ );
+ },
+ );
+ let _offset = request?.page != null ? request?.page : 1;
+ const dataWithRawResponse = await list(request).withRawResponse();
+ return new core.Page({
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) => (response?.companies ?? []).length > 0,
+ getItems: (response) => response?.companies ?? [],
+ loadPage: (_response) => {
+ _offset += 1;
+ return list(core.setObjectProperty(request, "page", _offset));
+ },
+ });
+ }
+
+ /**
+ * You can fetch a list of segments that are associated to a contact.
+ *
+ * @param {Intercom.ListSegmentsAttachedToContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.contacts.listAttachedSegments({
+ * contact_id: "63a07ddf05a32042dffac965"
+ * })
+ */
+ public listAttachedSegments(
+ request: Intercom.ListSegmentsAttachedToContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__listAttachedSegments(request, requestOptions));
+ }
+
+ private async __listAttachedSegments(
+ request: Intercom.ListSegmentsAttachedToContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/segments`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactSegments, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/contacts/{contact_id}/segments",
+ );
+ }
+
+ /**
+ * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type.
+ * This will return a list of Subscription Type objects that the contact is associated with.
+ *
+ * The data property will show a combined list of:
+ *
+ * 1.Opt-out subscription types that the user has opted-out from.
+ * 2.Opt-in subscription types that the user has opted-in to receiving.
+ *
+ * @param {Intercom.ListAttachedSubscriptionsRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.contacts.listAttachedSubscriptions({
+ * contact_id: "63a07ddf05a32042dffac965"
+ * })
+ */
+ public listAttachedSubscriptions(
+ request: Intercom.ListAttachedSubscriptionsRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__listAttachedSubscriptions(request, requestOptions));
+ }
+
+ private async __listAttachedSubscriptions(
+ request: Intercom.ListAttachedSubscriptionsRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/subscriptions`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.SubscriptionTypeList, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/contacts/{contact_id}/subscriptions",
+ );
+ }
+
+ /**
+ * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in:
+ *
+ * 1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.
+ *
+ * 2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.
+ *
+ * This will return a subscription type model for the subscription type that was added to the contact.
+ *
+ * @param {Intercom.AttachSubscriptionToContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.contacts.attachSubscription({
+ * contact_id: "63a07ddf05a32042dffac965",
+ * id: "37846",
+ * consent_type: "opt_in"
+ * })
+ *
+ * @example
+ * await client.contacts.attachSubscription({
+ * contact_id: "63a07ddf05a32042dffac965",
+ * id: "invalid_id",
+ * consent_type: "opt_in"
+ * })
+ */
+ public attachSubscription(
+ request: Intercom.AttachSubscriptionToContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__attachSubscription(request, requestOptions));
+ }
+
+ private async __attachSubscription(
+ request: Intercom.AttachSubscriptionToContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId, ..._body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/subscriptions`,
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.SubscriptionType, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/contacts/{contact_id}/subscriptions",
+ );
+ }
+
+ /**
+ * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact.
+ *
+ * @param {Intercom.DetachSubscriptionFromContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.contacts.detachSubscription({
+ * contact_id: "63a07ddf05a32042dffac965",
+ * subscription_id: "37846"
+ * })
+ */
+ public detachSubscription(
+ request: Intercom.DetachSubscriptionFromContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__detachSubscription(request, requestOptions));
+ }
+
+ private async __detachSubscription(
+ request: Intercom.DetachSubscriptionFromContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId, subscription_id: subscriptionId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/subscriptions/${core.url.encodePathParam(subscriptionId)}`,
+ ),
+ method: "DELETE",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.SubscriptionType, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "DELETE",
+ "/contacts/{contact_id}/subscriptions/{subscription_id}",
+ );
+ }
+
+ /**
+ * You can fetch a list of all tags that are attached to a specific contact.
+ *
+ * @param {Intercom.ListTagsAttachedToContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.contacts.listAttachedTags({
+ * contact_id: "63a07ddf05a32042dffac965"
+ * })
+ */
+ public listAttachedTags(
+ request: Intercom.ListTagsAttachedToContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__listAttachedTags(request, requestOptions));
+ }
+
+ private async __listAttachedTags(
+ request: Intercom.ListTagsAttachedToContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/tags`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.TagList, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{contact_id}/tags");
+ }
+
+ /**
+ * You can fetch the details of a single contact.
+ *
+ * @param {Intercom.FindContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.contacts.find({
+ * contact_id: "63a07ddf05a32042dffac965"
+ * })
+ */
+ public find(
+ request: Intercom.FindContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions));
+ }
+
+ private async __find(
+ request: Intercom.FindContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactsFindResponse, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{contact_id}");
+ }
+
+ /**
+ * You can update an existing contact (ie. user or lead).
+ *
+ * {% admonition type="info" %}
+ * This endpoint handles both **contact updates** and **custom object associations**.
+ *
+ * See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format.
+ * {% /admonition %}
+ *
+ * @param {Intercom.UpdateContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.contacts.update({
+ * contact_id: "63a07ddf05a32042dffac965",
+ * email: "joebloggs@intercom.io",
+ * name: "joe bloggs"
+ * })
+ *
+ * @example
+ * await client.contacts.update({
+ * contact_id: "63a07ddf05a32042dffac965",
+ * custom_attributes: {
+ * "order": [
+ * "21"
+ * ]
+ * }
+ * })
+ */
+ public update(
+ request: Intercom.UpdateContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions));
+ }
+
+ private async __update(
+ request: Intercom.UpdateContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId, ..._body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}`,
+ ),
+ method: "PUT",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactsUpdateResponse, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/contacts/{contact_id}");
+ }
+
+ /**
+ * You can delete a single contact.
+ *
+ * @param {Intercom.DeleteContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.contacts.delete({
+ * contact_id: "contact_id"
+ * })
+ */
+ public delete(
+ request: Intercom.DeleteContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions));
+ }
+
+ private async __delete(
+ request: Intercom.DeleteContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}`,
+ ),
+ method: "DELETE",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactDeleted, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/contacts/{contact_id}");
+ }
+
+ /**
+ * You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`.
+ *
+ * @param {Intercom.MergeContactsRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.contacts.mergeLeadInUser({
+ * from: "6762f0d51bb69f9f2193bb7f",
+ * into: "6762f0d51bb69f9f2193bb80"
+ * })
+ */
+ public mergeLeadInUser(
+ request: Intercom.MergeContactsRequest = {},
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__mergeLeadInUser(request, requestOptions));
+ }
+
+ private async __mergeLeadInUser(
+ request: Intercom.MergeContactsRequest = {},
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "contacts/merge",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.ContactsMergeLeadInUserResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/merge");
+ }
+
+ /**
+ * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want.
+ *
+ * To search for contacts, you need to send a `POST` request to `https://api.intercom.io/contacts/search`.
+ *
+ * This will accept a query object in the body which will define your filters in order to search for contacts.
+ *
+ * {% admonition type="warning" name="Optimizing search queries" %}
+ * Search queries can be complex, so optimizing them can help the performance of your search.
+ * Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize
+ * pagination to limit the number of results returned. The default is `50` results per page.
+ * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param.
+ * {% /admonition %}
+ * ### Contact Creation Delay
+ *
+ * If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters.
+ *
+ * ### Nesting & Limitations
+ *
+ * You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4).
+ * There are some limitations to the amount of multiple's there can be:
+ * * There's a limit of max 2 nested filters
+ * * There's a limit of max 15 filters for each AND or OR group
+ *
+ * ### Searching for Timestamp Fields
+ *
+ * All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second.
+ * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards.
+ * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM).
+ * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly.
+ *
+ * ### Accepted Fields
+ *
+ * Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`).
+ *
+ * | Field | Type |
+ * | ---------------------------------- | ------------------------------ |
+ * | id | String |
+ * | role | String
Accepts user or lead |
+ * | name | String |
+ * | avatar | String |
+ * | owner_id | Integer |
+ * | email | String |
+ * | email_domain | String |
+ * | phone | String |
+ * | external_id | String |
+ * | created_at | Date (UNIX Timestamp) |
+ * | signed_up_at | Date (UNIX Timestamp) |
+ * | updated_at | Date (UNIX Timestamp) |
+ * | last_seen_at | Date (UNIX Timestamp) |
+ * | last_contacted_at | Date (UNIX Timestamp) |
+ * | last_replied_at | Date (UNIX Timestamp) |
+ * | last_email_opened_at | Date (UNIX Timestamp) |
+ * | last_email_clicked_at | Date (UNIX Timestamp) |
+ * | language_override | String |
+ * | browser | String |
+ * | browser_language | String |
+ * | os | String |
+ * | location.country | String |
+ * | location.region | String |
+ * | location.city | String |
+ * | unsubscribed_from_emails | Boolean |
+ * | marked_email_as_spam | Boolean |
+ * | has_hard_bounced | Boolean |
+ * | ios_last_seen_at | Date (UNIX Timestamp) |
+ * | ios_app_version | String |
+ * | ios_device | String |
+ * | ios_app_device | String |
+ * | ios_os_version | String |
+ * | ios_app_name | String |
+ * | ios_sdk_version | String |
+ * | android_last_seen_at | Date (UNIX Timestamp) |
+ * | android_app_version | String |
+ * | android_device | String |
+ * | android_app_name | String |
+ * | andoid_sdk_version | String |
+ * | segment_id | String |
+ * | tag_id | String |
+ * | custom_attributes.{attribute_name} | String |
+ *
+ * ### Accepted Operators
+ *
+ * {% admonition type="warning" name="Searching based on `created_at`" %}
+ * You cannot use the `<=` or `>=` operators to search by `created_at`.
+ * {% /admonition %}
+ *
+ * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates).
+ *
+ * | Operator | Valid Types | Description |
+ * | :------- | :------------------------------- | :--------------------------------------------------------------- |
+ * | = | All | Equals |
+ * | != | All | Doesn't Equal |
+ * | IN | All | In
Shortcut for `OR` queries
Values must be in Array |
+ * | NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array |
+ * | > | Integer
Date (UNIX Timestamp) | Greater than |
+ * | < | Integer
Date (UNIX Timestamp) | Lower than |
+ * | ~ | String | Contains |
+ * | !~ | String | Doesn't Contain |
+ * | ^ | String | Starts With |
+ * | $ | String | Ends With |
+ *
+ * @param {Intercom.SearchRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.contacts.search({
+ * query: {
+ * operator: "AND",
+ * value: [{
+ * field: "created_at",
+ * operator: ">",
+ * value: "1306054154"
+ * }]
+ * },
+ * pagination: {
+ * per_page: 5
+ * }
+ * })
+ */
+ public async search(
+ request: Intercom.SearchRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (request: Intercom.SearchRequest): Promise> => {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "contacts/search",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactList, rawResponse: _response.rawResponse };
+ }
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/search");
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
+ return new core.Page({
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.pages?.next?.starting_after != null &&
+ !(
+ typeof response?.pages?.next?.starting_after === "string" &&
+ response?.pages?.next?.starting_after === ""
+ ),
+ getItems: (response) => response?.data ?? [],
+ loadPage: (response) => {
+ return list(
+ core.setObjectProperty(request, "pagination.starting_after", response?.pages?.next?.starting_after),
+ );
+ },
+ });
+ }
+
+ /**
+ * You can fetch a list of all contacts (ie. users or leads) in your workspace.
+ * {% admonition type="warning" name="Pagination" %}
+ * You can use pagination to limit the number of results returned. The default is `50` results per page.
+ * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param.
+ * {% /admonition %}
+ *
+ * @param {Intercom.ListContactsRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.contacts.list()
+ */
+ public async list(
+ request: Intercom.ListContactsRequest = {},
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (request: Intercom.ListContactsRequest): Promise> => {
+ const { page, per_page: perPage, starting_after: startingAfter } = request;
+ const _queryParams: Record = {};
+ if (page != null) {
+ _queryParams.page = page.toString();
+ }
+ if (perPage != null) {
+ _queryParams.per_page = perPage.toString();
+ }
+ if (startingAfter != null) {
+ _queryParams.starting_after = startingAfter;
+ }
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "contacts",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactList, rawResponse: _response.rawResponse };
+ }
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts");
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
+ return new core.Page({
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.pages?.next?.starting_after != null &&
+ !(
+ typeof response?.pages?.next?.starting_after === "string" &&
+ response?.pages?.next?.starting_after === ""
+ ),
+ getItems: (response) => response?.data ?? [],
+ loadPage: (response) => {
+ return list(core.setObjectProperty(request, "starting_after", response?.pages?.next?.starting_after));
+ },
+ });
+ }
+
+ /**
+ * You can create a new contact (ie. user or lead).
+ *
+ * @param {Intercom.CreateContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.contacts.create({
+ * email: "joebloggs@intercom.io"
+ * })
+ */
+ public create(
+ request: Intercom.CreateContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
+ }
+
+ private async __create(
+ request: Intercom.CreateContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "contacts",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactsCreateResponse, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts");
+ }
+
+ /**
+ * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads.
+ *
+ * @param {Intercom.ShowContactByExternalIdRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.contacts.showContactByExternalId({
+ * external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27"
+ * })
+ */
+ public showContactByExternalId(
+ request: Intercom.ShowContactByExternalIdRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__showContactByExternalId(request, requestOptions));
+ }
+
+ private async __showContactByExternalId(
+ request: Intercom.ShowContactByExternalIdRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { external_id: externalId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/find_by_external_id/${core.url.encodePathParam(externalId)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.ShowContactByExternalIdResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/contacts/find_by_external_id/{external_id}",
+ );
+ }
+
+ /**
+ * You can archive a single contact.
+ *
+ * @param {Intercom.ArchiveContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @example
+ * await client.contacts.archive({
+ * contact_id: "63a07ddf05a32042dffac965"
+ * })
+ */
+ public archive(
+ request: Intercom.ArchiveContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__archive(request, requestOptions));
+ }
+
+ private async __archive(
+ request: Intercom.ArchiveContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/archive`,
+ ),
+ method: "POST",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactArchived, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/contacts/{contact_id}/archive",
+ );
+ }
+
+ /**
+ * You can unarchive a single contact.
+ *
+ * @param {Intercom.UnarchiveContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @example
+ * await client.contacts.unarchive({
+ * contact_id: "63a07ddf05a32042dffac965"
+ * })
+ */
+ public unarchive(
+ request: Intercom.UnarchiveContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__unarchive(request, requestOptions));
+ }
+
+ private async __unarchive(
+ request: Intercom.UnarchiveContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/unarchive`,
+ ),
+ method: "POST",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactUnarchived, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/contacts/{contact_id}/unarchive",
+ );
+ }
+
+ /**
+ * Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs)
+ *
+ * @param {Intercom.BlockContactRequest} request
+ * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @example
+ * await client.contacts.blockContact({
+ * contact_id: "63a07ddf05a32042dffac965"
+ * })
+ */
+ public blockContact(
+ request: Intercom.BlockContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__blockContact(request, requestOptions));
+ }
+
+ private async __blockContact(
+ request: Intercom.BlockContactRequest,
+ requestOptions?: ContactsClient.RequestOptions,
+ ): Promise> {
+ const { contact_id: contactId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `contacts/${core.url.encodePathParam(contactId)}/block`,
+ ),
+ method: "POST",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ContactBlocked, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{contact_id}/block");
+ }
+}
diff --git a/src/api/resources/contacts/client/index.ts b/src/api/resources/contacts/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/contacts/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/contacts/client/requests/ArchiveContactRequest.ts b/src/api/resources/contacts/client/requests/ArchiveContactRequest.ts
new file mode 100644
index 00000000..9a3380a0
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/ArchiveContactRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965"
+ * }
+ */
+export interface ArchiveContactRequest {
+ /** contact_id */
+ contact_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/AttachSubscriptionToContactRequest.ts b/src/api/resources/contacts/client/requests/AttachSubscriptionToContactRequest.ts
new file mode 100644
index 00000000..8bd134af
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/AttachSubscriptionToContactRequest.ts
@@ -0,0 +1,32 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965",
+ * id: "37846",
+ * consent_type: "opt_in"
+ * }
+ *
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965",
+ * id: "37846",
+ * consent_type: "opt_in"
+ * }
+ *
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965",
+ * id: "invalid_id",
+ * consent_type: "opt_in"
+ * }
+ */
+export interface AttachSubscriptionToContactRequest {
+ /** The unique identifier for the contact which is given by Intercom */
+ contact_id: string;
+ /** The unique identifier for the subscription which is given by Intercom */
+ id: string;
+ /** The consent_type of a subscription, opt_out or opt_in. */
+ consent_type: string;
+}
diff --git a/src/api/resources/contacts/client/requests/BlockContactRequest.ts b/src/api/resources/contacts/client/requests/BlockContactRequest.ts
new file mode 100644
index 00000000..538c9a21
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/BlockContactRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965"
+ * }
+ */
+export interface BlockContactRequest {
+ /** contact_id */
+ contact_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/DeleteContactRequest.ts b/src/api/resources/contacts/client/requests/DeleteContactRequest.ts
new file mode 100644
index 00000000..42fb1445
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/DeleteContactRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "contact_id"
+ * }
+ */
+export interface DeleteContactRequest {
+ /** contact_id */
+ contact_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/DetachSubscriptionFromContactRequest.ts b/src/api/resources/contacts/client/requests/DetachSubscriptionFromContactRequest.ts
new file mode 100644
index 00000000..d5a9e4e3
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/DetachSubscriptionFromContactRequest.ts
@@ -0,0 +1,15 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965",
+ * subscription_id: "37846"
+ * }
+ */
+export interface DetachSubscriptionFromContactRequest {
+ /** The unique identifier for the contact which is given by Intercom */
+ contact_id: string;
+ /** The unique identifier for the subscription type which is given by Intercom */
+ subscription_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/FindContactRequest.ts b/src/api/resources/contacts/client/requests/FindContactRequest.ts
new file mode 100644
index 00000000..a73c27ad
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/FindContactRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965"
+ * }
+ */
+export interface FindContactRequest {
+ /** contact_id */
+ contact_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/ListAttachedCompaniesRequest.ts b/src/api/resources/contacts/client/requests/ListAttachedCompaniesRequest.ts
new file mode 100644
index 00000000..bf57a734
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/ListAttachedCompaniesRequest.ts
@@ -0,0 +1,18 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965",
+ * page: 1,
+ * per_page: 1
+ * }
+ */
+export interface ListAttachedCompaniesRequest {
+ /** The unique identifier for the contact which is given by Intercom */
+ contact_id: string;
+ /** The page of results to fetch. Defaults to first page */
+ page?: number;
+ /** How many results to display per page. Defaults to 15 */
+ per_page?: number;
+}
diff --git a/src/api/resources/contacts/client/requests/ListAttachedSubscriptionsRequest.ts b/src/api/resources/contacts/client/requests/ListAttachedSubscriptionsRequest.ts
new file mode 100644
index 00000000..12dce4dd
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/ListAttachedSubscriptionsRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965"
+ * }
+ */
+export interface ListAttachedSubscriptionsRequest {
+ /** The unique identifier for the contact which is given by Intercom */
+ contact_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/ListContactsRequest.ts b/src/api/resources/contacts/client/requests/ListContactsRequest.ts
new file mode 100644
index 00000000..779b4121
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/ListContactsRequest.ts
@@ -0,0 +1,14 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {}
+ */
+export interface ListContactsRequest {
+ /** The page of results to fetch. Defaults to first page */
+ page?: number;
+ /** How many results to display per page. Defaults to 15 */
+ per_page?: number;
+ /** String used to get the next page of conversations. */
+ starting_after?: string;
+}
diff --git a/src/api/resources/contacts/client/requests/ListSegmentsAttachedToContactRequest.ts b/src/api/resources/contacts/client/requests/ListSegmentsAttachedToContactRequest.ts
new file mode 100644
index 00000000..f2fe1a11
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/ListSegmentsAttachedToContactRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965"
+ * }
+ */
+export interface ListSegmentsAttachedToContactRequest {
+ /** The unique identifier for the contact which is given by Intercom */
+ contact_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/ListTagsAttachedToContactRequest.ts b/src/api/resources/contacts/client/requests/ListTagsAttachedToContactRequest.ts
new file mode 100644
index 00000000..1d62aa60
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/ListTagsAttachedToContactRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965"
+ * }
+ */
+export interface ListTagsAttachedToContactRequest {
+ /** The unique identifier for the contact which is given by Intercom */
+ contact_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/MergeContactsRequest.ts b/src/api/resources/contacts/client/requests/MergeContactsRequest.ts
new file mode 100644
index 00000000..520d7f83
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/MergeContactsRequest.ts
@@ -0,0 +1,15 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * from: "6762f0d51bb69f9f2193bb7f",
+ * into: "6762f0d51bb69f9f2193bb80"
+ * }
+ */
+export interface MergeContactsRequest {
+ /** The unique identifier for the contact to merge away from. Must be a lead. */
+ from?: string;
+ /** The unique identifier for the contact to merge into. Must be a user. */
+ into?: string;
+}
diff --git a/src/api/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts b/src/api/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts
new file mode 100644
index 00000000..d6f2b0d8
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27"
+ * }
+ */
+export interface ShowContactByExternalIdRequest {
+ /** The external ID of the user that you want to retrieve */
+ external_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/UnarchiveContactRequest.ts b/src/api/resources/contacts/client/requests/UnarchiveContactRequest.ts
new file mode 100644
index 00000000..76ecc8e1
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/UnarchiveContactRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965"
+ * }
+ */
+export interface UnarchiveContactRequest {
+ /** contact_id */
+ contact_id: string;
+}
diff --git a/src/api/resources/contacts/client/requests/UpdateContactRequest.ts b/src/api/resources/contacts/client/requests/UpdateContactRequest.ts
new file mode 100644
index 00000000..3f048efd
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/UpdateContactRequest.ts
@@ -0,0 +1,46 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965",
+ * email: "joebloggs@intercom.io",
+ * name: "joe bloggs"
+ * }
+ *
+ * @example
+ * {
+ * contact_id: "63a07ddf05a32042dffac965",
+ * custom_attributes: {
+ * "order": [
+ * "21"
+ * ]
+ * }
+ * }
+ */
+export interface UpdateContactRequest {
+ /** id */
+ contact_id: string;
+ /** The role of the contact. */
+ role?: string;
+ /** A unique identifier for the contact which is given to Intercom */
+ external_id?: string;
+ /** The contacts email */
+ email?: string;
+ /** The contacts phone */
+ phone?: string;
+ /** The contacts name */
+ name?: string;
+ /** An image URL containing the avatar of a contact */
+ avatar?: string;
+ /** The time specified for when a contact signed up */
+ signed_up_at?: number;
+ /** The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) */
+ last_seen_at?: number;
+ /** The id of an admin that has been assigned account ownership of the contact */
+ owner_id?: number;
+ /** Whether the contact is unsubscribed from emails */
+ unsubscribed_from_emails?: boolean;
+ /** The custom attributes which are set for the contact */
+ custom_attributes?: Record;
+}
diff --git a/src/api/resources/contacts/client/requests/index.ts b/src/api/resources/contacts/client/requests/index.ts
new file mode 100644
index 00000000..60cacd37
--- /dev/null
+++ b/src/api/resources/contacts/client/requests/index.ts
@@ -0,0 +1,15 @@
+export type { ArchiveContactRequest } from "./ArchiveContactRequest.js";
+export type { AttachSubscriptionToContactRequest } from "./AttachSubscriptionToContactRequest.js";
+export type { BlockContactRequest } from "./BlockContactRequest.js";
+export type { DeleteContactRequest } from "./DeleteContactRequest.js";
+export type { DetachSubscriptionFromContactRequest } from "./DetachSubscriptionFromContactRequest.js";
+export type { FindContactRequest } from "./FindContactRequest.js";
+export type { ListAttachedCompaniesRequest } from "./ListAttachedCompaniesRequest.js";
+export type { ListAttachedSubscriptionsRequest } from "./ListAttachedSubscriptionsRequest.js";
+export type { ListContactsRequest } from "./ListContactsRequest.js";
+export type { ListSegmentsAttachedToContactRequest } from "./ListSegmentsAttachedToContactRequest.js";
+export type { ListTagsAttachedToContactRequest } from "./ListTagsAttachedToContactRequest.js";
+export type { MergeContactsRequest } from "./MergeContactsRequest.js";
+export type { ShowContactByExternalIdRequest } from "./ShowContactByExternalIdRequest.js";
+export type { UnarchiveContactRequest } from "./UnarchiveContactRequest.js";
+export type { UpdateContactRequest } from "./UpdateContactRequest.js";
diff --git a/src/api/resources/contacts/index.ts b/src/api/resources/contacts/index.ts
new file mode 100644
index 00000000..d9adb1af
--- /dev/null
+++ b/src/api/resources/contacts/index.ts
@@ -0,0 +1,2 @@
+export * from "./client/index.js";
+export * from "./types/index.js";
diff --git a/src/api/resources/contacts/types/Contact.ts b/src/api/resources/contacts/types/Contact.ts
new file mode 100644
index 00000000..1df7ed44
--- /dev/null
+++ b/src/api/resources/contacts/types/Contact.ts
@@ -0,0 +1,94 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * Contacts represent your leads and users in Intercom.
+ */
+export interface Contact {
+ /** The type of object. */
+ type: "contact";
+ /** The unique identifier for the contact which is given by Intercom. */
+ id: string;
+ /** The unique identifier for the contact which is provided by the Client. */
+ external_id?: string;
+ /** The id of the workspace which the contact belongs to. */
+ workspace_id: string;
+ /** The role of the contact. */
+ role: string;
+ /** The contact's email. */
+ email?: string;
+ /** The contact's email domain. */
+ email_domain?: string;
+ /** The contacts phone. */
+ phone?: string;
+ /** The contacts name. */
+ name?: string;
+ /** The id of an admin that has been assigned account ownership of the contact. */
+ owner_id?: number;
+ /** Whether the contact has had an email sent to them hard bounce. */
+ has_hard_bounced: boolean;
+ /** Whether the contact has marked an email sent to them as spam. */
+ marked_email_as_spam: boolean;
+ /** Whether the contact is unsubscribed from emails. */
+ unsubscribed_from_emails: boolean;
+ /** (UNIX timestamp) The time when the contact was created. */
+ created_at: number;
+ /** (UNIX timestamp) The time when the contact was last updated. */
+ updated_at: number;
+ /** (UNIX timestamp) The time specified for when a contact signed up. */
+ signed_up_at?: number;
+ /** (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). */
+ last_seen_at?: number;
+ /** (UNIX timestamp) The time when the contact last messaged in. */
+ last_replied_at?: number;
+ /** (UNIX timestamp) The time when the contact was last messaged. */
+ last_contacted_at?: number;
+ /** (UNIX timestamp) The time when the contact last opened an email. */
+ last_email_opened_at?: number;
+ /** (UNIX timestamp) The time when the contact last clicked a link in an email. */
+ last_email_clicked_at?: number;
+ /** A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. */
+ language_override?: string;
+ /** The name of the browser which the contact is using. */
+ browser?: string;
+ /** The version of the browser which the contact is using. */
+ browser_version?: string;
+ /** The language set by the browser which the contact is using. */
+ browser_language?: string;
+ /** The operating system which the contact is using. */
+ os?: string;
+ /** The name of the Android app which the contact is using. */
+ android_app_name?: string;
+ /** The version of the Android app which the contact is using. */
+ android_app_version?: string;
+ /** The Android device which the contact is using. */
+ android_device?: string;
+ /** The version of the Android OS which the contact is using. */
+ android_os_version?: string;
+ /** The version of the Android SDK which the contact is using. */
+ android_sdk_version?: string;
+ /** (UNIX timestamp) The time when the contact was last seen on an Android device. */
+ android_last_seen_at?: number;
+ /** The name of the iOS app which the contact is using. */
+ ios_app_name?: string;
+ /** The version of the iOS app which the contact is using. */
+ ios_app_version?: string;
+ /** The iOS device which the contact is using. */
+ ios_device?: string;
+ /** The version of iOS which the contact is using. */
+ ios_os_version?: string;
+ /** The version of the iOS SDK which the contact is using. */
+ ios_sdk_version?: string;
+ /** (UNIX timestamp) The last time the contact used the iOS app. */
+ ios_last_seen_at?: number;
+ /** The custom attributes which are set for the contact. */
+ custom_attributes?: Record;
+ /** An image URL containing the avatar of a contact. */
+ avatar?: string;
+ tags?: Intercom.ContactTags;
+ notes?: Intercom.ContactNotes;
+ companies?: Intercom.ContactCompanies;
+ location?: Intercom.ContactLocation;
+ social_profiles?: Intercom.ContactSocialProfiles;
+}
diff --git a/src/api/resources/contacts/types/ContactsCreateResponse.ts b/src/api/resources/contacts/types/ContactsCreateResponse.ts
new file mode 100644
index 00000000..c124d661
--- /dev/null
+++ b/src/api/resources/contacts/types/ContactsCreateResponse.ts
@@ -0,0 +1,8 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+export interface ContactsCreateResponse extends Intercom.Contact {
+ /** If the user has enabled push messaging. */
+ enabled_push_messaging?: boolean;
+}
diff --git a/src/api/resources/contacts/types/ContactsFindResponse.ts b/src/api/resources/contacts/types/ContactsFindResponse.ts
new file mode 100644
index 00000000..96ff7ff5
--- /dev/null
+++ b/src/api/resources/contacts/types/ContactsFindResponse.ts
@@ -0,0 +1,8 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+export interface ContactsFindResponse extends Intercom.Contact {
+ /** If the user has enabled push messaging. */
+ enabled_push_messaging?: boolean;
+}
diff --git a/src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts b/src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts
new file mode 100644
index 00000000..95ca8cfb
--- /dev/null
+++ b/src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts
@@ -0,0 +1,8 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+export interface ContactsMergeLeadInUserResponse extends Intercom.Contact {
+ /** If the user has enabled push messaging. */
+ enabled_push_messaging?: boolean;
+}
diff --git a/src/api/resources/contacts/types/ContactsUpdateResponse.ts b/src/api/resources/contacts/types/ContactsUpdateResponse.ts
new file mode 100644
index 00000000..736895ee
--- /dev/null
+++ b/src/api/resources/contacts/types/ContactsUpdateResponse.ts
@@ -0,0 +1,8 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+export interface ContactsUpdateResponse extends Intercom.Contact {
+ /** If the user has enabled push messaging. */
+ enabled_push_messaging?: boolean;
+}
diff --git a/src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts b/src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts
new file mode 100644
index 00000000..c6dbf5c1
--- /dev/null
+++ b/src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts
@@ -0,0 +1,8 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+export interface ShowContactByExternalIdResponse extends Intercom.Contact {
+ /** If the user has enabled push messaging. */
+ enabled_push_messaging?: boolean;
+}
diff --git a/src/api/resources/contacts/types/index.ts b/src/api/resources/contacts/types/index.ts
new file mode 100644
index 00000000..adc73bae
--- /dev/null
+++ b/src/api/resources/contacts/types/index.ts
@@ -0,0 +1,6 @@
+export * from "./Contact.js";
+export * from "./ContactsCreateResponse.js";
+export * from "./ContactsFindResponse.js";
+export * from "./ContactsMergeLeadInUserResponse.js";
+export * from "./ContactsUpdateResponse.js";
+export * from "./ShowContactByExternalIdResponse.js";
diff --git a/src/api/resources/conversations/client/Client.ts b/src/api/resources/conversations/client/Client.ts
new file mode 100644
index 00000000..af9f6fc0
--- /dev/null
+++ b/src/api/resources/conversations/client/Client.ts
@@ -0,0 +1,1450 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace ConversationsClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+/**
+ * Everything about your Conversations
+ */
+export class ConversationsClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: ConversationsClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * You can fetch a list of all conversations.
+ *
+ * You can optionally request the result page size and the cursor to start after to fetch the result.
+ * {% admonition type="warning" name="Pagination" %}
+ * You can use pagination to limit the number of results returned. The default is `20` results per page.
+ * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param.
+ * {% /admonition %}
+ *
+ * @param {Intercom.ListConversationsRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ *
+ * @example
+ * await client.conversations.list({
+ * per_page: 1,
+ * starting_after: "starting_after"
+ * })
+ */
+ public async list(
+ request: Intercom.ListConversationsRequest = {},
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (
+ request: Intercom.ListConversationsRequest,
+ ): Promise> => {
+ const { per_page: perPage, starting_after: startingAfter } = request;
+ const _queryParams: Record = {};
+ if (perPage != null) {
+ _queryParams.per_page = perPage.toString();
+ }
+ if (startingAfter != null) {
+ _queryParams.starting_after = startingAfter;
+ }
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "conversations",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ConversationList, rawResponse: _response.rawResponse };
+ }
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/conversations");
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
+ return new core.Page({
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.pages?.next?.starting_after != null &&
+ !(
+ typeof response?.pages?.next?.starting_after === "string" &&
+ response?.pages?.next?.starting_after === ""
+ ),
+ getItems: (response) => response?.conversations ?? [],
+ loadPage: (response) => {
+ return list(core.setObjectProperty(request, "starting_after", response?.pages?.next?.starting_after));
+ },
+ });
+ }
+
+ /**
+ * You can create a conversation that has been initiated by a contact (ie. user or lead).
+ * The conversation can be an in-app message only.
+ *
+ * {% admonition type="info" name="Sending for visitors" %}
+ * You can also send a message from a visitor by specifying their `user_id` or `id` value in the `from` field, along with a `type` field value of `contact`.
+ * This visitor will be automatically converted to a contact with a lead role once the conversation is created.
+ * {% /admonition %}
+ *
+ * This will return the Message model that has been created.
+ *
+ *
+ * @param {Intercom.CreateConversationRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.conversations.create({
+ * from: {
+ * type: "user",
+ * id: "6762f11b1bb69f9f2193bba3"
+ * },
+ * body: "Hello there"
+ * })
+ *
+ * @example
+ * await client.conversations.create({
+ * from: {
+ * type: "user",
+ * id: "123_doesnt_exist"
+ * },
+ * body: "Hello there"
+ * })
+ */
+ public create(
+ request: Intercom.CreateConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
+ }
+
+ private async __create(
+ request: Intercom.CreateConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "conversations",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Message, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse);
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations");
+ }
+
+ /**
+ *
+ * You can fetch the details of a single conversation.
+ *
+ * This will return a single Conversation model with all its conversation parts.
+ *
+ * {% admonition type="warning" name="Hard limit of 500 parts" %}
+ * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts.
+ * {% /admonition %}
+ *
+ * For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a [paid feature](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671).
+ *
+ * @param {Intercom.FindConversationRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.conversations.find({
+ * conversation_id: "123",
+ * display_as: "plaintext",
+ * include_translations: true
+ * })
+ */
+ public find(
+ request: Intercom.FindConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions));
+ }
+
+ private async __find(
+ request: Intercom.FindConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const {
+ conversation_id: conversationId,
+ display_as: displayAs,
+ include_translations: includeTranslations,
+ } = request;
+ const _queryParams: Record = {};
+ if (displayAs != null) {
+ _queryParams.display_as = displayAs;
+ }
+
+ if (includeTranslations != null) {
+ _queryParams.include_translations = includeTranslations.toString();
+ }
+
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `conversations/${core.url.encodePathParam(conversationId)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse);
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/conversations/{conversation_id}",
+ );
+ }
+
+ /**
+ *
+ * You can update an existing conversation.
+ *
+ * {% admonition type="info" name="Replying and other actions" %}
+ * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints.
+ * {% /admonition %}
+ *
+ * {% admonition type="info" %}
+ * This endpoint handles both **conversation updates** and **custom object associations**.
+ *
+ * See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format.
+ * {% /admonition %}
+ *
+ *
+ * @param {Intercom.UpdateConversationRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.conversations.update({
+ * conversation_id: "conversation_id",
+ * display_as: "plaintext",
+ * read: true,
+ * title: "new conversation title",
+ * custom_attributes: {
+ * "issue_type": "Billing",
+ * "priority": "High"
+ * }
+ * })
+ *
+ * @example
+ * await client.conversations.update({
+ * conversation_id: "conversation_id",
+ * display_as: "plaintext",
+ * custom_attributes: {
+ * "order": {}
+ * }
+ * })
+ */
+ public update(
+ request: Intercom.UpdateConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions));
+ }
+
+ private async __update(
+ request: Intercom.UpdateConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const { conversation_id: conversationId, display_as: displayAs, ..._body } = request;
+ const _queryParams: Record = {};
+ if (displayAs != null) {
+ _queryParams.display_as = displayAs;
+ }
+
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `conversations/${core.url.encodePathParam(conversationId)}`,
+ ),
+ method: "PUT",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse);
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "PUT",
+ "/conversations/{conversation_id}",
+ );
+ }
+
+ /**
+ * You can delete a single conversation.
+ *
+ * @param {Intercom.DeleteConversationRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ *
+ * @example
+ * await client.conversations.deleteConversation({
+ * conversation_id: 1
+ * })
+ */
+ public deleteConversation(
+ request: Intercom.DeleteConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__deleteConversation(request, requestOptions));
+ }
+
+ private async __deleteConversation(
+ request: Intercom.DeleteConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const { conversation_id: conversationId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `conversations/${core.url.encodePathParam(conversationId)}`,
+ ),
+ method: "DELETE",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ConversationDeleted, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "DELETE",
+ "/conversations/{conversation_id}",
+ );
+ }
+
+ /**
+ * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want.
+ *
+ * To search for conversations, you need to send a `POST` request to `https://api.intercom.io/conversations/search`.
+ *
+ * This will accept a query object in the body which will define your filters in order to search for conversations.
+ * {% admonition type="warning" name="Optimizing search queries" %}
+ * Search queries can be complex, so optimizing them can help the performance of your search.
+ * Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize
+ * pagination to limit the number of results returned. The default is `20` results per page and maximum is `150`.
+ * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param.
+ * {% /admonition %}
+ *
+ * ### Nesting & Limitations
+ *
+ * You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4).
+ * There are some limitations to the amount of multiple's there can be:
+ * - There's a limit of max 2 nested filters
+ * - There's a limit of max 15 filters for each AND or OR group
+ *
+ * ### Accepted Fields
+ *
+ * Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`).
+ * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result.
+ *
+ * | Field | Type |
+ * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- |
+ * | id | String |
+ * | created_at | Date (UNIX timestamp) |
+ * | updated_at | Date (UNIX timestamp) |
+ * | source.type | String
Accepted fields are `conversation`, `email`, `facebook`, `instagram`, `phone_call`, `phone_switch`, `push`, `sms`, `twitter` and `whatsapp`. |
+ * | source.id | String |
+ * | source.delivered_as | String |
+ * | source.subject | String |
+ * | source.body | String |
+ * | source.author.id | String |
+ * | source.author.type | String |
+ * | source.author.name | String |
+ * | source.author.email | String |
+ * | source.url | String |
+ * | contact_ids | String |
+ * | teammate_ids | String |
+ * | admin_assignee_id | String |
+ * | team_assignee_id | String |
+ * | channel_initiated | String |
+ * | open | Boolean |
+ * | read | Boolean |
+ * | state | String |
+ * | waiting_since | Date (UNIX timestamp) |
+ * | snoozed_until | Date (UNIX timestamp) |
+ * | tag_ids | String |
+ * | priority | String |
+ * | statistics.time_to_assignment | Integer |
+ * | statistics.time_to_admin_reply | Integer |
+ * | statistics.time_to_first_close | Integer |
+ * | statistics.time_to_last_close | Integer |
+ * | statistics.median_time_to_reply | Integer |
+ * | statistics.first_contact_reply_at | Date (UNIX timestamp) |
+ * | statistics.first_assignment_at | Date (UNIX timestamp) |
+ * | statistics.first_admin_reply_at | Date (UNIX timestamp) |
+ * | statistics.first_close_at | Date (UNIX timestamp) |
+ * | statistics.last_assignment_at | Date (UNIX timestamp) |
+ * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) |
+ * | statistics.last_contact_reply_at | Date (UNIX timestamp) |
+ * | statistics.last_admin_reply_at | Date (UNIX timestamp) |
+ * | statistics.last_close_at | Date (UNIX timestamp) |
+ * | statistics.last_closed_by_id | String |
+ * | statistics.count_reopens | Integer |
+ * | statistics.count_assignments | Integer |
+ * | statistics.count_conversation_parts | Integer |
+ * | conversation_rating.requested_at | Date (UNIX timestamp) |
+ * | conversation_rating.replied_at | Date (UNIX timestamp) |
+ * | conversation_rating.score | Integer |
+ * | conversation_rating.remark | String |
+ * | conversation_rating.contact_id | String |
+ * | conversation_rating.admin_d | String |
+ * | ai_agent_participated | Boolean |
+ * | ai_agent.resolution_state | String |
+ * | ai_agent.last_answer_type | String |
+ * | ai_agent.rating | Integer |
+ * | ai_agent.rating_remark | String |
+ * | ai_agent.source_type | String |
+ * | ai_agent.source_title | String |
+ *
+ * ### Accepted Operators
+ *
+ * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates).
+ *
+ * | Operator | Valid Types | Description |
+ * | :------- | :----------------------------- | :----------------------------------------------------------- |
+ * | = | All | Equals |
+ * | != | All | Doesn't Equal |
+ * | IN | All | In Shortcut for `OR` queries Values most be in Array |
+ * | NIN | All | Not In Shortcut for `OR !` queries Values must be in Array |
+ * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than |
+ * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than |
+ * | ~ | String | Contains |
+ * | !~ | String | Doesn't Contain |
+ * | ^ | String | Starts With |
+ * | $ | String | Ends With |
+ *
+ * @param {Intercom.SearchRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @example
+ * await client.conversations.search({
+ * query: {
+ * operator: "AND",
+ * value: [{
+ * field: "created_at",
+ * operator: ">",
+ * value: "1306054154"
+ * }]
+ * },
+ * pagination: {
+ * per_page: 5
+ * }
+ * })
+ */
+ public async search(
+ request: Intercom.SearchRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const list = core.HttpResponsePromise.interceptFunction(
+ async (request: Intercom.SearchRequest): Promise> => {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "conversations/search",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.ConversationList, rawResponse: _response.rawResponse };
+ }
+ if (_response.error.reason === "status-code") {
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/conversations/search",
+ );
+ },
+ );
+ const dataWithRawResponse = await list(request).withRawResponse();
+ return new core.Page({
+ response: dataWithRawResponse.data,
+ rawResponse: dataWithRawResponse.rawResponse,
+ hasNextPage: (response) =>
+ response?.pages?.next?.starting_after != null &&
+ !(
+ typeof response?.pages?.next?.starting_after === "string" &&
+ response?.pages?.next?.starting_after === ""
+ ),
+ getItems: (response) => response?.conversations ?? [],
+ loadPage: (response) => {
+ return list(
+ core.setObjectProperty(request, "pagination.starting_after", response?.pages?.next?.starting_after),
+ );
+ },
+ });
+ }
+
+ /**
+ * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins.
+ *
+ * @param {Intercom.ReplyToConversationRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.conversations.reply({
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "comment",
+ * type: "user",
+ * body: "Thanks again :)",
+ * intercom_user_id: "6762f1571bb69f9f2193bbbb"
+ * }
+ * })
+ *
+ * @example
+ * await client.conversations.reply({
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "note",
+ * type: "admin",
+ * body: " An Unordered HTML List
An Ordered HTML List
- Coffee
- Tea
- Milk
",
+ * admin_id: "3156780"
+ * }
+ * })
+ *
+ * @example
+ * await client.conversations.reply({
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "quick_reply",
+ * type: "admin",
+ * admin_id: "3156780",
+ * reply_options: [{
+ * text: "Yes",
+ * uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb"
+ * }, {
+ * text: "No",
+ * uuid: "f4a98af1-be56-4948-a57e-e1a83f8484c6"
+ * }]
+ * }
+ * })
+ *
+ * @example
+ * await client.conversations.reply({
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "comment",
+ * type: "user",
+ * body: "body",
+ * reply_options: [{
+ * text: "Yes",
+ * uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb"
+ * }],
+ * intercom_user_id: "6762f1621bb69f9f2193bbbe"
+ * }
+ * })
+ *
+ * @example
+ * await client.conversations.reply({
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "comment",
+ * type: "user",
+ * body: "Thanks again :)",
+ * intercom_user_id: "6762f1661bb69f9f2193bbbf"
+ * }
+ * })
+ */
+ public reply(
+ request: Intercom.ReplyToConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__reply(request, requestOptions));
+ }
+
+ private async __reply(
+ request: Intercom.ReplyToConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const { conversation_id: conversationId, body: _body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `conversations/${core.url.encodePathParam(conversationId)}/reply`,
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse);
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/conversations/{conversation_id}/reply",
+ );
+ }
+
+ /**
+ * For managing conversations you can:
+ * - Close a conversation
+ * - Snooze a conversation to reopen on a future date
+ * - Open a conversation which is `snoozed` or `closed`
+ * - Assign a conversation to an admin and/or team.
+ *
+ * @param {Intercom.ManageConversationPartsRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.conversations.manage({
+ * conversation_id: "123",
+ * body: {
+ * message_type: "close",
+ * type: "admin",
+ * admin_id: "12345"
+ * }
+ * })
+ *
+ * @example
+ * await client.conversations.manage({
+ * conversation_id: "123",
+ * body: {
+ * message_type: "snoozed",
+ * admin_id: "5017691",
+ * snoozed_until: 1673609604
+ * }
+ * })
+ *
+ * @example
+ * await client.conversations.manage({
+ * conversation_id: "123",
+ * body: {
+ * message_type: "open",
+ * admin_id: "5017690"
+ * }
+ * })
+ *
+ * @example
+ * await client.conversations.manage({
+ * conversation_id: "123",
+ * body: {
+ * message_type: "assignment",
+ * type: "admin",
+ * admin_id: "12345",
+ * assignee_id: "4324241"
+ * }
+ * })
+ */
+ public manage(
+ request: Intercom.ManageConversationPartsRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__manage(request, requestOptions));
+ }
+
+ private async __manage(
+ request: Intercom.ManageConversationPartsRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const { conversation_id: conversationId, body: _body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `conversations/${core.url.encodePathParam(conversationId)}/parts`,
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse);
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/conversations/{conversation_id}/parts",
+ );
+ }
+
+ /**
+ * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin.
+ *
+ * {% admonition type="warning" name="Contacts without an email" %}
+ * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`.
+ * {% /admonition %}
+ *
+ *
+ * @param {Intercom.AttachContactToConversationRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.conversations.attachContactAsAdmin({
+ * conversation_id: "123",
+ * admin_id: "12345",
+ * customer: {
+ * intercom_user_id: "6762f19b1bb69f9f2193bbd4"
+ * }
+ * })
+ *
+ * @example
+ * await client.conversations.attachContactAsAdmin({
+ * conversation_id: "123",
+ * admin_id: "12345",
+ * customer: {
+ * intercom_user_id: "6762f19e1bb69f9f2193bbd5"
+ * }
+ * })
+ */
+ public attachContactAsAdmin(
+ request: Intercom.AttachContactToConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__attachContactAsAdmin(request, requestOptions));
+ }
+
+ private async __attachContactAsAdmin(
+ request: Intercom.AttachContactToConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const { conversation_id: conversationId, ..._body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `conversations/${core.url.encodePathParam(conversationId)}/customers`,
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse);
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/conversations/{conversation_id}/customers",
+ );
+ }
+
+ /**
+ * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin.
+ *
+ * {% admonition type="warning" name="Contacts without an email" %}
+ * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`.
+ * {% /admonition %}
+ *
+ *
+ * @param {Intercom.DetachContactFromConversationRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ * @throws {@link Intercom.NotFoundError}
+ * @throws {@link Intercom.UnprocessableEntityError}
+ *
+ * @example
+ * await client.conversations.detachContactAsAdmin({
+ * conversation_id: "123",
+ * contact_id: "123",
+ * admin_id: "5017690"
+ * })
+ */
+ public detachContactAsAdmin(
+ request: Intercom.DetachContactFromConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__detachContactAsAdmin(request, requestOptions));
+ }
+
+ private async __detachContactAsAdmin(
+ request: Intercom.DetachContactFromConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const { conversation_id: conversationId, contact_id: contactId, ..._body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `conversations/${core.url.encodePathParam(conversationId)}/customers/${core.url.encodePathParam(contactId)}`,
+ ),
+ method: "DELETE",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse);
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ case 422:
+ throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "DELETE",
+ "/conversations/{conversation_id}/customers/{contact_id}",
+ );
+ }
+
+ /**
+ * You can redact a conversation part or the source message of a conversation (as seen in the source object).
+ *
+ * {% admonition type="info" name="Redacting parts and messages" %}
+ * If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met.
+ * {% /admonition %}
+ *
+ *
+ * @param {Intercom.RedactConversationRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.conversations.redactConversationPart({
+ * type: "conversation_part",
+ * conversation_id: "19894788788",
+ * conversation_part_id: "19381789428"
+ * })
+ *
+ * @example
+ * await client.conversations.redactConversationPart({
+ * type: "conversation_part",
+ * conversation_id: "really_123_doesnt_exist",
+ * conversation_part_id: "really_123_doesnt_exist"
+ * })
+ */
+ public redactConversationPart(
+ request: Intercom.RedactConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__redactConversationPart(request, requestOptions));
+ }
+
+ private async __redactConversationPart(
+ request: Intercom.RedactConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "conversations/redact",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/redact");
+ }
+
+ /**
+ * You can convert a conversation to a ticket.
+ *
+ * @param {Intercom.ConvertConversationToTicketRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ *
+ * @example
+ * await client.conversations.convertToTicket({
+ * conversation_id: 1,
+ * ticket_type_id: "53"
+ * })
+ *
+ * @example
+ * await client.conversations.convertToTicket({
+ * conversation_id: 1,
+ * ticket_type_id: "54"
+ * })
+ */
+ public convertToTicket(
+ request: Intercom.ConvertConversationToTicketRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__convertToTicket(request, requestOptions));
+ }
+
+ private async __convertToTicket(
+ request: Intercom.ConvertConversationToTicketRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const { conversation_id: conversationId, ..._body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `conversations/${core.url.encodePathParam(conversationId)}/convert`,
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Ticket | undefined, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/conversations/{conversation_id}/convert",
+ );
+ }
+
+ /**
+ * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %}
+ * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail.
+ * {% /admonition %}
+ * You can let a conversation be automatically assigned following assignment rules.
+ * {% admonition type="warning" name="When using workflows" %}
+ * It is not possible to use this endpoint with Workflows.
+ * {% /admonition %}
+ *
+ * @param {Intercom.AutoAssignConversationRequest} request
+ * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.ForbiddenError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.conversations.runAssignmentRules({
+ * conversation_id: "123"
+ * })
+ */
+ public runAssignmentRules(
+ request: Intercom.AutoAssignConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__runAssignmentRules(request, requestOptions));
+ }
+
+ private async __runAssignmentRules(
+ request: Intercom.AutoAssignConversationRequest,
+ requestOptions?: ConversationsClient.RequestOptions,
+ ): Promise> {
+ const { conversation_id: conversationId } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `conversations/${core.url.encodePathParam(conversationId)}/run_assignment_rules`,
+ ),
+ method: "POST",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 403:
+ throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse);
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/conversations/{conversation_id}/run_assignment_rules",
+ );
+ }
+}
diff --git a/src/api/resources/conversations/client/index.ts b/src/api/resources/conversations/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/conversations/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/conversations/client/requests/AttachContactToConversationRequest.ts b/src/api/resources/conversations/client/requests/AttachContactToConversationRequest.ts
new file mode 100644
index 00000000..26b7dd3a
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/AttachContactToConversationRequest.ts
@@ -0,0 +1,46 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * conversation_id: "123",
+ * admin_id: "12345",
+ * customer: {
+ * intercom_user_id: "6762f19b1bb69f9f2193bbd4"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123",
+ * admin_id: "12345",
+ * customer: {
+ * intercom_user_id: "6762f19e1bb69f9f2193bbd5"
+ * }
+ * }
+ */
+export interface AttachContactToConversationRequest {
+ /** The identifier for the conversation as given by Intercom. */
+ conversation_id: string;
+ /** The `id` of the admin who is adding the new participant. */
+ admin_id?: string;
+ customer?: AttachContactToConversationRequest.Customer;
+}
+
+export namespace AttachContactToConversationRequest {
+ export type Customer =
+ | {
+ intercom_user_id: string;
+ customer?: Intercom.CustomerRequest | undefined;
+ }
+ | {
+ user_id: string;
+ customer?: Intercom.CustomerRequest | undefined;
+ }
+ | {
+ email: string;
+ customer?: Intercom.CustomerRequest | undefined;
+ };
+}
diff --git a/src/api/resources/conversations/client/requests/AutoAssignConversationRequest.ts b/src/api/resources/conversations/client/requests/AutoAssignConversationRequest.ts
new file mode 100644
index 00000000..a5a03bdc
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/AutoAssignConversationRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * conversation_id: "123"
+ * }
+ */
+export interface AutoAssignConversationRequest {
+ /** The identifier for the conversation as given by Intercom. */
+ conversation_id: string;
+}
diff --git a/src/api/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts b/src/api/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts
new file mode 100644
index 00000000..c5593cee
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts
@@ -0,0 +1,24 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * conversation_id: 1,
+ * ticket_type_id: "53"
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: 1,
+ * ticket_type_id: "54"
+ * }
+ */
+export interface ConvertConversationToTicketRequest {
+ /** The id of the conversation to target */
+ conversation_id: number;
+ /** The ID of the type of ticket you want to convert the conversation to */
+ ticket_type_id: string;
+ attributes?: Intercom.TicketRequestCustomAttributes;
+}
diff --git a/src/api/resources/conversations/client/requests/CreateConversationRequest.ts b/src/api/resources/conversations/client/requests/CreateConversationRequest.ts
new file mode 100644
index 00000000..0f8bcd9a
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/CreateConversationRequest.ts
@@ -0,0 +1,47 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * from: {
+ * type: "user",
+ * id: "6762f11b1bb69f9f2193bba3"
+ * },
+ * body: "Hello there"
+ * }
+ *
+ * @example
+ * {
+ * from: {
+ * type: "user",
+ * id: "123_doesnt_exist"
+ * },
+ * body: "Hello there"
+ * }
+ */
+export interface CreateConversationRequest {
+ from: CreateConversationRequest.From;
+ /** The content of the message. HTML is not supported. */
+ body: string;
+ /** The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom. */
+ created_at?: number;
+}
+
+export namespace CreateConversationRequest {
+ export interface From {
+ /** The role associated to the contact - user or lead. */
+ type: From.Type;
+ /** The identifier for the contact which is given by Intercom. */
+ id: string;
+ }
+
+ export namespace From {
+ /** The role associated to the contact - user or lead. */
+ export const Type = {
+ Lead: "lead",
+ User: "user",
+ Contact: "contact",
+ } as const;
+ export type Type = (typeof Type)[keyof typeof Type];
+ }
+}
diff --git a/src/api/resources/conversations/client/requests/DeleteConversationRequest.ts b/src/api/resources/conversations/client/requests/DeleteConversationRequest.ts
new file mode 100644
index 00000000..a5bf5e64
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/DeleteConversationRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * conversation_id: 1
+ * }
+ */
+export interface DeleteConversationRequest {
+ /** id */
+ conversation_id: number;
+}
diff --git a/src/api/resources/conversations/client/requests/DetachContactFromConversationRequest.ts b/src/api/resources/conversations/client/requests/DetachContactFromConversationRequest.ts
new file mode 100644
index 00000000..415bfae9
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/DetachContactFromConversationRequest.ts
@@ -0,0 +1,39 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * conversation_id: "123",
+ * contact_id: "123",
+ * admin_id: "5017690"
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123",
+ * contact_id: "123",
+ * admin_id: "5017690"
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123",
+ * contact_id: "123",
+ * admin_id: "5017690"
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123",
+ * contact_id: "123",
+ * admin_id: "5017690"
+ * }
+ */
+export interface DetachContactFromConversationRequest {
+ /** The identifier for the conversation as given by Intercom. */
+ conversation_id: string;
+ /** The identifier for the contact as given by Intercom. */
+ contact_id: string;
+ /** The `id` of the admin who is performing the action. */
+ admin_id: string;
+}
diff --git a/src/api/resources/conversations/client/requests/FindConversationRequest.ts b/src/api/resources/conversations/client/requests/FindConversationRequest.ts
new file mode 100644
index 00000000..c80a7032
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/FindConversationRequest.ts
@@ -0,0 +1,18 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * conversation_id: "123",
+ * display_as: "plaintext",
+ * include_translations: true
+ * }
+ */
+export interface FindConversationRequest {
+ /** The id of the conversation to target */
+ conversation_id: string;
+ /** Set to plaintext to retrieve conversation messages in plain text. */
+ display_as?: string;
+ /** If set to true, conversation parts will be translated to the detected language of the conversation. */
+ include_translations?: boolean;
+}
diff --git a/src/api/resources/conversations/client/requests/ListConversationsRequest.ts b/src/api/resources/conversations/client/requests/ListConversationsRequest.ts
new file mode 100644
index 00000000..4908f563
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/ListConversationsRequest.ts
@@ -0,0 +1,15 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * per_page: 1,
+ * starting_after: "starting_after"
+ * }
+ */
+export interface ListConversationsRequest {
+ /** How many results per page */
+ per_page?: number;
+ /** String used to get the next page of conversations. */
+ starting_after?: string;
+}
diff --git a/src/api/resources/conversations/client/requests/ManageConversationPartsRequest.ts b/src/api/resources/conversations/client/requests/ManageConversationPartsRequest.ts
new file mode 100644
index 00000000..a16fe3ec
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/ManageConversationPartsRequest.ts
@@ -0,0 +1,60 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * conversation_id: "123",
+ * body: {
+ * message_type: "close",
+ * type: "admin",
+ * admin_id: "12345"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123",
+ * body: {
+ * message_type: "snoozed",
+ * admin_id: "5017691",
+ * snoozed_until: 1673609604
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123",
+ * body: {
+ * message_type: "open",
+ * admin_id: "5017690"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123",
+ * body: {
+ * message_type: "assignment",
+ * type: "admin",
+ * admin_id: "12345",
+ * assignee_id: "4324241"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123",
+ * body: {
+ * message_type: "close",
+ * type: "admin",
+ * admin_id: "12345"
+ * }
+ * }
+ */
+export interface ManageConversationPartsRequest {
+ /** The identifier for the conversation as given by Intercom. */
+ conversation_id: string;
+ body: Intercom.ConversationsManageRequestBody;
+}
diff --git a/src/api/resources/conversations/client/requests/ReplyToConversationRequest.ts b/src/api/resources/conversations/client/requests/ReplyToConversationRequest.ts
new file mode 100644
index 00000000..9ef917d8
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/ReplyToConversationRequest.ts
@@ -0,0 +1,108 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "comment",
+ * type: "user",
+ * body: "Thanks again :)",
+ * intercom_user_id: "6762f1571bb69f9f2193bbbb"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "note",
+ * type: "admin",
+ * body: " An Unordered HTML List
An Ordered HTML List
- Coffee
- Tea
- Milk
",
+ * admin_id: "3156780"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "quick_reply",
+ * type: "admin",
+ * admin_id: "3156780",
+ * reply_options: [{
+ * text: "Yes",
+ * uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb"
+ * }, {
+ * text: "No",
+ * uuid: "f4a98af1-be56-4948-a57e-e1a83f8484c6"
+ * }]
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "comment",
+ * type: "user",
+ * body: "body",
+ * reply_options: [{
+ * text: "Yes",
+ * uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb"
+ * }],
+ * intercom_user_id: "6762f1621bb69f9f2193bbbe"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "comment",
+ * type: "user",
+ * body: "Thanks again :)",
+ * intercom_user_id: "6762f1661bb69f9f2193bbbf"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "comment",
+ * type: "user",
+ * body: "Thanks again :)",
+ * intercom_user_id: "6762f1571bb69f9f2193bbbb"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "comment",
+ * type: "user",
+ * body: "Thanks again :)",
+ * intercom_user_id: "6762f1571bb69f9f2193bbbb"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "123 or \"last\"",
+ * body: {
+ * message_type: "comment",
+ * type: "user",
+ * body: "Thanks again :)",
+ * intercom_user_id: "6762f1571bb69f9f2193bbbb"
+ * }
+ * }
+ */
+export interface ReplyToConversationRequest {
+ /** The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation */
+ conversation_id: string;
+ body: Intercom.ReplyConversationRequest;
+}
diff --git a/src/api/resources/conversations/client/requests/UpdateConversationRequest.ts b/src/api/resources/conversations/client/requests/UpdateConversationRequest.ts
new file mode 100644
index 00000000..164ecefe
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/UpdateConversationRequest.ts
@@ -0,0 +1,51 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * conversation_id: "conversation_id",
+ * display_as: "plaintext",
+ * read: true,
+ * title: "new conversation title",
+ * custom_attributes: {
+ * "issue_type": "Billing",
+ * "priority": "High"
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "conversation_id",
+ * display_as: "plaintext",
+ * custom_attributes: {
+ * "order": {}
+ * }
+ * }
+ *
+ * @example
+ * {
+ * conversation_id: "conversation_id",
+ * display_as: "plaintext",
+ * read: true,
+ * title: "new conversation title",
+ * custom_attributes: {
+ * "issue_type": "Billing",
+ * "priority": "High"
+ * }
+ * }
+ */
+export interface UpdateConversationRequest {
+ /** The id of the conversation to target */
+ conversation_id: string;
+ /** Set to plaintext to retrieve conversation messages in plain text. */
+ display_as?: string;
+ /** Mark a conversation as read within Intercom. */
+ read?: boolean;
+ /** The title given to the conversation */
+ title?: string;
+ custom_attributes?: Intercom.CustomAttributes;
+ /** The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. */
+ company_id?: string;
+}
diff --git a/src/api/resources/conversations/client/requests/index.ts b/src/api/resources/conversations/client/requests/index.ts
new file mode 100644
index 00000000..dbe79ca7
--- /dev/null
+++ b/src/api/resources/conversations/client/requests/index.ts
@@ -0,0 +1,11 @@
+export type { AttachContactToConversationRequest } from "./AttachContactToConversationRequest.js";
+export type { AutoAssignConversationRequest } from "./AutoAssignConversationRequest.js";
+export type { ConvertConversationToTicketRequest } from "./ConvertConversationToTicketRequest.js";
+export type { CreateConversationRequest } from "./CreateConversationRequest.js";
+export type { DeleteConversationRequest } from "./DeleteConversationRequest.js";
+export type { DetachContactFromConversationRequest } from "./DetachContactFromConversationRequest.js";
+export type { FindConversationRequest } from "./FindConversationRequest.js";
+export type { ListConversationsRequest } from "./ListConversationsRequest.js";
+export type { ManageConversationPartsRequest } from "./ManageConversationPartsRequest.js";
+export type { ReplyToConversationRequest } from "./ReplyToConversationRequest.js";
+export type { UpdateConversationRequest } from "./UpdateConversationRequest.js";
diff --git a/src/api/resources/conversations/index.ts b/src/api/resources/conversations/index.ts
new file mode 100644
index 00000000..d9adb1af
--- /dev/null
+++ b/src/api/resources/conversations/index.ts
@@ -0,0 +1,2 @@
+export * from "./client/index.js";
+export * from "./types/index.js";
diff --git a/src/api/resources/conversations/types/Conversation.ts b/src/api/resources/conversations/types/Conversation.ts
new file mode 100644
index 00000000..bf5334b2
--- /dev/null
+++ b/src/api/resources/conversations/types/Conversation.ts
@@ -0,0 +1,67 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact.
+ */
+export interface Conversation {
+ /** Always conversation. */
+ type: string;
+ /** The id representing the conversation. */
+ id: string;
+ /** The title given to the conversation. */
+ title?: string;
+ /** The time the conversation was created. */
+ created_at: number;
+ /** The last time the conversation was updated. */
+ updated_at: number;
+ /** The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. */
+ waiting_since?: number;
+ /** If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time. */
+ snoozed_until?: number;
+ /** Indicates whether a conversation is open (true) or closed (false). */
+ open: boolean;
+ /** Can be set to "open", "closed" or "snoozed". */
+ state: Conversation.State;
+ /** Indicates whether a conversation has been read. */
+ read: boolean;
+ /** If marked as priority, it will return priority or else not_priority. */
+ priority?: Conversation.Priority;
+ /** The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null. */
+ admin_assignee_id?: number;
+ /** The id of the team assigned to the conversation. If it's not assigned to a team it will return null. */
+ team_assignee_id?: string;
+ /** The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. */
+ company_id?: string;
+ tags?: Intercom.Tags;
+ conversation_rating?: Intercom.ConversationRating;
+ source: Intercom.ConversationSource;
+ contacts: Intercom.ConversationContacts;
+ teammates?: Intercom.ConversationTeammates;
+ custom_attributes: Intercom.CustomAttributes;
+ first_contact_reply?: Intercom.ConversationFirstContactReply;
+ sla_applied?: Intercom.SlaApplied;
+ statistics?: Intercom.ConversationStatistics;
+ conversation_parts?: Intercom.ConversationParts;
+ linked_objects?: Intercom.LinkedObjectList;
+ /** Indicates whether the AI Agent participated in the conversation. */
+ ai_agent_participated?: boolean;
+ ai_agent?: Intercom.AiAgent;
+}
+
+export namespace Conversation {
+ /** Can be set to "open", "closed" or "snoozed". */
+ export const State = {
+ Open: "open",
+ Closed: "closed",
+ Snoozed: "snoozed",
+ } as const;
+ export type State = (typeof State)[keyof typeof State];
+ /** If marked as priority, it will return priority or else not_priority. */
+ export const Priority = {
+ Priority: "priority",
+ NotPriority: "not_priority",
+ } as const;
+ export type Priority = (typeof Priority)[keyof typeof Priority];
+}
diff --git a/src/api/resources/conversations/types/ConversationsManageRequestBody.ts b/src/api/resources/conversations/types/ConversationsManageRequestBody.ts
new file mode 100644
index 00000000..7a8ef883
--- /dev/null
+++ b/src/api/resources/conversations/types/ConversationsManageRequestBody.ts
@@ -0,0 +1,27 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+export type ConversationsManageRequestBody =
+ | Intercom.ConversationsManageRequestBody.Close
+ | Intercom.ConversationsManageRequestBody.Snoozed
+ | Intercom.ConversationsManageRequestBody.Open
+ | Intercom.ConversationsManageRequestBody.Assignment;
+
+export namespace ConversationsManageRequestBody {
+ export interface Close extends Intercom.CloseConversationRequest {
+ message_type: "close";
+ }
+
+ export interface Snoozed extends Intercom.SnoozeConversationRequest {
+ message_type: "snoozed";
+ }
+
+ export interface Open extends Intercom.OpenConversationRequest {
+ message_type: "open";
+ }
+
+ export interface Assignment extends Intercom.AssignConversationRequest {
+ message_type: "assignment";
+ }
+}
diff --git a/src/api/resources/conversations/types/index.ts b/src/api/resources/conversations/types/index.ts
new file mode 100644
index 00000000..062aeafd
--- /dev/null
+++ b/src/api/resources/conversations/types/index.ts
@@ -0,0 +1,2 @@
+export * from "./Conversation.js";
+export * from "./ConversationsManageRequestBody.js";
diff --git a/src/api/resources/customChannelEvents/client/Client.ts b/src/api/resources/customChannelEvents/client/Client.ts
new file mode 100644
index 00000000..4ba0127c
--- /dev/null
+++ b/src/api/resources/customChannelEvents/client/Client.ts
@@ -0,0 +1,423 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace CustomChannelEventsClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+/**
+ * With the "Custom Channel" integration, you can bring Fin and Intercom capabilities to your own platform via API, enabling powerful custom integrations.
+ *
+ * Intercom treats your integration like any other Intercom channel, allowing your application and Intercom to exchange events seamlessly. This makes it possible, for example, for your users to interact with Fin directly within your own application’s UI.
+ *
+ * > **Note:** "Fin over API" is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.
+ */
+export class CustomChannelEventsClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: CustomChannelEventsClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration.
+ * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.
+ *
+ * @param {Intercom.CustomChannelBaseEvent} request
+ * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ * @throws {@link Intercom.UnprocessableEntityError}
+ *
+ * @example
+ * await client.customChannelEvents.notifyNewConversation({
+ * event_id: "event_id",
+ * external_conversation_id: "external_conversation_id",
+ * contact: {
+ * type: "user",
+ * external_id: "external_id"
+ * }
+ * })
+ */
+ public notifyNewConversation(
+ request: Intercom.CustomChannelBaseEvent,
+ requestOptions?: CustomChannelEventsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__notifyNewConversation(request, requestOptions));
+ }
+
+ private async __notifyNewConversation(
+ request: Intercom.CustomChannelBaseEvent,
+ requestOptions?: CustomChannelEventsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "custom_channel_events/notify_new_conversation",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.CustomChannelNotificationResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ case 422:
+ throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/custom_channel_events/notify_new_conversation",
+ );
+ }
+
+ /**
+ * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations.
+ * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.
+ *
+ * @param {Intercom.NotifyNewMessageRequest} request
+ * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ * @throws {@link Intercom.UnprocessableEntityError}
+ *
+ * @example
+ * await client.customChannelEvents.notifyNewMessage({
+ * body: "body",
+ * event_id: "event_id",
+ * external_conversation_id: "external_conversation_id",
+ * contact: {
+ * type: "user",
+ * external_id: "external_id"
+ * }
+ * })
+ */
+ public notifyNewMessage(
+ request: Intercom.NotifyNewMessageRequest,
+ requestOptions?: CustomChannelEventsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__notifyNewMessage(request, requestOptions));
+ }
+
+ private async __notifyNewMessage(
+ request: Intercom.NotifyNewMessageRequest,
+ requestOptions?: CustomChannelEventsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "custom_channel_events/notify_new_message",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.CustomChannelNotificationResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ case 422:
+ throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/custom_channel_events/notify_new_message",
+ );
+ }
+
+ /**
+ * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations.
+ * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.
+ *
+ * @param {Intercom.NotifyQuickReplySelectedRequest} request
+ * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ * @throws {@link Intercom.UnprocessableEntityError}
+ *
+ * @example
+ * await client.customChannelEvents.notifyQuickReplySelected({
+ * event_id: "evt_67890",
+ * external_conversation_id: "conv_13579",
+ * contact: {
+ * type: "user",
+ * external_id: "user_003",
+ * name: "Alice Example",
+ * email: "alice@example.com"
+ * },
+ * quick_reply_option_id: "1234"
+ * })
+ */
+ public notifyQuickReplySelected(
+ request: Intercom.NotifyQuickReplySelectedRequest,
+ requestOptions?: CustomChannelEventsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__notifyQuickReplySelected(request, requestOptions));
+ }
+
+ private async __notifyQuickReplySelected(
+ request: Intercom.NotifyQuickReplySelectedRequest,
+ requestOptions?: CustomChannelEventsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "custom_channel_events/notify_quick_reply_selected",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.CustomChannelNotificationResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ case 422:
+ throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/custom_channel_events/notify_quick_reply_selected",
+ );
+ }
+
+ /**
+ * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations.
+ * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support.
+ *
+ * @param {Intercom.NotifyAttributeCollectedRequest} request
+ * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ * @throws {@link Intercom.UnprocessableEntityError}
+ *
+ * @example
+ * await client.customChannelEvents.notifyAttributeCollected({
+ * attribute: {
+ * id: "id",
+ * value: "value"
+ * },
+ * event_id: "event_id",
+ * external_conversation_id: "external_conversation_id",
+ * contact: {
+ * type: "user",
+ * external_id: "external_id"
+ * }
+ * })
+ */
+ public notifyAttributeCollected(
+ request: Intercom.NotifyAttributeCollectedRequest,
+ requestOptions?: CustomChannelEventsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__notifyAttributeCollected(request, requestOptions));
+ }
+
+ private async __notifyAttributeCollected(
+ request: Intercom.NotifyAttributeCollectedRequest,
+ requestOptions?: CustomChannelEventsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "custom_channel_events/notify_attribute_collected",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.CustomChannelNotificationResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ case 422:
+ throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/custom_channel_events/notify_attribute_collected",
+ );
+ }
+}
diff --git a/src/api/resources/customChannelEvents/client/index.ts b/src/api/resources/customChannelEvents/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/customChannelEvents/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts b/src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts
new file mode 100644
index 00000000..a4a040d9
--- /dev/null
+++ b/src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts
@@ -0,0 +1,22 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * attribute: {
+ * id: "id",
+ * value: "value"
+ * },
+ * event_id: "event_id",
+ * external_conversation_id: "external_conversation_id",
+ * contact: {
+ * type: "user",
+ * external_id: "external_id"
+ * }
+ * }
+ */
+export interface NotifyAttributeCollectedRequest extends Intercom.CustomChannelBaseEvent {
+ attribute: Intercom.CustomChannelAttribute;
+}
diff --git a/src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts b/src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts
new file mode 100644
index 00000000..7f6483df
--- /dev/null
+++ b/src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts
@@ -0,0 +1,20 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * body: "body",
+ * event_id: "event_id",
+ * external_conversation_id: "external_conversation_id",
+ * contact: {
+ * type: "user",
+ * external_id: "external_id"
+ * }
+ * }
+ */
+export interface NotifyNewMessageRequest extends Intercom.CustomChannelBaseEvent {
+ /** The message content sent by the user. */
+ body: string;
+}
diff --git a/src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts b/src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts
new file mode 100644
index 00000000..e6cec3d9
--- /dev/null
+++ b/src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts
@@ -0,0 +1,22 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * event_id: "evt_67890",
+ * external_conversation_id: "conv_13579",
+ * contact: {
+ * type: "user",
+ * external_id: "user_003",
+ * name: "Alice Example",
+ * email: "alice@example.com"
+ * },
+ * quick_reply_option_id: "1234"
+ * }
+ */
+export interface NotifyQuickReplySelectedRequest extends Intercom.CustomChannelBaseEvent {
+ /** Id of the selected quick reply option. */
+ quick_reply_option_id: string;
+}
diff --git a/src/api/resources/customChannelEvents/client/requests/index.ts b/src/api/resources/customChannelEvents/client/requests/index.ts
new file mode 100644
index 00000000..702922d9
--- /dev/null
+++ b/src/api/resources/customChannelEvents/client/requests/index.ts
@@ -0,0 +1,3 @@
+export type { NotifyAttributeCollectedRequest } from "./NotifyAttributeCollectedRequest.js";
+export type { NotifyNewMessageRequest } from "./NotifyNewMessageRequest.js";
+export type { NotifyQuickReplySelectedRequest } from "./NotifyQuickReplySelectedRequest.js";
diff --git a/src/api/resources/customChannelEvents/index.ts b/src/api/resources/customChannelEvents/index.ts
new file mode 100644
index 00000000..914b8c3c
--- /dev/null
+++ b/src/api/resources/customChannelEvents/index.ts
@@ -0,0 +1 @@
+export * from "./client/index.js";
diff --git a/src/api/resources/customObjectInstances/client/Client.ts b/src/api/resources/customObjectInstances/client/Client.ts
new file mode 100644
index 00000000..0ae03367
--- /dev/null
+++ b/src/api/resources/customObjectInstances/client/Client.ts
@@ -0,0 +1,462 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace CustomObjectInstancesClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+/**
+ * Everything about your Custom Object instances.
+ * {% admonition type="warning" name="Permission Requirements" %}
+ * From now on, to access this endpoint, you need additional permissions. Please head over to the [Developer Hub](https://app.intercom.com/a/apps/_/developer-hub) app package authentication settings to configure the required permissions.
+ * {% /admonition %}
+ */
+export class CustomObjectInstancesClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: CustomObjectInstancesClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * Fetch a Custom Object Instance by external_id.
+ *
+ * @param {Intercom.GetCustomObjectInstancesByExternalIdRequest} request
+ * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.customObjectInstances.getCustomObjectInstancesByExternalId({
+ * custom_object_type_identifier: "Order",
+ * external_id: "external_id"
+ * })
+ */
+ public getCustomObjectInstancesByExternalId(
+ request: Intercom.GetCustomObjectInstancesByExternalIdRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(
+ this.__getCustomObjectInstancesByExternalId(request, requestOptions),
+ );
+ }
+
+ private async __getCustomObjectInstancesByExternalId(
+ request: Intercom.GetCustomObjectInstancesByExternalIdRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): Promise> {
+ const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request;
+ const _queryParams: Record = {};
+ _queryParams.external_id = externalId;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.CustomObjectInstance | undefined,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/custom_object_instances/{custom_object_type_identifier}",
+ );
+ }
+
+ /**
+ * Create or update a custom object instance
+ *
+ * @param {Intercom.CreateOrUpdateCustomObjectInstanceRequest} request
+ * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.customObjectInstances.createCustomObjectInstances({
+ * custom_object_type_identifier: "Order",
+ * external_id: "123",
+ * external_created_at: 1392036272,
+ * external_updated_at: 1392036272,
+ * custom_attributes: {
+ * "order_number": "ORDER-12345",
+ * "total_amount": "custom_attributes"
+ * }
+ * })
+ */
+ public createCustomObjectInstances(
+ request: Intercom.CreateOrUpdateCustomObjectInstanceRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__createCustomObjectInstances(request, requestOptions));
+ }
+
+ private async __createCustomObjectInstances(
+ request: Intercom.CreateOrUpdateCustomObjectInstanceRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): Promise> {
+ const { custom_object_type_identifier: customObjectTypeIdentifier, ..._body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}`,
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.CustomObjectInstance | undefined,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/custom_object_instances/{custom_object_type_identifier}",
+ );
+ }
+
+ /**
+ * Delete a single Custom Object instance by external_id.
+ *
+ * @param {Intercom.DeleteCustomObjectInstancesByIdRequest} request
+ * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.customObjectInstances.deleteCustomObjectInstancesById({
+ * custom_object_type_identifier: "Order",
+ * external_id: "external_id"
+ * })
+ */
+ public deleteCustomObjectInstancesById(
+ request: Intercom.DeleteCustomObjectInstancesByIdRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__deleteCustomObjectInstancesById(request, requestOptions));
+ }
+
+ private async __deleteCustomObjectInstancesById(
+ request: Intercom.DeleteCustomObjectInstancesByIdRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): Promise> {
+ const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request;
+ const _queryParams: Record = {};
+ _queryParams.external_id = externalId;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}`,
+ ),
+ method: "DELETE",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.CustomObjectInstanceDeleted, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "DELETE",
+ "/custom_object_instances/{custom_object_type_identifier}",
+ );
+ }
+
+ /**
+ * Fetch a Custom Object Instance by id.
+ *
+ * @param {Intercom.GetCustomObjectInstancesByIdRequest} request
+ * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.customObjectInstances.getCustomObjectInstancesById({
+ * custom_object_type_identifier: "Order",
+ * custom_object_instance_id: "custom_object_instance_id"
+ * })
+ */
+ public getCustomObjectInstancesById(
+ request: Intercom.GetCustomObjectInstancesByIdRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__getCustomObjectInstancesById(request, requestOptions));
+ }
+
+ private async __getCustomObjectInstancesById(
+ request: Intercom.GetCustomObjectInstancesByIdRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): Promise> {
+ const {
+ custom_object_type_identifier: customObjectTypeIdentifier,
+ custom_object_instance_id: customObjectInstanceId,
+ } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}/${core.url.encodePathParam(customObjectInstanceId)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.CustomObjectInstance | undefined,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/custom_object_instances/{custom_object_type_identifier}/{custom_object_instance_id}",
+ );
+ }
+
+ /**
+ * Delete a single Custom Object instance using the Intercom defined id.
+ *
+ * @param {Intercom.DeleteCustomObjectInstancesByExternalIdRequest} request
+ * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.customObjectInstances.deleteCustomObjectInstancesByExternalId({
+ * custom_object_type_identifier: "Order",
+ * custom_object_instance_id: "custom_object_instance_id"
+ * })
+ */
+ public deleteCustomObjectInstancesByExternalId(
+ request: Intercom.DeleteCustomObjectInstancesByExternalIdRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(
+ this.__deleteCustomObjectInstancesByExternalId(request, requestOptions),
+ );
+ }
+
+ private async __deleteCustomObjectInstancesByExternalId(
+ request: Intercom.DeleteCustomObjectInstancesByExternalIdRequest,
+ requestOptions?: CustomObjectInstancesClient.RequestOptions,
+ ): Promise> {
+ const {
+ custom_object_type_identifier: customObjectTypeIdentifier,
+ custom_object_instance_id: customObjectInstanceId,
+ } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}/${core.url.encodePathParam(customObjectInstanceId)}`,
+ ),
+ method: "DELETE",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.CustomObjectInstanceDeleted, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "DELETE",
+ "/custom_object_instances/{custom_object_type_identifier}/{custom_object_instance_id}",
+ );
+ }
+}
diff --git a/src/api/resources/customObjectInstances/client/index.ts b/src/api/resources/customObjectInstances/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/customObjectInstances/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts b/src/api/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts
new file mode 100644
index 00000000..97fa7ad7
--- /dev/null
+++ b/src/api/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts
@@ -0,0 +1,27 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * custom_object_type_identifier: "Order",
+ * external_id: "123",
+ * external_created_at: 1392036272,
+ * external_updated_at: 1392036272,
+ * custom_attributes: {
+ * "order_number": "ORDER-12345",
+ * "total_amount": "custom_attributes"
+ * }
+ * }
+ */
+export interface CreateOrUpdateCustomObjectInstanceRequest {
+ /** The unique identifier of the custom object type that defines the structure of the custom object instance. */
+ custom_object_type_identifier: string;
+ /** A unique identifier for the Custom Object instance in the external system it originated from. */
+ external_id?: string;
+ /** The time when the Custom Object instance was created in the external system it originated from. */
+ external_created_at?: number;
+ /** The time when the Custom Object instance was last updated in the external system it originated from. */
+ external_updated_at?: number;
+ /** The custom attributes which are set for the Custom Object instance. */
+ custom_attributes?: Record;
+}
diff --git a/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts b/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts
new file mode 100644
index 00000000..16385f5b
--- /dev/null
+++ b/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts
@@ -0,0 +1,15 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * custom_object_type_identifier: "Order",
+ * custom_object_instance_id: "custom_object_instance_id"
+ * }
+ */
+export interface DeleteCustomObjectInstancesByExternalIdRequest {
+ /** The unique identifier of the custom object type that defines the structure of the custom object instance. */
+ custom_object_type_identifier: string;
+ /** The Intercom defined id of the custom object instance */
+ custom_object_instance_id: string;
+}
diff --git a/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts b/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts
new file mode 100644
index 00000000..d97bc1ce
--- /dev/null
+++ b/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts
@@ -0,0 +1,14 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * custom_object_type_identifier: "Order",
+ * external_id: "external_id"
+ * }
+ */
+export interface DeleteCustomObjectInstancesByIdRequest {
+ /** The unique identifier of the custom object type that defines the structure of the custom object instance. */
+ custom_object_type_identifier: string;
+ external_id: string;
+}
diff --git a/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts b/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts
new file mode 100644
index 00000000..2d9d0fe3
--- /dev/null
+++ b/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts
@@ -0,0 +1,14 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * custom_object_type_identifier: "Order",
+ * external_id: "external_id"
+ * }
+ */
+export interface GetCustomObjectInstancesByExternalIdRequest {
+ /** The unique identifier of the custom object type that defines the structure of the custom object instance. */
+ custom_object_type_identifier: string;
+ external_id: string;
+}
diff --git a/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts b/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts
new file mode 100644
index 00000000..962a1337
--- /dev/null
+++ b/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts
@@ -0,0 +1,15 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * custom_object_type_identifier: "Order",
+ * custom_object_instance_id: "custom_object_instance_id"
+ * }
+ */
+export interface GetCustomObjectInstancesByIdRequest {
+ /** The unique identifier of the custom object type that defines the structure of the custom object instance. */
+ custom_object_type_identifier: string;
+ /** The id or external_id of the custom object instance */
+ custom_object_instance_id: string;
+}
diff --git a/src/api/resources/customObjectInstances/client/requests/index.ts b/src/api/resources/customObjectInstances/client/requests/index.ts
new file mode 100644
index 00000000..07816781
--- /dev/null
+++ b/src/api/resources/customObjectInstances/client/requests/index.ts
@@ -0,0 +1,5 @@
+export type { CreateOrUpdateCustomObjectInstanceRequest } from "./CreateOrUpdateCustomObjectInstanceRequest.js";
+export type { DeleteCustomObjectInstancesByExternalIdRequest } from "./DeleteCustomObjectInstancesByExternalIdRequest.js";
+export type { DeleteCustomObjectInstancesByIdRequest } from "./DeleteCustomObjectInstancesByIdRequest.js";
+export type { GetCustomObjectInstancesByExternalIdRequest } from "./GetCustomObjectInstancesByExternalIdRequest.js";
+export type { GetCustomObjectInstancesByIdRequest } from "./GetCustomObjectInstancesByIdRequest.js";
diff --git a/src/api/resources/customObjectInstances/index.ts b/src/api/resources/customObjectInstances/index.ts
new file mode 100644
index 00000000..d9adb1af
--- /dev/null
+++ b/src/api/resources/customObjectInstances/index.ts
@@ -0,0 +1,2 @@
+export * from "./client/index.js";
+export * from "./types/index.js";
diff --git a/src/api/resources/customObjectInstances/types/CustomObjectInstance.ts b/src/api/resources/customObjectInstances/types/CustomObjectInstance.ts
new file mode 100644
index 00000000..a4363acf
--- /dev/null
+++ b/src/api/resources/customObjectInstances/types/CustomObjectInstance.ts
@@ -0,0 +1,23 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * A Custom Object Instance represents an instance of a custom object type. This allows you to create and set custom attributes to store data about your customers that is not already captured by Intercom. The parent object includes recommended default attributes and you can add your own custom attributes.
+ */
+export interface CustomObjectInstance {
+ /** The Intercom defined id representing the custom object instance. */
+ id?: string;
+ /** The id you have defined for the custom object instance. */
+ external_id?: string;
+ /** The time when the Custom Object instance was created in the external system it originated from. */
+ external_created_at?: number;
+ /** The time when the Custom Object instance was last updated in the external system it originated from. */
+ external_updated_at?: number;
+ /** The time the attribute was created as a UTC Unix timestamp */
+ created_at?: number;
+ /** The time the attribute was last updated as a UTC Unix timestamp */
+ updated_at?: number;
+ /** The identifier of the custom object type that defines the structure of the custom object instance. */
+ type?: string;
+ /** The custom attributes you have set on the custom object instance. */
+ custom_attributes?: Record;
+}
diff --git a/src/api/resources/customObjectInstances/types/index.ts b/src/api/resources/customObjectInstances/types/index.ts
new file mode 100644
index 00000000..861f9ce5
--- /dev/null
+++ b/src/api/resources/customObjectInstances/types/index.ts
@@ -0,0 +1 @@
+export * from "./CustomObjectInstance.js";
diff --git a/src/api/resources/dataAttributes/client/Client.ts b/src/api/resources/dataAttributes/client/Client.ts
new file mode 100644
index 00000000..acff8f55
--- /dev/null
+++ b/src/api/resources/dataAttributes/client/Client.ts
@@ -0,0 +1,317 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace DataAttributesClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+/**
+ * Everything about your Data Attributes
+ */
+export class DataAttributesClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: DataAttributesClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations.
+ *
+ * @param {Intercom.ListDataAttributesRequest} request
+ * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.dataAttributes.list({
+ * model: "contact",
+ * include_archived: true
+ * })
+ */
+ public list(
+ request: Intercom.ListDataAttributesRequest = {},
+ requestOptions?: DataAttributesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
+ }
+
+ private async __list(
+ request: Intercom.ListDataAttributesRequest = {},
+ requestOptions?: DataAttributesClient.RequestOptions,
+ ): Promise> {
+ const { model, include_archived: includeArchived } = request;
+ const _queryParams: Record = {};
+ if (model != null) {
+ _queryParams.model = model;
+ }
+
+ if (includeArchived != null) {
+ _queryParams.include_archived = includeArchived.toString();
+ }
+
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "data_attributes",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.DataAttributeList, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/data_attributes");
+ }
+
+ /**
+ * You can create a data attributes for a `contact` or a `company`.
+ *
+ * @param {Intercom.CreateDataAttributeRequest} request
+ * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.dataAttributes.create({
+ * data_type: "string"
+ * })
+ *
+ * @example
+ * await client.dataAttributes.create({
+ * data_type: "integer"
+ * })
+ *
+ * @example
+ * await client.dataAttributes.create({
+ * options: [{
+ * value: "1-10"
+ * }]
+ * })
+ */
+ public create(
+ request: Intercom.CreateDataAttributeRequest,
+ requestOptions?: DataAttributesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
+ }
+
+ private async __create(
+ request: Intercom.CreateDataAttributeRequest,
+ requestOptions?: DataAttributesClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "data_attributes",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.DataAttribute, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/data_attributes");
+ }
+
+ /**
+ *
+ * You can update a data attribute.
+ *
+ * > 🚧 Updating the data type is not possible
+ * >
+ * > It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead.
+ *
+ * @param {Intercom.UpdateDataAttributeRequest} request
+ * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ * @throws {@link Intercom.UnprocessableEntityError}
+ *
+ * @example
+ * await client.dataAttributes.update({
+ * data_attribute_id: 1,
+ * body: {
+ * options: [{
+ * value: "1-10"
+ * }, {
+ * value: "11-20"
+ * }]
+ * }
+ * })
+ *
+ * @example
+ * await client.dataAttributes.update({
+ * data_attribute_id: 1,
+ * body: {
+ * options: [{
+ * value: "1-10"
+ * }, {
+ * value: "11-50"
+ * }]
+ * }
+ * })
+ *
+ * @example
+ * await client.dataAttributes.update({
+ * data_attribute_id: 1,
+ * body: {
+ * "description": "Trying to archieve",
+ * "archived": true
+ * }
+ * })
+ */
+ public update(
+ request: Intercom.UpdateDataAttributeRequest,
+ requestOptions?: DataAttributesClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions));
+ }
+
+ private async __update(
+ request: Intercom.UpdateDataAttributeRequest,
+ requestOptions?: DataAttributesClient.RequestOptions,
+ ): Promise> {
+ const { data_attribute_id: dataAttributeId, body: _body } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `data_attributes/${core.url.encodePathParam(dataAttributeId)}`,
+ ),
+ method: "PUT",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: _body,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.DataAttribute, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ case 422:
+ throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "PUT",
+ "/data_attributes/{data_attribute_id}",
+ );
+ }
+}
diff --git a/src/api/resources/dataAttributes/client/index.ts b/src/api/resources/dataAttributes/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/dataAttributes/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/dataAttributes/client/requests/ListDataAttributesRequest.ts b/src/api/resources/dataAttributes/client/requests/ListDataAttributesRequest.ts
new file mode 100644
index 00000000..f90a07a7
--- /dev/null
+++ b/src/api/resources/dataAttributes/client/requests/ListDataAttributesRequest.ts
@@ -0,0 +1,17 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * model: "contact",
+ * include_archived: true
+ * }
+ */
+export interface ListDataAttributesRequest {
+ /** Specify the data attribute model to return. */
+ model?: Intercom.DataAttributesListRequestModel;
+ /** Include archived attributes in the list. By default we return only non archived data attributes. */
+ include_archived?: boolean;
+}
diff --git a/src/api/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts b/src/api/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts
new file mode 100644
index 00000000..4b29b995
--- /dev/null
+++ b/src/api/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts
@@ -0,0 +1,55 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../../index.js";
+
+/**
+ * @example
+ * {
+ * data_attribute_id: 1,
+ * body: {
+ * options: [{
+ * value: "1-10"
+ * }, {
+ * value: "11-20"
+ * }]
+ * }
+ * }
+ *
+ * @example
+ * {
+ * data_attribute_id: 1,
+ * body: {
+ * options: [{
+ * value: "1-10"
+ * }, {
+ * value: "11-50"
+ * }]
+ * }
+ * }
+ *
+ * @example
+ * {
+ * data_attribute_id: 1,
+ * body: {
+ * options: [{
+ * value: "1-10"
+ * }, {
+ * value: "11-20"
+ * }]
+ * }
+ * }
+ *
+ * @example
+ * {
+ * data_attribute_id: 1,
+ * body: {
+ * "description": "Trying to archieve",
+ * "archived": true
+ * }
+ * }
+ */
+export interface UpdateDataAttributeRequest {
+ /** The data attribute id */
+ data_attribute_id: number;
+ body: Intercom.UpdateDataAttributeRequestBody;
+}
diff --git a/src/api/resources/dataAttributes/client/requests/index.ts b/src/api/resources/dataAttributes/client/requests/index.ts
new file mode 100644
index 00000000..a1a5824f
--- /dev/null
+++ b/src/api/resources/dataAttributes/client/requests/index.ts
@@ -0,0 +1,2 @@
+export type { ListDataAttributesRequest } from "./ListDataAttributesRequest.js";
+export type { UpdateDataAttributeRequest } from "./UpdateDataAttributeRequest.js";
diff --git a/src/api/resources/dataAttributes/index.ts b/src/api/resources/dataAttributes/index.ts
new file mode 100644
index 00000000..d9adb1af
--- /dev/null
+++ b/src/api/resources/dataAttributes/index.ts
@@ -0,0 +1,2 @@
+export * from "./client/index.js";
+export * from "./types/index.js";
diff --git a/src/api/resources/dataAttributes/types/DataAttribute.ts b/src/api/resources/dataAttributes/types/DataAttribute.ts
new file mode 100644
index 00000000..a2dbee88
--- /dev/null
+++ b/src/api/resources/dataAttributes/types/DataAttribute.ts
@@ -0,0 +1,59 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * Data Attributes are metadata used to describe your contact, company and conversation models. These include standard and custom attributes. By using the data attributes endpoint, you can get the global list of attributes for your workspace, as well as create and archive custom attributes.
+ */
+export interface DataAttribute {
+ /** Value is `data_attribute`. */
+ type: "data_attribute";
+ /** The unique identifier for the data attribute which is given by Intercom. Only available for custom attributes. */
+ id?: number;
+ /** Value is `contact` for user/lead attributes and `company` for company attributes. */
+ model?: DataAttribute.Model;
+ /** Name of the attribute. */
+ name: string;
+ /** Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on `.` to access nested user object values. */
+ full_name: string;
+ /** Readable name of the attribute (i.e. name you see in the UI) */
+ label: string;
+ /** Readable description of the attribute. */
+ description?: string;
+ /** The data type of the attribute. */
+ data_type: DataAttribute.DataType;
+ /** List of predefined options for attribute value. */
+ options?: string[];
+ /** Can this attribute be updated through API */
+ api_writable?: boolean;
+ /** Can this attribute be updated by the Messenger */
+ messenger_writable?: boolean;
+ /** Can this attribute be updated in the UI */
+ ui_writable?: boolean;
+ /** Set to true if this is a CDA */
+ custom?: boolean;
+ /** Is this attribute archived. (Only applicable to CDAs) */
+ archived?: boolean;
+ /** The time the attribute was created as a UTC Unix timestamp */
+ created_at?: number;
+ /** The time the attribute was last updated as a UTC Unix timestamp */
+ updated_at?: number;
+ /** Teammate who created the attribute. Only applicable to CDAs */
+ admin_id?: string;
+}
+
+export namespace DataAttribute {
+ /** Value is `contact` for user/lead attributes and `company` for company attributes. */
+ export const Model = {
+ Contact: "contact",
+ Company: "company",
+ } as const;
+ export type Model = (typeof Model)[keyof typeof Model];
+ /** The data type of the attribute. */
+ export const DataType = {
+ String: "string",
+ Integer: "integer",
+ Float: "float",
+ Boolean: "boolean",
+ Date: "date",
+ } as const;
+ export type DataType = (typeof DataType)[keyof typeof DataType];
+}
diff --git a/src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts b/src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts
new file mode 100644
index 00000000..8c42df63
--- /dev/null
+++ b/src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts
@@ -0,0 +1,9 @@
+// This file was auto-generated by Fern from our API Definition.
+
+export const DataAttributesListRequestModel = {
+ Contact: "contact",
+ Company: "company",
+ Conversation: "conversation",
+} as const;
+export type DataAttributesListRequestModel =
+ (typeof DataAttributesListRequestModel)[keyof typeof DataAttributesListRequestModel];
diff --git a/src/api/resources/dataAttributes/types/index.ts b/src/api/resources/dataAttributes/types/index.ts
new file mode 100644
index 00000000..cf0add2c
--- /dev/null
+++ b/src/api/resources/dataAttributes/types/index.ts
@@ -0,0 +1,2 @@
+export * from "./DataAttribute.js";
+export * from "./DataAttributesListRequestModel.js";
diff --git a/src/api/resources/dataEvents/index.ts b/src/api/resources/dataEvents/index.ts
new file mode 100644
index 00000000..2f88e301
--- /dev/null
+++ b/src/api/resources/dataEvents/index.ts
@@ -0,0 +1 @@
+export * from "./types/index.js";
diff --git a/src/api/resources/dataEvents/types/DataEvent.ts b/src/api/resources/dataEvents/types/DataEvent.ts
new file mode 100644
index 00000000..6efc5389
--- /dev/null
+++ b/src/api/resources/dataEvents/types/DataEvent.ts
@@ -0,0 +1,23 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * Data events are used to notify Intercom of changes to your data.
+ */
+export interface DataEvent {
+ /** The type of the object */
+ type: "event";
+ /** The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`. */
+ event_name: string;
+ /** The time the event occurred as a UTC Unix timestamp */
+ created_at: number;
+ /** Your identifier for the user. */
+ user_id?: string;
+ /** Your identifier for a lead or a user. */
+ id?: string;
+ /** The Intercom identifier for the user. */
+ intercom_user_id?: string;
+ /** An email address for your user. An email should only be used where your application uses email to uniquely identify users. */
+ email?: string;
+ /** Optional metadata about the event. */
+ metadata?: Record;
+}
diff --git a/src/api/resources/dataEvents/types/index.ts b/src/api/resources/dataEvents/types/index.ts
new file mode 100644
index 00000000..0272b738
--- /dev/null
+++ b/src/api/resources/dataEvents/types/index.ts
@@ -0,0 +1 @@
+export * from "./DataEvent.js";
diff --git a/src/api/resources/dataExport/client/Client.ts b/src/api/resources/dataExport/client/Client.ts
new file mode 100644
index 00000000..f9ea23e2
--- /dev/null
+++ b/src/api/resources/dataExport/client/Client.ts
@@ -0,0 +1,475 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace DataExportClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+/**
+ * Everything about your Data Exports
+ */
+export class DataExportClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: DataExportClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * @param {Intercom.ExportReportingDataRequest} request
+ * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.dataExport.exportReportingData({
+ * job_identifier: "job_identifier",
+ * app_id: "app_id",
+ * client_id: "client_id"
+ * })
+ */
+ public exportReportingData(
+ request: Intercom.ExportReportingDataRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__exportReportingData(request, requestOptions));
+ }
+
+ private async __exportReportingData(
+ request: Intercom.ExportReportingDataRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): Promise> {
+ const { job_identifier: jobIdentifier, app_id: appId, client_id: clientId } = request;
+ const _queryParams: Record = {};
+ _queryParams.app_id = appId;
+ _queryParams.client_id = clientId;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `export/reporting_data/${core.url.encodePathParam(jobIdentifier)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.DataExportExportReportingDataResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/export/reporting_data/{job_identifier}",
+ );
+ }
+
+ /**
+ * Download the data from a completed reporting data export job.
+ *
+ * > Octet header required
+ * >
+ * > You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint.
+ *
+ * @param {Intercom.DownloadReportingDataExportRequest} request
+ * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.dataExport.downloadReportingDataExport({
+ * job_identifier: "job_identifier",
+ * app_id: "app_id"
+ * })
+ */
+ public downloadReportingDataExport(
+ request: Intercom.DownloadReportingDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__downloadReportingDataExport(request, requestOptions));
+ }
+
+ private async __downloadReportingDataExport(
+ request: Intercom.DownloadReportingDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): Promise> {
+ const { job_identifier: jobIdentifier, app_id: appId } = request;
+ const _queryParams: Record = {};
+ _queryParams.app_id = appId;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({
+ Accept: "application/octet-stream",
+ "Intercom-Version": requestOptions?.version,
+ }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `download/reporting_data/${core.url.encodePathParam(jobIdentifier)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: undefined, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 404:
+ throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse);
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/download/reporting_data/{job_identifier}",
+ );
+ }
+
+ /**
+ * To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`.
+ *
+ * The only parameters you need to provide are the range of dates that you want exported.
+ *
+ * >🚧 Limit of one active job
+ * >
+ * > You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job.
+ *
+ * >❗️ Updated_at not included
+ * >
+ * > It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job.
+ *
+ * >📘 Date ranges are inclusive
+ * >
+ * > Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99.
+ *
+ * @param {Intercom.CreateDataExportRequest} request
+ * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @example
+ * await client.dataExport.create({
+ * created_at_after: 1734519776,
+ * created_at_before: 1734537776
+ * })
+ */
+ public create(
+ request: Intercom.CreateDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
+ }
+
+ private async __create(
+ request: Intercom.CreateDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "export/content/data",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.DataExport, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/export/content/data");
+ }
+
+ /**
+ * You can view the status of your job by sending a `GET` request to the URL
+ * `https://api.intercom.io/export/content/data/{job_identifier}` - the `{job_identifier}` is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model.
+ *
+ * > 🚧 Jobs expire after two days
+ * > All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available.
+ *
+ * @param {Intercom.FindDataExportRequest} request
+ * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @example
+ * await client.dataExport.find({
+ * job_identifier: "job_identifier"
+ * })
+ */
+ public find(
+ request: Intercom.FindDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions));
+ }
+
+ private async __find(
+ request: Intercom.FindDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): Promise> {
+ const { job_identifier: jobIdentifier } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `export/content/data/${core.url.encodePathParam(jobIdentifier)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.DataExport, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/export/content/data/{job_identifier}",
+ );
+ }
+
+ /**
+ * You can cancel your job
+ *
+ * @param {Intercom.CancelDataExportRequest} request
+ * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @example
+ * await client.dataExport.cancel({
+ * job_identifier: "job_identifier"
+ * })
+ */
+ public cancel(
+ request: Intercom.CancelDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__cancel(request, requestOptions));
+ }
+
+ private async __cancel(
+ request: Intercom.CancelDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): Promise> {
+ const { job_identifier: jobIdentifier } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `export/cancel/${core.url.encodePathParam(jobIdentifier)}`,
+ ),
+ method: "POST",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.DataExport, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/export/cancel/{job_identifier}",
+ );
+ }
+
+ /**
+ * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234.
+ *
+ * Your exported message data will be streamed continuously back down to you in a gzipped CSV format.
+ *
+ * > 📘 Octet header required
+ * >
+ * > You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint.
+ *
+ * @param {Intercom.DownloadDataExportRequest} request
+ * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @example
+ * await client.dataExport.download({
+ * job_identifier: "job_identifier"
+ * })
+ */
+ public download(
+ request: Intercom.DownloadDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__download(request, requestOptions));
+ }
+
+ private async __download(
+ request: Intercom.DownloadDataExportRequest,
+ requestOptions?: DataExportClient.RequestOptions,
+ ): Promise> {
+ const { job_identifier: jobIdentifier } = request;
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ `download/content/data/${core.url.encodePathParam(jobIdentifier)}`,
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: undefined, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/download/content/data/{job_identifier}",
+ );
+ }
+}
diff --git a/src/api/resources/dataExport/client/index.ts b/src/api/resources/dataExport/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/dataExport/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/dataExport/client/requests/CancelDataExportRequest.ts b/src/api/resources/dataExport/client/requests/CancelDataExportRequest.ts
new file mode 100644
index 00000000..4e387ec1
--- /dev/null
+++ b/src/api/resources/dataExport/client/requests/CancelDataExportRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * job_identifier: "job_identifier"
+ * }
+ */
+export interface CancelDataExportRequest {
+ /** job_identifier */
+ job_identifier: string;
+}
diff --git a/src/api/resources/dataExport/client/requests/CreateDataExportRequest.ts b/src/api/resources/dataExport/client/requests/CreateDataExportRequest.ts
new file mode 100644
index 00000000..b0bc000c
--- /dev/null
+++ b/src/api/resources/dataExport/client/requests/CreateDataExportRequest.ts
@@ -0,0 +1,15 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * created_at_after: 1734519776,
+ * created_at_before: 1734537776
+ * }
+ */
+export interface CreateDataExportRequest {
+ /** The start date that you request data for. It must be formatted as a unix timestamp. */
+ created_at_after: number;
+ /** The end date that you request data for. It must be formatted as a unix timestamp. */
+ created_at_before: number;
+}
diff --git a/src/api/resources/dataExport/client/requests/DownloadDataExportRequest.ts b/src/api/resources/dataExport/client/requests/DownloadDataExportRequest.ts
new file mode 100644
index 00000000..98aab0f3
--- /dev/null
+++ b/src/api/resources/dataExport/client/requests/DownloadDataExportRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * job_identifier: "job_identifier"
+ * }
+ */
+export interface DownloadDataExportRequest {
+ /** job_identifier */
+ job_identifier: string;
+}
diff --git a/src/api/resources/dataExport/client/requests/DownloadReportingDataExportRequest.ts b/src/api/resources/dataExport/client/requests/DownloadReportingDataExportRequest.ts
new file mode 100644
index 00000000..92bec12f
--- /dev/null
+++ b/src/api/resources/dataExport/client/requests/DownloadReportingDataExportRequest.ts
@@ -0,0 +1,13 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * job_identifier: "job_identifier",
+ * app_id: "app_id"
+ * }
+ */
+export interface DownloadReportingDataExportRequest {
+ job_identifier: string;
+ app_id: string;
+}
diff --git a/src/api/resources/dataExport/client/requests/ExportReportingDataRequest.ts b/src/api/resources/dataExport/client/requests/ExportReportingDataRequest.ts
new file mode 100644
index 00000000..15b8c300
--- /dev/null
+++ b/src/api/resources/dataExport/client/requests/ExportReportingDataRequest.ts
@@ -0,0 +1,24 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * job_identifier: "job_identifier",
+ * app_id: "app_id",
+ * client_id: "client_id"
+ * }
+ *
+ * @example
+ * {
+ * job_identifier: "job_identifier",
+ * app_id: "app_id",
+ * client_id: "client_id"
+ * }
+ */
+export interface ExportReportingDataRequest {
+ /** Unique identifier of the job. */
+ job_identifier: string;
+ /** The Intercom defined code of the workspace the company is associated to. */
+ app_id: string;
+ client_id: string;
+}
diff --git a/src/api/resources/dataExport/client/requests/FindDataExportRequest.ts b/src/api/resources/dataExport/client/requests/FindDataExportRequest.ts
new file mode 100644
index 00000000..cc335ddb
--- /dev/null
+++ b/src/api/resources/dataExport/client/requests/FindDataExportRequest.ts
@@ -0,0 +1,12 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * job_identifier: "job_identifier"
+ * }
+ */
+export interface FindDataExportRequest {
+ /** job_identifier */
+ job_identifier: string;
+}
diff --git a/src/api/resources/dataExport/client/requests/index.ts b/src/api/resources/dataExport/client/requests/index.ts
new file mode 100644
index 00000000..753260ad
--- /dev/null
+++ b/src/api/resources/dataExport/client/requests/index.ts
@@ -0,0 +1,6 @@
+export type { CancelDataExportRequest } from "./CancelDataExportRequest.js";
+export type { CreateDataExportRequest } from "./CreateDataExportRequest.js";
+export type { DownloadDataExportRequest } from "./DownloadDataExportRequest.js";
+export type { DownloadReportingDataExportRequest } from "./DownloadReportingDataExportRequest.js";
+export type { ExportReportingDataRequest } from "./ExportReportingDataRequest.js";
+export type { FindDataExportRequest } from "./FindDataExportRequest.js";
diff --git a/src/api/resources/dataExport/index.ts b/src/api/resources/dataExport/index.ts
new file mode 100644
index 00000000..d9adb1af
--- /dev/null
+++ b/src/api/resources/dataExport/index.ts
@@ -0,0 +1,2 @@
+export * from "./client/index.js";
+export * from "./types/index.js";
diff --git a/src/api/resources/dataExport/types/DataExport.ts b/src/api/resources/dataExport/types/DataExport.ts
new file mode 100644
index 00000000..002d8072
--- /dev/null
+++ b/src/api/resources/dataExport/types/DataExport.ts
@@ -0,0 +1,28 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * The data export api is used to view all message sent & viewed in a given timeframe.
+ */
+export interface DataExport {
+ /** The identifier for your job. */
+ job_identifier?: string;
+ /** The current state of your job. */
+ status?: DataExport.Status;
+ /** The time after which you will not be able to access the data. */
+ download_expires_at?: string;
+ /** The location where you can download your data. */
+ download_url?: string;
+}
+
+export namespace DataExport {
+ /** The current state of your job. */
+ export const Status = {
+ Pending: "pending",
+ InProgress: "in_progress",
+ Failed: "failed",
+ Completed: "completed",
+ NoData: "no_data",
+ Canceled: "canceled",
+ } as const;
+ export type Status = (typeof Status)[keyof typeof Status];
+}
diff --git a/src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts b/src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts
new file mode 100644
index 00000000..1eda3ab4
--- /dev/null
+++ b/src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts
@@ -0,0 +1,8 @@
+// This file was auto-generated by Fern from our API Definition.
+
+export interface DataExportExportReportingDataResponse {
+ job_identifier?: string;
+ status?: string;
+ download_url?: string;
+ download_expires_at?: string;
+}
diff --git a/src/api/resources/dataExport/types/index.ts b/src/api/resources/dataExport/types/index.ts
new file mode 100644
index 00000000..222f0cce
--- /dev/null
+++ b/src/api/resources/dataExport/types/index.ts
@@ -0,0 +1,2 @@
+export * from "./DataExport.js";
+export * from "./DataExportExportReportingDataResponse.js";
diff --git a/src/api/resources/events/client/Client.ts b/src/api/resources/events/client/Client.ts
new file mode 100644
index 00000000..2c645b76
--- /dev/null
+++ b/src/api/resources/events/client/Client.ts
@@ -0,0 +1,330 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace EventsClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+export class EventsClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: EventsClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ *
+ * > 🚧
+ * >
+ * > Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days
+ *
+ * The events belonging to a customer can be listed by sending a GET request to `https://api.intercom.io/events` with a user or lead identifier along with a `type` parameter. The identifier parameter can be one of `user_id`, `email` or `intercom_user_id`. The `type` parameter value must be `user`.
+ *
+ * - `https://api.intercom.io/events?type=user&user_id={user_id}`
+ * - `https://api.intercom.io/events?type=user&email={email}`
+ * - `https://api.intercom.io/events?type=user&intercom_user_id={id}` (this call can be used to list leads)
+ *
+ * The `email` parameter value should be [url encoded](http://en.wikipedia.org/wiki/Percent-encoding) when sending.
+ *
+ * You can optionally define the result page size as well with the `per_page` parameter.
+ *
+ * @param {Intercom.ListEventsRequest} request
+ * @param {EventsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.events.list({
+ * user_id: "user_id",
+ * intercom_user_id: "intercom_user_id",
+ * email: "email",
+ * type: "type",
+ * summary: true,
+ * per_page: 1
+ * })
+ */
+ public list(
+ request: Intercom.ListEventsRequest,
+ requestOptions?: EventsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions));
+ }
+
+ private async __list(
+ request: Intercom.ListEventsRequest,
+ requestOptions?: EventsClient.RequestOptions,
+ ): Promise> {
+ const {
+ user_id: userId,
+ intercom_user_id: intercomUserId,
+ email,
+ type: type_,
+ summary,
+ per_page: perPage,
+ } = request;
+ const _queryParams: Record = {};
+ if (userId != null) {
+ _queryParams.user_id = userId;
+ }
+
+ if (intercomUserId != null) {
+ _queryParams.intercom_user_id = intercomUserId;
+ }
+
+ if (email != null) {
+ _queryParams.email = email;
+ }
+
+ _queryParams.type = type_;
+ if (summary != null) {
+ _queryParams.summary = summary.toString();
+ }
+
+ if (perPage != null) {
+ _queryParams.per_page = perPage.toString();
+ }
+
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "events",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: _response.body as Intercom.DataEventSummary, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/events");
+ }
+
+ /**
+ *
+ * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a `Content-Type` of `application/json`.
+ *
+ * When using the JavaScript API, [adding the code to your app](http://docs.intercom.io/configuring-Intercom/tracking-user-events-in-your-app) makes the Events API available. Once added, you can submit an event using the `trackEvent` method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event.
+ *
+ * With the Ruby client you pass a hash describing the event to `Intercom::Event.create`, or call the `track_user` method directly on the current user object (e.g. `user.track_event`).
+ *
+ * **NB: For the JSON object types, please note that we do not currently support nested JSON structure.**
+ *
+ * | Type | Description | Example |
+ * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- |
+ * | String | The value is a JSON String | `"source":"desktop"` |
+ * | Number | The value is a JSON Number | `"load": 3.67` |
+ * | Date | The key ends with the String `_date` and the value is a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time), assumed to be in the [UTC](http://en.wikipedia.org/wiki/Coordinated_Universal_Time) timezone. | `"contact_date": 1392036272` |
+ * | Link | The value is a HTTP or HTTPS URI. | `"article": "https://example.org/ab1de.html"` |
+ * | Rich Link | The value is a JSON object that contains `url` and `value` keys. | `"article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"}` |
+ * | Monetary Amount | The value is a JSON object that contains `amount` and `currency` keys. The `amount` key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | `"price": {"amount": 34999, "currency": "eur"}` |
+ *
+ * **Lead Events**
+ *
+ * When submitting events for Leads, you will need to specify the Lead's `id`.
+ *
+ * **Metadata behaviour**
+ *
+ * - We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
+ * - It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
+ * - There might be up to 24 hrs delay when you send a new metadata for an existing event.
+ *
+ * **Event de-duplication**
+ *
+ * The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is **strongly recommended** to send a second granularity Unix timestamp in the `created_at` field.
+ *
+ * Duplicated events are responded to using the normal `202 Accepted` code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place.
+ *
+ * ### HTTP API Responses
+ *
+ * - Successful responses to submitted events return `202 Accepted` with an empty body.
+ * - Unauthorised access will be rejected with a `401 Unauthorized` or `403 Forbidden` response code.
+ * - Events sent about users that cannot be found will return a `404 Not Found`.
+ * - Event lists containing duplicate events will have those duplicates ignored.
+ * - Server errors will return a `500` response code and may contain an error message in the body.
+ *
+ *
+ * @param {Intercom.CreateDataEventRequest} request
+ * @param {EventsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.events.create({
+ * id: "8a88a590-e1c3-41e2-a502-e0649dbf721c",
+ * event_name: "invited-friend",
+ * created_at: 1671028894
+ * })
+ */
+ public create(
+ request: Intercom.CreateDataEventRequest,
+ requestOptions?: EventsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
+ }
+
+ private async __create(
+ request: Intercom.CreateDataEventRequest,
+ requestOptions?: EventsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "events",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: undefined, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/events");
+ }
+
+ /**
+ * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred.
+ *
+ *
+ * @param {Intercom.ListEventSummariesRequest} request
+ * @param {EventsClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ *
+ * @example
+ * await client.events.summaries()
+ */
+ public summaries(
+ request: Intercom.ListEventSummariesRequest = {},
+ requestOptions?: EventsClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__summaries(request, requestOptions));
+ }
+
+ private async __summaries(
+ request: Intercom.ListEventSummariesRequest = {},
+ requestOptions?: EventsClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "events/summaries",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return { data: undefined, rawResponse: _response.rawResponse };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/events/summaries");
+ }
+}
diff --git a/src/api/resources/events/client/index.ts b/src/api/resources/events/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/events/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/events/client/requests/ListEventSummariesRequest.ts b/src/api/resources/events/client/requests/ListEventSummariesRequest.ts
new file mode 100644
index 00000000..6c0d7bca
--- /dev/null
+++ b/src/api/resources/events/client/requests/ListEventSummariesRequest.ts
@@ -0,0 +1,28 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {}
+ */
+export interface ListEventSummariesRequest {
+ /** Your identifier for the user. */
+ user_id?: string;
+ /** A list of event summaries for the user. Each event summary should contain the event name, the time the event occurred, and the number of times the event occurred. The event name should be a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`. */
+ event_summaries?: ListEventSummariesRequest.EventSummaries;
+}
+
+export namespace ListEventSummariesRequest {
+ /**
+ * A list of event summaries for the user. Each event summary should contain the event name, the time the event occurred, and the number of times the event occurred. The event name should be a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`.
+ */
+ export interface EventSummaries {
+ /** The name of the event that occurred. A good event name is typically a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`. */
+ event_name?: string;
+ /** The number of times the event occurred. */
+ count?: number;
+ /** The first time the event was sent */
+ first?: number;
+ /** The last time the event was sent */
+ last?: number;
+ }
+}
diff --git a/src/api/resources/events/client/requests/ListEventsRequest.ts b/src/api/resources/events/client/requests/ListEventsRequest.ts
new file mode 100644
index 00000000..6617f912
--- /dev/null
+++ b/src/api/resources/events/client/requests/ListEventsRequest.ts
@@ -0,0 +1,27 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * user_id: "user_id",
+ * intercom_user_id: "intercom_user_id",
+ * email: "email",
+ * type: "type",
+ * summary: true,
+ * per_page: 1
+ * }
+ */
+export interface ListEventsRequest {
+ /** user_id query parameter */
+ user_id?: string;
+ /** intercom_user_id query parameter */
+ intercom_user_id?: string;
+ /** email query parameter */
+ email?: string;
+ /** The value must be user */
+ type: string;
+ /** summary flag */
+ summary?: boolean;
+ /** How many results to display per page. Defaults to 15 */
+ per_page?: number;
+}
diff --git a/src/api/resources/events/client/requests/index.ts b/src/api/resources/events/client/requests/index.ts
new file mode 100644
index 00000000..584ea81e
--- /dev/null
+++ b/src/api/resources/events/client/requests/index.ts
@@ -0,0 +1,2 @@
+export type { ListEventSummariesRequest } from "./ListEventSummariesRequest.js";
+export type { ListEventsRequest } from "./ListEventsRequest.js";
diff --git a/src/api/resources/events/index.ts b/src/api/resources/events/index.ts
new file mode 100644
index 00000000..914b8c3c
--- /dev/null
+++ b/src/api/resources/events/index.ts
@@ -0,0 +1 @@
+export * from "./client/index.js";
diff --git a/src/api/resources/export/client/Client.ts b/src/api/resources/export/client/Client.ts
new file mode 100644
index 00000000..521fe210
--- /dev/null
+++ b/src/api/resources/export/client/Client.ts
@@ -0,0 +1,176 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+
+export declare namespace ExportClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+export class ExportClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+
+ constructor(options: ExportClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ /**
+ * @param {Intercom.PostExportReportingDataEnqueueRequest} request
+ * @param {ExportClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.BadRequestError}
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.TooManyRequestsError}
+ *
+ * @example
+ * await client.export.enqueueANewReportingDataExportJob({
+ * dataset_id: "conversation",
+ * attribute_ids: ["conversation_id", "conversation_started_at"],
+ * start_time: 1717490000,
+ * end_time: 1717510000
+ * })
+ */
+ public enqueueANewReportingDataExportJob(
+ request: Intercom.PostExportReportingDataEnqueueRequest,
+ requestOptions?: ExportClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__enqueueANewReportingDataExportJob(request, requestOptions));
+ }
+
+ private async __enqueueANewReportingDataExportJob(
+ request: Intercom.PostExportReportingDataEnqueueRequest,
+ requestOptions?: ExportClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "export/reporting_data/enqueue",
+ ),
+ method: "POST",
+ headers: _headers,
+ contentType: "application/json",
+ queryParameters: requestOptions?.queryParams,
+ requestType: "json",
+ body: request,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.PostExportReportingDataEnqueueResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ switch (_response.error.statusCode) {
+ case 400:
+ throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse);
+ case 401:
+ throw new Intercom.UnauthorizedError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ case 429:
+ throw new Intercom.TooManyRequestsError(
+ _response.error.body as Intercom.Error_,
+ _response.rawResponse,
+ );
+ default:
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "POST",
+ "/export/reporting_data/enqueue",
+ );
+ }
+
+ /**
+ * @param {ExportClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @example
+ * await client.export.listAvailableDatasetsAndAttributes()
+ */
+ public listAvailableDatasetsAndAttributes(
+ requestOptions?: ExportClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__listAvailableDatasetsAndAttributes(requestOptions));
+ }
+
+ private async __listAvailableDatasetsAndAttributes(
+ requestOptions?: ExportClient.RequestOptions,
+ ): Promise> {
+ const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest();
+ const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
+ _authRequest.headers,
+ this._options?.headers,
+ mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }),
+ requestOptions?.headers,
+ );
+ const _response = await (this._options.fetcher ?? core.fetcher)({
+ url: core.url.join(
+ (await core.Supplier.get(this._options.baseUrl)) ??
+ (await core.Supplier.get(this._options.environment)) ??
+ environments.IntercomEnvironment.UsProduction,
+ "export/reporting_data/get_datasets",
+ ),
+ method: "GET",
+ headers: _headers,
+ queryParameters: requestOptions?.queryParams,
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000,
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
+ abortSignal: requestOptions?.abortSignal,
+ fetchFn: this._options?.fetch,
+ logging: this._options.logging,
+ });
+ if (_response.ok) {
+ return {
+ data: _response.body as Intercom.GetExportReportingDataGetDatasetsResponse,
+ rawResponse: _response.rawResponse,
+ };
+ }
+
+ if (_response.error.reason === "status-code") {
+ throw new errors.IntercomError({
+ statusCode: _response.error.statusCode,
+ body: _response.error.body,
+ rawResponse: _response.rawResponse,
+ });
+ }
+
+ return handleNonStatusCodeError(
+ _response.error,
+ _response.rawResponse,
+ "GET",
+ "/export/reporting_data/get_datasets",
+ );
+ }
+}
diff --git a/src/api/resources/export/client/index.ts b/src/api/resources/export/client/index.ts
new file mode 100644
index 00000000..195f9aa8
--- /dev/null
+++ b/src/api/resources/export/client/index.ts
@@ -0,0 +1 @@
+export * from "./requests/index.js";
diff --git a/src/api/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts b/src/api/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts
new file mode 100644
index 00000000..57767a44
--- /dev/null
+++ b/src/api/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts
@@ -0,0 +1,17 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * @example
+ * {
+ * dataset_id: "conversation",
+ * attribute_ids: ["conversation_id", "conversation_started_at"],
+ * start_time: 1717490000,
+ * end_time: 1717510000
+ * }
+ */
+export interface PostExportReportingDataEnqueueRequest {
+ dataset_id: string;
+ attribute_ids: string[];
+ start_time: number;
+ end_time: number;
+}
diff --git a/src/api/resources/export/client/requests/index.ts b/src/api/resources/export/client/requests/index.ts
new file mode 100644
index 00000000..a18772b7
--- /dev/null
+++ b/src/api/resources/export/client/requests/index.ts
@@ -0,0 +1 @@
+export type { PostExportReportingDataEnqueueRequest } from "./PostExportReportingDataEnqueueRequest.js";
diff --git a/src/api/resources/export/index.ts b/src/api/resources/export/index.ts
new file mode 100644
index 00000000..d9adb1af
--- /dev/null
+++ b/src/api/resources/export/index.ts
@@ -0,0 +1,2 @@
+export * from "./client/index.js";
+export * from "./types/index.js";
diff --git a/src/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts b/src/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts
new file mode 100644
index 00000000..725ac29a
--- /dev/null
+++ b/src/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts
@@ -0,0 +1,31 @@
+// This file was auto-generated by Fern from our API Definition.
+
+export interface GetExportReportingDataGetDatasetsResponse {
+ type?: string;
+ data?: GetExportReportingDataGetDatasetsResponse.Data.Item[];
+}
+
+export namespace GetExportReportingDataGetDatasetsResponse {
+ export type Data = Data.Item[];
+
+ export namespace Data {
+ export interface Item {
+ id?: string;
+ name?: string;
+ description?: string;
+ default_time_attribute_id?: string;
+ attributes?: Item.Attributes.Item[];
+ }
+
+ export namespace Item {
+ export type Attributes = Attributes.Item[];
+
+ export namespace Attributes {
+ export interface Item {
+ id?: string;
+ name?: string;
+ }
+ }
+ }
+ }
+}
diff --git a/src/api/resources/export/types/PostExportReportingDataEnqueueResponse.ts b/src/api/resources/export/types/PostExportReportingDataEnqueueResponse.ts
new file mode 100644
index 00000000..c15d988e
--- /dev/null
+++ b/src/api/resources/export/types/PostExportReportingDataEnqueueResponse.ts
@@ -0,0 +1,8 @@
+// This file was auto-generated by Fern from our API Definition.
+
+export interface PostExportReportingDataEnqueueResponse {
+ job_identifier?: string;
+ status?: string;
+ download_url?: string;
+ download_expires_at?: string;
+}
diff --git a/src/api/resources/export/types/index.ts b/src/api/resources/export/types/index.ts
new file mode 100644
index 00000000..27e82ed3
--- /dev/null
+++ b/src/api/resources/export/types/index.ts
@@ -0,0 +1,2 @@
+export * from "./GetExportReportingDataGetDatasetsResponse.js";
+export * from "./PostExportReportingDataEnqueueResponse.js";
diff --git a/src/api/resources/helpCenter/index.ts b/src/api/resources/helpCenter/index.ts
new file mode 100644
index 00000000..2f88e301
--- /dev/null
+++ b/src/api/resources/helpCenter/index.ts
@@ -0,0 +1 @@
+export * from "./types/index.js";
diff --git a/src/api/resources/helpCenter/types/Collection.ts b/src/api/resources/helpCenter/types/Collection.ts
new file mode 100644
index 00000000..7c9a53b2
--- /dev/null
+++ b/src/api/resources/helpCenter/types/Collection.ts
@@ -0,0 +1,34 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * Collections are top level containers for Articles within the Help Center.
+ */
+export interface Collection {
+ /** The unique identifier for the collection which is given by Intercom. */
+ id: string;
+ /** The id of the workspace which the collection belongs to. */
+ workspace_id: string;
+ /** The name of the collection. For multilingual collections, this will be the name of the default language's content. */
+ name: string;
+ /** The description of the collection. For multilingual help centers, this will be the description of the collection for the default language. */
+ description?: string;
+ /** The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content. */
+ created_at: number;
+ /** The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content. */
+ updated_at?: number;
+ /** The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language. */
+ url?: string;
+ /** The icon of the collection. */
+ icon?: string;
+ /** The order of the section in relation to others sections within a collection. Values go from `0` upwards. `0` is the default if there's no order. */
+ order: number;
+ /** The default locale of the help center. This field is only returned for multilingual help centers. */
+ default_locale?: string;
+ translated_content?: Intercom.GroupTranslatedContent;
+ /** The id of the parent collection. If `null` then it is the first level collection. */
+ parent_id?: string;
+ /** The id of the help center the collection is in. */
+ help_center_id?: number;
+}
diff --git a/src/api/resources/helpCenter/types/HelpCenter.ts b/src/api/resources/helpCenter/types/HelpCenter.ts
new file mode 100644
index 00000000..3715e87f
--- /dev/null
+++ b/src/api/resources/helpCenter/types/HelpCenter.ts
@@ -0,0 +1,25 @@
+// This file was auto-generated by Fern from our API Definition.
+
+/**
+ * Help Centers contain collections
+ */
+export interface HelpCenter {
+ /** The unique identifier for the Help Center which is given by Intercom. */
+ id?: string;
+ /** The id of the workspace which the Help Center belongs to. */
+ workspace_id?: string;
+ /** The time when the Help Center was created. */
+ created_at?: number;
+ /** The time when the Help Center was last updated. */
+ updated_at?: number;
+ /** The identifier of the Help Center. This is used in the URL of the Help Center. */
+ identifier?: string;
+ /** Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */
+ website_turned_on?: boolean;
+ /** The display name of the Help Center only seen by teammates. */
+ display_name?: string;
+ /** The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. */
+ url?: string;
+ /** Custom domain configured for the help center */
+ custom_domain?: string;
+}
diff --git a/src/api/resources/helpCenter/types/HelpCenterList.ts b/src/api/resources/helpCenter/types/HelpCenterList.ts
new file mode 100644
index 00000000..e034eaff
--- /dev/null
+++ b/src/api/resources/helpCenter/types/HelpCenterList.ts
@@ -0,0 +1,13 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as Intercom from "../../../index.js";
+
+/**
+ * A list of Help Centers belonging to the App
+ */
+export interface HelpCenterList {
+ /** The type of the object - `list`. */
+ type?: "list";
+ /** An array of Help Center objects */
+ data?: Intercom.HelpCenter[];
+}
diff --git a/src/api/resources/helpCenter/types/index.ts b/src/api/resources/helpCenter/types/index.ts
new file mode 100644
index 00000000..097e7b49
--- /dev/null
+++ b/src/api/resources/helpCenter/types/index.ts
@@ -0,0 +1,3 @@
+export * from "./Collection.js";
+export * from "./HelpCenter.js";
+export * from "./HelpCenterList.js";
diff --git a/src/api/resources/helpCenters/client/Client.ts b/src/api/resources/helpCenters/client/Client.ts
new file mode 100644
index 00000000..5541fb5c
--- /dev/null
+++ b/src/api/resources/helpCenters/client/Client.ts
@@ -0,0 +1,199 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
+import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
+import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js";
+import * as core from "../../../../core/index.js";
+import * as environments from "../../../../environments.js";
+import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
+import * as errors from "../../../../errors/index.js";
+import * as Intercom from "../../../index.js";
+import { CollectionsClient } from "../resources/collections/client/Client.js";
+
+export declare namespace HelpCentersClient {
+ export interface Options extends BaseClientOptions {}
+
+ export interface RequestOptions extends BaseRequestOptions {}
+}
+
+export class HelpCentersClient {
+ protected readonly _options: NormalizedClientOptionsWithAuth;
+ protected _collections: CollectionsClient | undefined;
+
+ constructor(options: HelpCentersClient.Options = {}) {
+ this._options = normalizeClientOptionsWithAuth(options);
+ }
+
+ public get collections(): CollectionsClient {
+ return (this._collections ??= new CollectionsClient(this._options));
+ }
+
+ /**
+ * You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`.
+ *
+ * @param {Intercom.FindHelpCenterRequest} request
+ * @param {HelpCentersClient.RequestOptions} requestOptions - Request-specific configuration.
+ *
+ * @throws {@link Intercom.UnauthorizedError}
+ * @throws {@link Intercom.NotFoundError}
+ *
+ * @example
+ * await client.helpCenters.find({
+ * help_center_id: 1
+ * })
+ */
+ public find(
+ request: Intercom.FindHelpCenterRequest,
+ requestOptions?: HelpCentersClient.RequestOptions,
+ ): core.HttpResponsePromise {
+ return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions));
+ }
+
+ private async __find(
+ request: Intercom.FindHelpCenterRequest,
+ requestOptions?: HelpCentersClient.RequestOptions,
+ ): Promise