← Back to Help

API Documentation

Send WhatsApp messages from your apps and tools

Overview

The Habit of a Lifetime API lets you send WhatsApp messages from your own applications, scripts, or automation tools. It's perfect for:

  • Sending alerts and notifications
  • Job completion confirmations
  • Integration with n8n, Zapier, or Make.com
  • Custom webhooks and serverless functions
  • Any external tool that needs to send WhatsApp messages
Pro feature: API access requires a Pro subscription. Generate your API key in Settings.

Authentication

Authenticate requests using your API key in the X-API-Key header:

X-API-Key: hoal_your_api_key_here

To get your API key:

  1. Log in to your account
  2. Go to Notifications → Settings
  3. Scroll to "API Access" section
  4. Click "Generate API Key" and copy it
Keep your API key secret! Treat it like a password. Don't share it publicly or commit it to version control.

Endpoints

POST /api/send-message

Send a WhatsApp message to your configured number

Headers:

Content-Type: application/json
X-API-Key: hoal_your_api_key_here

Request Body:

{
  "message": "Hello! This is a test message from the API."
}

Parameters:

Parameter Type Description
message string Your message (max 1024 characters). WhatsApp template limit.

Success Response (200):

{
  "success": true,
  "message": "Message sent.",
  "characters": 45,
  "limit": 1024
}

Error Response Examples:

401 Unauthorized (missing/invalid API key):

{
  "error": "Invalid API key."
}

429 Rate Limited (10 requests/hour exceeded):

{
  "error": "Rate limit exceeded. Please wait before trying again."
}

429 Monthly Quota Exceeded:

{
  "error": "Monthly message limit reached (100 messages). Resets when your subscription renews.",
  "sent": 100,
  "limit": 100
}

Code Examples

cURL

curl -X POST https://www.habitofalifetime.com/api/send-message \
  -H "Content-Type: application/json" \
  -H "X-API-Key: hoal_your_api_key_here" \
  -d '{"message": "Job completed successfully!"}'

Python

import requests

url = "https://www.habitofalifetime.com/api/send-message"
headers = {
    "Content-Type": "application/json",
    "X-API-Key": "hoal_your_api_key_here"
}
payload = {"message": "Job completed successfully!"}

response = requests.post(url, json=payload, headers=headers)
print(response.json())

JavaScript (Node.js)

const fetch = require('node-fetch');

const url = "https://www.habitofalifetime.com/api/send-message";
const options = {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": "hoal_your_api_key_here"
  },
  body: JSON.stringify({ message: "Job completed successfully!" })
};

fetch(url, options)
  .then(res => res.json())
  .then(data => console.log(data));

n8n

Use the HTTP Request node:

  • URL: https://www.habitofalifetime.com/api/send-message
  • Method: POST
  • Headers: Add X-API-Key with your API key
  • Body: {"message": "Your message here"}

Rate Limits & Quotas

Per-Key Rate Limit

10 requests per hour per API key

If you exceed this, you'll get a 429 response. Requests are counted every hour. Plan your automation accordingly or contact us if you need higher limits.

Monthly Message Quota

Varies by subscription level

Each API call counts toward your monthly message limit. The limit resets when your Pro subscription renews. Check your Dashboard to see current usage.

Message Size

Max 1024 characters

This is a WhatsApp template limit. Longer messages will be rejected.

IP Rate Limiting

60 requests per minute per IP

This is a global backstop to prevent abuse. Legitimate automation should stay well under this limit.

Need Help?

Have questions about the API? Email us at hello@habitofalifetime.com

Also check the FAQ for common questions about the API.