Personalize WhatsApp Messages per Recipient via API
With the official WhatsApp Business API, you have to submit messages to Meta for approval in advance as a "template", with fixed placeholders like {{1}} and {{2}}. That takes days, and every change to the text means waiting for approval again.
TextMeFlow works differently: you send plain text to POST /v1/messages. There is no template registration, no approval wait and no fixed placeholder format. The downside is that personalization is your responsibility; the upside is that you have complete freedom over every sentence, per recipient, without waiting on anyone. This article shows how to build that in practice.
Why personalization is more than filling in a name
Identical text sent to dozens of contacts in one batch is exactly the pattern that makes TextMeFlow's internal risk score climb: content uniqueness is one of the signals that count, together with the number of unique recipients and the bounce rate over the past 24 hours (see /en/docs/anti-spam). A reminder that is word-for-word the same for everyone looks like a blast. The same reminder with a name, a date and a small extra detail looks like a personal message, and in practice that saves a lot of support questions and opt-outs.
The approach: build the text before you send
Because the API has no placeholder syntax, you simply assemble the string yourself in your own code, per row from your database or CSV, and send each message separately to the API.
<?php
$apiKey = getenv('TEXTMEFLOW_API_KEY');
$afspraken = [
['naam' => 'Sofie', 'telefoon' => '+32472932208', 'datum' => 'Thursday at 2 pm', 'dienst' => 'service'],
['naam' => 'Karim', 'telefoon' => '+32498112233', 'datum' => 'Friday at 9:30 am', 'dienst' => 'tire change'],
];
foreach ($afspraken as $a) {
$tekst = sprintf(
"Hi %s, your appointment for %s is scheduled for %s. Reply STOP to opt out.",
$a['naam'],
$a['dienst'],
$a['datum']
);
$response = file_get_contents('https://api.textmeflow.eu/v1/messages', false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Authorization: Bearer {$apiKey}\r\nContent-Type: application/json\r\n",
'content' => json_encode(['to' => $a['telefoon'], 'text' => $tekst]),
],
]));
// Respect the rate limit: max 1 message per second per number.
usleep(1_100_000);
}
The sprintf approach is deliberately simple: no templating library needed for a handful of variables. At larger volumes (hundreds of rows), a short pause between calls, like the usleep above, is enough to stay within the limit of 1 message per second per number. Above that limit the API responds with 429 Too Many Requests; catch that response and retry with a short backoff instead of letting the whole batch crash.
Vary more than just the name
A few ways to personalize further without adding complexity:
- Context from your own system: amount, order number, license plate, room number: everything you already have in your database belongs in the text, not just the name.
- Time-sensitive phrasing: "tomorrow morning" instead of a fixed date format reads as more personal and prevents 200 messages from being literally identical.
- Small variations in sentence structure: alternate "your appointment is scheduled for" with "we're expecting you on" for part of the batch. Small swaps are enough to lower content uniqueness risk.
Media is part of it too
Personalization doesn't stop at text. The media_url field on /v1/messages accepts a link to a file up to 100 MB: an invoice PDF with the right amount, a photo of the right room, a custom-generated QR code. Generate that file per recipient before you send and pass the URL alongside the text.
What not to do
Don't send identical text to a list of purchased or non-opt-in numbers; that is prohibited regardless, and personalization changes nothing about it. And don't use the urgent flag on /v1/messages to routinely bypass quiet hours; that flag is meant for exceptions, not as a habit. How to spread bulk sends further to stay under the radar of broadcast detection is covered in our article on bulk reminders.
You'll find the full request and response schemas, including error codes, in the API reference.
Start today
You don't have to wait for Meta approval to test. Create a free account, grab your API key and send your first personalized message within minutes.
Want to send WhatsApp messages via API yourself?
Free forever up to 50 messages/month. Scan a QR and send your first message within 5 minutes.
Free forever