Tenreply logoTenreply
← Back to Blog
Guide

How to Send a WhatsApp Message via API Using Tenreply

Send WhatsApp messages programmatically via the official API — from order confirmations to OTPs to broadcast campaigns. Here is the complete developer guide.

Two Ways to Send WhatsApp Messages via API

If you need to send WhatsApp messages programmatically, you have two approaches:

  1. Direct Graph API call — your application calls Meta's Graph API directly using your access token. Full control, requires managing credentials and rate limits yourself.
  2. Through a platform like TenreplyTenreply handles credential management, rate limiting, and delivery tracking. Your app calls Tenreply's API instead. Simpler, with a shared inbox for your support team built in.

This guide covers both paths.

Path 1: Direct Graph API (WhatsApp Cloud API)

Prerequisites

  • A WhatsApp Business Account (WABA) connected to a Meta App
  • A Phone Number ID and System User access token
  • An approved message template (for messages outside the 24-hour window)

Sending a Text Message (within 24-hour window)

curl -X POST https://graph.facebook.com/v19.0/{PHONE_NUMBER_ID}/messages   -H "Authorization: Bearer {ACCESS_TOKEN}"   -H "Content-Type: application/json"   -d '{
    "messaging_product": "whatsapp",
    "to": "919876543210",
    "type": "text",
    "text": { "body": "Hello! Your order #1234 has been confirmed." }
  }'

Sending a Template Message (outside 24-hour window)

curl -X POST https://graph.facebook.com/v19.0/{PHONE_NUMBER_ID}/messages   -H "Authorization: Bearer {ACCESS_TOKEN}"   -H "Content-Type: application/json"   -d '{
    "messaging_product": "whatsapp",
    "to": "919876543210",
    "type": "template",
    "template": {
      "name": "order_confirmation",
      "language": { "code": "en" },
      "components": [
        {
          "type": "body",
          "parameters": [
            { "type": "text", "text": "Fadhil" },
            { "type": "text", "text": "#ORD-1234" }
          ]
        }
      ]
    }
  }'

Path 2: Send via Tenreply (Simpler for Teams)

If your team uses Tenreply as the inbox, you can trigger outbound messages programmatically while keeping the conversation visible to your agents. Use the Tenreply API (documented in Settings → API) with a Bearer token from your account:

# Create and send a message via Tenreply API
curl -X POST https://app.tenreply.com/api/messages/send   -H "Authorization: Bearer {TENREPLY_TOKEN}"   -H "Content-Type: application/json"   -d '{
    "conversationId": "conv_abc123",
    "type": "text",
    "content": { "text": "Your order has shipped!" }
  }'

Receiving Incoming Messages via Webhook

Incoming messages arrive as POST requests to your webhook URL. In Tenreply, set your webhook URL in Settings → WhatsApp. The payload structure:

{
  "object": "whatsapp_business_account",
  "entry": [{
    "id": "WABA_ID",
    "changes": [{
      "value": {
        "messages": [{
          "from": "919876543210",
          "id": "wamid.xxx",
          "type": "text",
          "text": { "body": "Hello" }
        }]
      }
    }]
  }]
}

Tenreply processes this webhook automatically and surfaces the message in your inbox — no code required on your side for basic receive functionality.

Rate Limits to Know

  • New numbers start at Tier 1: 1,000 business-initiated conversations per 24 hours
  • Per-second limit: approximately 80 messages/second (varies by tier)
  • Template messages: subject to quality score — poor quality reduces your limits automatically

For a deeper integration walkthrough, see our WhatsApp API integration guide.