WhatsApp Messaging with Advantus

WhatsApp serves as the primary communication channel that businesses can leverage to strengthen their audience reach.

Advantus takes it a step further by enabling you to send bulk messages to the right audience with WhatsApp notifications. With the Advantus App, you leverage hyper-personalisation in real-time by sending recommendations based on their preferences, activities and purchase history.

A significant advantage of the Advantus App is that it enables you to create highly customised experiences for each user. Moreover, it provides you with key insights into your messages, helping you improve your messaging campaigns and build strong relationships with users.

Pre-Requisites to Use WhatsApp API

To leverage the WhatsApp API to send messages via Advantus, you need:

1. Meta Developer Account

A Meta Developer Account refers to an account that developers create on the Meta (formerly Facebook) platform. It enables them to access developer tools, resources, and documentation for building applications and integrating with Meta's ecosystem.

If you don't have the Meta developer's account, register here or contact us for any query.

2. WhatsApp Business Account

A WhatsApp Business Account is an account specifically for businesses to communicate with customers on WhatsApp. It offers features like business profiles and tools for better customer interaction.

If you don't have a WhatsApp business account, create here or contact us for any query.

Method Type and API End Point

The Method Type and API Endpoint are as follows:

POST: /api/notifications/whatsapp

The Header for WhatsApp sending is:


{

"Authorization": "YOUR_TOKEN_HERE"

}

API request

To send a request to the API, the following parameters must be included in the payload.

ItemData TypeDescriptionRequired
campaign_namestringA friendly name to identify your campaign (e.g., "Welcome Message", "December Promotion")No
message_typestringCurrently only supports "template" as WhatsApp requires pre-approved messagesYes
template_namestringThe name of your pre-approved WhatsApp template from your Business AccountYes
template_languagestringShould be an ISO-certified language code. Language code for your template (e.g., "en", "es"). Must match your approved template languageYes
segment_uuidstringUUID of your saved audience segment. Use segment_uuid OR receiver, not bothYes (if receiver not provided)
receiverarray[string]List of recipient phone numbers with country codes (e.g., "912345678999")

Note: Leverage segment_uuid for scenarios with multiple recipients.
Yes (if segment_uuid not provided)
mapper_fields1objectIt enables the senders to use variables2 through a template or auidence segment. These variables can be used for hyper-personalisation when sending a message using Advantus.Yes3
typeintegerType defines the nature of the value. If the type is 0 then the value will be taken from audience segment.

If the type is 1 then the value will be taken from value.
Yes
valuestringThe variable value defined in the type 0 (audience segment) or type 1 (text).Yes
sub_typestringVariables defined in the template for header, and button.Yes
mapper_fields.header.nobjectValues for header variable. Only one variable allowed. n is the variable numberYes (if header has variables)
mapper_fields.header.n.typeintegerUse 1 for direct value, 0 for audience segment valueYes (if using header)
mapper_fields.header.n.sub_typestringEither text or media.

