Skip to main content

Introduction

Template management endpoints allow you to retrieve, inspect, and create WhatsApp message templates. Templates are pre-approved message formats required by WhatsApp for business communications.

πŸ“‹ Get Available Templates

Retrieve all templates available for your company and phone number.

Endpoint

GET https://cloud.lovi.ai/functions/v1/notify/templates?access_key={YOUR_ACCESS_KEY}&phone_number={PHONE_NUMBER}

Query Parameters

ParameterRequiredDescription
access_keyYesYour unique API access key.
phone_numberYesPhone number to filter templates (without ’+’ sign).
Example Request:
GET https://cloud.lovi.ai/functions/v1/notify/templates?access_key=your-api-key&phone_number=34666033135

Response

{
  "templates": [
    {
      "id": "template_001",
      "name": "bienvenida_usuario",
      "language": "es_ES",
      "status": "approved",
      "category": "marketing",
      "components": [
        {
          "type": "header",
          "format": "text"
        },
        {
          "type": "body",
          "format": "text"
        },
        {
          "type": "footer",
          "format": "text"
        }
      ]
    },
    {
      "id": "template_002",
      "name": "order_confirmation",
      "language": "en_US",
      "status": "approved",
      "category": "transactional"
    }
  ],
  "total": 2
}

πŸ” Get Template Components

Retrieve detailed information about a specific template’s components and structure.

Endpoint

GET https://cloud.lovi.ai/functions/v1/notify/template/components?access_key={YOUR_ACCESS_KEY}&template={TEMPLATE_ID}

Query Parameters

ParameterRequiredDescription
access_keyYesYour unique API access key.
templateYesID or name of the template to query.
Example Request:
GET https://cloud.lovi.ai/functions/v1/notify/template/components?access_key=your-api-key&template=template_001

Response

{
  "template": {
    "id": "template_001",
    "name": "bienvenida_usuario",
    "language": "es_ES",
    "category": "marketing",
    "status": "approved"
  },
  "components": [
    {
      "type": "header",
      "format": "text",
      "text": "Welcome {{1}}!",
      "example": "Welcome John!",
      "position": 0
    },
    {
      "type": "body",
      "format": "text",
      "text": "Hello {{1}}, your course {{2}} is now available. Please visit {{3}} to get started.",
      "example": "Hello Maria, your course Nursing Assistant is now available. Please visit https://example.com to get started.",
      "position": 0
    },
    {
      "type": "footer",
      "format": "text",
      "text": "Support Team",
      "position": 0
    },
    {
      "type": "buttons",
      "buttons": [
        {
          "type": "url",
          "text": "Visit Course",
          "url": "https://example.com/course/{{1}}"
        },
        {
          "type": "quick_reply",
          "text": "Contact Support"
        }
      ]
    }
  ]
}

πŸ†• Create New Template

Create a new WhatsApp message template for approval by Meta.

Endpoint

POST https://cloud.lovi.ai/functions/v1/admin/whatsapp/create/template

Headers

KeyValueRequiredDescription
Content-Typeapplication/jsonYesIndicates that the request body is in JSON format.

Body Request

{
  "company_id": "uuid-company",
  "waba_id": "whatsapp-business-account-id",
  "name_template": "nuevo_template",
  "language_template": "es_ES",
  "category_template": "MARKETING",
  "components_template": {
    "HEADER": {
      "format": "TEXT",
      "text": "Important: {{1}}"
    },
    "BODY": {
      "text": "Hello {{1}}, we inform you that {{2}}. For more information visit {{3}}."
    },
    "FOOTER": {
      "text": "Support Team"
    },
    "BUTTONS": [
      {
        "type": "URL",
        "text": "View Details",
        "url": "https://example.com/details/{{1}}"
      },
      {
        "type": "QUICK_REPLY",
        "text": "Contact Support"
      }
    ]
  }
}

Required Parameters

ParameterTypeDescriptionExample
company_idStringUnique company identifier"uuid-company"
waba_idStringWhatsApp Business Account ID"123456789"
name_templateStringTemplate name (lowercase, underscores only)"order_confirmation"
language_templateStringLanguage code"es_ES", "en_US"
category_templateStringTemplate category"MARKETING", "UTILITY"
components_templateObjectTemplate components structureSee example above

Template Categories

CategoryDescriptionUse Case
MARKETINGPromotional messagesOffers, announcements
UTILITYTransactional, functional messagesOrder updates, alerts
AUTHENTICATIONSecurity and verification messagesOTP codes, confirmations

Component Types

  • format: "TEXT", "IMAGE", "VIDEO", "DOCUMENT"
  • text: Text content (only for TEXT format)
  • example: Example for variables

BODY

  • text: Main message content
  • Variables: Use {{1}}, {{2}}, etc. for dynamic content
  • text: Footer text (static only, no variables)

BUTTONS

Array of button objects: URL Button:
{
  "type": "URL",
  "text": "Button Text",
  "url": "https://example.com/{{1}}"
}
Quick Reply Button:
{
  "type": "QUICK_REPLY",
  "text": "Button Text"
}

Response

{
  "success": true,
  "message": "Template created successfully",
  "template": {
    "id": "new_template_id",
    "name": "nuevo_template",
    "status": "pending",
    "submitted_at": "2024-12-25T10:00:00Z"
  }
}

Template Approval Process

  1. Submission: Template is sent to Meta for review
  2. Review: Meta reviews template (usually 24-48 hours)
  3. Approval/Rejection: Template is approved or rejected with feedback
  4. Usage: Approved templates can be used in notifications

Template Status Values

StatusDescription
pendingSubmitted for review
approvedApproved and ready to use
rejectedRejected (check feedback for reasons)
disabledTemporarily disabled

πŸ“ Template Best Practices

Naming Conventions

  • Use lowercase letters only
  • Use underscores for spaces
  • Be descriptive: welcome_new_user vs template1
  • Include language if multiple: welcome_es, welcome_en

Content Guidelines

  • Be Clear: Templates should be easily understood
  • Variables: Use meaningful placeholders like {{customer_name}}
  • Compliance: Follow WhatsApp commerce policies
  • Testing: Test with real data before submission

Common Rejection Reasons

  • ❌ Generic greetings (β€œHello”, β€œHi there”)
  • ❌ Promotional language in UTILITY templates
  • ❌ Missing context or unclear purpose
  • ❌ Incorrect variable usage
  • ❌ Policy violations (spam, inappropriate content)

Approval Tips

  • βœ… Include specific business context
  • βœ… Use clear, professional language
  • βœ… Provide meaningful examples
  • βœ… Follow WhatsApp template guidelines
  • βœ… Test variable substitution thoroughly

πŸ”§ Development Tips

  • Cache template information to reduce API calls
  • Monitor template status changes
  • Have fallback templates for rejected ones
  • Use consistent naming across your organization
  • Document templates for team reference