### Install, Start, and Enable Nginx Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nginx.mdx Installs Nginx, starts the service, and ensures it runs on boot. Verifies the status to confirm it's active. ```bash apt-get install -y nginx systemctl start nginx systemctl enable nginx systemctl status nginx ``` -------------------------------- ### Start MySQL Service Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/requirements/database.mdx Start the MySQL service on your system. ```bash sudo service mysql start ``` -------------------------------- ### Install Docker Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/docker.mdx Installs Docker on the server using the official installation script. This is a prerequisite for using Docker Swarm. ```bash curl -fsSL https://get.docker.com | bash ``` -------------------------------- ### Start PostgreSQL Service Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/requirements/database.mdx Start the PostgreSQL service on your system. ```bash sudo service postgresql start ``` -------------------------------- ### Build and Start Evolution API Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Build the application for production and start the Evolution API. ```bash npm run build npm run start:prod ``` -------------------------------- ### Install NVM Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Download and install NVM using the provided script. ```bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Navigate to the project directory and install all necessary Node.js dependencies. ```bash cd evolution-api npm install ``` -------------------------------- ### Install MySQL on Ubuntu Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/requirements/database.mdx Install the MySQL server package on Ubuntu-based systems. ```bash sudo apt-get update sudo apt-get install mysql-server ``` -------------------------------- ### Load NVM and Install Node.js Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Load NVM into the current environment and install the required Node.js version. ```bash source ~/.bashrc nvm install v20.10.0 && nvm use v20.10.0 ``` -------------------------------- ### Start API with PM2 Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Start the Evolution API using PM2, assigning it a name and configuring startup behavior. ```bash pm2 start 'npm run start:prod' --name ApiEvolution pm2 startup pm2 save --force ``` -------------------------------- ### Install PostgreSQL on Ubuntu Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/requirements/database.mdx Install PostgreSQL and its contrib package on Ubuntu-based systems. ```bash sudo apt-get update sudo apt-get install postgresql postgresql-contrib ``` -------------------------------- ### Create .env File Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Copy the example environment file to create a new .env file for custom configurations. ```bash cp ./.env.example ./.env ``` -------------------------------- ### Start Redis Server Service Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/requirements/redis.mdx Start the Redis server service on your local machine. ```bash sudo service redis-server start ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/evolution-foundation/docs-evolution/blob/main/README.md Install the Mintlify CLI globally to manage your documentation locally. This command is run in your terminal. ```bash npm i -g mintlify ``` -------------------------------- ### Install Redis Server on Ubuntu Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/requirements/redis.mdx Install the Redis server package on Ubuntu-based systems using apt-get. ```bash sudo apt-get update sudo apt-get install redis-server ``` -------------------------------- ### Start Mintlify Development Server Source: https://github.com/evolution-foundation/docs-evolution/blob/main/README.md Run the Mintlify development server from the root of your documentation project to preview changes locally. Ensure mint.json is present. ```bash mintlify dev ``` -------------------------------- ### Example cURL Request to Create Instance Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/evolution-channel.mdx This cURL command demonstrates how to send a POST request to create an instance with the specified parameters. ```bash curl -X POST http://API_URL/instance/create \ -H "Content-Type: application/json" \ -d '{ "instanceName": "MyInstance", "token": "123456", "number": "9876543210", "qrcode": false, "integration": "EVOLUTION" }' ``` -------------------------------- ### Install PM2 Globally Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Install PM2, a process manager for Node.js applications, globally on your system. ```bash npm install pm2 -g ``` -------------------------------- ### Install Dependencies and Restart API with PM2 Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/updates.mdx After updating the code, remove the existing `node_modules` directory for a clean installation, install the new dependencies using NPM, and then restart the Evolution API process using PM2. Optionally, view the logs to verify. ```shell # Remove the current node_modules directory to ensure a clean installation rm -rf node_modules # Install dependencies with NPM npm i # Restart the Evolution API with the updated version pm2 start ApiEvolution # Optionally, view the PM2 logs for the Evolution API pm2 log ApiEvolution ``` -------------------------------- ### Start Evolution API with Docker Compose Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/docker.mdx Command to build and start the Evolution API services defined in the docker-compose.yml file in detached mode. ```bash docker compose up -d ``` -------------------------------- ### Example Request to Create Instance Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/cloudapi.mdx This cURL command demonstrates how to send a POST request to the Evolution API v2 to create a WhatsApp Cloud API instance. It includes the necessary headers and a JSON payload with example values. ```bash curl -X POST http://API_URL/instance/create \ -H "Content-Type: application/json" \ -d '{ "instanceName": "MyInstance", "token": "EAAGm0PX4ZCpsBA...", "number": "1234567890", "businessId": "9876543210", "qrcode": false, "integration": "WHATSAPP-BUSINESS" }' ``` -------------------------------- ### Start PostgreSQL with Docker Compose Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/requirements/database.mdx Use this command to start a PostgreSQL instance in detached mode using Docker Compose. ```bash docker-compose up -d ``` -------------------------------- ### Get Webhook - GET /webhook/find/{instance} Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Retrieves the current webhook configuration for a given instance. Returns the enabled status, URL, and event subscriptions. ```bash curl -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ https://api.yoursite.com/webhook/find/my-instance ``` ```json { "enabled": true, "url": "https://yourapp.com/webhook", "webhookByEvents": true, "events": ["MESSAGES_UPSERT", "CONNECTION_UPDATE"] } ``` -------------------------------- ### Connect Instance - GET /instance/connect/{instance} Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Generates a QR code or pairing code for WhatsApp connection. Requires an API key and the instance name. ```bash curl -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ "https://api.yoursite.com/instance/connect/my-instance?number=5511999999999" ``` -------------------------------- ### Typebot Integration - Start Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Manually start a Typebot flow for a specific contact. ```APIDOC ## POST /typebot/start/{instance} ### Description Manually starts a Typebot flow for a specific contact. ### Method POST ### Endpoint /typebot/start/{instance} ### Parameters #### Path Parameters - **instance** (string) - Required - The instance ID. #### Request Body - **url** (string) - Required - The Typebot instance URL. - **typebot** (string) - Required - The Typebot ID. - **remoteJid** (string) - Required - The contact's JID. - **startSession** (boolean) - Optional - Whether to start a new session. - **variables** (array of objects) - Optional - Variables to pass to the Typebot flow. - **name** (string) - Required - The variable name. - **value** (string) - Required - The variable value. ### Request Example ```json { "url": "https://bot.yourcompany.com", "typebot": "onboarding-flow-abc123", "remoteJid": "5511999999999@s.whatsapp.net", "startSession": false, "variables": [ { "name": "pushName", "value": "John Doe" }, { "name": "plan", "value": "premium" } ] } ``` ``` -------------------------------- ### Install Certbot via Snap Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nginx.mdx Installs the Certbot tool, which is used to obtain and renew SSL certificates, using the snap package manager. ```bash snap install --classic certbot ``` -------------------------------- ### Update and Install AppArmor Utilities Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/docker.mdx Run this command on Hetzner servers to update package lists and install necessary AppArmor utilities. ```bash sudo apt-get update && sudo apt-get install -y apparmor-utils ``` -------------------------------- ### Install AppArmor Utilities on Hetzner Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/docker.mdx Installs necessary utilities for AppArmor on Hetzner servers, a prerequisite for some Docker Swarm configurations. ```bash sudo apt-get update && apt-get install -y apparmor-utils ``` -------------------------------- ### Verify NVM Installation Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Check if NVM is installed and accessible in the current environment. ```bash command -v nvm ``` -------------------------------- ### Get Connection State - GET /instance/connectionState/{instance} Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Retrieves the current WhatsApp connection state of a specified instance. Requires an API key. ```bash curl -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ https://api.yoursite.com/instance/connectionState/my-instance ``` -------------------------------- ### Evolution API Response Example Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Example of the JSON response received when the Evolution API is running successfully. ```json { "status": 200, "message": "Welcome to the Evolution API, it is working!", "version": "2.0.10", "clientName": "evolution01", "manager": "https://evo2.site.com/manager", "documentation": "https://doc.evolution-api.com" } ``` -------------------------------- ### Start API with Increased Memory Limit using PM2 Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Start the Evolution API with PM2, allocating more memory for the Node.js process. Recommended for servers with at least 4GB of RAM. ```bash pm2 start 'npm run start:prod' --name ApiEvolution -- start --node-args="--max-old-space-size=4096" --max-memory-restart 4G ``` -------------------------------- ### Manage Evolution API Service with Docker Compose Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Commands to start, view logs, and stop the Evolution API service deployed via Docker Compose. ```bash # Start the service docker compose up -d # Check logs docker logs evolution_api # Stop docker compose down ``` -------------------------------- ### Active Bot Initialization Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/typebot.mdx Actively start a Typebot for a specific contact. This allows for direct initiation of a bot conversation, optionally passing initial variables. ```APIDOC ## POST {{baseUrl}}/typebot/start/{{instance}} ### Description Actively start a Typebot for a specific contact. This allows for direct initiation of a bot conversation, optionally passing initial variables. ### Method POST ### Endpoint POST {{baseUrl}}/typebot/start/{{instance}} ### Parameters #### Request Body - **url** (string) - Required - The URL of the Typebot API. - **typebot** (string) - Required - The public name of the bot in Typebot. - **remoteJid** (string) - Required - JID (identifier) of the contact on WhatsApp. - **startSession** (boolean) - Optional - Whether to start a new session or continue an existing one. - **variables** (array) - Optional - An array of key-value pairs for initial variables. - **name** (string) - Required - The name of the variable. - **value** (string) - Required - The value of the variable. ### Request Example ```json { "url": "https://bot.dgcode.com.br", "typebot": "fluxo-unico-3uuso28", "remoteJid": "557499879409@s.whatsapp.net", "startSession": false, "variables": [ { "name": "pushName", "value": "Davidson Gomes" } ] } ``` ``` -------------------------------- ### Establish WebSocket Connection with Socket.IO Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/websocket.mdx Use Socket.IO to establish a WebSocket connection. Ensure you specify 'websocket' as a transport. This example connects in traditional mode. ```javascript const socket = io('wss://api.yoursite.com/instance_name', { transports: ['websocket'] }); socket.on('connect', () => { console.log('Connected to the Evolution API WebSocket'); }); // Listening to events socket.on('event_name', (data) => { console.log('Event received:', data); }); // Handling disconnection socket.on('disconnect', () => { console.log('Disconnected from the Evolution API WebSocket'); }); ``` -------------------------------- ### Deploy Database Migrations Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Apply database migrations to set up the database schema. ```bash npm run db:deploy ``` -------------------------------- ### Create a New WhatsApp Instance Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Use this POST request to create a new WhatsApp instance, configuring various settings like webhooks and integration type. The response includes instance details and API key hash. ```bash curl -X POST https://api.yoursite.com/instance/create \ -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ -H "Content-Type: application/json" \ -d '{ "instanceName": "my-instance", "token": "my-secret-token", "qrcode": true, "number": "5511999999999", "integration": "WHATSAPP-BAILEYS", "rejectCall": false, "msgCall": "Sorry, I cannot answer calls.", "groupsIgnore": true, "alwaysOnline": false, "readMessages": false, "readStatus": false, "syncFullHistory": false, "webhook": { "url": "https://yourapp.com/webhook", "byEvents": true, "base64": false, "events": ["MESSAGES_UPSERT", "CONNECTION_UPDATE", "QRCODE_UPDATED"] } }' # Response 201 { "instance": { "instanceName": "my-instance", "instanceId": "af6c5b7c-ee27-4f94-9ea8-192393746ddd", "webhook_wa_business": null, "access_token_wa_business": "", "status": "created" }, "hash": { "apikey": "my-secret-token" }, "settings": { "reject_call": false, "msg_call": "Sorry, I cannot answer calls.", "groups_ignore": true, "always_online": false, "read_messages": false, "read_status": false, "sync_full_history": false } } ``` -------------------------------- ### Configure S3 / MinIO Media Storage Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Configure environment variables to automatically store incoming WhatsApp media files in S3 or MinIO. Specify endpoint, credentials, and bucket details. ```bash # .env configuration S3_ENABLED=true S3_ACCESS_KEY=your-access-key S3_SECRET_KEY=your-secret-key S3_BUCKET=evolution S3_PORT=443 S3_USE_SSL=true # For Amazon S3 (include region in endpoint) S3_ENDPOINT=s3.eu-west-3.amazonaws.com S3_REGION=eu-west-3 # For MinIO (custom domain) S3_ENDPOINT=minio.yourcompany.com ``` -------------------------------- ### Manually Start Typebot Flow Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Initiates a Typebot flow for a specific contact, optionally setting initial variables. Useful for starting conversations programmatically. ```bash # Manually start a Typebot flow for a specific contact curl -X POST https://api.yoursite.com/typebot/start/my-instance \ -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ -H "Content-Type: application/json" \ -d '{ "url": "https://bot.yourcompany.com", "typebot": "onboarding-flow-abc123", "remoteJid": "5511999999999@s.whatsapp.net", "startSession": false, "variables": [ { "name": "pushName", "value": "John Doe" }, { "name": "plan", "value": "premium" } ] }' ``` -------------------------------- ### Restart Instance - PUT /instance/restart/{instance} Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Restarts an instance without interrupting the active WhatsApp session. Requires an API key. ```bash curl -X PUT \ -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ https://api.yoursite.com/instance/restart/my-instance ``` -------------------------------- ### Webhook Example with Speech-to-Text Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/openai.mdx This example demonstrates the structure of a webhook event when the speechToText parameter is enabled. It includes the transcribed text from audio messages within the 'speechToText' field. ```json { "event": "message", "data": { "message": { "id": "message-id", "from": "sender-number", "to": "receiver-number", "content": "Text message", "speechToText": "This is the transcribed text from the audio." } } } ``` -------------------------------- ### Re-install Mintlify Dependencies Source: https://github.com/evolution-foundation/docs-evolution/blob/main/README.md If Mintlify dev is not running, use this command to re-install dependencies. This is a troubleshooting step. ```bash mintlify install ``` -------------------------------- ### Create PostgreSQL Database Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/requirements/database.mdx Create a new database named 'evolution' for the Evolution API v2. ```bash sudo -u postgres createdb evolution ``` -------------------------------- ### Get Webhook Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Retrieves the current webhook configuration. ```APIDOC ## GET /webhook/find/{instance} ### Description Retrieves the current webhook configuration. ### Method GET ### Endpoint /webhook/find/{instance} ### Response #### Success Response (200) - **enabled** (boolean) - Whether the webhook is enabled. - **url** (string) - The URL of the webhook endpoint. - **webhookByEvents** (boolean) - Whether webhooks are routed by events. - **events** (array) - A list of subscribed events. #### Response Example ```json { "enabled": true, "url": "https://yourapp.com/webhook", "webhookByEvents": true, "events": ["MESSAGES_UPSERT", "CONNECTION_UPDATE"] } ``` **Webhook by-events URL routing** (when `webhookByEvents: true`): | Event | | --- | | `MESSAGES_UPSERT` | URL suffix appended: `/messages-upsert` | | `CONNECTION_UPDATE` | URL suffix appended: `/connection-update` | | `QRCODE_UPDATED` | URL suffix appended: `/qrcode-updated` | | `GROUP_PARTICIPANTS_UPDATE` | URL suffix appended: `/group-participants-update` | ``` -------------------------------- ### Configure Chatwoot Integration Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Connects an instance to Chatwoot for centralizing customer conversations. Requires Chatwoot account details and an admin token. ```bash # Configure Chatwoot on an existing instance curl -X POST https://api.yoursite.com/chatwoot/set/my-instance \ -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ -H "Content-Type: application/json" \ -d '{ "enabled": true, "accountId": "1", "token": "your-chatwoot-admin-token", "url": "https://chatwoot.yourcompany.com", "signMsg": true, "reopenConversation": true, "conversationPending": false, "nameInbox": "whatsapp-bot", "mergeBrazilContacts": true, "importContacts": true, "importMessages": true, "daysLimitImportMessages": 7, "signDelimiter": "\n", "autoCreate": true, "organization": "Support Bot", "logo": "https://example.com/logo.png" }' ``` -------------------------------- ### Connection State Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Gets the current WhatsApp connection state of an instance. ```APIDOC ## Connection State — `GET /instance/connectionState/{instance}` ### Description Gets the current WhatsApp connection state of an instance. ### Method GET ### Endpoint `/instance/connectionState/{instance}` ### Response #### Success Response (200) - **instance** (object) - Information about the instance. - **instanceName** (string) - The name of the instance. - **state** (string) - The connection state: `open`, `close`, or `connecting`. #### Response Example ```json { "instance": { "instanceName": "my-instance", "state": "open" } } ``` ``` -------------------------------- ### Fetch Invite Code Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Gets the current invite link code for a group. ```APIDOC ## GET /group/inviteCode/{instance} ### Description Gets the current invite link code for a group. ### Method GET ### Endpoint /group/inviteCode/{instance} ### Parameters #### Path Parameters - **instance** (string) - Required - The instance ID. #### Query Parameters - **groupJid** (string) - Required - The group JID. ### Response #### Success Response (200) - **inviteCode** (string) - The invite code. - **inviteUrl** (string) - The full invite URL. ### Response Example ```json { "inviteCode": "AbCd1234XyZ", "inviteUrl": "https://chat.whatsapp.com/AbCd1234XyZ" } ``` ``` -------------------------------- ### Create MySQL Database Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/requirements/database.mdx Create a new database named 'evolution' for the Evolution API v2 using the MySQL client. ```bash mysql -u root -p -e "CREATE DATABASE evolution;" ``` -------------------------------- ### Automatic Variables in EvoAI Session Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/evoai.mdx These variables are automatically provided when an EvoAI session starts, offering context about the contact and instance. ```json inputs: { remoteJid: "Contact JID", pushName: "Contact name", instanceName: "Instance name", serverUrl: "API server URL", apiKey: "Evolution API Key" }; ``` -------------------------------- ### Enable Nginx Virtual Host and Test Configuration Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nginx.mdx Creates a symbolic link to enable the custom virtual host configuration and tests the Nginx configuration syntax for errors. ```bash ln -s /etc/nginx/sites-available/api /etc/nginx/sites-enabled nginx -t ``` -------------------------------- ### Set Instance Settings Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Updates behavioral settings for a specific WhatsApp instance. Requires an ApiKey and Content-Type header. ```bash curl -X POST https://api.yoursite.com/settings/set/my-instance \ -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ -H "Content-Type: application/json" \ -d '{ "rejectCall": true, "msgCall": "Sorry, I cannot take calls right now.", "groupsIgnore": true, "alwaysOnline": true, "readMessages": true, "readStatus": false, "syncFullHistory": false }' ``` -------------------------------- ### Fetch Profile Picture URL Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/api-reference/chat-controller/fetch-profilepic-url.mdx Use this endpoint to get the URL of a user's profile picture. You need to provide the instance ID in the path. ```APIDOC ## POST /chat/fetchProfilePictureUrl/{instance} ### Description Retrieves the URL for a user's profile picture. ### Method POST ### Endpoint /chat/fetchProfilePictureUrl/{instance} ### Parameters #### Path Parameters - **instance** (string) - Required - The identifier for the instance. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **profilePictureUrl** (string) - The URL of the user's profile picture. #### Response Example ```json { "profilePictureUrl": "https://example.com/path/to/profile.jpg" } ``` ``` -------------------------------- ### Fetch Instances Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Returns all instances or a specific one by name or ID. ```APIDOC ## GET /instance/fetchInstances ### Description Returns all instances or a specific one by name or ID. ### Method GET ### Endpoint /instance/fetchInstances ### Parameters #### Query Parameters - **instanceName** (string) - Optional - The name of the instance to fetch. ### Request Example ```bash # Fetch all instances curl -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ https://api.yoursite.com/instance/fetchInstances # Fetch a specific instance by name curl -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ "https://api.yoursite.com/instance/fetchInstances?instanceName=my-instance" ``` ### Response #### Success Response (200) - **instances** (array) - A list of instance objects. - Each object contains details about an instance, such as `instanceName`, `instanceId`, `status`, etc. #### Response Example ```json [ { "instanceName": "my-instance", "instanceId": "af6c5b7c-ee27-4f94-9ea8-192393746ddd", "status": "running" } ] ``` ``` -------------------------------- ### Connect Instance Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Generates a QR code or pairing code for WhatsApp connection. ```APIDOC ## Connect Instance — `GET /instance/connect/{instance}` ### Description Generates a QR code / pairing code for WhatsApp connection. ### Method GET ### Endpoint `/instance/connect/{instance}` ### Parameters #### Query Parameters - **number** (string) - Required - The phone number to connect. ### Request Example ```bash curl -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ "https://api.yoursite.com/instance/connect/my-instance?number=5511999999999" ``` ### Response #### Success Response (200) - **pairingCode** (string) - The pairing code. - **code** (string) - The connection code. - **count** (integer) - The number of connections. #### Response Example ```json { "pairingCode": "WZYEH1YY", "code": "2@y8eK+bjtEjUWy9/FOM...", "count": 1 } ``` ``` -------------------------------- ### Media Storage Webhook Payload Example Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt When S3/MinIO storage is configured, media messages in the webhook payload will include a `mediaUrl` field pointing to the stored file. ```json { "event": "messages.upsert", "data": { "message": { "mediaUrl": "https://files.yourcompany.com/evolution/path/to/media/image.jpg", "imageMessage": { "caption": "..." } } } } ``` -------------------------------- ### Initialize Docker Swarm Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/docker.mdx Initializes a new Docker Swarm on the current node, making it the manager. Replace 'IP_SERVER' with the actual IP address of the server. ```bash docker swarm init --advertise-addr IP_SERVER ``` -------------------------------- ### Create Bot Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/evolution-bot.mdx Configure and create a new bot instance by specifying its behavior, triggers, and API integration details. ```APIDOC ## POST /evolutionBot/create/{{instance}} ### Description Creates a new bot instance with specified configurations. ### Method POST ### Endpoint POST {{baseUrl}}/evolutionBot/create/{{instance}} ### Parameters #### Request Body - **enabled** (boolean) - Required - Enables (`true`) or disables (`false`) the bot. - **apiUrl** (string) - Required - API URL that the bot will call (without a trailing `/`). - **apiKey** (string) - Optional - API key provided by your application. - **triggerType** (string) - Optional - Type of trigger to start the bot (`all` or `keyword`). Defaults to `keyword`. - **triggerOperator** (string) - Optional - Operator used to evaluate the trigger (`contains`, `equals`, `startsWith`, `endsWith`, `regex`, `none`). Defaults to `equals`. - **triggerValue** (string) - Optional - Value used in the trigger (e.g., a keyword or regex). - **expire** (number) - Optional - Time in minutes after which the bot expires. Defaults to `0`. - **keywordFinish** (string) - Optional - Keyword that ends the bot session. Defaults to `#EXIT`. - **delayMessage** (number) - Optional - Delay (in milliseconds) to simulate typing before sending a message. Defaults to `1000`. - **unknownMessage** (string) - Optional - Message sent when the user's input is not recognized. Defaults to `Message not recognized`. - **listeningFromMe** (boolean) - Optional - Defines if the bot should listen to messages sent by the user. Defaults to `false`. - **stopBotFromMe** (boolean) - Optional - Defines if the bot should stop when the user sends a message. Defaults to `false`. - **keepOpen** (boolean) - Optional - Keeps the session open, preventing the bot from restarting for the same contact. Defaults to `false`. - **debounceTime** (number) - Optional - Time (in seconds) to combine multiple messages into one. Defaults to `0`. - **ignoreJids** (array) - Optional - List of JIDs of contacts that will not activate the bot. Defaults to `[]`. ### Request Example ```json { "enabled": true, "apiUrl": "http://api.site.com/v1", "apiKey": "app-123456", "triggerType": "keyword", "triggerOperator": "equals", "triggerValue": "test", "expire": 0, "keywordFinish": "#EXIT", "delayMessage": 1000, "unknownMessage": "Message not recognized", "listeningFromMe": false, "stopBotFromMe": false, "keepOpen": false, "debounceTime": 0, "ignoreJids": [] } ``` ### Response #### Success Response (200) - **message** (string) - The response message from the bot. #### Response Example ```json { "message": "Your response here" } ``` ``` -------------------------------- ### Authenticate API Requests with ApiKey Header Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt All requests to the Evolution API must include the 'ApiKey' header. This example shows how to fetch instances using cURL. ```bash # All requests must include this header curl -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ https://api.yoursite.com/instance/fetchInstances ``` -------------------------------- ### Evolution Channel Message Input Payload Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/evolution-channel.mdx This is an example of the JSON payload format received by the Evolution Channel webhook when a message is sent. It includes sender details and message content. ```json { "numberId": "1234567", "key": { "remoteJid": "557499879409", "fromMe": false, "id": "ABC1234" }, "pushName": "Davidson", "message": { "conversation": "What is your name?" }, "messageType": "conversation" } ``` -------------------------------- ### Set Webhook - POST /webhook/set/{instance} Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Configures the webhook endpoint and event subscriptions for an instance. Requires a URL, and optionally enables event-specific routing. ```bash curl -X POST https://api.yoursite.com/webhook/set/my-instance \ -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ -H "Content-Type: application/json" \ -d '{ "enabled": true, "url": "https://yourapp.com/webhook", "webhookByEvents": true, "webhookBase64": false, "events": [ "QRCODE_UPDATED", "MESSAGES_UPSERT", "MESSAGES_UPDATE", "MESSAGES_DELETE", "SEND_MESSAGE", "CONNECTION_UPDATE", "CONTACTS_UPDATE", "GROUPS_UPSERT", "GROUP_PARTICIPANTS_UPDATE", "CALL" ] }' ``` ```json { "webhook": { "instanceName": "my-instance", "webhook": { "url": "https://yourapp.com/webhook", "events": ["QRCODE_UPDATED", "MESSAGES_UPSERT", "CONNECTION_UPDATE"], "enabled": true } } } ``` -------------------------------- ### Generate Prisma Client Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/install/nvm.mdx Generate the Prisma client files, which are necessary for database interactions. ```bash npm run db:generate ``` -------------------------------- ### Restart Docker Containers Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/updates.mdx After pulling the latest Docker image, use these commands to stop the current containers and then start them with the updated image. The '-d' flag runs containers in detached mode. ```shell docker compose down && docker compose up -d ``` -------------------------------- ### Active Typebot Initialization Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/typebot.mdx Initiate a Typebot bot actively for a contact. You can specify bot URL, typebot ID, and initial variables like 'pushName'. Set 'startSession' to false to prevent immediate session start. ```json { "url": "https://bot.dgcode.com.br", "typebot": "fluxo-unico-3uuso28", "remoteJid": "557499879409@s.whatsapp.net", "startSession": false, "variables": [ { "name": "pushName", "value": "Davidson Gomes" } ] } ``` -------------------------------- ### Fetch WhatsApp Instances Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Retrieve a list of all WhatsApp instances or a specific instance by its name. Requires the 'ApiKey' header for authentication. ```bash # Fetch all instances curl -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ https://api.yoursite.com/instance/fetchInstances # Fetch a specific instance by name curl -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ "https://api.yoursite.com/instance/fetchInstances?instanceName=my-instance" ``` -------------------------------- ### Create Dify AI Bot Instance Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Connect Dify AI bots to WhatsApp by creating an instance. Specify Dify API URL and key, along with trigger settings. ```bash curl -X POST https://api.yoursite.com/dify/create/my-instance \ -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ -H "Content-Type: application/json" \ -d '{ "enabled": true, "botType": "chatBot", "apiUrl": "https://dify.yourcompany.com/v1", "apiKey": "app-abc123", "triggerType": "keyword", "triggerOperator": "startsWith", "triggerValue": "dify", "expire": 30, "keywordFinish": "#EXIT", "delayMessage": 1000, "unknownMessage": "I did not understand that.", "listeningFromMe": false, "stopBotFromMe": false, "keepOpen": false, "debounceTime": 0, "ignoreJids": [] }' ``` -------------------------------- ### Create OpenAI Chat Completion Bot Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/openai.mdx Create a chat completion bot using a specified OpenAI model. Configure system messages, initial assistant messages, and user message examples for desired behavior. ```json { "enabled": true, "openaiCredsId": "clyrx36wj0001119ucjjzxik1", "botType": "chatCompletion", "model": "gpt-4", "systemMessages": [ "You are a helpful assistant." ], "assistantMessages": [ "\n\nHello there, how may I assist you today?" ], "userMessages": [ "Hello!" ], "maxTokens": 300, "triggerType": "keyword", "triggerOperator": "equals", "triggerValue": "test", "expire": 20, "keywordFinish": "#EXIT", "delayMessage": 1000, "unknownMessage": "Message not recognized", "listeningFromMe": false, "stopBotFromMe": false, "keepOpen": false, "debounceTime": 10, "ignoreJids": [] } ``` -------------------------------- ### Register OpenAI Credentials Source: https://context7.com/evolution-foundation/docs-evolution/llms.txt Registers your OpenAI API key with the instance. This is the first step to integrating GPT-based models. ```bash # Step 1: Register OpenAI credentials curl -X POST https://api.yoursite.com/openai/creds/my-instance \ -H "ApiKey: 429683C4C977415CAAFCCE10F7D57E11" \ -H "Content-Type: application/json" \ -d '{ "name": "my-openai-key", "apiKey": "sk-proj-..." }' ``` -------------------------------- ### Workflow Input Variables Example Source: https://github.com/evolution-foundation/docs-evolution/blob/main/v2/en/integrations/flowise.mdx This JSON structure illustrates the input variables available for workflow bots in Flowise when integrating with Evolution API. It includes standard bot variables and the 'query' variable for received message content. ```json inputs: { remoteJid: "Contact JID", pushName: "Contact name", instanceName: "Instance name", serverUrl: "API server URL", apiKey: "Evolution API Key", query: "Received message content" } ```