API Reference v1.0 5 min read

API Introduction

Get started with the Wasapia API. Learn about authentication, rate limits, and basic API concepts to integrate WhatsApp automation into your applications.

API Introduction

Welcome to the Wasapia API! Our RESTful API allows you to integrate WhatsApp automation capabilities directly into your applications, websites, and workflows.

Base URL

All API requests should be made to:

https://api.wasapia.com/v1

Authentication

The Wasapia API uses API keys for authentication. You can generate API keys from your account dashboard.

API Key Authentication

Include your API key in the Authorization header of all requests:

curl -H "Authorization: Bearer YOUR_API_KEY" \
     https://api.wasapia.com/v1/campaigns

Getting Your API Key

  1. Log in to your Wasapia dashboard
  2. Navigate to SettingsAPI Keys
  3. Click Generate New Key
  4. Copy your key and store it securely

⚠️ Important: Keep your API key secure and never expose it in client-side code.

Request Format

All API requests should:

  • Use HTTPS
  • Include the Content-Type: application/json header for POST/PUT requests
  • Send data as JSON in the request body

Example Request

curl -X POST https://api.wasapia.com/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+1234567890",
    "message": "Hello from Wasapia!",
    "type": "text"
  }'

Response Format

All API responses are returned as JSON with the following structure:

Success Response

{
  "success": true,
  "data": {
    "id": "msg_12345",
    "status": "sent",
    "to": "+1234567890",
    "message": "Hello from Wasapia!",
    "created_at": "2024-06-02T10:30:00Z"
  },
  "meta": {
    "request_id": "req_67890",
    "timestamp": "2024-06-02T10:30:00Z"
  }
}

Error Response

{
  "success": false,
  "error": {
    "code": "INVALID_PHONE_NUMBER",
    "message": "The phone number format is invalid",
    "details": {
      "field": "to",
      "provided": "invalid-number"
    }
  },
  "meta": {
    "request_id": "req_67890",
    "timestamp": "2024-06-02T10:30:00Z"
  }
}

Rate Limits

To ensure service quality for all users, the API implements rate limiting:

Plan Requests per Minute Requests per Hour
Free 60 1,000
Pro 300 10,000
Enterprise 1,000 50,000

Rate Limit Headers

Each response includes rate limit information:

X-RateLimit-Limit: 300
X-RateLimit-Remaining: 299
X-RateLimit-Reset: 1635724800

Handling Rate Limits

When you exceed the rate limit, you'll receive a 429 Too Many Requests response:

{
  "success": false,
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Too many requests. Please try again later.",
    "retry_after": 60
  }
}

Error Codes

Common error codes you may encounter:

Code Description
INVALID_API_KEY The provided API key is invalid or expired
INVALID_PHONE_NUMBER The phone number format is incorrect
MESSAGE_TOO_LONG The message exceeds the maximum length
INSUFFICIENT_CREDITS Your account doesn't have enough credits
RATE_LIMIT_EXCEEDED You've exceeded the rate limit
CAMPAIGN_NOT_FOUND The specified campaign doesn't exist
VALIDATION_ERROR Request validation failed

Pagination

List endpoints use cursor-based pagination:

curl -H "Authorization: Bearer YOUR_API_KEY" \
     "https://api.wasapia.com/v1/messages?limit=50&cursor=eyJpZCI6MTIzfQ"

Pagination Response

{
  "success": true,
  "data": [
    // ... message objects
  ],
  "pagination": {
    "has_more": true,
    "next_cursor": "eyJpZCI6MTczfQ",
    "total_count": 1250
  }
}

Webhooks

Wasapia can send webhook notifications for various events. Configure webhooks in your dashboard under SettingsWebhooks.

Webhook Events

  • message.sent - Message successfully sent
  • message.delivered - Message delivered to recipient
  • message.read - Message read by recipient
  • message.failed - Message failed to send
  • campaign.completed - Campaign finished sending

Webhook Payload

{
  "event": "message.delivered",
  "data": {
    "id": "msg_12345",
    "status": "delivered",
    "to": "+1234567890",
    "delivered_at": "2024-06-02T10:35:00Z"
  },
  "webhook_id": "wh_67890",
  "timestamp": "2024-06-02T10:35:00Z"
}

SDKs and Libraries

We provide official SDKs for popular programming languages:

JavaScript/Node.js

npm install @wasapia/sdk
const Wasapia = require("@wasapia/sdk");

const client = new Wasapia({
  apiKey: "your-api-key",
});

// Send a message
const message = await client.messages.send({
  to: "+1234567890",
  message: "Hello from Wasapia!",
  type: "text",
});

Python

pip install wasapia-python
from wasapia import Wasapia

client = Wasapia(api_key='your-api-key')

# Send a message
message = client.messages.send(
    to='+1234567890',
    message='Hello from Wasapia!',
    type='text'
)

PHP

composer require wasapia/sdk
<?php
use Wasapia\WasapiaClient;

$client = new WasapiaClient('your-api-key');

// Send a message
$message = $client->messages->send([
    'to' => '+1234567890',
    'message' => 'Hello from Wasapia!',
    'type' => 'text'
]);

Testing

Use our sandbox environment for testing:

https://api-sandbox.wasapia.com/v1

The sandbox environment:

  • Doesn't send real messages
  • Has relaxed rate limits
  • Provides realistic response data
  • Supports all API endpoints

Support

Need help with the API? We're here to help:

Next Steps

Now that you understand the basics, explore these topics:


Ready to start building? Get your API key and send your first message!

Share this documentation

On this page