### Install Dependencies Source: https://github.com/intercom/intercom-openapi/blob/main/CLAUDE.md Command to install project dependencies. ```bash npm install ``` -------------------------------- ### Request Format Example Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/api-overview.md Demonstrates the expected format for a GET request to the contacts endpoint, including the base URL, host, and required headers. ```APIDOC ## Request Format All requests use `application/json` content type. ```http GET /contacts HTTP/1.1 Host: api.intercom.io Authorization: Bearer YOUR_ACCESS_TOKEN Intercom-Version: 2.15 Content-Type: application/json ``` ``` -------------------------------- ### Install Fern CLI Source: https://github.com/intercom/intercom-openapi/blob/main/CONTRIBUTING.md Install the Fern CLI globally using npm. This is required for interacting with the Fern toolchain. ```bash npm install -g fern-api ``` -------------------------------- ### Intercom API Request Format Example Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/api-overview.md Example of a GET request to the contacts endpoint, including all necessary headers. ```http GET /contacts HTTP/1.1 Host: api.intercom.io Authorization: Bearer YOUR_ACCESS_TOKEN Intercom-Version: 2.15 Content-Type: application/json ``` -------------------------------- ### List All Articles using GET Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/articles-api.md Fetch a list of all articles by making a GET request to the /articles endpoint. Articles are returned in descending order of their 'updated_at' attribute. ```http GET https://api.intercom.io/articles ``` -------------------------------- ### Create Lead Message Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/messages-api.md Example of creating a message initiated by a user, targeting a lead. ```json { "from": { "type": "lead", "id": "6762f2371bb69f9f2193bc18" }, "body": "heyy", "referer": "https://twitter.com/bob" } ``` -------------------------------- ### Create User Message Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/messages-api.md Example of creating an in-app message initiated by a user. ```json { "from": { "type": "user", "id": "6762f2341bb69f9f2193bc17" }, "body": "heyy", "referer": "https://twitter.com/bob" } ``` -------------------------------- ### Authenticate with Intercom API using Node.js Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md This Node.js example shows how to set up authentication headers for API requests using the fetch API. ```javascript const headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Intercom-Version": "2.15", "Content-Type": "application/json" }; const response = await fetch("https://api.intercom.io/me", { headers: headers }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Search Articles using GET Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/articles-api.md Search for articles by making a GET request to the /articles/search endpoint. You can filter by phrase, state, help_center_id, and request highlighting. ```http GET https://api.intercom.io/articles/search ``` -------------------------------- ### Get a Specific Article using GET Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/articles-api.md Retrieve the details of a single article by making a GET request to the /articles/{article_id} endpoint. Replace {article_id} with the article's unique identifier. ```http GET https://api.intercom.io/articles/ ``` -------------------------------- ### List Company Contacts Response Example Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/companies-api.md Example JSON response structure for listing contacts associated with a company. This includes data, total count, and pagination details. ```json { "type": "list", "data": [], "total_count": 0, "pages": { "type": "pages", "page": 1, "per_page": 50, "total_pages": 0 } } ... ``` -------------------------------- ### List All Admins Response Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/admins-api.md Example JSON response when listing all admins. Includes basic admin details and type information. ```json { "type": "admin.list", "admins": [ { "type": "admin", "email": "admin7@email.com", "id": "991267466", "name": "Ciaran7 Lee", "away_mode_enabled": false, "away_mode_reassign": false, "has_inbox_seat": true, "team_ids": [] } ] } ``` -------------------------------- ### Response Format Examples Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/api-overview.md Illustrates the structure of successful JSON responses and error responses from the Intercom API. ```APIDOC ## Response Format Responses are always in JSON format. ### Successful Response ```json { "type": "contact", "id": "12345", "email": "user@example.com", "name": "John Doe" } ``` ### Error Response ```json { "type": "error.list", "request_id": "request-uuid", "errors": [ { "code": "error_code", "message": "Error description" } ] } ``` ``` -------------------------------- ### Authenticate with Intercom API using Python Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md This Python example demonstrates how to include authentication headers in your requests using the requests library. ```python import requests headers = { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Intercom-Version": "2.15", "Content-Type": "application/json" } response = requests.get( "https://api.intercom.io/me", headers=headers ) data = response.json() print(data) ``` -------------------------------- ### List All Tags Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/tags-api.md Fetch a list of all tags for a given workspace using the GET /tags endpoint. ```http GET /tags ``` -------------------------------- ### Successful Message Creation Response Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/messages-api.md Example of a successful response when creating a message. ```json { "type": "user_message", "id": "403918396", "created_at": 1734537780, "body": "heyy", "message_type": "inapp", "conversation_id": "613" } ``` -------------------------------- ### Get Fern Generate Command Help Source: https://github.com/intercom/intercom-openapi/blob/main/CONTRIBUTING.md Obtain specific help for the `fern generate` command, including its options and usage. This is useful for understanding advanced generation configurations. ```bash fern generate help ``` -------------------------------- ### List Company Segments Response Example Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/companies-api.md Example JSON response structure for listing segments associated with a company. This response includes the type and a list of data. ```json { "type": "list", "data": [] } ... ``` -------------------------------- ### Retrieve an Admin Response Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/admins-api.md Example JSON response when retrieving details for a specific admin. Contains comprehensive admin information. ```json { "type": "admin", "id": "991267468", "name": "Ciaran9 Lee", "email": "admin9@email.com", "away_mode_enabled": false, "away_mode_reassign": false, "has_inbox_seat": true, "away_status_reason_id": null, "team_ids": [] } ``` -------------------------------- ### Create Admin Message Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/messages-api.md Example of an admin-initiated message to multiple users and leads, including CC and BCC recipients. ```json { "from": { "type": "admin", "id": "991267816" }, "to": [ { "type": "user", "id": "6762f2391bb69f9f2193bc19" }, { "type": "lead", "id": "6762f23c1bb69f9f2193bc1b" }, { "type": "user", "id": "6762f23d1bb69f9f2193bc1c" } ], "cc": [ { "type": "user", "id": "6762f23e1bb69f9f2193bc1d" }, { "type": "user", "id": "6762f23f1bb69f9f2193bc1e" } ], "bcc": [ { "type": "user", ``` -------------------------------- ### Get General Fern Help Source: https://github.com/intercom/intercom-openapi/blob/main/CONTRIBUTING.md Access general help information for the Fern CLI by running the `fern help` command. This provides an overview of available commands and options. ```bash fern help ``` -------------------------------- ### Verify Token with GET /me Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/best-practices.md Use this endpoint to verify if your authentication token is valid and not expired. ```http GET /me ``` -------------------------------- ### Handle Resource Not Found Error in Node.js Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md This Node.js example shows how to check for a 404 status code and log the error message when a requested resource is not found. ```javascript const response = await fetch( "https://api.intercom.io/contacts/nonexistent", { headers: { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Intercom-Version": "2.15" } } ); if (response.status === 404) { console.error("Contact not found"); const error = await response.json(); console.error(error.errors[0].message); } ``` -------------------------------- ### List Activity Logs Response Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/admins-api.md Example JSON response for listing admin activity logs. This shows the structure of the log list, including pagination details and individual activity log entries. ```json { "type": "activity_log.list", "pages": { "type": "pages", "next": null, "page": 1, "per_page": 20, "total_pages": 1 }, "activity_logs": [ { "id": "fca05814-4b72-4dce-ad4f-77a786a2c136", "performed_by": { "type": "admin", "id": "991267464", "email": "admin5@email.com", "ip": "127.0.0.1" }, "metadata": { "before": "before", "after": "after" }, "created_at": 1734537253, "activity_type": "app_name_change", "activity_description": "Ciaran5 Lee changed your app name from b" } ] } ``` -------------------------------- ### List All Articles Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/articles-api.md Fetch a list of all articles by making a GET request to the articles endpoint. Articles are returned in descending order of the `updated_at` attribute. ```APIDOC ## GET /articles ### Description Retrieve a list of all articles. ### Method GET ### Endpoint /articles ### Parameters #### Headers - **Intercom-Version** (string) - Required - The API version to use. ### Response #### Success Response (200) *Note: Response schema is not provided in the source.* ``` -------------------------------- ### Complex Contact Query (AND) Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/query-language.md Combines multiple conditions using the 'AND' operator to find contacts matching all criteria. This example finds contacts with emails containing '@example.com' and a 'premium' plan. ```json { "query": { "operator": "AND", "value": [ { "field": "email", "operator": "~", "value": "@example.com" }, { "field": "custom_attributes.plan", "operator": "=", "value": "premium" } ] } } ``` -------------------------------- ### Search Contacts Request Example Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/contacts-api.md This JSON object demonstrates the structure of a request body for searching contacts. It includes fields for filtering and pagination. ```json { "type": "list", "data": [], "total_count": 0, "pages": { "type": "pages", "page": 1, "per_page": 5, "total_pages": 0 } } ``` -------------------------------- ### List Notes for Contact Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/endpoints.md Use this GET endpoint to fetch a list of notes associated with a specific contact. Requires the contact_id. ```http GET /contacts/{contact_id}/notes ``` -------------------------------- ### List Subscriptions for Contact Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/endpoints.md Use this GET endpoint to fetch a list of subscription types attached to a contact. Requires the contact_id. ```http GET /contacts/{contact_id}/subscriptions ``` -------------------------------- ### Handle Authentication Error in Node.js Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md This Node.js example demonstrates how to catch and handle a 401 Unauthorized error when making API requests with an invalid token. ```javascript try { const response = await fetch("https://api.intercom.io/contacts", { headers: { "Authorization": "Bearer INVALID_TOKEN", "Intercom-Version": "2.15" } }); if (response.status === 401) { console.error("Authentication failed"); } const data = await response.json(); console.log(data); } catch (error) { console.error("Request failed:", error); } ``` -------------------------------- ### Search Contact by Custom Attribute Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/query-language.md Filter contacts based on the value of a custom attribute. This example searches for contacts with the 'premium' plan. ```json { "query": { "field": "custom_attributes.plan", "operator": "=", "value": "premium" } } ``` -------------------------------- ### Set Admin Away Status Response Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/admins-api.md Example JSON response when successfully setting an admin's away status. This includes details about the admin's current away mode configuration. ```json { "type": "admin", "id": "991267460", "name": "Ciaran2 Lee", "email": "admin2@email.com", "away_mode_enabled": true, "away_mode_reassign": true, "has_inbox_seat": true, "away_status_reason_id": "12345", "team_ids": [] } ``` -------------------------------- ### Complex Contact Query (OR) Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/query-language.md Combines multiple conditions using the 'OR' operator to find contacts matching any of the criteria. This example finds contacts with either a 'free' or 'trial' plan. ```json { "query": { "operator": "OR", "value": [ { "field": "custom_attributes.plan", "operator": "=", "value": "free" }, { "field": "custom_attributes.plan", "operator": "=", "value": "trial" } ] } } ``` -------------------------------- ### Get an Article Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/articles-api.md Fetch the details of a single article by making a GET request to the articles endpoint using the article's ID. ```APIDOC ## GET /articles/{article_id} ### Description Retrieve the details of a specific article. ### Method GET ### Endpoint /articles/{article_id} ### Parameters #### Path Parameters - **article_id** (integer) - Required - The unique identifier for the article. #### Headers - **Intercom-Version** (string) - Required - The API version to use. ### Response #### Success Response (200) *Note: Response schema is not provided in the source.* ``` -------------------------------- ### Create an Article using POST Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/articles-api.md Make a POST request to the /articles endpoint to create a new knowledge base article. Note that article tags are read-only via this API. ```http POST https://api.intercom.io/articles ``` -------------------------------- ### Intercom API Error Response Example Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/api-overview.md Example of a JSON response when an API request fails, detailing the error type and message. ```json { "type": "error.list", "request_id": "request-uuid", "errors": [ { "code": "error_code", "message": "Error description" } ] } ``` -------------------------------- ### Create a Contact Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/contacts-api.md Use this endpoint to create a new contact, such as a lead, in your workspace. Ensure the Intercom-Version header is included. ```json { "type": "contact", "id": "6762f0dd1bb69f9f2193bb83", "workspace_id": "this_is_an_id303_that_should_be_at_least_", "external_id": null, "role": "user", "email": "joebloggs@intercom.io", "phone": null, "name": null, "avatar": null, "owner_id": null, "social_profiles": { "type": "list", "data": [] }, "has_hard_bounced": false, "marked_email_as_spam": false, "unsubscribed_from_emails": false, "created_at": 1734537437, "updated_at": 1734537437, "signed_up ``` -------------------------------- ### Get a Contact by ID Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md Retrieves a specific contact by their unique identifier. ```APIDOC ## GET /contacts/{id} ### Description Retrieves a specific contact by their unique identifier. ### Method GET ### Endpoint https://api.intercom.io/contacts/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the contact. #### Headers - **Authorization** (string) - Required - Bearer token for authentication. - **Intercom-Version** (string) - Required - The API version to use. ### Response #### Success Response (200) - **type** (string) - The type of the contact object. - **id** (string) - The unique identifier for the contact. - **email** (string) - The email address of the contact. - **name** (string) - The name of the contact. ``` -------------------------------- ### Get a Ticket Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/tickets-api.md Fetch the details of a single ticket using its unique identifier. ```http GET /tickets/{ticket_id} ``` -------------------------------- ### Fern SDK Generation Commands Source: https://github.com/intercom/intercom-openapi/blob/main/CLAUDE.md Commands for generating SDKs, distinguishing between safe local previews and dangerous CI-only operations. ```bash # SAFE — local preview only fern generate --preview --group ts-sdk # DANGEROUS — opens PRs on SDK repos! fern generate --group ts-sdk ``` -------------------------------- ### Preview SDK Generation with Fern Source: https://github.com/intercom/intercom-openapi/blob/main/CONTRIBUTING.md Generate SDKs in preview mode to see the impact of changes without submitting pull requests. Always use the `--preview` flag for local development. The group name can be found in `generators.yml`. ```bash fern generate --preview --group ``` -------------------------------- ### Get Current User Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md Retrieves the details of the authenticated user making the API request. ```APIDOC ## GET /me ### Description Retrieves the details of the authenticated user. ### Method GET ### Endpoint https://api.intercom.io/me ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. - **Intercom-Version** (string) - Required - The API version to use. - **Content-Type** (string) - Required - Specifies the content type of the request body. ### Response #### Success Response (200) - **type** (string) - The type of the user object. - **id** (string) - The unique identifier for the user. - **name** (string) - The name of the user. - **email** (string) - The email address of the user. ``` -------------------------------- ### Project Directory Structure Source: https://github.com/intercom/intercom-openapi/blob/main/CLAUDE.md Overview of the repository file layout, including versioned API specifications and Fern configuration files. ```text descriptions/ 2.7/ ... 2.15/ # Stable versioned API specs (one YAML each) 0/ # Preview version (version "0" internally) fern/ generators.yml # SDK generation config (TS, Java, Python, PHP) openapi-overrides.yml # Fern overrides for stable spec (v2.14) preview-openapi-overrides.yml # Fern overrides for Preview fern.config.json # Fern org config scripts/ run-sync.js # Entry point for spec upload (CI only) upload-api-specification.js # Upload logic for ReadMe API postman/ # Postman collection generation postman/ # Postman collection outputs ``` -------------------------------- ### Get a Company Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/companies-api.md Fetches a single company's details using its unique identifier. ```APIDOC ## GET /companies/{company_id} ### Description Fetches a single company's details using its unique identifier. ### Method GET ### Endpoint /companies/{company_id} ### Parameters #### Path Parameters - **company_id** (string) - Required - The unique identifier for the company which is given by Intercom ### Response #### Success Response (200 OK) - **type** (string) - The type of the object, expected to be "company". - **company_id** (string) - The unique identifier for the company. - **id** (string) - The internal Intercom ID for the company. - **app_id** (string) - The ID of the app associated with the company. - **name** (string) - The name of the company. - **remote_created_at** (integer) - Timestamp of when the company was created in the remote system. - **created_at** (integer) - Timestamp of when the company was created in Intercom. - **updated_at** (integer) - Timestamp of when the company was last updated in Intercom. - **monthly_spend** (integer) - The monthly spend associated with the company. - **session_count** (integer) - The number of sessions for the company. - **user_count** (integer) - The number of users associated with the company. - **tags** (object) - An object containing a list of tags associated with the company. - **segments** (object) - An object containing a list of segments the company belongs to. ### Response Example ```json { "type": "company", "company_id": "1", "id": "6762f07f1bb69f9f2193baf5", "app_id": "this_is_an_id159_that_should_be_at_least_", "name": "company1", "remote_created_at": 1734537343, "created_at": 1734537343, "updated_at": 1734537343, "monthly_spend": 0, "session_count": 0, "user_count": 1, "tags": { "type": "tag.list", "tags": [] }, "segments": { "type": "se" } } ``` ``` -------------------------------- ### Get a Conversation using cURL Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md Fetch a specific conversation using its unique identifier. ```bash curl -X GET https://api.intercom.io/conversations/12345 \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Intercom-Version: 2.15" ``` -------------------------------- ### Validate and Preview SDK Generation Source: https://github.com/intercom/intercom-openapi/blob/main/CLAUDE.md Commands to validate the OpenAPI specification and generate a preview SDK using Fern. ```bash npm install -g fern-api fern check # Validate spec fern generate --preview --group ts-sdk # Preview SDK generation ``` -------------------------------- ### Combine Query with Pagination Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/query-language.md Demonstrates how to combine a search query with pagination parameters to control the number of results and cursor for fetching subsequent pages. ```json { "query": { ... }, "pagination": { "per_page": 50, "starting_after": "cursor_id" } } ``` -------------------------------- ### Get a Conversation Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/conversations-api.md Fetch the details of a single conversation. This will return a single Conversation model with all its conversation parts. ```APIDOC ## GET /conversations/{conversation_id} ### Description Retrieve the details of a single conversation, including all its parts. ### Method GET ### Endpoint /conversations/{conversation_id} ### Parameters #### Path Parameters - **conversation_id** (integer) - Required - The id of the conversation to target #### Query Parameters - **display_as** (string) - Optional - Set to plaintext to retrieve conversation messages in plain text. - **include_translations** (boolean) - Optional - If set to true, conversation parts will be translated to the detected language of the conversation. ### Response #### Success Response (200) - **conversation** (Conversation) - The Conversation model with all its parts. ``` -------------------------------- ### Handle Intercom API Tokens Securely Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/best-practices.md Demonstrates secure methods for loading and using API tokens, emphasizing environment variables over hardcoding. Avoid committing sensitive tokens to version control. ```javascript // Good: Load from environment const token = process.env.INTERCOM_API_TOKEN; // Good: Use in request const headers = { "Authorization": `Bearer ${token}`, "Intercom-Version": "2.15" }; // Bad: Hardcoded token const badHeaders = { "Authorization": "Bearer sk_live_1234567890abcdef" }; ``` -------------------------------- ### Create a Company using cURL Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md Create a new company record in Intercom, including its name, website, and custom attributes. ```bash curl -X POST https://api.intercom.io/companies \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Intercom-Version: 2.15" \ -H "Content-Type: application/json" \ -d '{ "name": "Acme Corp", "website": "https://acme.com", "custom_attributes": { "industry": "Technology" } }' ``` -------------------------------- ### Email Message Without Subject Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/messages-api.md Example of an email message where the subject is omitted. This is valid for email messages. ```json { "from": { "type": "admin", "id": "991267819" }, "to": { "type": "user", "user_id": "70" }, "message_type": "email", "body": "hey there" } ``` -------------------------------- ### List All Tags Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/tags-api.md Fetches a list of all tags for a given workspace. ```APIDOC ## GET /tags ### Description Fetches a list of all tags for a given workspace. ### Method GET ### Endpoint /tags ``` -------------------------------- ### Fin Agent API Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/full-endpoint-reference.md Endpoints for interacting with the Fin Agent, including replying to Fin and starting a conversation. ```APIDOC ## POST /fin/reply ### Description Reply to Fin. ### Method POST ### Endpoint /fin/reply ``` ```APIDOC ## POST /fin/start ### Description Start a conversation with Fin. ### Method POST ### Endpoint /fin/start ``` -------------------------------- ### Get a Contact by ID using cURL Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md Retrieve a specific contact by their unique ID using this cURL command. ```bash curl -X GET https://api.intercom.io/contacts/12345 \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Intercom-Version: 2.15" ``` -------------------------------- ### API Versioning Header Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/endpoints.md Specify the API version using the Intercom-Version header. For example, use '2.15' for this version. ```http Intercom-Version: 2.15 ``` -------------------------------- ### Message with Null Body Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/messages-api.md Example of a message where the body is explicitly set to null. This is valid for certain message types. ```json { "from": { "type": "admin", "id": "991267818" }, "to": { "type": "user", "id": "6762f23b1bb69f9f2193bc1a" }, "message_type": "inapp", "body": null, "subject": "heyy" } ``` -------------------------------- ### Create a ticket Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/endpoints.md Creates a new ticket in the system. ```APIDOC ## POST /tickets ### Description You can create a new ticket. ### Method POST ### Endpoint /tickets ### Response #### Success Response (200 OK) - Response body ### Response Example { "example": "{ // Response body }" } ``` -------------------------------- ### Sync New Customer to Intercom Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/workflows.md Use this function when a new customer signs up in your system to create a contact in Intercom. It handles creating the contact, attaching them to a company if specified, and returns the created contact object. Ensure you replace 'YOUR_ACCESS_TOKEN' with your actual Intercom API key. ```javascript async function syncCustomerToIntercom(customer) { // Create contact const contactResponse = await fetch("https://api.intercom.io/contacts", { method: "POST", headers: { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Intercom-Version": "2.15", "Content-Type": "application/json" }, body: JSON.stringify({ email: customer.email, name: customer.name, phone: customer.phone, custom_attributes: { plan: customer.plan, signup_date: new Date().toISOString() } }) }); const contact = await contactResponse.json(); console.log("Contact created:", contact.id); // Attach to company if applicable if (customer.companyId) { await fetch( `https://api.intercom.io/contacts/${contact.id}/companies`, { method: "POST", headers: { "Authorization": "Bearer YOUR_ACCESS_TOKEN", "Intercom-Version": "2.15", "Content-Type": "application/json" }, body: JSON.stringify({ company_id: customer.companyId }) } ); } return contact; } ``` -------------------------------- ### List Segments for Contact Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/endpoints.md Use this GET endpoint to fetch a list of segments associated with a specific contact. Requires the contact_id. ```http GET /contacts/{contact_id}/segments ``` -------------------------------- ### Create a Company Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/usage-examples.md Creates a new company in Intercom with provided details. ```APIDOC ## POST /companies ### Description Creates a new company in Intercom. ### Method POST ### Endpoint https://api.intercom.io/companies ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. - **Intercom-Version** (string) - Required - The API version to use. - **Content-Type** (string) - Required - Specifies the content type of the request body. #### Request Body - **name** (string) - Required - The name of the company. - **website** (string) - Optional - The website of the company. - **custom_attributes** (object) - Optional - A key-value object for custom attributes. - **industry** (string) - Example custom attribute. ### Request Example ```json { "name": "Acme Corp", "website": "https://acme.com", "custom_attributes": { "industry": "Technology" } } ``` ### Response #### Success Response (200) - **type** (string) - The type of the company object. - **id** (string) - The unique identifier for the company. - **name** (string) - The name of the company. - **website** (string) - The website of the company. - **custom_attributes** (object) - The custom attributes of the company. ``` -------------------------------- ### Email Message Without Body Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/messages-api.md Example of an email message where the body is explicitly set to null. This is valid for email messages. ```json { "from": { "type": "admin", "id": "991267820" }, "to": { "type": "user", "id": "6762f23d1bb69f9f2193bc1c" }, "message_type": "email", "body": null, "subject": "heyy" } ``` -------------------------------- ### Create a Ticket Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/tickets-api.md Use this endpoint to create a new support ticket in Intercom. ```http POST /tickets ``` -------------------------------- ### Create an Article Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/articles-api.md Create a new article by making a POST request to the articles endpoint. ```APIDOC ## POST /articles ### Description Create a new article. ### Method POST ### Endpoint /articles ### Parameters #### Headers - **Intercom-Version** (string) - Required - The API version to use. ### Request Body *Note: Request body schema is not provided in the source.* ``` -------------------------------- ### Intercom API Successful Response Example Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/api-overview.md A typical JSON response for a successful API request, such as retrieving contact information. ```json { "type": "contact", "id": "12345", "email": "user@example.com", "name": "John Doe" } ``` -------------------------------- ### List All Conversations Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/conversations-api.md Fetch a list of all conversations. You can optionally request the result page size and the cursor to start after to fetch the result. ```APIDOC ## GET /conversations ### Description Fetch a list of all conversations. You can optionally request the result page size and the cursor to start after to fetch the result. ### Method GET ### Endpoint /conversations ### Query Parameters - **per_page** (integer) - No - How many results per page - **starting_after** (string) - No - String used to get the next page of conversations. ``` -------------------------------- ### List All Companies (Batch) Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/companies-api.md Use the `POST /companies/list` endpoint to retrieve a list of companies. The list is sorted by `last_request_at` in descending order by default. Companies without associated users are not included. ```JSON { "type": "list", "data": [ { "type": "company", "company_id": "remote_companies_scroll_2", "id": "6762f0941bb69f9f2193bb25", "app_id": "this_is_an_id189_that_should_be_at_least_", "name": "IntercomQATest1", "remote_created_at": 1734537364, "created_at": 1734537364, "updated_at": 1734537364, "monthly_spend": 0, "session_count": 0, ... } ] } ``` -------------------------------- ### Get Contact by External ID Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/endpoints.md Fetch a single contact's details using their external ID. This endpoint is for users only, not leads. ```json { // Response body } ``` -------------------------------- ### List Attached Companies for Contact Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/endpoints.md Use this GET endpoint to fetch a list of companies associated with a specific contact. Requires the contact_id. ```http GET /contacts/{contact_id}/companies ``` -------------------------------- ### List Attached Contacts for Company Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/endpoints.md Use this GET endpoint to fetch a list of all contacts belonging to a specific company. Requires the company_id. ```http GET /companies/{company_id}/contacts ``` -------------------------------- ### Create Git Branch Source: https://github.com/intercom/intercom-openapi/blob/main/CONTRIBUTING.md Create a new branch for your changes using Git. It's recommended to prefix branch names with `my-` for clarity. ```bash git checkout -b my-branch-name ``` -------------------------------- ### Get a Company Response Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/companies-api.md This JSON structure represents the response when retrieving a single company by its ID. It includes detailed information about the company. ```json { "type": "company", "company_id": "1", "id": "6762f07f1bb69f9f2193baf5", "app_id": "this_is_an_id159_that_should_be_at_least_", "name": "company1", "remote_created_at": 1734537343, "created_at": 1734537343, "updated_at": 1734537343, "monthly_spend": 0, "session_count": 0, "user_count": 1, "tags": { "type": "tag.list", "tags": [] }, "segments": { "type": "se ... } ``` -------------------------------- ### Create a Tag Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/tags-api.md Creates a new tag by passing the tag name. ```APIDOC ## POST /tags ### Description Creates a new tag by passing the tag name. ### Method POST ### Endpoint /tags ``` -------------------------------- ### List Contact Tags Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/tags-api.md Fetch a list of all tags attached to a specific contact using the GET /contacts/{contact_id}/tags endpoint. ```http GET /contacts/{contact_id}/tags ``` -------------------------------- ### Create contact Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/endpoints.md You can create a new contact (user or lead). ```APIDOC ## POST /contacts ### Description Creates a new contact (user or lead). ### Method POST ### Endpoint /contacts ### Response #### Success Response (200 OK) - Response body (object) - The newly created contact details. ``` -------------------------------- ### Basic Query Structure Source: https://github.com/intercom/intercom-openapi/blob/main/_autodocs/query-language.md Illustrates the fundamental structure of a query object used for filtering API resources. ```json { "query": { "field": "field_name", "operator": "operator_name", "value": "value" } } ```