{"id":13011,"library":"crisp-api","title":"Crisp API Node.js Client","description":"crisp-api is the official Node.js wrapper for the Crisp API, maintained directly by Crisp. It provides a comprehensive interface to interact with the Crisp platform's REST and WebSocket APIs, enabling developers to authenticate, manage conversations, send messages, access agent accounts, and build custom bots. The current stable version is 10.9.3, requiring Node.js 16.0.0 or higher. As an official library, it typically aligns closely with the latest API revisions (last updated 29/01/2026), offering stability and reliability for integrations. It differentiates itself by providing full API resource implementation, type definitions for TypeScript, and dedicated maintainer support from Crisp, ensuring it remains up-to-date with Crisp's evolving services.","status":"active","version":"10.9.3","language":"javascript","source_language":"en","source_url":"git://github.com/crisp-im/node-crisp-api","tags":["javascript","crisp","integration","wrapper","api","rest","websocket","typescript"],"install":[{"cmd":"npm install crisp-api","lang":"bash","label":"npm"},{"cmd":"yarn add crisp-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add crisp-api","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The main client class `Crisp` is a named export, not a default export.","wrong":"import Crisp from 'crisp-api';","symbol":"Crisp","correct":"import { Crisp } from 'crisp-api';"},{"note":"Even in CommonJS, `Crisp` is a named export, requiring destructuring.","wrong":"const Crisp = require('crisp-api');","symbol":"Crisp (CommonJS)","correct":"const { Crisp } = require('crisp-api');"},{"note":"Import the type for `Crisp` class if you're only using it in type annotations, common in TypeScript for tree-shaking benefits.","symbol":"Crisp (Type)","correct":"import type { Crisp } from 'crisp-api';"}],"quickstart":{"code":"import { Crisp } from 'crisp-api';\n\nconst identifier = process.env.CRISP_IDENTIFIER ?? '';\nconst key = process.env.CRISP_KEY ?? '';\nconst websiteID = process.env.CRISP_WEBSITE_ID ?? '';\n\nasync function main() {\n  if (!identifier || !key || !websiteID) {\n    console.error('Please set CRISP_IDENTIFIER, CRISP_KEY, and CRISP_WEBSITE_ID environment variables.');\n    process.exit(1);\n  }\n\n  const CrispClient = new Crisp();\n\n  try {\n    // Authenticate with your plugin token keypair\n    CrispClient.authenticateTier('plugin', identifier, key);\n    console.log('Authenticated successfully.');\n\n    // List conversations for a specific website\n    const conversations = await CrispClient.website.listConversations(websiteID, 1);\n    console.log(`Successfully listed ${conversations.length} conversations for website ${websiteID}:`);\n    conversations.forEach((conv: any) => {\n      console.log(`- Conversation ID: ${conv.session_id}, Status: ${conv.status}, Last Message: ${conv.last_message_text}`);\n    });\n  } catch (error: any) {\n    console.error('Error interacting with Crisp API:', error.message);\n    if (error.response) {\n      console.error('API Response Data:', error.response.data);\n    }\n  }\n}\n\nmain();\n","lang":"typescript","description":"This quickstart demonstrates authenticating to the Crisp API with plugin credentials and fetching a list of conversations for a specified website ID."},"warnings":[{"fix":"Upgrade your Node.js environment to version 16.0.0 or a later compatible version.","message":"The `crisp-api` package requires Node.js version 16.0.0 or higher. Earlier Node.js versions are not supported and may lead to runtime errors or unexpected behavior.","severity":"breaking","affected_versions":"<16.0.0"},{"fix":"Ensure you are using the correct token tier for the API operations you intend to perform. Refer to the Crisp API documentation for specific method permissions per tier.","message":"API methods are restricted based on your authentication token tier (`user`, `website`, or `plugin`). Attempting to call a method not permitted by your token tier will result in an authorization error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Store your API credentials in environment variables or a secure secrets management system. Never hardcode them directly in your source code or commit them to version control.","message":"Your authentication token keypair (identifier and key) should be kept strictly private and stored securely. Exposing these credentials can compromise your Crisp account and data.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always call `CrispClient.authenticateTier()` and wait for its completion (e.g., using `await` or `.then()`) before setting up any `CrispClient.on()` event listeners.","message":"When using WebSocket event listeners (e.g., `CrispClient.on('message:send', ...) `), ensure that you have successfully authenticated the `CrispClient` instance *before* registering the event listener. Events will not be processed otherwise.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"For CommonJS, use `const { Crisp } = require('crisp-api');`. For ESM, use `import { Crisp } from 'crisp-api';`.","cause":"Incorrect import statement, likely trying to use `require('crisp-api')` directly without destructuring, or using `import Crisp from 'crisp-api'` (default import) in an ESM context.","error":"ReferenceError: Crisp is not defined"},{"fix":"Verify that your `identifier` and `key` are correct and that the `authenticateTier` ('plugin', 'user', 'website') matches the permissions required for the API call. Consult the Crisp API documentation for specific method permissions.","cause":"Attempting to use an API method that is not permitted by the authentication token's tier (e.g., 'plugin' token trying to access 'user' specific methods) or using invalid credentials.","error":"Error: Not Authorized (website)"},{"fix":"Ensure `CrispClient = new Crisp()` is called correctly, and critically, `CrispClient.authenticateTier()` completes successfully before any `CrispClient.on()` calls.","cause":"This error occurs if you attempt to register a WebSocket event listener (e.g., `CrispClient.on`) before the client instance has been properly authenticated, or if the client instance itself is not correctly initialized.","error":"TypeError: CrispClient.on is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}