When selecting media, can add any of these: Image, video, document4, or location.
Yes (if using header)
mapper_fields.header.n.valuestringThe actual content to replace the variable withYes (if using header)
mapper_fields.body.nobjectValues for body variables. Can have multiple. n is the variable numberYes (if body has variables)
mapper_fields.body.n.typeintegerUse 1 for direct value, 0 for audience segment valueYes (if using body variables)
mapper_fields.body.n.valuestringThe actual content to replace the variable with.Yes (if using body variables)
mapper_fields.button.nobjectButton variable values. Maximum 2 buttons. n is the variable numberYes (if buttons have variables)
mapper_fields.button.n.typeintegerUse 1 for direct value, 0 for audience segment valueYes (if using buttons)
mapper_fields.button.n.sub_typestring"url" for links or "coupon_code" for copyable codesYes (if using buttons)
mapper_fields.button.n.valuestringThe URL or coupon codeYes (if using buttons)
mapper_fields.button.n.indexinteger0 for first button, 1 for second buttonYes (if using buttons)
scheduleobjectMain configuration object that contains all scheduling settingsYes
schedule.message_typeobjectContains settings about how often and when to send messagesYes
schedule.campaign_start_dateobjectContains settings about when to start the campaignYes
schedule.sunsetobjectContains settings about when to end the campaignYes when message_type.type = 3
schedule.message_type.typeintegerChoose how often to send messages:
1 = send once
2 = send on specific dates
3 = send repeatedly
Yes
schedule.message_type.date
(for one-time sending)
integerThe exact date and time to send the message, in UTC timestamp format.
Only used when type = 1
Yes when type = 1
schedule.message_type.date
(for multiple dates)
integerList of dates and times to send the message, each in UTC timestamp format.
Only used when type = 2
Yes when type = 2
schedule.message_type.interval
(for recurring1 messages)
integerHow many seconds to wait between each message send.
Only used when type = 3.
Cannot be used with days_of_week or days_of_month
Yes when type = 3 and not using days
schedule.message_type.days_of_week
(for recurring messages)
integerWhich day of the week to send (1-7).
Only used when type = 3.
Cannot be used with interval or days_of_month
Yes when type = 3 and not using interval or month
schedule.message_type.days_of_month
(for recurring messages)
integerWhich day of the month to send (1-31).
Only used when type = 3.
Cannot be used with interval or days_of_week
Yes when type = 3 and not using interval or week
schedule.campaign_start_date.type7integerChoose when to start the campaign:
1 = send immediately
2 = intelligent delivery (The notification will be sent based on user's timezone between 10am to 7pm and on the weekdays of Tuesday, Wednesday and Thursday.)
3 = time (After a fixed time is set, the next one can only be scheduled after 900 seconds.)

Please refer to important notes below.
Yes
schedule.campaign_start_date.send_immediatelybooleanMust be set to true if starting right away.
Only used when type = 1
Yes when type = 1
schedule.campaign_start_date.intelligent_deliverybooleanMust be set to true if letting system choose time.
Only used when type = 2
Yes when type = 2
schedule.campaign_start_date.timeintegerThe specific time to start (in seconds).
Only used when type = 3
Yes when type = 3
schedule.sunset.type
(for recurring3 campaigns)
integerChoose when to stop the campaign:
1 = Stop on specific date
2 = Never end campaign
3 = Stop after sending X times
Only needed for recurring campaigns (message_type.type = 3)
Yes when using recurring messages
schedule.sunset.date
(for specific end date)
integerThe date to stop the campaign, in UTC timestamp format.
Only used when sunset.type = 1
Yes when sunset.type = 1
schedule.sunset.never_end_campaign
(for endless campaigns)
booleanMust be set to true for never-ending campaigns.
Only used when sunset.type = 2
Yes when sunset.type = 2
schedule.sunset.number_of_send
(for limited sends)
integerHow many times to send before stopping.
Must be a positive number.
Only used when sunset.type = 3
Yes when sunset.type = 3

Important Notes:

  1. All timestamps must be UTC.
  2. Include country code in phone numbers (e.g., "91" for India).
  3. Choose only one option for recurring messages: interval, days_of_week, or days_of_month.
  4. Template variables start from .
  5. Maximum 2 buttons per template.
  6. Only one header variable allowed.
  7. Time Interval Requirements
  • All schedules must be divisible by 900 seconds (15-minute intervals)
  • Schedules must align with fixed times: HH:00, HH:15, HH:30, HH:45
  • No arbitrary times between intervals are allowed. Examples:
    ✅ Valid: 09:00, 09:15, 09:30, 09:45, 10:00
    ❌ Invalid: 09:05, 09:20, 09:40, 09:50
  • Non-compliant schedules will be automatically rejected by the system.

1 : In a template, mapper_fields are optional; thus, you can leverage varibles for hyper-personalisation only if the mapper_fields are selected.

2 : Each dynamic field within the body, header, and button is represented by a variable, numbered sequentially as , , and so on.

3 : All mapper fields including, body, header, button, type, value, sub_type, and index will be required only if the variable for each is present in the template.

4 : If media type is document then provide filename as shown in the example.



curl--location 'https://api.advantus.io/api/notifications/whatsapp'\
    --header 'Authorization: YOUR_TOKEN_HERE'\
    --header 'Content-Type: application/json'\
    --data '{
  "campaign_name": "NAME_OF_CAMPAIGN",
  "message_type": "template",
  "template_name": "NAME_OF_TEMPLATE",
  "template_language": "en_US",
  "segment_uuid": "YOUR_SEGMENT_UUID HERE",
  "receiver": [
    "A_VALID_PHONE_NUMBER_WITH_ISO_COUNTRY_CODE"
  ],
  "mapper_fields": {
    "header": {
      "1": {
        "type": 1,
        "sub_type": "document",
        "value": "1618285602295311",
        "filename": "custom_filename.pdf"
      }
    },
    "body": {
      "1": {
        "type": 1,
        "sub_type": "text",
        "value": "09-04-2024"
      },
      "2": {
        "type": 1,
        "sub_type": "text",
        "value": "10-04-2024"
      }
    },
    "button": {
      "1": {
        "type": 1,
        "sub_type": "SHOULD_BE_A_VALID_SUB_TYPE(COUPON_CODE OR/AND URL)",
        "value": "value",
        "index": 0
      }
    }
  },
  "schedule": {
    "message_type": {
      "type": 1,
      "date": 1735516800
    },
    "campaign_start_date": {
      "type": 1,
      "send_immediately": true
    },
    "sunset": {
      "type": 1,
      "date": 1735516800
    }
  }
}
}

