PAY HERO DOCS
  • Introduction-Pay Hero Developer APIs
  • Creating Account
  • Authorization
  • GET: Service Wallet Balance
  • GET: Payments Wallet Balance
  • POST: Service Wallet Top Up
  • POST: Initiate MPESA STK Push Request
  • Payment Button
  • Lipwa Link
  • POST: Pay Hero Wallet- Withdraw To Mobile
  • GET: Account Transactions
  • GET: Transaction Status
  • WooCommerce Plugin
    • Plugin Installation
  • Shopify
  • Videos
  • Other Integrations
  • Email API Reference
    • Register SMTP
    • Send Email
    • Mail status
  • WhatsApp API Reference
    • Introduction
    • Getting Started
    • Send API Whats App Text
    • Bulk WhatsApp API Messaging
    • Bulk WhatsApp Using UI/CSV File
Powered by GitBook
On this page
  • sendText
  • Sample API Call Code

Was this helpful?

  1. WhatsApp API Reference

Send API Whats App Text

This API enables you to send a plain text message to a whats app number

PreviousGetting StartedNextBulk WhatsApp API Messaging

Last updated 3 months ago

Was this helpful?

sendText

POST

Sends a text message to a number that you have provided

Headers

Name
Value

Content-Type

application/json

Authorization

Basic <token>

Body (JSON)

Name
Type
Description

message

string

The text message to send

phone_number

string

Phone number of the recipient e,g 0787877878

session

string

Your Session name, that you used to register the session.

Response

{
    "success": true
}
{
    "error_code": "INTERNAL",
    "error_message": "request sending whatsapp text v2 faile with error: [{\"statusCode\":404,\"message\":\"We didn't find a session with name 'XXXX'. Please start it first by using POST /sessions/start request\",\"error\":\"Not Found\"}]",
    "status_code": 500
}

Sample API Call Code

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://backend.payhero.co.ke/api/v2/whatspp/sendText',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "message": "My First Text",
    "phone_number": "0787877878",
    "session": "18gdPWKzoXXXX"
}
',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic MThPQ014dGxGeDRuWmdkUFdLem86ZFQ5Vj'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
https://backend.payhero.co.ke/api/v2/whatspp/sendText