Whatify LogoWhatify
API

Manual API Testing Guide

Learn how to manually test the Whatify API endpoints using cURL, Postman, or other HTTP clients

Manual API Testing Guide

This guide shows you how to manually test the Whatify API endpoints using cURL, Postman, or other HTTP clients.

Table of Contents

Prerequisites

  • Active Whatify account
  • API token from your dashboard

Getting Your API Token

  1. Log in to your Whatify dashboard
  2. Navigate to Settings → API
  3. Click "Create New Token"
  4. Give it a name (e.g., "Testing Token")
  5. Optionally link it to a specific device
  6. Copy the generated token

Testing with cURL

1. Connect to WhatsApp

QR Code Method:

curl -X POST "https://whatify.dev/api/whatsapp/v1/connect?method=qrCode" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Expected Response:

{
  "success": true,
  "qrCode": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
  "status": "connecting"
}

Pairing Code Method:

curl -X POST "https://whatify.dev/api/whatsapp/v1/connect?method=pairingCode&phoneNumber=1234567890" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Expected Response:

{
  "success": true,
  "pairingCode": "ABCD1234",
  "status": "connecting"
}

Force New Connection:

curl -X POST "https://whatify.dev/api/whatsapp/v1/connect?forceNew=true" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

2. Check Connection Status

curl -X GET "https://whatify.dev/api/whatsapp/v1/status" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Expected Response (Connected):

{
  "success": true,
  "status": "connected",
  "phone": "1234567890",
  "name": "My WhatsApp",
  "profilePic": "https://..."
}

Expected Response (Disconnected):

{
  "success": true,
  "status": "disconnected"
}

3. Send Text Message

curl -X POST "https://whatify.dev/api/whatsapp/v1/send" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "1234567890",
    "text": "Hello from cURL!"
  }'

Expected Response:

{
  "success": true,
  "messageId": "msg_12345"
}

4. Send Message to Multiple Recipients

curl -X POST "https://whatify.dev/api/whatsapp/v1/send" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": ["1234567890", "0987654321"],
    "text": "Bulk message test"
  }'

5. Send Image from URL

curl -X POST "https://whatify.dev/api/whatsapp/v1/send" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "1234567890",
    "attachment": {
      "type": "image",
      "url": "https://picsum.photos/200/300",
      "caption": "Random image from Lorem Picsum"
    }
  }'

6. Send Document from Base64

# First, convert a file to base64
BASE64_DATA=$(base64 -i document.pdf)

curl -X POST "https://whatify.dev/api/whatsapp/v1/send" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{
    \"to\": \"1234567890\",
    \"attachment\": {
      \"type\": \"document\",
      \"base64\": \"$BASE64_DATA\",
      \"filename\": \"document.pdf\",
      \"mimeType\": \"application/pdf\",
      \"caption\": \"Test document\"
    }
  }"

7. Send Text with Image

curl -X POST "https://whatify.dev/api/whatsapp/v1/send" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "1234567890",
    "text": "Here is the image you requested:",
    "attachment": {
      "type": "image",
      "url": "https://picsum.photos/400/300",
      "caption": "Product image"
    }
  }'

8. Send Video

curl -X POST "https://whatify.dev/api/whatsapp/v1/send" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "1234567890",
    "attachment": {
      "type": "video",
      "url": "https://www.w3schools.com/html/mov_bbb.mp4",
      "caption": "Sample video"
    }
  }'

9. Disconnect from WhatsApp

curl -X POST "https://whatify.dev/api/whatsapp/v1/disconnect" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Expected Response:

{
  "success": true,
  "message": "Disconnected successfully"
}

Testing with Postman

Setup

  1. Open Postman
  2. Create a new collection called "Whatify API"
  3. Add environment variables:
    • base_url: https://whatify.dev
    • api_token: Your API token

1. Connect to WhatsApp

  • Method: GET
  • URL: https://whatify.dev/api/whatsapp/v1/connect
  • Query Params:
    • method: qrCode
  • Headers:
    • Authorization: Bearer {{api_token}}

2. Check Status

  • Method: GET
  • URL: https://whatify.dev/api/whatsapp/v1/status
  • Headers:
    • Authorization: Bearer {{api_token}}

3. Send Text Message

  • Method: POST
  • URL: https://whatify.dev/api/whatsapp/v1/send
  • Headers:
    • Authorization: Bearer {{api_token}}
    • Content-Type: application/json
  • Body (raw JSON):
    {
      "to": "1234567890",
      "text": "Hello from Postman!"
    }

4. Send Image

  • Method: POST
  • URL: https://whatify.dev/api/whatsapp/v1/send
  • Headers:
    • Authorization: Bearer {{api_token}}
    • Content-Type: application/json
  • Body (raw JSON):
    {
      "to": "1234567890",
      "attachment": {
        "type": "image",
        "url": "https://picsum.photos/400/300",
        "caption": "Test image from Postman"
      }
    }