WhatsApp message types

There are multiple ways to use WhatsApp messging platform.

Examples

Schema if the header is text

"header": {
  "1": {
    "type": 1,
    "sub_type": "text",
    "value": "Hello world"
  }
}

Schema if the media sub_type is image

"header": {
  "1": {
    "type": 1,
    "sub_type": "image",
    "value": "id or https://unsplash.com/photos/a-person-with-a-surfboard-walking-on-a-beach-WEP4kGnoDhs"
  }
}

Schema if the media sub_type is video

"header": {
  "1": {
    "type": 1,
    "sub_type": "video",
    "value": "id or https://unsplash.com/photos/a-person-with-a-surfboard-walking-on-a-beach-WEP4kGnoDhs"
  }
}

Schema if the media sub_type is document

"header": {
  "1": {
    "type": 1,
    "sub_type": "document",
    "value": "id or https://unsplash.com/photos/a-person-with-a-surfboard-walking-on-a-beach-WEP4kGnoDhs",
    "filename": "example.pdf"
  }
}

Schema if the media sub_type is location

"header": {
    "1": {
        "type": 1,
        "sub_type": "location",
        "location": {
            "longitude": LONG_NUMBER,
            "latitude": LAT_NUMBER,
            "name": LOCATION_NAME,
            "address": LOCATION_ADDRESS
        },
    },
}

Schema if the button sub_type is coupon_code

"button": {
  "1": {
    "type": 1,
    "sub_type": "coupon_code",
    "value": "code",
    "index": 0
  }
}

Schema if the sub_type is url

"button": {
  "1": {
    "type": 1,
    "value": "lightbill",
    "index": 1,
    "sub_type": "url"
  }
}

WhatsApp schedule message types

There are multiple ways to use WhatsApp scheduling platform.

Examples

Schema if the message.type either 1, or 2, or 3

{
    "schedule": {
        "message_type": {
            "type": 1,
            "date": 1735516800,
 
            "type":2,
            "date": [1735516800,1735516800],
 
            "type":3,
            "days_of_week": [],
            "days_of_month": [],
            "months_of_year": [],
            "interval":3600
        }
    }
}

