How to Send WhatsApp Messages from Your Website or App Using an API

How to Send WhatsApp Messages from Your Website or App Using an API

A step-by-step guide for developers: connect a WhatsApp number, get your API keys and send your first message from PHP, Node.js or any language. Includes images, documents and the most common errors.

Order confirmations, payment receipts, appointment reminders: most of the messages your customers care about are created by your software. Sending them on WhatsApp takes one HTTP request. This guide shows the full process from a fresh account to your first message.

Step 1: Connect your WhatsApp number

  1. Log in to the Soft API panel and open My Devices.
  2. Click Add device, give it a name and confirm with the OTP.
  3. Open WhatsApp on your phone, go to Linked devices and scan the QR code.

Use a number that your customers will recognise, ideally a WhatsApp Business number with your logo and business hours filled in.

Step 2: Create an app and copy your keys

Open My Apps, create an app for the device and copy two values:

  • appkey – identifies which connected number sends the message.
  • authkey – your account key. Treat it like a password and keep it on the server only.

Step 3: Send your first message

All messages go to one endpoint: POST https://softapi.in/api/create-message

cURL

curl -X POST https://softapi.in/api/create-message \
  -d "appkey=YOUR_APP_KEY" -d "authkey=YOUR_AUTH_KEY" \
  -d "to=919876543210" \
  -d "message=Hi Rahul, your order #1042 has been shipped."

PHP

$ch = curl_init('https://softapi.in/api/create-message');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 20,
    CURLOPT_POSTFIELDS     => [
        'appkey'  => getenv('SOFTAPI_APPKEY'),
        'authkey' => getenv('SOFTAPI_AUTHKEY'),
        'to'      => '919876543210',
        'message' => 'Hi Rahul, your order #1042 has been shipped.',
    ],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);

Node.js

const body = new URLSearchParams({
  appkey: process.env.SOFTAPI_APPKEY,
  authkey: process.env.SOFTAPI_AUTHKEY,
  to: '919876543210',
  message: 'Hi Rahul, your order #1042 has been shipped.'
});
const res = await fetch('https://softapi.in/api/create-message', { method: 'POST', body });
console.log(await res.json());

Step 4: Send an image or a PDF

Add a file parameter with a public link to the file. The text in message becomes the caption.

-d "file=https://yourshop.in/invoices/1042.pdf" \
-d "message=Your invoice for order #1042"

Keep files small (under a few MB) and make sure the link opens without a login.

Step 5: Use templates for repeated messages

If you send the same message with different names or amounts, create a template in the panel and pass template_id with your variables instead of the full text. Your copy stays consistent and you can edit it without touching code.

Common errors and fixes

What you seeWhat to check
Invalid auth key or app keyCopy both keys again; the app must belong to the same account as the auth key.
Plan expiredRenew your plan from the panel; the API stops working after expiry.
Device not connectedOpen My Devices and scan the QR again if the phone was logged out.
Message not receivedUse the full number with 91 and no plus sign; make sure the number is on WhatsApp.

Security checklist

  • Call the API only from your server, never from browser JavaScript or a mobile app.
  • Store keys in environment variables, not in your code repository.
  • If a key leaks, regenerate it from the panel straight away.

That is all you need to start. Questions about a specific language or framework? Write to our team and we will help you with the integration.