5. Disconnect

  • Method: POST
  • URL: https://whatify.dev/api/whatsapp/v1/disconnect
  • Headers:
    • Authorization: Bearer {{api_token}}

Testing with HTTP Client Tools

Using HTTPie

Install HTTPie:

brew install httpie  # macOS
pip install httpie   # Python

Send Text Message:

http POST https://whatify.dev/api/whatsapp/v1/send \
  Authorization:"Bearer YOUR_API_TOKEN" \
  to=1234567890 \
  text="Hello from HTTPie!"

Check Status:

http GET https://whatify.dev/api/whatsapp/v1/status \
  Authorization:"Bearer YOUR_API_TOKEN"

Using Insomnia

  1. Create a new request
  2. Set method and URL
  3. Go to Auth tab → Select Bearer Token
  4. Paste your API token
  5. Add request body (for POST requests)
  6. Send request

Testing Workflows

Complete Connection Flow

# 1. Check initial status
curl -X GET "https://whatify.dev/api/whatsapp/v1/status" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# 2. Connect to WhatsApp
curl -X GET "https://whatify.dev/api/whatsapp/v1/connect" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# 3. Wait for user to scan QR code...

# 4. Check status again (should be connected)
curl -X GET "https://whatify.dev/api/whatsapp/v1/status" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# 5. Send a test message
curl -X POST "https://whatify.dev/api/whatsapp/v1/send" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "YOUR_PHONE_NUMBER",
    "text": "Connection test successful!"
  }'

Bulk Message Testing

Create a shell script for testing:

#!/bin/bash

API_TOKEN="YOUR_API_TOKEN"
BASE_URL="https://whatify.dev"

# Array of phone numbers
PHONES=("1234567890" "0987654321" "1111111111")

# Send message to each number
for phone in "${PHONES[@]}"; do
  echo "Sending to $phone..."

  curl -X POST "$BASE_URL/api/whatsapp/v1/send" \
    -H "Authorization: Bearer $API_TOKEN" \
    -H "Content-Type: application/json" \
    -d "{
      \"to\": \"$phone\",
      \"text\": \"Bulk test message\"
    }"

  echo ""
  sleep 2  # Wait 2 seconds between messages
done

Save as bulk-test.sh and run:

chmod +x bulk-test.sh
./bulk-test.sh

Error Testing

Test Invalid Token

curl -X GET "https://whatify.dev/api/whatsapp/v1/status" \
  -H "Authorization: Bearer invalid_token_here"

Expected Response:

{
  "success": false,
  "error": "Invalid API token"
}

Test Missing Required Fields

curl -X POST "https://whatify.dev/api/whatsapp/v1/send" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "1234567890"
  }'

Expected Response:

{
  "success": false,
  "error": "Invalid request data",
  "details": [
    {
      "path": ["text", "attachment"],
      "message": "Either text or attachment must be provided"
    }
  ]
}

Test Rate Limiting

Send many requests quickly to trigger rate limiting:

for i in {1..50}; do
  curl -X GET "https://whatify.dev/api/whatsapp/v1/status" \
    -H "Authorization: Bearer YOUR_API_TOKEN"
done

Expected Response (after hitting limit):

{
  "success": false,
  "error": "Rate limit exceeded",
  "resetIn": 45
}

Troubleshooting

Common Issues

1. Connection Refused

curl: (7) Failed to connect to whatify.dev port 443: Connection refused
  • Check if the base URL is correct
  • Verify the server is running
  • Check firewall settings

2. SSL Certificate Errors

curl: (60) SSL certificate problem: unable to get local issuer certificate
  • Use -k flag to skip SSL verification (for testing only):
    curl -k -X GET "https://..."

3. Unauthorized Error

{
  "success": false,
  "error": "Invalid API token"
}
  • Verify your API token is correct
  • Check if the token has expired
  • Ensure you're using the correct authentication method

4. Device Not Found

{
  "success": false,
  "error": "No connected WhatsApp device found"
}
  • Connect to WhatsApp first using the /connect endpoint
  • Check if the device is still connected using /status

Best Practices

  1. Use Environment Variables: Store tokens securely
  2. Save Requests: Save common requests as scripts or Postman collections
  3. Test Incrementally: Start with simple requests, then move to complex ones
  4. Check Responses: Always verify the response status and structure
  5. Respect Rate Limits: Don't spam the API during testing
  6. Use Test Numbers: Use dedicated test phone numbers for testing

Quick Reference

EndpointMethodPurpose
/api/whatsapp/v1/connectGETConnect to WhatsApp
/api/whatsapp/v1/disconnectPOSTDisconnect from WhatsApp
/api/whatsapp/v1/statusGETCheck connection status
/api/whatsapp/v1/sendPOSTSend message

All endpoints require: Authorization: Bearer YOUR_API_TOKEN