Schema if the campaign_start_date.type either 1, or 2, or 3

{
  "schedule": {
     "campaign_start_date": {
        "type":1,
        "send_immediately":true,
 
        "type": 2,
        "intelligent_delivery":"true",
 
        "type": 3,
        "time": 72000
     }
  }
}

Schema if the sunset.type either 1, or 2, or 3

{
  "schedule": {
     "sunset":{
        "type":1,
        "date":1735516800,
 
        "type":2,
        "never_end_camgaign":false,
 
        "type":3,
        "number_of_send":3
     }
  }
}

API response

When making a request, replace value with your token. If the request is successful, you will get a JSON response containing the access token.

Success response use case

If the API receives a successful request, it will typically return specific parameters as part of the response:

Response_payload :
  {
    "success": true,
    "message": "Your notification has been queued for delivery.",
    "data": {
        "notification_id": 10 OR "schedule_id": "5c1f2266-b4fc-4bfe-84ef-819e552cc6da"
    }
}
fieldData typeDescriptionRequired
successbooleanIndicating whether the request was successful or not.Yes
messageboolean/stringInforms of additional value if sent along with the response, which can be either false or a string that defines the action done by the API caller.Yes
dataobjectA JSON object containing information related to the requestYes
data.notification_idintegerA notification ID generated after making an API call.Yes
data.schedule_idstringOnly received at the time of whatsapp scehdulingOptional

Failure response use case

If the WhatsApp request fails, the API will return specific parameters (HTTP errors) as part of the response:

Error CodeHTTP StatusCauseSolution
1227400invalid template languageProvide a valid available template languages from the available options
1274400invalid segmentProvide a valid segment
1339400audience missingSelect a correct segment with audience
1341400incorrect WhatsApp business idProvide a valid WhatsApp business id
1342400invalid tokenProvide a valid WhatsApp token
1343400invalid WhatsApp configurationConfigure your WhatsApp setting with Advantus
1345400invalid typeProvide a valid type (either 0 or 1)
1346400invalid mapper fields keyProvide correct key names (body, header, button) in the mapper fields
1347400blank/missing template valueProvide a valid template value
1348400incorrect index sequenceProvide a valid index sequence (0 and 1)
1349400invalid sub_typeProvide a valid value for sub_type (location, image, video, or document)
1350400missing/invalid locationProvide a valid location (longitude, latitude, name, address)

Note: Longitude and latitude cannot be a string value.
1358400Invalid mobile number formatEnsure mobile number follows the required format
1359400Invalid schedule message typeSpecify a valid message schedule type
1360400Invalid scheduled message dateProvide a valid date for scheduled messages
1361400Invalid scheduled advanced settingsCheck and correct the advanced scheduling settings
1362400Invalid timezone setting for scheduled deliveryEnsure correct timezone is specified for scheduled delivery
1363400Invalid campaign start dateProvide a valid start date for the campaign
1364400Missing schedule parametersProvide either 'interval' or at least one of: 'days_of_week', 'days_of_month', or 'months_of_year'
1365400Invalid schedule timeSpecify a valid time for scheduling
1366400Invalid days of weekProvide valid days of the week values
1367400Invalid days of monthProvide valid days of the month values
1368400Invalid months of yearProvide valid months of the year values
1369400Invalid date selection for immediate campaignCannot select future date when campaign is set to start immediately
1374400Past date selectedSelect a future date where required
1375400Invalid sunset dateProvide a valid sunset date
1376400Invalid sunset typeSpecify a valid sunset type
1377400Invalid never-end campaign settingProvide valid settings for never-ending campaigns
1378400Missing recipient informationProvide either 'segment_uuid' or 'receiver'
1379400Conflicting recipient informationProvide either 'segment_uuid' or 'receiver', not both
1387400Invalid schedule payloadEnsure schedule payload is properly formatted
1395400Duplicate template nameChoose a unique template name
1396400Invalid end dateEnsure end date is after Tuesday