> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whatsable.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Send a WhatsApp message

> Send a WhatsApp message with optional attachments (images, videos, documents)



## OpenAPI

````yaml /openapi/whatsable-api.json post /send
openapi: 3.0.0
info:
  title: WhatsAble API
  description: >-
    WhatsAble API Documentation (Version 2) - A comprehensive API for sending
    WhatsApp messages programmatically
  version: 2.0.0
servers:
  - url: https://dashboard.whatsable.app/api/whatsapp/messages/v2.0.0
    description: WhatsAble API v2
security: []
paths:
  /send:
    post:
      tags:
        - Messages
      summary: Send a WhatsApp message
      description: >-
        Send a WhatsApp message with optional attachments (images, videos,
        documents)
      operationId: sendMessage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessageRequest'
            examples:
              textOnly:
                value:
                  to: '+1234567890'
                  text: Hello, this is a test message from WhatsAble!
              withAttachment:
                value:
                  to: '+1234567890'
                  text: Hello, this is a test message with an attachment!
                  attachment: https://example.com/image.jpg
                  filename: image.jpg
      responses:
        '200':
          description: Message sent successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: cURL
          source: |-
            curl -X POST \
              'https://dashboard.whatsable.app/api/whatsapp/messages/v2.0.0/send' \
              -H 'Authorization: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                "to": "+1234567890",
                "text": "Hello, this is a test message from WhatsAble!"
              }'
        - lang: JavaScript
          source: |-
            const axios = require('axios');

            const sendMessage = async () => {
              try {
                const response = await axios.post(
                  'https://dashboard.whatsable.app/api/whatsapp/messages/v2.0.0/send',
                  {
                    to: '+1234567890',
                    text: 'Hello, this is a test message from WhatsAble!'
                  },
                  {
                    headers: {
                      'Authorization': 'YOUR_API_KEY',
                      'Content-Type': 'application/json'
                    }
                  }
                );
                console.log(response.data);
              } catch (error) {
                console.error(error.response.data);
              }
            };

            sendMessage();
        - lang: Python
          source: |-
            import requests

            def send_message():
                url = 'https://dashboard.whatsable.app/api/whatsapp/messages/v2.0.0/send'
                headers = {
                    'Authorization': 'YOUR_API_KEY',
                    'Content-Type': 'application/json'
                }
                data = {
                    'to': '+1234567890',
                    'text': 'Hello, this is a test message from WhatsAble!'
                }
                
                try:
                    response = requests.post(url, headers=headers, json=data)
                    response.raise_for_status()
                    print(response.json())
                except requests.exceptions.RequestException as e:
                    print(f'Error: {e.response.json() if e.response else e}')
        - lang: Go
          source: |-
            package main

            import (
                "bytes"
                "encoding/json"
                "fmt"
                "net/http"
            )

            type Message struct {
                To   string `json:"to"`
                Text string `json:"text"`
            }

            func main() {
                url := "https://dashboard.whatsable.app/api/whatsapp/messages/v2.0.0/send"
                message := Message{
                    To:   "+1234567890",
                    Text: "Hello, this is a test message from WhatsAble!",
                }
                
                jsonData, err := json.Marshal(message)
                if err != nil {
                    fmt.Printf("Error marshaling JSON: %v\n", err)
                    return
                }
                
                req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
                if err != nil {
                    fmt.Printf("Error creating request: %v\n", err)
                    return
                }
                
                req.Header.Set("Authorization", "YOUR_API_KEY")
                req.Header.Set("Content-Type", "application/json")
                
                client := &http.Client{}
                resp, err := client.Do(req)
                if err != nil {
                    fmt.Printf("Error making request: %v\n", err)
                    return
                }
                defer resp.Body.Close()
                
                var result map[string]interface{}
                if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
                    fmt.Printf("Error decoding response: %v\n", err)
                    return
                }
                
                fmt.Printf("Response: %+v\n", result)
            }
        - lang: PHP
          source: >-
            <?php


            $url =
            'https://dashboard.whatsable.app/api/whatsapp/messages/v2.0.0/send';

            $data = [
                'to' => '+1234567890',
                'text' => 'Hello, this is a test message from WhatsAble!'
            ];


            $options = [
                'http' => [
                    'header' => [
                        'Authorization: YOUR_API_KEY',
                        'Content-Type: application/json'
                    ],
                    'method' => 'POST',
                    'content' => json_encode($data)
                ]
            ];


            $context = stream_context_create($options);


            try {
                $result = file_get_contents($url, false, $context);
                $response = json_decode($result, true);
                print_r($response);
            } catch (Exception $e) {
                echo 'Error: ' . $e->getMessage();
            }
        - lang: Ruby
          source: >-
            require 'net/http'

            require 'json'

            require 'uri'


            url =
            URI('https://dashboard.whatsable.app/api/whatsapp/messages/v2.0.0/send')


            data = {
              to: '+1234567890',
              text: 'Hello, this is a test message from WhatsAble!'
            }


            http = Net::HTTP.new(url.host, url.port)

            http.use_ssl = true


            request = Net::HTTP::Post.new(url)

            request['Authorization'] = 'YOUR_API_KEY'

            request['Content-Type'] = 'application/json'

            request.body = data.to_json


            begin
              response = http.request(request)
              puts JSON.parse(response.body)
            rescue => e
              puts "Error: #{e.message}"
            end
        - lang: Java
          source: |-
            import java.net.http.HttpClient;
            import java.net.http.HttpRequest;
            import java.net.http.HttpResponse;
            import java.net.URI;
            import org.json.JSONObject;

            public class WhatsAbleClient {
                public static void main(String[] args) {
                    try {
                        HttpClient client = HttpClient.newHttpClient();
                        
                        JSONObject data = new JSONObject();
                        data.put("to", "+1234567890");
                        data.put("text", "Hello, this is a test message from WhatsAble!");
                        
                        HttpRequest request = HttpRequest.newBuilder()
                            .uri(URI.create("https://dashboard.whatsable.app/api/whatsapp/messages/v2.0.0/send"))
                            .header("Authorization", "YOUR_API_KEY")
                            .header("Content-Type", "application/json")
                            .POST(HttpRequest.BodyPublishers.ofString(data.toString()))
                            .build();
                        
                        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
                        System.out.println(response.body());
                        
                    } catch (Exception e) {
                        System.out.println("Error: " + e.getMessage());
                    }
                }
            }
components:
  schemas:
    MessageRequest:
      type: object
      required:
        - to
        - text
      properties:
        to:
          type: string
          description: The recipient's phone number in E.164 format (e.g., +1234567890)
        text:
          type: string
          description: The message content you want to send
        attachment:
          type: string
          description: URL or base64-encoded file for attachments (images, videos, PDFs)
        filename:
          type: string
          description: Name of the file if sending a document
    MessageResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Indicates if the message was sent successfully
        message:
          type: string
          description: A human-readable message describing the result
        details:
          type: object
          properties:
            messages:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    description: The WhatsApp message ID
                  message_status:
                    type: string
                    description: The status of the message
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          description: Error message
        details:
          type: string
          description: Additional error details
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Your WhatsAble API Key

````