Introduction
This section provides the official documentation for using Lovi’s API with WhatsApp via Postman. It includes detailed instructions on how to set up and test API requests for WhatsApp integration, ensuring smooth communication through the platform. Authentication is performed using tokens that enable basic authentication for the API services. For more details on how to authenticate, please refer to the Authentication page. The Lovi API supports WhatsApp notifications with multimedia content, dynamic placeholders, scheduled delivery, and conversation flow integration.Key Features:
- WhatsApp notifications with multimedia support
- Dynamic content personalization with placeholders
- Scheduled message delivery with timezone support
- Conversation flow integration
- Two data structure formats (nested and flat)
📣 Send WhatsApp Notification
To send a notification via the Lovi API, make a POST request to the endpoint with the necessary parameters and authentication.Method: POST Format: JSON
Endpoint
Query Parameters
| Parameter | Required | Description |
|---|---|---|
access_key | Yes | Your unique API access key. |
unflatten | No | If set to true, the body must contain flat variables (no nested objects). If set to false or omitted, the body can contain nested objects. |
Headers
| Key | Value | Required | Description |
|---|---|---|---|
| Content-Type | application/json | Yes | Indicates that the request body is in JSON format. |
access_key parameter in the URL, not through headers.
📋 Request Parameters
The API supports two data structure formats controlled by theunflatten parameter.
Required Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
contact OR contacts | Object OR Array | Choose one: Single contact (object) OR Multiple contacts (array, max 100) | See below |
language_template | String | Language code for the template | "es_ES", "en_US" |
name_template | String | Name of the approved template | "welcome_user" |
recipient_id | String | ID or phone number of the recipient | "34666033135" |
notification_type | String | Type for analytics | "marketing", "transactional", "utility" |
campaign_name | String | Campaign identifier name | "Black Friday 2024" |
contact (for single recipient) OR contacts (for multiple recipients), but NOT both.
Optional Parameters
| Parameter | Type | Description | When to Use | Example |
|---|---|---|---|---|
contact.name | String | Contact’s name for personalization | For personalized messages | "Juan Pérez" |
contact.email | String | Contact’s email | For additional contact data | "[email protected]" |
name_event | String | Event to trigger conversation flows | When you want to start a specific conversation flow | "intent-general-push" |
datetime_sending | DateTime | Scheduled delivery time (ISO 8601) | When you want to schedule the message for later | "2024-12-25T10:30:00" |
timezone | String | Timezone for scheduled delivery | When using datetime_sending | "Europe/Madrid" |
components_push.* | Mixed | Template components (text, media) | When template requires dynamic content | See components section |
👥 Single vs Multiple Recipients
Using contact - Send to One Person
Use contact when you want to send a notification to one recipient.
Structure:
contactis an object (not a list)- Required field:
number - Optional fields:
name,email, and any custom fields
Using contacts - Send to Multiple People (Bulk Sending)
Use contacts when you want to send the same notification to multiple recipients at once.
Structure:
contactsis a list/array (not a single object)- Maximum: 100 contacts per request
- Each contact in the list must have a
number - Optional fields:
name,email, and any custom fields
- ⚠️ Cannot use
unflatten=truewithcontacts- Bulk sending only works with nested structure - ⚠️ Cannot use both
contactandcontactsin the same request - choose one - ⚠️
contactslist cannot be empty - must have at least 1 contact
🔄 Data Structure Formats
The API supports two formats based on theunflatten parameter:
Nested Structure (unflatten=false or omitted)
Whenunflatten=false or not specified, use nested objects:
Flat Structure (unflatten=true)
Whenunflatten=true, all nested objects must be flattened using dot notation:
When to Use Each Format
- Nested Structure (
unflatten=false): Recommended for better readability and when your system supports nested objects - Flat Structure (
unflatten=true): Use when your system doesn’t support nested objects or requires flat data structure
🎨 Components & Multimedia
IMPORTANT: Components you can send dynamically are ONLY those returned by the template components endpoint. The structure varies depending on whether the template has variables or media.Component Naming Rules
- Header media:
header_image,header_video,header_document(NO suffix number) - Body variables:
body_text_0,body_text_1,body_text_2, etc. (with index number for each{"{1}"},{"{2}"},{"{3}"}placeholder) - Footer and Buttons: Are STATIC in the template definition and CANNOT be sent dynamically
How to Know Which Components to Send
-
First, call the template components endpoint:
-
The API returns only the components you need to provide:
- Send ONLY those components in your notification request
Component Types by Position
Header Components (Media Only)
IMPORTANT: Only ONE header component per template. Header text is STATIC in the template.| Type | Component Name | Description | Example Value | Specifications |
|---|---|---|---|---|
image | header_image | Header image URL | "https://example.com/image.jpg" | JPG, PNG, GIF - Max 5MB |
video | header_video | Header video URL | "https://example.com/video.mp4" | MP4, AVI, MOV - Max 16MB, 30s |
document | header_document | Header document URL | "https://example.com/doc.pdf" | PDF, DOC, XLS, PPT - Max 100MB |
header_text is NOT a dynamic component. Header text is defined in the template and cannot be changed.
Body Components (Variables Only)
Body text with placeholders requires variables in order:{"{1}"}, {"{2}"}, {"{3}"}, etc.
| Component Name | Description | Maps to Template Placeholder |
|---|---|---|
body_text_0 | First variable in body | {"{1}"} |
body_text_1 | Second variable in body | {"{2}"} |
body_text_2 | Third variable in body | {"{3}"} |
body_text_N | N-th variable in body | {"{N}"} |
{"{1}"}, your course {"{2}"} is ready”
body_text_0: Value for{"{1}"}(e.g., “Maria”)body_text_1: Value for{"{2}"}(e.g., “JavaScript”)
Footer Components
⚠️ Footer is STATIC - defined in the template and cannot be modified per message.Button Components
IMPORTANT: Most buttons are STATIC in the template. However, URL buttons with variables CAN be dynamic.| Component Name | Description | When It Appears |
|---|---|---|
buttons_url_0 | URL for first URL button with variable {"{1}"} | When template has URL button with {"{1}"} placeholder |
buttons_url_1 | URL for second URL button with variable {"{2}"} | When template has multiple URL buttons with variables |
"url": "https://example.com/{"{1}"}"
- The template defines the URL pattern with placeholder
- You provide the value for
{"{1}"}viabuttons_url_0
Component Examples
Example 1: Template with Image Header (Nested Structure)
Example 2: Template with Body Variables (Nested Structure)
Example 3: Template with Image and Variables (Flat Structure)
🧩 Template Variables (Body Text)
CRITICAL: Variables in WhatsApp templates use positional placeholders like{"{1}"}, {"{2}"}, {"{3}"}, NOT named variables like {"{name}"}.
How Template Variables Work
WhatsApp templates define variables as numbered placeholders in the template body text:- Template text: “Hello
{"{1}"}, your course{"{2}"}is ready” {"{1}"}maps tobody_text_0{"{2}"}maps tobody_text_1
Variable Assignment
You provide the values for these numbered placeholders in thecomponents_push object:
Important Rules
- Positional order matters:
body_text_0={"{1}"},body_text_1={"{2}"}, etc. - Direct values: Provide the actual value, not
{"{variable}"}syntax - All variables required: Must provide values for all
{"{N}"}placeholders in the template - No mixing: Cannot combine variables with static text in components_push
✅ Valid Examples
Template: “Hello{"{1}"}, your order {"{2}"} is ready”
❌ Invalid Examples
Variable Resolution
The system resolves{"{variable}"} references in components_push by searching:
- First in
contactobject - Then in root-level parameters
⏰ Scheduling & Conversation Flows
Immediate Delivery (Default)
Ifdatetime_sending is not specified, the message is sent immediately:
Scheduled Delivery
Usedatetime_sending and timezone to schedule messages:
Nested Structure:
Conversation Flow Integration
Usename_event to trigger specific conversation flows:
📋 Complete Examples
Example 1: Single Recipient with Body Variables
Sending to ONE person usingcontact
Template: “Hello {"{1}"}, thank you for your interest in {"{2}"}!”
Request:
Example 1B: Multiple Recipients (Bulk Sending)
Sending to MULTIPLE people usingcontacts
Template: “Hello {"{1}"}, thank you for your interest in {"{2}"}!”
Request:
Example 2: Template with Image Header
Template components:["header_image"]
URL:
Example 3: Template with PDF Document
Template components:["header_document"]
URL:
Example 4: Conversation Flow Trigger
Nested Structure:📊 Response Codes
Successful Response (200 OK)
Immediate sending:Error Responses
400 Bad Request - Invalid Parameters
401 Unauthorized - Invalid Access Key
404 Not Found - Template Not Found
422 Unprocessable Entity - Business Logic Error
429 Too Many Requests - Rate Limit
🔧 Best Practices
Data Structure
- Prefer nested structure (
unflatten=false) for better readability - Use flat structure (
unflatten=true) only when your system requires it - Validate structure before sending requests
Media Guidelines
- Use HTTPS URLs for all media files
- Optimize file sizes for faster delivery
- Use public URLs without authentication requirements
- Test media URLs before sending to ensure accessibility
Scheduling
- Specify timezone when using
datetime_sending - Validate future dates before scheduling
- Consider business hours for better engagement
- Test scheduling in development environment
Placeholders
- Use meaningful variable names that match your data
- Test variable substitution before production
- Keep one variable per field to avoid errors
- Provide fallback values in your application logic
Performance
- Batch multiple notifications when possible
- Cache template information to reduce API calls
- Monitor rate limits and implement backoff strategies
- Use connection pooling for better performance
🚨 Common Errors & Solutions
Contact/Contacts Validation Errors
Error: Missing Contact Information
Problem: Request doesn’t includecontact or contacts
contact (for one person) OR contacts (for multiple people)
Error: Using Both Contact and Contacts
Problem: Request includes bothcontact and contacts at the same time
contact for single recipient or contacts for multiple recipients
Error: Contact is a List Instead of Object
Problem: Sentcontact as a list [...] instead of an object {...}
contact as an object:
Error: Contacts is Not a List
Problem: Sentcontacts as an object {...} instead of a list [...]
contacts as a list:
Error: Empty Contacts List
Problem: Sentcontacts as an empty list []
Error: Too Many Contacts
Problem: Sent more than 100 contacts in thecontacts list
Error: Unflatten with Contacts
Problem: Usedunflatten=true with contacts (bulk sending)
contacts only works with nested structure. Remove unflatten=true or use unflatten=false
Structure Mismatch
Problem: Mixing nested and flat structures Solution: Choose one format consistently based onunflatten parameter
Template Not Found
Problem: Using non-existent or non-approved template Solution: Verify template name and approval status using template management endpointsInvalid Phone Format
Problem: Including ’+’ or spaces in phone number Solution: Use clean international format without symbols (e.g.,34666033135)
Component Naming Errors
Problem: Using incorrect component names likeheader_image_0 instead of header_image
Solution: Always check template components first using the /notify/template/components endpoint
Variable Position Errors
Problem: Incorrect mapping between template placeholders and body_text components Solution: Remember{"{1}"} = body_text_0, {"{2}"} = body_text_1, etc.
Modifying Static Components
Problem: Trying to send footer, buttons, or header text dynamically Solution: These components are static in the template. Only send components returned by the template components endpointScheduling Errors
Problem: Past dates or invalid timezone Solution: Use future dates in ISO 8601 format with valid IANA timezone codes🔬 Template Examples
These examples demonstrate different types of template structures.Example 1: Simple Text Only Template
Components returned by API:[] (empty - no dynamic components)
components_push needed since template has no dynamic components.
Example 2: Template with Body Variables
Template Body: “Hello{"{1}"}, your {"{2}"} is ready!”
Components returned by API: ["body_text_0", "body_text_1"]
Example 3: Template with Image Header
Components returned by API:["header_image"]
Example 4: Template with Video Header
Components returned by API:["header_video"]
Example 5: Template with PDF Document
Components returned by API:["header_document"]
Example 6: Template with Header Text and Body Variable
Header: “Important Notice” (static text in template) Body: “Hello{"{1}"}, welcome to our platform!”
Components returned by API: ["body_text_0"]
- Header: “Important Notice”
- Body: “Hello Michael, welcome to our platform!”
Example 7: Template with Dynamic URL Button
Body: Static text Buttons:- URL button with variable:
"url": "https://example.com/{"{1}"}"(dynamic) - Quick reply button: “Contact Support” (static)
Components returned by API:
["buttons_url_0"]
https://example.com/profile/12345
Note: The variable in buttons_url_0 can reference contact fields using {"{variable}"} syntax, and the system will resolve it before sending.
📚 Related Documentation
- Authentication - How to obtain access tokens and API keys
- Voice Notifications - Send automated voice calls
- Template Management - Create and manage WhatsApp templates
- Scheduling - Advanced scheduling and timezone management
- Error Handling - Complete error codes and handling strategies
- Best Practices - Security and performance guidelines
