Skip to main content

Prerequisites

Before you begin, make sure you have:

Step 1: Get Your API Key

Navigate to the API Keys section in your dashboard and create a new API key.
Keep your API key secure! Never expose it in client-side code or public repositories.

Step 2: Get Your Instance ID

Find your connected instance ID in the Instances page. You’ll need this to send messages.

Step 3: Send Your First Message

Choose your preferred programming language and send your first message:
import { EnviaAI } from '@enviaai/sdk';

const client = new EnviaAI({
  apiKey: 'your-api-key'
});

async function sendMessage() {
  const response = await client.messages.send({
    instanceId: 'your-instance-id',
    to: '5511999999999',
    message: 'Hello from EnviaAI!'
  });

  console.log('Message sent:', response.messageId);
}

sendMessage();

Step 4: Check the Response

A successful response will look like this:
{
  "success": true,
  "messageId": "msg_abc123xyz",
  "status": "queued",
  "timestamp": "2026-02-03T12:00:00.000Z"
}

Step 5: Track Message Status

Monitor your message delivery status using webhooks or the status endpoint:
const status = await client.messages.getStatus('msg_abc123xyz');
console.log('Status:', status.status); // sent, delivered, read, failed

Message Status Flow

Messages go through the following states:
StatusDescription
queuedMessage is queued for sending
sentMessage was sent to WhatsApp
deliveredMessage was delivered to the recipient
readRecipient has read the message
failedMessage delivery failed

Next Steps

Common Issues

Make sure you’re using the correct API key and that it hasn’t been revoked. Check your API Keys page.
Your WhatsApp instance must be connected to send messages. Check the Instances page and scan the QR code if needed.
Phone numbers must be in international format without + or spaces. Example: 5511999999999
If you’re hitting rate limits, consider upgrading your plan or implementing request throttling. See Authentication for limits.